Classes | Public Member Functions | Private Attributes | List of all members
dune::SSPRawDecoder Class Reference
Inheritance diagram for dune::SSPRawDecoder:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Classes

struct  trig_variables
 

Public Member Functions

 SSPRawDecoder (fhicl::ParameterSet const &p)
 
 SSPRawDecoder (SSPRawDecoder const &)=delete
 
 SSPRawDecoder (SSPRawDecoder &&)=delete
 
SSPRawDecoderoperator= (SSPRawDecoder const &)=delete
 
SSPRawDecoderoperator= (SSPRawDecoder &&)=delete
 
void produce (art::Event &e) override
 
void reconfigure (const fhicl::ParameterSet &pset)
 
void printParameterSet ()
 
void readHeader (const SSPDAQ::EventHeader *daqHeader, struct trig_variables *tv)
 
void getFragments (art::Event &evt, std::vector< artdaq::Fragment > *fragments)
 
void beginJob () override
 
void endJob () override
 
void beginEvent (art::EventNumber_t eventNumber)
 
void setRootObjects ()
 
recob::OpHit ConstructOpHit (detinfo::DetectorClocksData const &clockData, trig_variables &trig, unsigned int channel)
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Attributes

std::string fRawDataLabel
 
bool fSplitTriggers
 
std::string fOutputDataLabel
 
std::string fExtTrigOutputLabel
 
std::string fIntTrigOutputLabel
 
bool fUseChannelMap
 
bool fDebug
 
raw::Compress_t fCompression
 compression type to use More...
 
unsigned int fZeroThreshold
 Zero suppression threshold. More...
 
uint32_t n_adc_counter_
 
uint64_t adc_cumulative_
 
uint64_t intreftime_ [24]
 
uint64_t int_ireftime_ [24]
 
uint64_t extreftime_ [24]
 
uint64_t ext_ireftime_ [24]
 
uint64_t allreftime
 
uint32_t verb_adcs_
 
bool verb_meta_
 
bool timed_
 
TH1D * n_event_packets_
 
TH1D * frag_sizes_
 
double m1
 
double m2
 
double i1
 
double i2
 
double SPESize
 
int number_of_packets = 12
 
std::map< int, int > ssp_map_
 
std::map< size_t, TH1D * > trigger_type_
 
std::vector< raw::OpDetWaveformwaveforms
 
std::vector< raw::OpDetWaveformext_waveforms
 
std::vector< raw::OpDetWaveformint_waveforms
 
std::vector< recob::OpHithits
 
std::vector< recob::OpHitext_hits
 
std::vector< recob::OpHitint_hits
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 48 of file SSPRawDecoder_module.cc.

Constructor & Destructor Documentation

dune::SSPRawDecoder::SSPRawDecoder ( fhicl::ParameterSet const &  p)
explicit

Definition at line 185 of file SSPRawDecoder_module.cc.

186  : EDProducer{pset}
187 {
188  reconfigure(pset);
189  if (!fSplitTriggers) {
190  produces< std::vector<raw::OpDetWaveform> > (fOutputDataLabel);
191  produces< std::vector<recob::OpHit> > (fOutputDataLabel);
192  }
193  else{
194  produces< std::vector<raw::OpDetWaveform> > (fExtTrigOutputLabel);
195  produces< std::vector<raw::OpDetWaveform> > (fIntTrigOutputLabel);
196  produces< std::vector<recob::OpHit> > (fExtTrigOutputLabel);
197  produces< std::vector<recob::OpHit> > (fIntTrigOutputLabel);
198  }
199 }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
void reconfigure(const fhicl::ParameterSet &pset)
dune::SSPRawDecoder::SSPRawDecoder ( SSPRawDecoder const &  )
delete
dune::SSPRawDecoder::SSPRawDecoder ( SSPRawDecoder &&  )
delete

Member Function Documentation

void dune::SSPRawDecoder::beginEvent ( art::EventNumber_t  eventNumber)

Definition at line 412 of file SSPRawDecoder_module.cc.

413 {
414  //intializing adc counters and internal references
415  n_adc_counter_ = 0;
416  adc_cumulative_ = 0;
417  for(int i=0;i<24;i++) {
418  intreftime_[i]=0;
419  // extreftime_[i]=0;
420  }
421  timed_ = false;
422 
423 }
void dune::SSPRawDecoder::beginJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 402 of file SSPRawDecoder_module.cc.

