/long double time = trig.timestamp_nova*clockData.OpticalClock().TickPeriod(); //in experiment microseconds
440 std::vector<artdaq::Fragment> fragments;
443 unsigned int allPacketsProcessed = 0;
444 unsigned int waveform_counter = 0;
445 uint64_t ssptrigtime = 0;
446 std::map<int, int> packets_per_fragment;
461 for(
auto const& frag: fragments){
462 if((
unsigned)frag.type() != 3)
continue;
470 if(frag.hasMetadata()) meta = &(frag.metadata<SSPFragment::Metadata>()->sliceHeader);
471 else std::cout <<
"SSP fragment has no metadata associated with it." <<
std::endl;
474 const unsigned int* dataPointer = sspf.dataBegin();
477 unsigned int packetsProcessed=0;
478 while(( meta==0 || packetsProcessed<meta->nTriggers) && dataPointer<sspf.dataEnd() ){
484 struct trig_variables trig;
491 double time = double(trig.timestamp_nova % 1000000000 ) / double(clockData.OpticalClock().Frequency());
494 unsigned int channel = ((trunc(frag.fragmentID()/10) -1 )*4 + frag.fragmentID()%10 -1 )*
number_of_packets + trig.channel_id;
501 if (ssptrigtime==0) {
502 ssptrigtime=trig.timestamp_nova;
507 extreftime_[ssp_map_[trig.module_id]] = trig.timestamp_nova;
515 TH1D* tth = tFileService->make<TH1D>(Form(
"trigger_type_channel_%d",channel),Form(
"trigger_type_channel_%d",channel),4,0,3);
516 tth->SetTitle(Form(
"Trigger type - Channel %d",channel));
517 tth->GetXaxis()->SetTitle(
"Trigger type");
518 tth->GetXaxis()->SetBinLabel(2,
"Internal (16)");
519 tth->GetXaxis()->SetBinLabel(3,
"External (48)");
530 bool verb_values =
false;
536 const unsigned short* adcPointer=
reinterpret_cast<const unsigned short*
>(dataPointer);
539 sprintf(histname,
"evt%i_frag%d_wav%d",eventNumber, frag.fragmentID(), packetsProcessed);
541 TH1D*
hist=
new TH1D(
"hist",
"hist",nADC,0,nADC);
545 unsigned int mappedchannel =
channel;
550 unsigned short OpChannel = (
unsigned short) mappedchannel;
554 unsigned long calbasesum = 0;
555 unsigned short maxadc = 0;
556 unsigned long calintsum = 0;
557 unsigned short calpeaktime = 0;
558 unsigned int calpeaksum =0;
560 for(
size_t idata = 0; idata < nADC; idata++) {
562 const unsigned short*
adc = adcPointer + idata;
563 if(idata <
i1) calbasesum +=
static_cast<unsigned long>(*adc);
564 if(idata >
i1+
m1 && idata <=
i2+
i1+
m1) calintsum +=
static_cast<unsigned long>(*adc);
565 if(idata >=
i1+
m1+
m2 && idata <=
i1+2*
m1+
m2) calpeaksum +=
static_cast<unsigned int>(*adc);
568 if(maxadc == *adc) calpeaktime = idata;
576 hist->SetBinContent(idata+1,*adc);
582 if(idata == 0&&
verb_adcs_>0) std::cout <<
"Printing the " << nADC <<
" ADC values saved with the packet:" <<
std::endl;
583 std::cout << *adc <<
" ";
588 double pedestal = calbasesum / ((double)
i1);
589 double area = calintsum-(pedestal*
i2);
591 double peak = maxadc;
593 trig.baselinesum = calbasesum;
594 trig.intsum = calintsum;
595 trig.peaktime = calpeaktime;
596 trig.peaksum = calpeaksum;
600 <<
"Channel: " << channel << std::endl
601 <<
"Header: " << trig.header << std::endl
602 <<
"Length: " << trig.length << std::endl
603 <<
"Trigger type: " << trig.type << std::endl
604 <<
"Status flags: " << trig.status_flags << std::endl
605 <<
"Header type: " << trig.header_type << std::endl
606 <<
"Trigger ID: " << trig.trig_id << std::endl
607 <<
"Module ID: " << trig.module_id << std::endl
608 <<
"Channel ID: " << trig.channel_id << std::endl
609 <<
"External timestamp (F mode): " << std::endl
610 <<
" Sync delay: " << trig.timestamp_sync_delay << std::endl
611 <<
" Sync count: " << trig.timestamp_sync_count << std::endl
612 <<
"External timestamp (NOvA mode): " << trig.timestamp_nova << std::endl
613 <<
"Peak sum: " << trig.peaksum << std::endl
614 <<
"Peak time: " << trig.peaktime << std::endl
615 <<
"Prerise: " << trig.prerise << std::endl
616 <<
"Integrated sum: " << trig.intsum << std::endl
617 <<
"Baseline sum: " << trig.baselinesum << std::endl
618 <<
"CFD Timestamp interpolation points: " << trig.cfd_interpol[0] <<
" " << trig.cfd_interpol[1] <<
" " << trig.cfd_interpol[2] <<
" " << trig.cfd_interpol[3] << std::endl
619 <<
"Internal interpolation point: " << trig.internal_interpol << std::endl
620 <<
"Internal timestamp: " << trig.internal_timestamp << std::endl
622 <<
"Pedestal " << pedestal << std::endl
623 <<
"Area " << area << std::endl
624 <<
"Peak heigth " << peak << std::endl
638 if (trig.type == 48 ) {
642 else if (trig.type == 16) {
647 std::cerr <<
"Unknown trigger type " << trig.type <<
", cannot assign to appropriate data product with SplitTriggers enabled." <<
std::endl;
656 packets_per_fragment[frag.fragmentID()] = packetsProcessed;
657 allPacketsProcessed += packetsProcessed;
Index OpChannel(Index detNum, Index channel)
std::vector< recob::OpHit > hits
std::map< int, int > ssp_map_
std::string fOutputDataLabel
void readHeader(const SSPDAQ::EventHeader *daqHeader, struct trig_variables *tv)
uint64_t ext_ireftime_[24]
uint64_t int_ireftime_[24]
std::vector< raw::OpDetWaveform > waveforms
std::vector< raw::OpDetWaveform > int_waveforms
unsigned int SSPOfflineChannelFromOnlineChannel(unsigned int onlineChannel)
std::map< size_t, TH1D * > trigger_type_
recob::OpHit ConstructOpHit(detinfo::DetectorClocksData const &clockData, trig_variables &trig, unsigned int channel)
static int max(int a, int b)
std::string fExtTrigOutputLabel
std::vector< raw::OpDetWaveform > ext_waveforms
std::string fIntTrigOutputLabel
std::vector< recob::OpHit > ext_hits
IDNumber_t< Level::Event > EventNumber_t
std::vector< recob::OpHit > int_hits
QTextStream & endl(QTextStream &s)
void getFragments(art::Event &evt, std::vector< artdaq::Fragment > *fragments)