@@ -466,12 +466,12 @@ void sbndaq::SBNDPMTDecoder::produce(art::Event& evt)
466466
467467 for (size_t itrig=0 ; itrig < frag_v.size (); itrig++){
468468 raw::pmt::boardTimingInfo board_info;
469+ std::vector<uint32_t > board_ttt_v;
469470 std::vector<std::vector<uint16_t >> iwvfm_v;
470471 auto ifrag = frag_v.at (itrig);
471472 uint16_t ipostpercent = 0 ; // nanosecond portion of the timestamp (at flash trigger)
472473 uint32_t ittt = 0 ; // trigger time tag in ns (at end of the waveform)
473474 uint32_t ilen = 0 ;
474- // uint32_t isec = 0; // needs to be set to the **start** of the waveform for consistency
475475 int itick = 0 ;
476476
477477 get_timing (ifrag, ipostpercent, ittt, ilen, itick);
@@ -482,7 +482,7 @@ void sbndaq::SBNDPMTDecoder::produce(art::Event& evt)
482482 }
483483 full_found++;
484484 board_info.postPercent = ipostpercent;
485- board_info. triggerTimeTag = ittt;
485+ board_ttt_v. push_back ( ittt) ;
486486
487487 get_waveforms (ifrag, iwvfm_v);
488488 uint iwvfm_start = 0 ;
@@ -494,7 +494,7 @@ void sbndaq::SBNDPMTDecoder::produce(art::Event& evt)
494494 else iwvfm_start = ittt - ilen*2 ;
495495
496496 if (fdebug>2 ){
497- std::cout << " Frag ID : " << fragid
497+ std::cout << " Board : " << fragid
498498 << " , ttt: " << ittt
499499 << " , tick: " << itick
500500 << " , frag ts: " << ifrag.timestamp ()%uint (1e9 )
@@ -506,28 +506,43 @@ void sbndaq::SBNDPMTDecoder::produce(art::Event& evt)
506506 auto jfrag = frag_v.at (jtrig);
507507 auto jlen = get_length (jfrag);
508508 auto jttt = get_ttt (jfrag);
509- // if the next trigger is more than 10 us away than the end of the wvfm or is equal to the nominal length, stop looking
510- if (((signed )(jttt - iwvfm_end) > (signed )(fnominal_length*2 )) || (jlen >= fnominal_length)) break ;
511- else if (((jttt - iwvfm_end) < 1e4 ) && (jlen < fnominal_length)){
509+ // to be an extended trigger, need to fulfill both conditions:
510+ // 1. the length of the extension will be less than the nominal length
511+ // 2. the time between the first ttt and the extended ttt will be less than the nominal length*2 (2 ns tick)
512+ bool length_check = (jlen < fnominal_length);
513+ bool ttt_check=false ;
514+ if (iwvfm_end < uint (1e9 -fnominal_length*2 )){
515+ if ((jttt-iwvfm_end) < fnominal_length*2 )
516+ ttt_check = true ;
517+ }
518+ // if the end of wvfm is less than 10 us away from end of the second, may be second rollover
519+ else if ((iwvfm_end > uint (1e9 -fnominal_length*2 )) && (jttt < fnominal_length*2 )) {
520+ if ((jttt + 1e9 - iwvfm_end) < fnominal_length*2 ){
521+ ttt_check = true ;
522+ }
523+ }
524+ if (length_check && ttt_check){
512525 extensions_used++;
526+ board_ttt_v.push_back (jttt);
513527 std::vector<std::vector<uint16_t >> jwvfm_v;
514528 get_waveforms (jfrag, jwvfm_v);
515529 for (size_t ich=0 ; ich < iwvfm_v.size (); ich++){
516530 std::vector<uint16_t >& orig_wvfm = iwvfm_v.at (ich);
517531 std::vector<uint16_t > extd_wvfm = jwvfm_v.at (ich); // extended waveform
518532 orig_wvfm.insert ( orig_wvfm.end (), extd_wvfm.begin (), extd_wvfm.end ());
519- } // end ch loop
533+ } // end ch loop
520534 } // end if extension condition
535+ else break ; // if the immediate next trigger is not an extension, break
521536 iwvfm_end = jttt;
522537 } // end jtrig loop
523538 if (fdebug>2 ){
524- std::cout << " Frag ID : " << fragid
539+ std::cout << " Board : " << fragid
525540 << " -> start time: " << int (iwvfm_start) - int (event_trigger_time)
526541 << " , extended wvfm length: " << iwvfm_v.at (0 ).size ()
527542 << std::endl;
528543 }
529544 } // end extended flag
530-
545+ board_info. triggerTimeTag = board_ttt_v;
531546 brdTimingInfoVec->push_back (board_info);
532547 art::Ptr<raw::pmt::boardTimingInfo> brdTimingInfoPtr = make_pmtbrd_ptr (brdTimingInfoVec->size ()-1 );
533548
@@ -547,15 +562,14 @@ void sbndaq::SBNDPMTDecoder::produce(art::Event& evt)
547562 }
548563 double time_diff = (int (iwvfm_start) - int (event_trigger_time))*1e-3 ; // us
549564 if ((std::abs (time_diff) > fallowed_time_diff) && (timing_type<2 )){
550- std::cout << " EVENT ROLLOVER: " << event_trigger_time << " , " << iwvfm_start << std::endl;
551565 // second rollover between reference time and waveform start
552566 if (std::abs (time_diff + 1e6 ) < fallowed_time_diff)
553567 time_diff += 1e6 ; // us
554568 // second rollover between waveform start and reference time
555569 else if (std::abs (time_diff - 1e6 ) < fallowed_time_diff)
556570 time_diff -= 1e6 ; // us
557571 else if (fdebug>1 )
558- std::cout << " WARNING: TIME DIFFERENCE IS GREATER THAN 3 ms . Event timestamp: " << event_trigger_time << " , waveform timestamp: " << iwvfm_start << std::endl;
572+ std::cout << " WARNING: TIME DIFFERENCE IS GREATER THAN " << fallowed_time_diff << " us . Event timestamp: " << event_trigger_time << " , waveform timestamp: " << iwvfm_start << std::endl;
559573 }
560574 uint ch;
561575 if (i == 15 )
@@ -584,13 +598,20 @@ void sbndaq::SBNDPMTDecoder::produce(art::Event& evt)
584598 } // end itrig loop
585599
586600 if (fdebug>1 ){
587- // print number of triggers, number of extensions found, and number of extensions used
601+ bool trigger_bookkeeping = (full_found + extensions_used) == int (frag_v.size ());
602+ bool found_used = (extensions_used == extensions_found);
588603 std::cout << " Board: " << fragid
589- << " -> # of triggers: " << frag_v.size ()
590- << " , full found: " << full_found
591- << " , extensions found: " << extensions_found
592- << " , extensions used: " << extensions_used
593- << std::endl;
604+ << " , passed trigger bookkeeping: " << (trigger_bookkeeping && found_used)
605+ << std::endl;
606+ if (fdebug>2 ){
607+ // print number of triggers, number of extensions found, and number of extensions used
608+ std::cout << " Board: " << fragid
609+ << " -> # of triggers: " << frag_v.size ()
610+ << " , full found: " << full_found
611+ << " , extensions found: " << extensions_found
612+ << " , extensions used: " << extensions_used
613+ << std::endl;
614+ }
594615 }
595616 } // end board loop
596617 board_frag_v.clear ();
0 commit comments