402  {
403  //intializing normalizing time references for use in the producer method
404  setRootObjects();
405  allreftime=0;
406  for(int i=0;i<24;i++){
407  int_ireftime_[i]=0;
408  ext_ireftime_[i]=0;
409  }
410 }
recob::OpHit dune::SSPRawDecoder::ConstructOpHit ( detinfo::DetectorClocksData const &  clockData,
trig_variables trig,
unsigned int  channel 
)

< Derived Optical channel

< first sample experiment time in microseconds

Definition at line 676 of file SSPRawDecoder_module.cc.

678 {
679  // Get basic information from the header
680  unsigned short OpChannel = channel; ///< Derived Optical channel
681  unsigned long FirstSample = trig.timestamp_nova;
682  double TimeStamp = ((double)FirstSample); ///< first sample experiment time in microseconds
683 
684  double peakTime = ((double) trig.peaktime) * clockData.OpticalClock().TickPeriod(); // microseconds
685  double width = ((double)i1) * clockData.OpticalClock().TickPeriod(); // microseconds
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;
689 
690 
691  recob::OpHit ophit(OpChannel,
692  TimeStamp+peakTime, // Relative Time
693  TimeStamp+peakTime, // Absolute time
694  0, // Frame, not used by DUNE
695  width,
696  area,
697  peak,
698  area / SPESize, // PE
699  0.);
700 
701  return ophit;
702 }
Index OpChannel(Index detNum, Index channel)
uint8_t channel
Definition: CRTFragment.hh:201
void dune::SSPRawDecoder::endJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 425 of file SSPRawDecoder_module.cc.

425  {
426 
427 }
void dune::SSPRawDecoder::getFragments ( art::Event evt,
std::vector< artdaq::Fragment > *  fragments 
)

look for Container Fragments:

Look for non-container Raw Fragments:

Definition at line 315 of file SSPRawDecoder_module.cc.

315  {
316 
317  art::EventNumber_t eventNumber = evt.event();
318 
319  bool have_data = true;
320 
321  /// look for Container Fragments:
322  art::InputTag itag1(fRawDataLabel, "ContainerPHOTON");
323  auto containerFragments = evt.getHandle<artdaq::Fragments>(itag1);
324 
325  // Check if there is SSP data in this event. Rearranged -- the isValid test tells us whether the branch was found
326 
327  if(!containerFragments){
328  have_data = false;
329  }
330 
331  // Don't crash code if not present, just don't save anything. The above test ought to detect situations where we do not have
332  // container fragments or if the label is wrong. Test if we can access it however just to be safe.
333 
334  if (have_data)
335  {
336  try { containerFragments->size(); }
337  catch(std::exception const&) {
338  MF_LOG_ERROR("SSPRawDecoder") << "Run: " << evt.run()
339  << ", SubRun: " << evt.subRun()
340  << ", Event: " << eventNumber
341  << " Container Fragments found but size is invalid";
342  have_data = false;
343  }
344  }
345 
346  if (have_data)
347  {
348  for (auto cont : *containerFragments)
349  {
350  //std::cout << "container fragment type: " << (unsigned)cont.type() << std::endl;
351  artdaq::ContainerFragment contf(cont);
352  for (size_t ii = 0; ii < contf.block_count(); ++ii)
353  {
354  size_t fragSize = contf.fragSize(ii);
355  frag_sizes_->Fill(fragSize);
356  //artdaq::Fragment thisfrag;
357  //thisfrag.resizeBytes(fragSize);
358 
359  //memcpy(thisfrag.headerAddress(), contf.at(ii), fragSize);
360  fragments->emplace_back(*contf[ii]);
361  }
362  }
363  }
364 
365  /// Look for non-container Raw Fragments:
366 
367  bool have_data2=true;
368 
369  art::InputTag itag2(fRawDataLabel, "PHOTON");
370  auto rawFragments = evt.getHandle<artdaq::Fragments>(itag2);
371 
372  // Check if there is SSP data in this event
373 
374  //Check that the data is valid
375  if (!rawFragments){
376  have_data2 = false;
377  }
378 
379  // Don't crash code if not present, just don't save anything
380 
381  if (have_data2)
382  {
383  try { rawFragments->size(); }
384  catch(std::exception const&) {
385  //std::cout << "WARNING: Raw SSP data not found in event " << eventNumber << std::endl;
386  MF_LOG_ERROR("SSPRawDecoder") << "Run: " << evt.run()
387  << ", SubRun: " << evt.subRun()
388  << ", Event: " << eventNumber
389  << " Non-Container Fragments found but size is invalid";
390  have_data2=false;
391  }
392  }
393 
394  if (have_data2)
395  {
396  for(auto const& rawfrag: *rawFragments){
397  fragments->emplace_back( rawfrag );
398  }
399  }
400 }
EventNumber_t event() const
Definition: DataViewImpl.cc:85
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
#define MF_LOG_ERROR(category)
SubRunNumber_t subRun() const
Definition: DataViewImpl.cc:78
RunNumber_t run() const
Definition: DataViewImpl.cc:71
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:118
std::vector< Fragment > Fragments
Definition: HDF5Utils.h:57
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
SSPRawDecoder& dune::SSPRawDecoder::operator= ( SSPRawDecoder const &  )
delete
SSPRawDecoder& dune::SSPRawDecoder::operator= ( SSPRawDecoder &&  )
delete
void dune::SSPRawDecoder::printParameterSet ( )

