Skip to content

Commit 177f2b4

Browse files
committed
Add warning for some unexpected types of fragments and fix fragments indexing. Improve jittering application.
1 parent 43f7614 commit 177f2b4

2 files changed

Lines changed: 29 additions & 21 deletions

File tree

sbndcode/Decoders/XARAPUCA/SBNDXARAPUCADecoder_module.cc

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -541,23 +541,7 @@ void sbndaq::SBNDXARAPUCADecoder::decode_fragment(uint64_t timestamp, uint64_t&
541541
}
542542

543543
// - Computation of the difference between TTTs difference and the length of the fragment in ns (to detect jittering between fragments).
544-
//int32_t J = TTT_dif - frag_length;
545-
546-
// - Combination boolean variable.
547-
//bool dump_comb_wvfms = true;
548-
/* if (is_nominal) { // Nominal fragment
549-
if (!is_first && (TTT_dif <= (frag_length - fallowed_jittering))) {
550-
std::cout << "\t\t WARNING: NOMINAL fragment too close to previous one! TTT_dif: " << TTT_dif << " ns, fragment idx: " << fragment_indices[board_idx] << ", board idx: " << board_idx << " (slot " << fboard_id_list[board_idx] << "), " << num_samples_per_wvfm << " samples. Skipping this fragment..." << std::endl;
551-
}
552-
} else { // Extended fragment
553-
if (std::abs(J) <= fallowed_jittering) {
554-
dump_comb_wvfms = false;
555-
} else if (TTT_dif <= (frag_length - fallowed_jittering)) {
556-
dump_comb_wvfms = false;
557-
std::cout << "\t\t WARNING: EXTENDED fragment too close to previous one! TTT_dif: " << TTT_dif << " ns, fragment idx: " << fragment_indices[board_idx] << ", board idx: " << board_idx << " (slot " << fboard_id_list[board_idx] << "), " << num_samples_per_wvfm << " samples. Skipping this fragment..." << std::endl;
558-
}
559-
}*/
560-
544+
int32_t J = TTT_dif - frag_length;
561545

562546
bool dump_comb_wvfms = !is_first && (is_nominal || (!is_nominal && (TTT_dif > (frag_length + fallowed_jittering))));
563547

@@ -573,19 +557,43 @@ void sbndaq::SBNDXARAPUCADecoder::decode_fragment(uint64_t timestamp, uint64_t&
573557
first_frag_idx = fragment_indices[board_idx];
574558
first_TTT = TTT_end_ns;
575559
first_frag_timestamp = frag_timestamp;
560+
if (fdebug_jittering) std::cout << "NC - ";
561+
} else {
562+
if (fdebug_jittering) std::cout << "C - ";
576563
}
577564
append_waveforms(wvfms, fragment_wvfms, num_channels);
578565

579566
if (last_one) {
580567
if (fdebug_extended_fragments) std::cout << "\t\t LAST fragment " << std::endl;
581-
fragment_indices[board_idx]++;
582568
shift_time(TTT_ticks, first_TTT, first_frag_timestamp, timestamp, num_nominal_samples_per_wvfm, ini_wvfm_timestamp, end_wvfm_timestamp);
583569
dump_waveforms(prod_wvfms, wvfms, first_frag_idx, board_idx, num_channels, ini_wvfm_timestamp, end_wvfm_timestamp);
584570
}
585571

572+
if (fdebug_jittering) {
573+
if (is_first) {
574+
std::cout << "\t\t FIRST ";
575+
}
576+
if (is_nominal) {
577+
int32_t TTT_ini_ns = TTT_end_ns - static_cast<int32_t>(num_nominal_samples_per_wvfm * fns_per_sample);
578+
std::cout << "NOMINAL fragment " << fboard_id_list[board_idx] << " - " << fragment_indices[board_idx] << " (" << num_samples_per_wvfm << "): [" << TTT_ini_ns << ", " << TTT_end_ns << "] diff with prev: " << TTT_dif << " ns, length: " << frag_length << " ns, diff_with_length (jitt): " << J << std::endl;
579+
} else {
580+
int32_t TTT_ini_ns = TTT_end_ns - static_cast<int32_t>(num_nominal_samples_per_wvfm * fns_per_sample);
581+
std::cout << "EXTENDED fragment " << fboard_id_list[board_idx] << " - " << fragment_indices[board_idx] << " (" << num_samples_per_wvfm << "): [" << TTT_ini_ns << ", " << TTT_end_ns << "] diff with prev: " << TTT_dif << " ns, length: " << frag_length << " ns, diff_with_length (jitt): " << J << std::endl;
582+
}
583+
}
584+
585+
// WARNINGS
586+
if (TTT_dif < frag_length - fallowed_jittering) {
587+
if (!is_first) {
588+
if (!is_nominal) std::cout << "\t\t WARNING: EXTENDED fragment too close! This fragment is being combined." << std::endl;
589+
if (is_nominal) std::cout << "\t\t WARNING: NOMINAL fragment too close! This fragment is not being combined." << std::endl;
590+
}
591+
}
592+
586593
prev_TTT = TTT_end_ns;
587594

588595
} else { // Combination of extended fragments disabled.
596+
first_frag_idx = fragment_indices[board_idx];
589597
shift_time(TTT_ticks, TTT_end_ns, frag_timestamp, timestamp, num_samples_per_wvfm, ini_wvfm_timestamp, end_wvfm_timestamp);
590598
dump_waveforms(prod_wvfms, fragment_wvfms, first_frag_idx, board_idx, num_channels, ini_wvfm_timestamp, end_wvfm_timestamp);
591599
}

sbndcode/Decoders/XARAPUCA/xarapucadecoder.fcl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ xarapucadecoder:
3232
# - Output data product instance name.
3333
waveforms_instance_name: "XARAPUCAChannels" # Name for the instance product containing the raw decoded waveforms.
3434
timing_ref_instance_name: "" # Name for the instance product containing the timing reference information.
35-
store_debug_waveforms: -1 # Number of waveforms to store (0: none, -1: all, n: first n waveforms).
35+
store_debug_waveforms: 0 # Number of waveforms to store (0: none, -1: all, n: first n waveforms).
3636
# Combination of extended fragments.
3737
combine_ext_frag: true # (De)activates the combination of extended fragments into a single raw::OpDetWaveform object.
3838
allowed_jittering: 64 # Allowed jittering (in ns) between fragments to be combined.
@@ -44,9 +44,9 @@ xarapucadecoder:
4444
debug_buffer: false # (De)activates buffer status printing.
4545
debug_waveforms: false # (De)activates waveforms decoding printing.
4646
debug_extended_fragments: false # (De)activates extended fragments information printing.
47-
debug_jittering: true # (De)activates trigger jittering information printing.
47+
debug_jittering: false # (De)activates trigger jittering information printing.
4848
# - Verbose option.
49-
verbose: true # (De)activates verbosity.
49+
verbose: false # (De)activates verbosity.
5050
}
5151

5252
END_PROLOG

0 commit comments

Comments
 (0)