TestBeamRawInputDriver.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////
2 /// \file TestBeamRawInputDriver.h
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 #ifndef DAQ2RAWDIGIT_TESTBEAMRAWINPUTDRIVER_H
11 #define DAQ2RAWDIGIT_TESTBEAMRAWINPUTDRIVER_H
12 
13 // framework
24 #include "fhiclcpp/ParameterSet.h"
26 
27 // artdaq
28 #include "artdaq-core/Data/Fragment.hh"
29 #include "artdaq-core/Data/ContainerFragment.hh"
30 
31 // beamline
32 #include "LArIATFragments/LariatFragment.h"
33 #include "LArIATFragments/TDUFragment.h"
34 
35 // nova
40 #include "NovaDAQConventions/DAQConventions.h"
41 #include "NovaTimingUtilities/TimingUtilities.h"
42 #include "RawData/DAQHeader.h"
43 #include "RawData/RawDigit.h"
44 #include "RawData/RawTrigger.h"
45 #include "RawData/FlatDAQData.h"
46 #include "RawData/RawSumDropMB.h"
47 #include "RawData/RawSumDCM.h"
48 #include "RawFileParser/RawFileParser.h"
49 #include "SummaryData/RunData.h"
50 
51 // stl
52 #include <iostream>
53 #include <string>
54 
55 // root
56 #include "TSystem.h"
57 #include "TDirectory.h"
58 #include "TFile.h"
59 #include "TSystemDirectory.h"
60 #include "TSystemFile.h"
61 #include "TCollection.h"
62 #include "TTree.h"
63 
64 // -----------------------------------------------------------------------
65 namespace daq2raw {
66  class TestBeamRawInputDriver;
67 }
68 
69 // -----------------------------------------------------------------------
70 namespace daq2raw {
71  struct BeamlineFile;
72  struct BeamlineSpill;
73  struct BeamlineTrigger;
74 }
75 
76 // -----------------------------------------------------------------------
77 namespace fhicl {
78  class ParameterSet;
79 }
80 
81 // -----------------------------------------------------------------------
82 namespace art {
83  class ProductRegistryHelper;
84  class RunPrincipal;
85  class SubRunPrincipal;
86  class EventPrincipal;
87  class FileBlock;
88 }
89 
90 // -----------------------------------------------------------------------
91 namespace daq2raw {
92 
95  File(file) { }
98  };
99 
102  BeamlineFileIndex(file), Spill(spill) { }
104  unsigned int Spill;
105  };
106 
109  BeamlineSpillIndex(spill), Trigger(trigger) { }
111  unsigned int Trigger;
112  };
113 
114  // -----------------------------------------------------------------------
115  /// Class to fill the constraints on a template argument to the class,
116  /// art::Source
118  public:
119 
120  // Required constructor
123  art::SourceHelper const &pm);
124 
125  // Required by art::Source
126  void closeCurrentFile();
127  void readFile(std::string const &name,
128  art::FileBlock* &fb);
129  bool readNext(art::RunPrincipal* const &inR,
130  art::SubRunPrincipal* const &inSR,
131  art::RunPrincipal* &outR,
132  art::SubRunPrincipal* &outSR,
133  art::EventPrincipal* &outE);
134 
135  // art
136  void reconfigure(const fhicl::ParameterSet& pset);
137 
138  private:
139 
140  /// read in the beamline files corresponding to the time period of this input file
141  void readBeamline();
142 
143  /// load the artdaq spill fragments from the input file
144  LariatFragment* loadSpillFragments(TBranch* fragBranch, unsigned int index);
145 
146  /// load the artdaq TDU fragments from the input file
147  std::vector<TDUFragment*> loadTDUFragments(TBranch* tduBranch, unsigned int index);
148 
149  /// get the lariat fragment from the artdaq fragments
150  LariatFragment* getSpillFrag(const SpillWrapper* spillWrapper);
151 
152  /// find and load the beamline event which corresponds to a specific TDU timestamp
153  BeamlineEvent* loadBeamlineEvent(unsigned long long tduTime);
154 
155  // beamline config
167 
169 
170  std::unique_ptr<daq2raw::BeamlineUnpack> fBeamlineUnpack; ///< Algorithm to handle unpacking of beamline data.
171  std::unique_ptr<BeamlineEvents> fBeamlineEvents; ///< Container to hold all beamline events before matching with detector data
172  std::map<unsigned long long,
173  BeamlineTriggerIndex> fBeamlineIndex; ///< Container to index beamline file, spill, trigger and TDU information
174 
175  art::SourceHelper const& fSourceHelper; ///< Class to help with {Run, SubRun, Event}Principal construction.
176  std::string fCurrentFilename; ///< Hang on to the current filename.
177  art::SubRunID fCurrentSubRunID; ///< Keep track of the current subRun details.
178  rawfileparser::RawFileParser fParser; ///< Online raw file parsing utility.
179  size_t fMaxEventSize; ///< Will not try to read an event bigger than this.
180  bool fFilterCorruptedNanoslices;///< Filter the corrupted nanaslices in the unpacking?
181  bool fDoFillFlatDAQData; ///< Do we need to fill FlatDAQData object?
182  bool fFilterBeamlineEvents; ///< Filter bad beamline events
183 
184  }; // TestBeamRawInputDriver
185 
186 } // namespace
187 
188 #endif /* DAQ2RAWDIGIT_TESTBEAMRAWINPUTDRIVER_H */
const XML_Char * name
Definition: expat.h:151
bool fDoFillFlatDAQData
Do we need to fill FlatDAQData object?
rawfileparser::RawFileParser fParser
Online raw file parsing utility.
art::SourceHelper const & fSourceHelper
Class to help with {Run, SubRun, Event}Principal construction.
bool fFilterBeamlineEvents
Filter bad beamline events.
Encapsulate the geometry of one entire detector (near, far, ndos)
std::unique_ptr< BeamlineEvents > fBeamlineEvents
Container to hold all beamline events before matching with detector data.
A module to produce rawdata::RawDigits from NOvADDT DAQHits.
BeamlineSpillIndex(BeamlineFileIndex file, unsigned int spill)
size_t fMaxEventSize
Will not try to read an event bigger than this.
Methods to interface with the DAQ-formatted output file for the beamline components of the test beam ...
std::map< unsigned long long, BeamlineTriggerIndex > fBeamlineIndex
Container to index beamline file, spill, trigger and TDU information.
std::unique_ptr< daq2raw::BeamlineUnpack > fBeamlineUnpack
Algorithm to handle unpacking of beamline data.
bool fFilterCorruptedNanoslices
Filter the corrupted nanaslices in the unpacking?
BeamlineTriggerIndex(BeamlineSpillIndex spill, unsigned int trigger)
const int File
TFile * file
Definition: cellShifts.C:17
Service to store calibration data products (CDP) in the SQLite3 metadatabase of a file...
Definition: FillParentInfo.h:8
std::string fCurrentFilename
Hang on to the current filename.
art::SubRunID fCurrentSubRunID
Keep track of the current subRun details.
enum BeamMode string