Definition at line 242 of file SSPRawDecoder_module.cc.

242  {
243 
244  for(int i=0;i<20;i++) std::cout << "=";
245  std::cout << std::endl;
246  std::cout << "Parameter Set" << std::endl;
247  for(int i=0;i<20;i++) std::cout << "=";
248  std::cout << std::endl;
249 
250  std::cout << "fRawDataLabel: " << fRawDataLabel << std::endl;
251  if (!fSplitTriggers) {
252  std::cout << "Not splitting triggers" << std::endl;
253  std::cout << "fOutputDataLabel: " << fOutputDataLabel << std::endl;
254  }
255  else{
256  std::cout << "Splitting triggers" << std::endl;
257  std::cout << "fExtTrigOutputLabel: " << fExtTrigOutputLabel << std::endl;
258  std::cout << "fIntTrigOutputLabel: " << fIntTrigOutputLabel << std::endl;
259  }
260  std::cout << "fDebug: ";
261  if(fDebug) std::cout << "true" << std::endl;
262  else std::cout << "false" << std::endl;
263 
264  for(int i=0;i<20;i++) std::cout << "=";
265  std::cout << std::endl;
266 }
QTextStream & endl(QTextStream &s)
void dune::SSPRawDecoder::produce ( art::Event e)
overridevirtual

Get the fragments (Container or Raw)

Process all packets:

Create a SSPFragment from the generic artdaq fragment

get the information from the header

get the metadata

get a pointer to the first packet in the millislice

loop over the packets in the millislice

get the packet header

read the header to provide the trigger variables structure

time

/long double time = trig.timestamp_nova*clockData.OpticalClock().TickPeriod(); //in experiment microseconds

increment the data pointer past the packet header

get the number of ADC values in the packet

get a pointer to the first ADC value

< Derived Optical channel

copy the waveforms

get the 'idata-th' ADC value

Waveform

increment the data pointer to the end of the current packet (to the start of the next packet header, if available)

Implements art::EDProducer.

Definition at line 429 of file SSPRawDecoder_module.cc.

