TestBeamRawInputDriver.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////
2 /// \file TestBeamRawInputDriver.cxx
3 /// \brief Implementation of the offline conversion of both
4 /// test beam data streams (beamline and detector).
5 /// Provided as the templated argument to art::Source.
6 /// \author Mike Wallbank (University of Cincinnati) <wallbank@fnal.gov>
7 /// \date December 2018
8 ////////////////////////////////////////////////////////////////////////////
9 
10 ////////////////////////////////////////////////////////////////////////////
11 /// So, how does this work? Good question.
12 ///
13 /// We have two data streams: detector and beamline.
14 /// Anticipate both beamline and detector files will be data collected
15 /// over period of ~O(1 hour) (similar to ND), but they will obviously
16 /// not necessarily overlap.
17 /// The detector files contain beamline triggers and other (e.g. cosmic)
18 /// triggers. Beamline triggers will line up with triggers in the
19 /// beamline files. Other trigger streams are saved in separate output
20 /// files, so only need to worry about beamline triggers here.
21 ///
22 /// Demonstration (| = trigger):
23 ///
24 /// | || | | | |
25 /// ---------------------------------------- ------- Detector data
26 /// -------------------- --------------------------- Beamline data
27 /// | || | | | |
28 ///
29 /// This module is designed to run over a single detector file and assumes
30 /// the beamline data files which align with this in time are in the
31 /// working directory. No checks on this are performed nor are any
32 /// attempts made to look up files in this module.
33 ///
34 /// In order to match and merge the two streams into the same art::Event,
35 /// the following is performed:
36 /// -- perform an initial scan through the beamline data files to index
37 /// the file name, spill number and trigger number for each TDU
38 /// timestamp;
39 /// -- read in the given detector data file and convert to NOvASoft
40 /// data formatting;
41 /// -- convert the detector data into NOvASoft-formatted offline data
42 /// products;
43 /// -- for each event, compare TDU timestamp with the timestamps of the
44 /// beamline events and find corresponding beamline information;
45 /// -- save all the NOvASoft data products within an art::Event.
46 ////////////////////////////////////////////////////////////////////////////
47 
49 
50 //------------------------------------------------------------------------------
53  art::SourceHelper const &pm) :
54  NOvAInputDriverBase(pset.get<std::string>("GDMLFileBase","")),
55  fBeamlineUnpack(new BeamlineUnpack(pset.get<fhicl::ParameterSet>("BeamlineUnpack"))),
56  fSourceHelper(pm),
57  fCurrentFilename(),
58  fCurrentSubRunID(-1, -1),
59  fParser() {
60 
61  this->reconfigure(pset);
62 
63  fParser.setDebug(false);
64 
65  // Declare everything to be put in the art record
68  helper.reconstitutes<std::vector<rawdata::RawDigit>, art::InEvent>(fSourceName);
69  helper.reconstitutes<std::vector<rawdata::RawTrigger>, art::InEvent>(fSourceName);
70  helper.reconstitutes<std::vector<rawdata::RawSumDropMB>, art::InEvent>(fSourceName);
71  helper.reconstitutes<std::vector<rawdata::RawSumDCM>, art::InEvent>(fSourceName);
73  helper.reconstitutes<std::vector<rawdata::FlatDAQData>, art::InEvent>(fSourceName);
75  helper.reconstitutes<std::vector<rawdata::RawBeamlineTrigger>, art::InEvent>(fSourceName, fTriggerName);
76  helper.reconstitutes<std::vector<rawdata::RawBeamlineDigit>, art::InEvent>(fSourceName, fToFName);
77  helper.reconstitutes<std::vector<rawdata::RawBeamlineWC>, art::InEvent>(fSourceName, fWCName);
78  helper.reconstitutes<std::vector<rawdata::RawBeamlineDigit>, art::InEvent>(fSourceName, fCherenkovName);
79  helper.reconstitutes<std::vector<rawdata::RawBeamlineDigit>, art::InEvent>(fSourceName, fMuonStackName);
80  helper.reconstitutes<std::vector<rawdata::RawBeamlineDigit>, art::InEvent>(fSourceName, fPaddleDigitName);
81  helper.reconstitutes<std::vector<rawdata::RawBeamlineDigit>, art::InEvent>(fSourceName, fWCDigitName);
82  helper.reconstitutes<std::vector<rawdata::RawBeamlineDigit>, art::InEvent>(fSourceName, fOtherDigitName);
83 
84  // Read in all the beamline data
85  this->readBeamline();
86 
87 }
88 
89 //------------------------------------------------------------------------------
91 
92  // output module label
93  fSourceName = pset.get<std::string>("SourceName");
94 
95  // beamline unpack config
96  fhicl::ParameterSet beamline_config = pset.get<fhicl::ParameterSet>("BeamlineUnpackConfig");
97  fInputSpillTag = beamline_config.get<art::InputTag>("InputSpillTag");
98  fInputTDUTag = beamline_config.get<art::InputTag>("InputTDUTag");
99  fConfigName = beamline_config.get<std::string>("ConfigName");
100  fTriggerName = beamline_config.get<std::string>("TriggerName");
101  fToFName = beamline_config.get<std::string>("ToFName");
102  fWCName = beamline_config.get<std::string>("WCName");
103  fCherenkovName = beamline_config.get<std::string>("CherenkovName");
104  fMuonStackName = beamline_config.get<std::string>("MuonStackName");
105  fPaddleDigitName = beamline_config.get<std::string>("PaddleDigitName");
106  fWCDigitName = beamline_config.get<std::string>("WCDigitName");
107  fOtherDigitName = beamline_config.get<std::string>("OtherDigitName");
108 
109  // running options
110  fMaxEventSize = pset.get<size_t>("maxEventSizeK", 65536) * 1024;
111  fFilterCorruptedNanoslices = pset.get<bool>("FilterCorruptedNanoslices");
112  fDoFillFlatDAQData = pset.get<bool>("DoFillFlatDAQData");
113  fFilterBeamlineEvents = pset.get<bool>("FilterBeamlineEvents");
114 
115 }
116 
117 //------------------------------------------------------------------------------
118 /// Close currently-open file.
120  fParser.close();
121 }
122 
123 // -----------------------------------------------------------------------
124 /// Read in all the beamline triggers from the beamline data files.
125 /// Expect all files relevant for this detector data to have been found
126 /// and placed in this working directory.
128 
129  fBeamlineEvents.reset(new BeamlineEvents(0));
130 
131  // get files in working directory
132  TString pwd(gSystem->pwd());
133  TSystemDirectory dir(pwd, pwd);
134  TList* files = dir.GetListOfFiles();
135  if (!files)
136  return;
137 
138  // loop over files in working directory
139  TSystemFile* file;
140  TString file_name;
141  TIter next(files);
142  while ((file = (TSystemFile*)next())) {
143 
144  file_name = file->GetName();
145  if (!file_name.BeginsWith("novabeamline_") or !file_name.EndsWith(".root"))
146  continue;
147  mf::LogVerbatim("TestBeamRawInputDriver::readBeamline")
148  << "Reading in beamline file " << file_name << std::endl;
149  BeamlineFileIndex bl_file(file_name.Data());
150 
151  // get artdaq::Fragments branch
152  TFile* inFile = TFile::Open(file_name, "READ");
153  TTree* eventTree = reinterpret_cast<TTree*>(inFile->Get(art::rootNames::eventTreeName().c_str()));
154  TBranch* spillBranch = eventTree->GetBranch(getBranchName<artdaq::Fragments>(fInputSpillTag).data());
155  TBranch* tduBranch = eventTree->GetBranch(getBranchName<artdaq::Fragments>(fInputTDUTag).data());
156 
157  // ensure we have the same number of spills in each component
158  unsigned int numSpillsInFile = 0;
159  if (spillBranch->GetEntries() != tduBranch->GetEntries())
160  throw cet::exception("TestBeamRawInputDriver::readBeamline")
161  << "In file " << file_name << ", "
162  << "number of spills recorded in spill branch (" << spillBranch->GetEntries() << ") "
163  << "does not match number of spills recorded in TDU branch (" << tduBranch->GetEntries() << ")."
164  << std::endl;
165  else {
166  numSpillsInFile = spillBranch->GetEntries();
167  mf::LogVerbatim("TestBeamRawInputDriver::readBeamline")
168  << "Number of spills in file " << file_name << ": "
169  << numSpillsInFile << std::endl;
170  }
171 
172  // loop through spills in the file
173  for (unsigned int spillIt = 0; spillIt < numSpillsInFile; ++spillIt) {
174 
175  BeamlineSpillIndex bl_spill(bl_file, spillIt);
176 
177  // load the artdaq fragments
178  LariatFragment* spillFrag = loadSpillFragments(spillBranch, spillIt);
179  std::vector<TDUFragment*> tduFrags = loadTDUFragments(tduBranch, spillIt);
180 
181  // configure beamline unpack alg?
182 
183  // fill all novasoft data products
184  try {
185  fBeamlineUnpack->Unpack(spillFrag, tduFrags);
186  }
187  catch (cet::exception& e) {
188  mf::LogWarning("TestBeamRawInputDriver::readBeamline")
189  << "Unpacking " << file_name << ", spill " << spillIt << std::endl
190  << e.what() << std::endl
191  << "EXCEPTION CAUGHT: ignoring this spill." << std::endl;
192  continue;
193  }
194 
195  // get the beamline events
196  BeamlineEvents* beamlineEvents = fBeamlineUnpack->GetBeamlineEvents();
197  mf::LogVerbatim("TestBeamRawInputDriver::readBeamline")
198  << "Number of spills in file " << file_name << ", spill " << spillIt << ": "
199  << beamlineEvents->NumEvents() << std::endl;
200 
201  // loop through triggers in this spill
202  for (unsigned int triggerIt = 0; triggerIt < beamlineEvents->NumEvents(); ++triggerIt) {
203 
204  BeamlineTriggerIndex bl_trigger(bl_spill, triggerIt);
205 
206  BeamlineEvent* beamlineEvent = beamlineEvents->FindEvent(triggerIt);
207  fBeamlineIndex.insert(std::make_pair(beamlineEvent->GetTDUTime(), bl_trigger));
208 
209  } // trigger
210 
211  delete spillFrag;
212  for (std::vector<TDUFragment*>::const_iterator tduIt = tduFrags.begin();
213  tduIt != tduFrags.end(); ++tduIt)
214  delete *tduIt;
215  fBeamlineUnpack->EndSpill();
216 
217  } // spill
218 
219  inFile->Close();
220 
221  } // file
222 
223  mf::LogVerbatim("TestBeamRawInputDriver::readBeamline")
224  << "Contents of the beamline index map:" << std::endl;
225  for (std::map<unsigned long long, BeamlineTriggerIndex>::const_iterator blIndexIt = fBeamlineIndex.begin();
226  blIndexIt != fBeamlineIndex.end(); ++blIndexIt)
227  mf::LogVerbatim("TestBeamRawInputDriver::readBeamline")
228  << "NOvA time " << blIndexIt->first
229  << " corresponds to file " << blIndexIt->second.File
230  << ", spill " << blIndexIt->second.Spill
231  << " and trigger " << blIndexIt->second.Trigger << "." << std::endl;
232 
233  return;
234 
235 }
236 
237 // -----------------------------------------------------------------------
238 /// Get the lariat fragment from the spill wrapper
239 LariatFragment* daq2raw::TestBeamRawInputDriver::getSpillFrag(const SpillWrapper* spillWrapper) {
240 
241  // get the spill data
242  mf::LogVerbatim("TestBeamRawInputDriver") << "Spill construction complete\n"
243  << "Spill starts at "
244  << static_cast<const void*>(spillWrapper->get())
245  << ", can pass this pointer to the LariatFragment constructor\n"
246  << "Spill appears to be " << spillWrapper->size() << " bytes\n";
247 
248  const uint8_t* spillDataPtr(spillWrapper->get());
249 
250  mf::LogVerbatim("TestBeamRawInputDriver") << "Spill is "
251  << spillWrapper->size()
252  << " bytes, starting at "
253  << static_cast<const void*>(spillDataPtr);
254 
255  // make a lariat fragment
256  LariatFragment* spillFrag = new LariatFragment((char*)spillDataPtr, spillWrapper->size());
257 
258  return spillFrag;
259 
260 }
261 
262 // -----------------------------------------------------------------------
263 /// Load the artdaq fragments
264 LariatFragment* daq2raw::TestBeamRawInputDriver::loadSpillFragments(TBranch* fragBranch,
265  unsigned int index) {
266 
267  SpillWrapper* spillWrapper = new SpillWrapper(1);
268  artdaq::Fragments* fragments = getFragments(fragBranch, index);
269 
270  if ((*fragments).size() > 1)
271  throw cet::exception("TestBeamRawInputDriver")
272  << "artdaq::Fragment SPILL vector contains more than one fragment.";
273 
274  const artdaq::Fragment& fragment = fragments->at(0);
275  spillWrapper->add(fragment);
276 
277  if (!spillWrapper->ready())
278  throw cet::exception("TestBeamRawInputDriver")
279  << "Spill construction failed; spill is incomplete." << std::endl;
280 
281  // load the lariat fragment
282  LariatFragment* spillFrag = getSpillFrag(spillWrapper);
283 
284  delete spillWrapper;
285  return spillFrag;
286 }
287 
288 // -----------------------------------------------------------------------
289 /// Load the TDU artdaq fragment
290 std::vector<TDUFragment*> daq2raw::TestBeamRawInputDriver::loadTDUFragments(TBranch* tduBranch,
291  unsigned int index) {
292 
293  // container of tdu fragments to be read in from the
294  // artdaq branch
295  std::vector<TDUFragment*> tduFrags;
296 
297  artdaq::Fragments* fragments = getFragments(tduBranch, index);
298 
299  if ((*fragments).size() > 1)
300  throw cet::exception("TestBeamRawInputDriver")
301  << "artdaq::Fragment TDU vector contains more than one fragment.";
302 
303  for (artdaq::Fragments::const_iterator fragIt = fragments->begin(); fragIt != fragments->end(); ++fragIt) {
304 
305  artdaq::ContainerFragment cont_frag(*fragIt);
306 
307  for (size_t block = 0; block < cont_frag.block_count(); ++block) {
308  const artdaq::Fragment frag = *cont_frag[block];
309  TDUFragment* tduFrag = new TDUFragment(reinterpret_cast<const char*>(frag.dataBeginBytes()));
310  tduFrags.push_back(tduFrag);
311  }
312 
313  }
314 
315  return tduFrags;
316 
317 }
318 
319 // -----------------------------------------------------------------------
320 /// Find and load the beamline event which corresponds to a specific
321 /// TDU timestamp
323 
324  BeamlineTriggerIndex bl_index;
325 
326  if (fBeamlineIndex.count(tduTime))
327  bl_index = fBeamlineIndex[tduTime];
328  else if (fBeamlineIndex.count(tduTime-1))
329  bl_index = fBeamlineIndex[tduTime-1];
330  else if (fBeamlineIndex.count(tduTime+1))
331  bl_index = fBeamlineIndex[tduTime+1];
332  else if (fBeamlineIndex.count(tduTime+2))
333  bl_index = fBeamlineIndex[tduTime+2];
334  else if (fBeamlineIndex.count(tduTime-2))
335  bl_index = fBeamlineIndex[tduTime-2];
336  else {
337  mf::LogWarning("TestBeamRawInputDriver::loadBeamlineEvent")
338  << "No beamline event with TDU timestamp " << tduTime << " found." << std::endl;
339  return nullptr;
340  }
341 
342  // open the input file and get the branches
343  TFile* inFile = TFile::Open(bl_index.File.c_str(), "READ");
344  TTree* eventTree = reinterpret_cast<TTree*>(inFile->Get(art::rootNames::eventTreeName().c_str()));
345  TBranch* eventAuxBranch = eventTree->GetBranch("EventAuxiliary");
346  TBranch* spillBranch = eventTree->GetBranch(getBranchName<artdaq::Fragments>(fInputSpillTag).data());
347  TBranch* tduBranch = eventTree->GetBranch(getBranchName<artdaq::Fragments>(fInputTDUTag).data());
348 
349  // load the artdaq fragments
350  LariatFragment* spillFrag = loadSpillFragments(spillBranch, bl_index.Spill);
351  std::vector<TDUFragment*> tduFrags = loadTDUFragments(tduBranch, bl_index.Spill);
352 
353  // find run number for unpacking the magnetic field
354  art::EventAuxiliary eventAux;
355  art::EventAuxiliary* eventAuxPtr = &eventAux;
356  eventAuxBranch->SetAddress(&eventAuxPtr);
357  eventAuxBranch->GetEntry(bl_index.Spill);
358  unsigned int beamline_run = eventAux.run();
359 
360  // configure beamline unpack alg?
361 
362  // unpack and retrieve the beamline events
363  fBeamlineUnpack->Unpack(spillFrag, tduFrags, beamline_run, bl_index.File);
364  BeamlineEvents* beamlineEvents = fBeamlineUnpack->GetBeamlineEvents();
365 
366  // find the trigger
367  // Make a new pointer to this on heap so all the other events
368  // can be cleaned up at the end of this function.
369  // It is the responsibility of the eventual user of this data
370  // to clean up when done.
371  BeamlineEvent* beamlineEvent
372  = new BeamlineEvent(*beamlineEvents->FindEvent(bl_index.Trigger));
373 
374  // tidy up
375  inFile->Close();
376  delete spillFrag;
377  for (std::vector<TDUFragment*>::const_iterator tduIt = tduFrags.begin();
378  tduIt != tduFrags.end(); ++tduIt)
379  delete *tduIt;
380  fBeamlineUnpack->EndSpill();
381 
382  mf::LogVerbatim("TestBeamRawInputDriver::loadBeamlineEvent")
383  << "Found matching beamline event from file "
384  << bl_index.File << ", spill "
385  << bl_index.Spill << " and trigger "
386  << bl_index.Trigger << std::endl;
387 
388  return beamlineEvent;
389 
390 }
391 
392 //------------------------------------------------------------------------------
393 /// Open the file, "name" and construct and return a
394 /// new FileBlock object. MUST be successful or throw:
395 /// art::Exception(art::errors::FileOpenError) or
396 /// art::Exception(art::errors::FileReadError) are good candidates.
398  art::FileBlock* &fb) {
399 
401 
402  int fd = fParser.open(fCurrentFilename.c_str());
403  if (fd == -1) { // Failure
405  << "Unable to open file "
406  << name
407  << " due to system error, \""
408  << strerror(errno)
409  << "\"\n";
410  }
411 
412  fb = new art::FileBlock(art::FileFormatVersion(1, "NOvARawInput 2011a"),
414 }
415 
416 //------------------------------------------------------------------------------
417 /// Read and fill Run, SubRun and/or Event as might be
418 /// appropriate.
420  art::SubRunPrincipal* const &inSR,
421  art::RunPrincipal* &outR,
422  art::SubRunPrincipal* &outSR,
423  art::EventPrincipal* &outE) {
424 
425  ////////////////////////////////////
426  // Unpack the data.
427 
428  // NOTE: As of OnlineUnpack.cxx r1.9, the histogram pointers required
429  // in the constructor are *not* filled. In the event that one *does*
430  // want this kind of information, the data to be histogrammed should
431  // be put into event products (not necessarily written out to file)
432  // and turned into histograms by a downstream analyzer. This will
433  // enable easy management of different histograms for diferent runs,
434  // subruns, etc, etc and trivial control of whether histograns are
435  // actually wanted or not.
436  daq2raw::OnlineUnpack up(nullptr, nullptr, nullptr, &fCurrentFilename);
438 
439  /// Define data structures, which will be filled by OnlineUnpack::ProcessRawEvent
440  std::unique_ptr<std::vector<rawdata::RawDigit> > digits(new std::vector<rawdata::RawDigit>);
441  rawdata::RawTrigger raw_trigger;
442  rawdata::RawSumDropMB raw_sumDropMB;
443  rawdata::RawSumDCM raw_sumDCM;
444  rawdata::FlatDAQData flat_daq_data;
445  rawdata::DAQHeader daq_header;
446 
447  /// Fill the data structures for this event.
448  if (!up.ProcessRawEvent(fParser,
449  digits.get(),
450  &raw_trigger,
451  &raw_sumDropMB,
452  &raw_sumDCM,
453  &flat_daq_data,
454  &daq_header))
455  return false;
456 
457  // Get the actual timestamp here - use the current time as the
458  // default, maybe the default should really be a ridiculous value
459  struct timespec ts;
460 
463 
464  // Find the corresponding beamline event which matches this
465  // detector trigger.
466  BeamlineEvent* beamlineEvent
468  // // Consider leaving this event if there is no corresponding beamline data
469  // if (!beamlineEvent)
470  // return true;
471 
472  // art::Timestamp has the seconds since the beginning of the epoch
473  // in the upper 32 bits and the fractional seconds in the lower 32
474  // bits.
475  art::Timestamp tstamp = (ts.tv_sec << 32) | ts.tv_nsec;
476 
477  ////////////////////////////////////
478  // Assemble new principals as required.
479  art::SubRunID newID(up.getRunNumber(), up.getSubrunNumber());
480  if (inR == nullptr || fCurrentSubRunID.runID() != newID.runID()) { // New Run fragment
481  outR = fSourceHelper.makeRunPrincipal(up.getRunNumber(), tstamp);
482 
483  // get the base form of the geometry file for the current detector
484  //\todo at some point we should query a database to get this, especially
485  //\todo when we have instances of only part of a detector working
486  std::string detFileBase = getDetectorGDML(up.getDetId());
487  std::unique_ptr<sumdata::RunData> rundata
489  detFileBase,
490  geo::GeometryBase::ExtractGDML(detFileBase+".gdml", false)));
491  art::put_product_in_principal(std::move(rundata),
492  *outR,
493  fSourceName); // Module label
494  }
495  if (inSR == nullptr || fCurrentSubRunID != newID) { // New SubRun fragment
497  up.getSubrunNumber(),
498  tstamp);
499  fCurrentSubRunID = newID;
500  }
502  up.getSubrunNumber(),
503  up.getEventNumber(),
504  tstamp);
505 
506  ////////////////////////////////////
507  // Add the event products to the event:
508 
509  // Digitized data:
510  art::put_product_in_principal(std::move(digits), *outE, fSourceName);
511 
512  // Trigger data:
513  std::unique_ptr<std::vector<rawdata::RawTrigger> > rtcol(new std::vector<rawdata::RawTrigger>);
514  rtcol->push_back(raw_trigger); // Read one, product is a vector.
515  art::put_product_in_principal(std::move(rtcol),
516  *outE,
517  fSourceName);
518 
519  // RawSumDropMB data:
520  std::unique_ptr<std::vector<rawdata::RawSumDropMB> > rtcol_MB(new std::vector<rawdata::RawSumDropMB>);
521  rtcol_MB->push_back(raw_sumDropMB); // Read one, product is a vector.
522  art::put_product_in_principal(std::move(rtcol_MB),
523  *outE,
524  fSourceName);
525 
526  // RawSumDCM data:
527  std::unique_ptr<std::vector<rawdata::RawSumDCM> > rtcol_DCM(new std::vector<rawdata::RawSumDCM>);
528  rtcol_DCM->push_back(raw_sumDCM); // Read one, product is a vector.
529  art::put_product_in_principal(std::move(rtcol_DCM),
530  *outE,
531  fSourceName);
532 
533  // DAQ header:
534  std::unique_ptr<rawdata::DAQHeader > daqcol(new rawdata::DAQHeader(daq_header));
535  art::put_product_in_principal(std::move(daqcol),
536  *outE,
537  fSourceName);
538 
539  /// Put FlatDAQData object
540  if(fDoFillFlatDAQData) {
541  std::unique_ptr<std::vector<rawdata::FlatDAQData> > flatcol(new std::vector<rawdata::FlatDAQData>);
542  flatcol->push_back(flat_daq_data); // Read one, product is a vector.
543  art::put_product_in_principal(std::move(flatcol),
544  *outE,
545  fSourceName);
546  }
547 
548  ////////////////////////////////////
549  // Beamline data products:
550  rawdata::RawBeamlineConfig bl_config;
551  std::vector<rawdata::RawBeamlineTrigger> bl_trigger;
552  std::vector<rawdata::RawBeamlineDigit> bl_tof;
553  std::vector<rawdata::RawBeamlineWC> bl_wc;
554  std::vector<rawdata::RawBeamlineDigit> bl_cherenkov;
555  std::vector<rawdata::RawBeamlineDigit> bl_muonstack;
556  std::vector<rawdata::RawBeamlineDigit> bl_paddledigit;
557  std::vector<rawdata::RawBeamlineDigit> bl_wcdigit;
558  std::vector<rawdata::RawBeamlineDigit> bl_otherdigit;
559 
560  if (beamlineEvent) {
561  bl_config = beamlineEvent->GetConfig();
562  bl_trigger = beamlineEvent->GetTrigger();
563  bl_tof = beamlineEvent->GetToF();
564  bl_wc = beamlineEvent->GetWC();
565  bl_cherenkov = beamlineEvent->GetCherenkov();
566  bl_muonstack = beamlineEvent->GetMuonStack();
567  delete beamlineEvent;
568  }
569 
571  (std::make_unique<rawdata::RawBeamlineConfig>(bl_config), *outE, fSourceName, fConfigName);
573  (std::make_unique<std::vector<rawdata::RawBeamlineTrigger> >(bl_trigger), *outE, fSourceName, fTriggerName);
575  (std::make_unique<std::vector<rawdata::RawBeamlineDigit> >(bl_tof), *outE, fSourceName, fToFName);
577  (std::make_unique<std::vector<rawdata::RawBeamlineWC> >(bl_wc), *outE, fSourceName, fWCName);
579  (std::make_unique<std::vector<rawdata::RawBeamlineDigit> >(bl_cherenkov), *outE, fSourceName, fCherenkovName);
581  (std::make_unique<std::vector<rawdata::RawBeamlineDigit> >(bl_muonstack), *outE, fSourceName, fMuonStackName);
583  (std::make_unique<std::vector<rawdata::RawBeamlineDigit> >(bl_paddledigit), *outE, fSourceName, fPaddleDigitName);
585  (std::make_unique<std::vector<rawdata::RawBeamlineDigit> >(bl_wcdigit), *outE, fSourceName, fWCDigitName);
587  (std::make_unique<std::vector<rawdata::RawBeamlineDigit> >(bl_otherdigit), *outE, fSourceName, fOtherDigitName);
588 
589 
590  return true;
591 }
void setDebug(bool f)
Close any currently open file.
Definition: RawFileParser.h:65
int open(const char *filename)
General initialization and reinitialization.
RunNumber_t run() const
std::string getDetectorGDML(const int detid) const
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
const XML_Char * name
Definition: expat.h:151
EventPrincipal * makeEventPrincipal(EventAuxiliary const &eventAux, std::shared_ptr< History > &&history) const
BeamlineEvent * FindEvent(unsigned int event)
rawdata::RawBeamlineConfig GetConfig() const
std::enable_if_t< P::branch_type==InEvent||P::branch_type==InResults > put_product_in_principal(std::unique_ptr< T > &&product, P &principal, std::string const &module_label, std::string const &instance_name={})
std::size_t size() const
std::vector< TDUFragment * > loadTDUFragments(TBranch *tduBranch, unsigned int index)
load the artdaq TDU fragments from the input file
uint32_t getSubrunNumber() const
Definition: OnlineUnpack.h:80
std::vector< rawdata::RawBeamlineTrigger > GetTrigger() const
std::vector< rawdata::RawBeamlineDigit > GetCherenkov() const
std::vector< rawdata::RawBeamlineWC > GetWC() const
std::string const & eventTreeName()
bool fFilterCorruptedNanoslices
Do we need to filter out Corrupted NanoSlices?
Definition: OnlineUnpack.h:96
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
bool fDoFillFlatDAQData
Do we need to fill FlatDAQData object?
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
rawfileparser::RawFileParser fParser
Online raw file parsing utility.
bool convertNovaTimeToUnixTime(uint64_t const &inputNovaTime, struct timespec &outputUnixTime)
void readBeamline()
read in the beamline files corresponding to the time period of this input file
art::SourceHelper const & fSourceHelper
Class to help with {Run, SubRun, Event}Principal construction.
def pwd()
Definition: g4zmq.py:47
artdaq::Fragments * getFragments(TBranch *br, unsigned entry)
uint64_t GetTDUTime() const
bool fFilterBeamlineEvents
Filter bad beamline events.
BeamlineEvent * loadBeamlineEvent(unsigned long long tduTime)
find and load the beamline event which corresponds to a specific TDU timestamp
TypeLabel const & reconstitutes(std::string const &modLabel, std::string const &instanceName={})
std::vector< rawdata::RawBeamlineDigit > GetToF() const
const XML_Char const XML_Char * data
Definition: expat.h:268
LariatFragment * getSpillFrag(const SpillWrapper *spillWrapper)
get the lariat fragment from the artdaq fragments
ifstream inFile
Definition: AnaPlotMaker.h:34
RunID const & runID() const
Definition: SubRunID.h:77
block
print "ROW IS " print row
Definition: elec2geo.py:31
Implementation of the offline conversion of both test beam data streams (beamline and detector)...
LariatFragment * loadSpillFragments(TBranch *fragBranch, unsigned int index)
load the artdaq spill fragments from the input file
std::unique_ptr< BeamlineEvents > fBeamlineEvents
Container to hold all beamline events before matching with detector data.
T get(std::string const &key) const
Definition: ParameterSet.h:231
int close()
Open a file for parsing.
bool readNext(art::RunPrincipal *const &inR, art::SubRunPrincipal *const &inSR, art::RunPrincipal *&outR, art::SubRunPrincipal *&outSR, art::EventPrincipal *&outE)
RunPrincipal * makeRunPrincipal(RunAuxiliary const &runAux) const
void closeCurrentFile()
Close currently-open file.
size_t fMaxEventSize
Will not try to read an event bigger than this.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
std::map< unsigned long long, BeamlineTriggerIndex > fBeamlineIndex
Container to index beamline file, spill, trigger and TDU information.
TDirectory * dir
Definition: macro.C:5
unsigned long long fTriggerTimingMarker_TimeStart
Definition: RawTrigger.h:38
std::unique_ptr< daq2raw::BeamlineUnpack > fBeamlineUnpack
Algorithm to handle unpacking of beamline data.
void readFile(std::string const &name, art::FileBlock *&fb)
bool fFilterCorruptedNanoslices
Filter the corrupted nanaslices in the unpacking?
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
const uint8_t * get() const
TFile * file
Definition: cellShifts.C:17
std::string ExtractGDML() const
Extract contents from fGDMLFile and return as a string.
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary const &subRunAux) const
int getDetId() const
Definition: OnlineUnpack.h:82
std::vector< rawdata::RawBeamlineDigit > GetMuonStack() const
uint32_t getRunNumber() const
Definition: OnlineUnpack.h:79
Float_t e
Definition: plot.C:35
void add(const art::Event &evt, const art::InputTag &tag)
std::string fCurrentFilename
Hang on to the current filename.
void reconfigure(const fhicl::ParameterSet &pset)
art::SubRunID fCurrentSubRunID
Keep track of the current subRun details.
bool ProcessRawEvent(void *rawevent_buffer, std::vector< rawdata::RawDigit > *, rawdata::RawTrigger *, rawdata::RawSumDropMB *, rawdata::RawSumDCM *, rawdata::FlatDAQData *, rawdata::DAQHeader *)
Unpack the RawEvent.
void next()
Definition: show_event.C:84
unsigned long long getEventNumber() const
Definition: OnlineUnpack.h:81
int errno
Definition: errno.cpp:12
unsigned int NumEvents() const
TestBeamRawInputDriver(fhicl::ParameterSet const &pset, art::ProductRegistryHelper &help, art::SourceHelper const &pm)