@@ -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 }
0 commit comments