429  {
430 
433 
434  //MF_LOG_INFO("SSPRawDecoder") << "-------------------- SSP RawDecoder -------------------";
435  // Implementation of required member function here.
436 
437  art::EventNumber_t eventNumber = evt.event();
438 
439  /// Get the fragments (Container or Raw)
440  std::vector<artdaq::Fragment> fragments;
441  getFragments(evt,&fragments);
442 
443  unsigned int allPacketsProcessed = 0;
444  unsigned int waveform_counter = 0;
445  uint64_t ssptrigtime = 0;
446  std::map<int, int> packets_per_fragment;
447 
448  // just to make sure -- the std::move from the previous event should clear them out, but this is
449  // not guaranteed by the standard.
450 
451  waveforms.clear();
452  int_waveforms.clear();
453  ext_waveforms.clear();
454  hits.clear();
455  int_hits.clear();
456  ext_hits.clear();
457 
458  /// Process all packets:
459 
460  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
461  for(auto const& frag: fragments){
462  if((unsigned)frag.type() != 3) continue;
463 
464  ///> Create a SSPFragment from the generic artdaq fragment
465  dune::SSPFragment sspf(frag);
466 
467  const SSPDAQ::MillisliceHeader* meta=0;
468 
469  ///> get the information from the header
470  if(frag.hasMetadata()) meta = &(frag.metadata<SSPFragment::Metadata>()->sliceHeader); ///> get the metadata
471  else std::cout << "SSP fragment has no metadata associated with it." << std::endl;
472 
473  ///> get a pointer to the first packet in the millislice
474  const unsigned int* dataPointer = sspf.dataBegin();
475 
476  ///> loop over the packets in the millislice
477  unsigned int packetsProcessed=0;
478  while(( meta==0 || packetsProcessed<meta->nTriggers) && dataPointer<sspf.dataEnd() ){
479 
480  ///> get the packet header
481  const SSPDAQ::EventHeader* daqHeader=reinterpret_cast<const SSPDAQ::EventHeader*>(dataPointer);
482 
483  /// read the header to provide the trigger variables structure
484  struct trig_variables trig;
485  readHeader(daqHeader, &trig);
486 
487  /// time
488  ////long double time = trig.timestamp_nova*clockData.OpticalClock().TickPeriod(); //in experiment microseconds
489  // DO NOT USE clockData.OpticalClock().TickPeriod()!!!! It is not precise enough
490  // use OpticalClock().Frequency, and do the division yourself with high precission.
491  double time = double(trig.timestamp_nova % 1000000000 ) / double(clockData.OpticalClock().Frequency());
492  //true time truncated by 10 digits in order to make sure the math works correctly
493  //std::cout << time << std::endl;
494  unsigned int channel = ((trunc(frag.fragmentID()/10) -1 )*4 + frag.fragmentID()%10 -1 )*number_of_packets + trig.channel_id;
495 
496  //set external reference time to the first time stamp of the run, if a lower time stamp is found, adjust
497  if(allreftime==0 || (allreftime > trig.timestamp_nova)) allreftime=trig.timestamp_nova;
498 
499  //internal and external reference times on external (beam/cosmic window triggers). Can be used to time external timestamp down to the internal timesample. Might want to try this at some point in production...
500  if(trig.type==48) {
501  if (ssptrigtime==0) {
502  ssptrigtime=trig.timestamp_nova;
503  if(verb_meta_) std::cout << "SSP: " << ssptrigtime << std::endl;
504  }
505 
506  intreftime_[ssp_map_[trig.module_id]] = trig.internal_timestamp;
507  extreftime_[ssp_map_[trig.module_id]] = trig.timestamp_nova;
508  if(int_ireftime_[ssp_map_[trig.module_id]] == 0) int_ireftime_[ssp_map_[trig.module_id]] = trig.internal_timestamp;
509  if(ext_ireftime_[ssp_map_[trig.module_id]] == 0) ext_ireftime_[ssp_map_[trig.module_id]] = trig.timestamp_nova;
510  }
511 
512  // Trigger type histogram
513  if (trigger_type_.find(channel) == trigger_type_.end())
514  {
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)");
520  trigger_type_[channel] = tth;
521  }
522 
523  if ( trig.type == 16 ) trigger_type_[channel]->Fill(1);
524  if ( trig.type == 48 ) trigger_type_[channel]->Fill(2);
525 
526  ///> increment the data pointer past the packet header
527  dataPointer+=sizeof(SSPDAQ::EventHeader)/sizeof(unsigned int);
528 
529  //>get the information from the data
530  bool verb_values = false;
531 
532  ///> get the number of ADC values in the packet
533  unsigned int nADC=(trig.length-sizeof(SSPDAQ::EventHeader)/sizeof(unsigned int))*2;
534 
535  ///> get a pointer to the first ADC value
536  const unsigned short* adcPointer=reinterpret_cast<const unsigned short*>(dataPointer);
537 
538  char histname[100];
539  sprintf(histname,"evt%i_frag%d_wav%d",eventNumber, frag.fragmentID(), packetsProcessed);
540 
541  TH1D* hist=new TH1D("hist","hist",nADC,0,nADC);
542 
543  // map the channel number to offline if requested
544 
545  unsigned int mappedchannel = channel;
546  if (fUseChannelMap) mappedchannel = channelMap->SSPOfflineChannelFromOnlineChannel(channel);
547 
548  // Get information from the header, //added by Jingbo
549 
550  unsigned short OpChannel = (unsigned short) mappedchannel; ///< Derived Optical channel
551  raw::OpDetWaveform Waveform(time, OpChannel, nADC);
552 
553  //calculating relevant values in decoder because what comes out of the trigger header seems incorrect-Bryan Ramson
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;
559  ///> copy the waveforms
560  for(size_t idata = 0; idata < nADC; idata++) {
561  ///> get the 'idata-th' ADC value
562  const unsigned short* adc = adcPointer + idata;
563  if(idata < i1) calbasesum += static_cast<unsigned long>(*adc); //added by Bryan Ramson
564  if(idata > i1+m1 && idata <= i2+i1+m1) calintsum += static_cast<unsigned long>(*adc); //added by Bryan Ramson
565  if(idata >= i1+m1+m2 && idata <= i1+2*m1+m2) calpeaksum += static_cast<unsigned int>(*adc); //added by Bryan Ramson
566 
567  maxadc = std::max(maxadc,*adc); //added by Bryan Ramson
568  if(maxadc == *adc) calpeaktime = idata; //added by Bryan Ramson
569  Waveform.push_back(*adc); //added by Jingbo
570  waveform_counter++;
571 
572  n_adc_counter_++;
573  adc_cumulative_ += (uint64_t)(*adc);
574 
575  ///> Waveform
576  hist->SetBinContent(idata+1,*adc);
577 
578  if (idata >= verb_adcs_) verb_values = false;
579 
580  verb_values = false; //don't print adc. Added by J.Wang
581  if(verb_values) {
582  if(idata == 0&&verb_adcs_>0) std::cout << "Printing the " << nADC << " ADC values saved with the packet:" << std::endl;
583  std::cout << *adc << " ";
584  }
585  }// idata
586 
587  // pedestal, area and peak (according to the Register table, the SSP User Manual has i1 and i2 inverted)
588  double pedestal = calbasesum / ((double)i1);
589  double area = calintsum-(pedestal*i2);
590  if(area<0) area=0; //On external triggers area over "peak" less pedestal could be negative which is nonsense.
591  double peak = maxadc;
592 
593  trig.baselinesum = calbasesum;
594  trig.intsum = calintsum;
595  trig.peaktime = calpeaktime;
596  trig.peaksum = calpeaksum;
597 
598  if(verb_meta_) {
599  std::cout
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
621  << std::endl
622  << "Pedestal " << pedestal << std::endl
623  << "Area " << area << std::endl
624  << "Peak heigth " << peak << std::endl
625  << std::endl;
626  }
627 
628  ///> increment the data pointer to the end of the current packet (to the start of the next packet header, if available)
629  dataPointer+=nADC/2;
630 
631  // Put waveform and ophit into collections
632  // Split into internal and external triggers if that has been set.
633  if (!fSplitTriggers) {
634  waveforms.emplace_back( Waveform );
635  hits.emplace_back( ConstructOpHit(clockData, trig, mappedchannel) );
636  }
637  else{
638  if (trig.type == 48 ) {
639  ext_waveforms.emplace_back( Waveform );
640  ext_hits.emplace_back( ConstructOpHit(clockData, trig, mappedchannel) );
641  }
642  else if (trig.type == 16) {
643  int_waveforms.emplace_back( Waveform );
644  int_hits.emplace_back( ConstructOpHit(clockData, trig, mappedchannel) );
645  }
646  else {
647  std::cerr << "Unknown trigger type " << trig.type << ", cannot assign to appropriate data product with SplitTriggers enabled." << std::endl;
648  }
649  }
650 
651  hist->Delete();
652 
653  ++packetsProcessed; // packets
654  }
655 
656  packets_per_fragment[frag.fragmentID()] = packetsProcessed;
657  allPacketsProcessed += packetsProcessed;
658  }//frag: fragments
659 
660  n_event_packets_->Fill(allPacketsProcessed);
661 
662  if (!fSplitTriggers) {
663  evt.put(std::make_unique<decltype(waveforms)>(std::move(waveforms)), fOutputDataLabel);
664  evt.put(std::make_unique<decltype(hits)>( std::move(hits)), fOutputDataLabel);
665  }
666  else {
667  evt.put(std::make_unique<decltype(ext_waveforms)>(std::move(ext_waveforms)), fExtTrigOutputLabel);
668  evt.put(std::make_unique<decltype(ext_hits)>( std::move(ext_hits)), fExtTrigOutputLabel);
669  evt.put(std::make_unique<decltype(int_waveforms)>(std::move(int_waveforms)), fIntTrigOutputLabel);
670  evt.put(std::make_unique<decltype(int_hits)>( std::move(int_hits)), fIntTrigOutputLabel);
671  }
672 }
Index OpChannel(Index detNum, Index channel)
std::vector< recob::OpHit > hits
unsigned int event
Definition: DataStructs.h:636
std::map< int, int > ssp_map_
std::vector< T > Waveform
Definition: IWaveformTool.h:21
void readHeader(const SSPDAQ::EventHeader *daqHeader, struct trig_variables *tv)
int16_t adc
Definition: CRTFragment.hh:202
uint8_t channel
Definition: CRTFragment.hh:201
std::vector< raw::OpDetWaveform > waveforms
std::vector< raw::OpDetWaveform > int_waveforms
unsigned int SSPOfflineChannelFromOnlineChannel(unsigned int onlineChannel)
std::map< size_t, TH1D * > trigger_type_
def move(depos, offset)
Definition: depos.py:107
recob::OpHit ConstructOpHit(detinfo::DetectorClocksData const &clockData, trig_variables &trig, unsigned int channel)
static int max(int a, int b)
std::vector< raw::OpDetWaveform > ext_waveforms
std::vector< recob::OpHit > ext_hits
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:118
TCEvent evt
Definition: DataStructs.cxx:7
std::vector< recob::OpHit > int_hits
QTextStream & endl(QTextStream &s)
void getFragments(art::Event &evt, std::vector< artdaq::Fragment > *fragments)
void dune::SSPRawDecoder::readHeader ( const SSPDAQ::EventHeader daqHeader,
struct trig_variables tv 
)

