21 #include "art_root_io/TFileService.h" 26 #include "artdaq-core/Data/ContainerFragment.hh" 178 std::vector<recob::OpHit>
hits;
222 m1=pset.
get<
int>(
"SSP_m1");
223 m2=pset.
get<
int>(
"SSP_m2");
224 i1=pset.
get<
int>(
"SSP_i1");
225 i2=pset.
get<
int>(
"SSP_i2");
229 std::cout <<
"Parameters from the fcl file" <<
std::endl;
235 std::cout <<
"SPESize: " << SPESize <<
std::endl;
244 for(
int i=0;i<20;i++) std::cout <<
"=";
246 std::cout <<
"Parameter Set" <<
std::endl;
247 for(
int i=0;i<20;i++) std::cout <<
"=";
252 std::cout <<
"Not splitting triggers" <<
std::endl;
256 std::cout <<
"Splitting triggers" <<
std::endl;
260 std::cout <<
"fDebug: ";
264 for(
int i=0;i<20;i++) std::cout <<
"=";
271 n_event_packets_ = tFileService->make<TH1D>(
"ssp_n_event_packets",
"SSP: n_event_packets",960,-0.5,959.5);
272 frag_sizes_ = tFileService->make<TH1D>(
"ssp_frag_sizes",
"SSP: frag_sizes",960,0,2e6);
280 tv->
type = ((daqHeader->
group1 & 0xFF00) >> 8);
293 + ((
unsigned long)daqHeader->
timestamp[1] << 16) + ((
unsigned long)daqHeader->
timestamp[0] << 0);
306 for(
unsigned int i_cfdi = 0; i_cfdi < 4; i_cfdi++)
319 bool have_data =
true;
327 if(!containerFragments){
336 try { containerFragments->size(); }
339 <<
", SubRun: " << evt.
subRun()
340 <<
", Event: " << eventNumber
341 <<
" Container Fragments found but size is invalid";
348 for (
auto cont : *containerFragments)
351 artdaq::ContainerFragment contf(cont);
352 for (
size_t ii = 0; ii < contf.block_count(); ++ii)
354 size_t fragSize = contf.fragSize(ii);
360 fragments->emplace_back(*contf[ii]);
367 bool have_data2=
true;
383 try { rawFragments->size(); }
387 <<
", SubRun: " << evt.
subRun()
388 <<
", Event: " << eventNumber
389 <<
" Non-Container Fragments found but size is invalid";
396 for(
auto const& rawfrag: *rawFragments){
397 fragments->emplace_back( rawfrag );
406 for(
int i=0;i<24;i++){
417 for(
int i=0;i<24;i++) {
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;
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() ){
491 double time = double(trig.
timestamp_nova % 1000000000 ) / double(clockData.OpticalClock().Frequency());
501 if (ssptrigtime==0) {
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;
569 Waveform.push_back(*adc);
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;
600 <<
"Channel: " << channel << std::endl
601 <<
"Header: " << trig.
header << std::endl
602 <<
"Length: " << trig.
length << std::endl
603 <<
"Trigger type: " << trig.
type << 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
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
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;
682 double TimeStamp = ((double)FirstSample);
686 double pedestal = ( (double) trig.
baselinesum ) / ( (double)
i1 );
687 double area = ( (double) trig.
intsum ) - pedestal * ( (double)
i2 );
688 double peak = ( (double) trig.
peaksum ) / ( (double)
m1 ) - pedestal;
Index OpChannel(Index detNum, Index channel)
std::vector< recob::OpHit > hits
EventNumber_t event() const
enum raw::_compress Compress_t
std::map< int, int > ssp_map_
std::string fOutputDataLabel
Handle< PROD > getHandle(SelectorBase const &) const
void readHeader(const SSPDAQ::EventHeader *daqHeader, struct trig_variables *tv)
EDProducer(fhicl::ParameterSet const &pset)
unsigned short status_flags
uint64_t ext_ireftime_[24]
uint64_t int_ireftime_[24]
unsigned int fZeroThreshold
Zero suppression threshold.
std::string fRawDataLabel
#define MF_LOG_ERROR(category)
unsigned long baselinesum
adc_t const * dataEnd() const
SSPRawDecoder(fhicl::ParameterSet const &p)
unsigned long timestamp_sync_count
void beginEvent(art::EventNumber_t eventNumber)
adc_t const * dataBegin() const
constexpr double TickPeriod() const noexcept
A single tick period in microseconds.
std::vector< raw::OpDetWaveform > waveforms
SSPRawDecoder & operator=(SSPRawDecoder const &)=delete
unsigned long cfd_interpol[4]
std::vector< raw::OpDetWaveform > int_waveforms
#define DEFINE_ART_MODULE(klass)
unsigned int SSPOfflineChannelFromOnlineChannel(unsigned int onlineChannel)
std::map< size_t, TH1D * > trigger_type_
T get(std::string const &key) const
ElecClock const & OpticalClock() const noexcept
Borrow a const Optical clock with time set to Trigger time [us].
recob::OpHit ConstructOpHit(detinfo::DetectorClocksData const &clockData, trig_variables &trig, unsigned int channel)
SubRunNumber_t subRun() const
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
unsigned long internal_interpol
static int max(int a, int b)
std::string fExtTrigOutputLabel
std::vector< raw::OpDetWaveform > ext_waveforms
std::string fIntTrigOutputLabel
raw::Compress_t fCompression
compression type to use
unsigned long timestamp_sync_delay
Contains all timing reference information for the detector.
std::vector< recob::OpHit > ext_hits
IDNumber_t< Level::Event > EventNumber_t
void reconfigure(const fhicl::ParameterSet &pset)
unsigned short header_type
std::vector< recob::OpHit > int_hits
void produce(art::Event &e) override
std::vector< Fragment > Fragments
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
uint64_t internal_timestamp
unsigned short channel_id
void getFragments(art::Event &evt, std::vector< artdaq::Fragment > *fragments)