Definition at line 275 of file SSPRawDecoder_module.cc.

275  {
276 
277 
278  tv->header = daqHeader->header; // the 'start of header word' (should always be 0xAAAAAAAA)
279  tv->length = daqHeader->length; // the length of the packet in unsigned ints (including header)
280  tv->type = ((daqHeader->group1 & 0xFF00) >> 8); // packet type
281  tv->status_flags = ((daqHeader->group1 & 0x00F0) >> 4); // status flags
282  tv->header_type = ((daqHeader->group1 & 0x000F) >> 0); // header type
283  tv->trig_id = daqHeader->triggerID; // the packet ID
284  tv->module_id = ((daqHeader->group2 & 0xFFF0) >> 4); // module ID
285  tv->channel_id = ((daqHeader->group2 & 0x000F) >> 0); // channel ID
286 
287  // external timestamp sync delay (FP mode)
288  tv->timestamp_sync_delay = ((unsigned int)(daqHeader->timestamp[1]) << 16) + (unsigned int)(daqHeader->timestamp[0]);
289  // external timestamp sync count (FP mode)
290  tv->timestamp_sync_count = ((unsigned int)(daqHeader->timestamp[3]) << 16) + (unsigned int)(daqHeader->timestamp[2]);
291  // get the external timestamp (NOvA mode)
292  tv->timestamp_nova = ((unsigned long)daqHeader->timestamp[3] << 48) + ((unsigned long)daqHeader->timestamp[2] << 32)
293  + ((unsigned long)daqHeader->timestamp[1] << 16) + ((unsigned long)daqHeader->timestamp[0] << 0);
294 
295 
296  tv->peaksum = ((daqHeader->group3 & 0x00FF) >> 16) + daqHeader->peakSumLow; // peak sum
297  if(tv->peaksum & 0x00800000) {
298  tv->peaksum |= 0xFF000000;
299  }
300 
301  tv->peaktime = ((daqHeader->group3 & 0xFF00) >> 8); // peak time
302  tv->prerise = ((daqHeader->group4 & 0x00FF) << 16) + daqHeader->preriseLow; // prerise
303  tv->intsum = ((unsigned int)(daqHeader->intSumHigh) << 8) + (((unsigned int)(daqHeader->group4) & 0xFF00) >> 8); // integrated sum
304  tv->baseline = daqHeader->baseline; // baseline
305  tv->baselinesum = ((daqHeader->group4 & 0x00FF) << 16) + daqHeader->preriseLow; // baselinesum
306  for(unsigned int i_cfdi = 0; i_cfdi < 4; i_cfdi++) // CFD timestamp interpolation points
307  tv->cfd_interpol[i_cfdi] = daqHeader->cfdPoint[i_cfdi];
308 
309  tv->internal_interpol = daqHeader->intTimestamp[0]; // internal interpolation point
310  // internal timestamp
311  tv->internal_timestamp = ((uint64_t)((uint64_t)daqHeader->intTimestamp[3] << 32)) + ((uint64_t)((uint64_t)daqHeader->intTimestamp[2]) << 16) + ((uint64_t)((uint64_t)daqHeader->intTimestamp[1]));
312 
313 }
unsigned short triggerID
Definition: anlTypes.hh:72
unsigned short group2
Definition: anlTypes.hh:73
unsigned short cfdPoint[4]
Definition: anlTypes.hh:83
unsigned short length
Definition: anlTypes.hh:70
unsigned short timestamp[4]
Definition: anlTypes.hh:74
unsigned short intSumHigh
Definition: anlTypes.hh:81
unsigned short preriseLow
Definition: anlTypes.hh:79
unsigned short group4
Definition: anlTypes.hh:80
unsigned short peakSumLow
Definition: anlTypes.hh:77
unsigned int header
Definition: anlTypes.hh:69
unsigned short baseline
Definition: anlTypes.hh:82
unsigned short intTimestamp[4]
Definition: anlTypes.hh:84
unsigned short group1
Definition: anlTypes.hh:71
unsigned short group3
Definition: anlTypes.hh:78
void dune::SSPRawDecoder::reconfigure ( const fhicl::ParameterSet pset)

Definition at line 201 of file SSPRawDecoder_module.cc.

201  {
202 
203  fRawDataLabel = pset.get<std::string>("RawDataLabel");
204  fSplitTriggers = pset.get<bool>("SplitTriggers");
205  fOutputDataLabel = pset.get<std::string>("OutputDataLabel");
206  fExtTrigOutputLabel = pset.get<std::string>("ExtTrigOutputLabel");
207  fIntTrigOutputLabel = pset.get<std::string>("IntTrigOutputLabel");
208  fUseChannelMap = pset.get<bool>("UseChannelMap");
209  number_of_packets=pset.get<int>("number_of_packets");
210  fDebug = pset.get<bool>("Debug");
211  fZeroThreshold=0;
213 
214  if(fDebug) printParameterSet();
215 
216  verb_adcs_=pset.get<uint32_t> ("verbose_adcs", 10000);
217  verb_meta_=pset.get<bool> ("verbose_metadata", false);
218  n_adc_counter_=0;
219  adc_cumulative_=0;
220 
221  // m1, i1, i2
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");
226  //NOvAClockFrequency=pset.get<double>("NOvAClockFrequency"); // in MHz
227  SPESize=pset.get<double>("SPESize");
228 
229  std::cout << "Parameters from the fcl file" << std::endl;
230  std::cout << "m1: " << m1 << std::endl;
231  std::cout << "m2: " << m2 << std::endl;
232  std::cout << "i1: " << i1 << std::endl;
233  std::cout << "i2: " << i2 << std::endl;
234  //std::cout << "NOvAClockFrequency: " << NOvAClockFrequency << std::endl;
235  std::cout << "SPESize: " << SPESize << std::endl;
236  std::cout << std::endl;
237 
238  //startTime=0;
239 
240 }
std::string string
Definition: nybbler.cc:12
unsigned int fZeroThreshold
Zero suppression threshold.
no compression
Definition: RawTypes.h:9
T get(std::string const &key) const
Definition: ParameterSet.h:271
raw::Compress_t fCompression
compression type to use
QTextStream & endl(QTextStream &s)
void dune::SSPRawDecoder::setRootObjects ( )

Definition at line 268 of file SSPRawDecoder_module.cc.

268  {
270 
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);
273 }

Member Data Documentation

uint64_t dune::SSPRawDecoder::adc_cumulative_
private

Definition at line 113 of file SSPRawDecoder_module.cc.

uint64_t dune::SSPRawDecoder::allreftime
private

Definition at line 120 of file SSPRawDecoder_module.cc.

std::vector<recob::OpHit> dune::SSPRawDecoder::ext_hits
private

Definition at line 179 of file SSPRawDecoder_module.cc.

uint64_t dune::SSPRawDecoder::ext_ireftime_[24]
private

Definition at line 119 of file SSPRawDecoder_module.cc.

std::vector<raw::OpDetWaveform> dune::SSPRawDecoder::ext_waveforms
private

Definition at line 176 of file SSPRawDecoder_module.cc.

uint64_t dune::SSPRawDecoder::extreftime_[24]
private

Definition at line 118 of file SSPRawDecoder_module.cc.

raw::Compress_t dune::SSPRawDecoder::fCompression
private

compression type to use

Definition at line 109 of file SSPRawDecoder_module.cc.

bool dune::SSPRawDecoder::fDebug
private

Definition at line 108 of file SSPRawDecoder_module.cc.

std::string dune::SSPRawDecoder::fExtTrigOutputLabel
private

Definition at line 105 of file SSPRawDecoder_module.cc.

std::string dune::SSPRawDecoder::fIntTrigOutputLabel
private

Definition at line 106 of file SSPRawDecoder_module.cc.

std::string dune::SSPRawDecoder::fOutputDataLabel
private

Definition at line 104 of file SSPRawDecoder_module.cc.

TH1D* dune::SSPRawDecoder::frag_sizes_
private

Definition at line 128 of file SSPRawDecoder_module.cc.

std::string dune::SSPRawDecoder::fRawDataLabel
private

Definition at line 102 of file SSPRawDecoder_module.cc.

bool dune::SSPRawDecoder::fSplitTriggers
private

Definition at line 103 of file SSPRawDecoder_module.cc.

bool dune::SSPRawDecoder::fUseChannelMap
private

Definition at line 107 of file SSPRawDecoder_module.cc.

unsigned int dune::SSPRawDecoder::fZeroThreshold
private

Zero suppression threshold.

Definition at line 110 of file SSPRawDecoder_module.cc.

std::vector<recob::OpHit> dune::SSPRawDecoder::hits
private

Definition at line 178 of file SSPRawDecoder_module.cc.

double dune::SSPRawDecoder::i1
private

Definition at line 133 of file SSPRawDecoder_module.cc.

double dune::SSPRawDecoder::i2
private

Definition at line 133 of file SSPRawDecoder_module.cc.

std::vector<recob::OpHit> dune::SSPRawDecoder::int_hits
private

Definition at line 180 of file SSPRawDecoder_module.cc.

uint64_t dune::SSPRawDecoder::int_ireftime_[24]
private

Definition at line 117 of file SSPRawDecoder_module.cc.

std::vector<raw::OpDetWaveform> dune::SSPRawDecoder::int_waveforms
private

Definition at line 177 of file SSPRawDecoder_module.cc.

uint64_t dune::SSPRawDecoder::intreftime_[24]
private

Definition at line 116 of file SSPRawDecoder_module.cc.

double dune::SSPRawDecoder::m1
private

Definition at line 133 of file SSPRawDecoder_module.cc.

double dune::SSPRawDecoder::m2
private

Definition at line 133 of file SSPRawDecoder_module.cc.

uint32_t dune::SSPRawDecoder::n_adc_counter_
private

Definition at line 112 of file SSPRawDecoder_module.cc.

TH1D* dune::SSPRawDecoder::n_event_packets_
private

Definition at line 127 of file SSPRawDecoder_module.cc.

int dune::SSPRawDecoder::number_of_packets = 12
private

Definition at line 142 of file SSPRawDecoder_module.cc.

double dune::SSPRawDecoder::SPESize
private

Definition at line 136 of file SSPRawDecoder_module.cc.

std::map<int,int> dune::SSPRawDecoder::ssp_map_
private
Initial value:
=
{ {11,0},
{12,1},
{13,2},
{14,3},
{21,4},
{22,5},
{23,6},
{24,7},
{31,8},
{32,9},
{33,10},
{34,11},
{41,12},
{42,13},
{43,14},
{44,15},
{51,16},
{52,17},
{53,18},
{54,19},
{61,20},
{62,21},
{63,22},
{64,23} }

Definition at line 145 of file SSPRawDecoder_module.cc.

bool dune::SSPRawDecoder::timed_
private

Definition at line 125 of file SSPRawDecoder_module.cc.

std::map<size_t,TH1D*> dune::SSPRawDecoder::trigger_type_
private

Definition at line 171 of file SSPRawDecoder_module.cc.

uint32_t dune::SSPRawDecoder::verb_adcs_
private

Definition at line 123 of file SSPRawDecoder_module.cc.

bool dune::SSPRawDecoder::verb_meta_
private

Definition at line 124 of file SSPRawDecoder_module.cc.

std::vector<raw::OpDetWaveform> dune::SSPRawDecoder::waveforms
private

Definition at line 175 of file SSPRawDecoder_module.cc.


The documentation for this class was generated from the following file: