BeamlineRawInputDriver.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////
2 /// \file BeamlineRawInputDriver.h
3 /// \brief Implementation of the offline conversion for raw beamline
4 /// data for test beam experiment.
5 /// Provided as the templated argument to art::Source.
6 /// \author Mike Wallbank (University of Cincinnati) <wallbank@fnal.gov>
7 /// \date November 2018
8 ////////////////////////////////////////////////////////////////////////////
9 
10 #ifndef DAQ2RAWDIGIT_BEAMLINERAWINPUTDRIVER_H
11 #define DAQ2RAWDIGIT_BEAMLINERAWINPUTDRIVER_H
12 
13 // framework
24 #include "fhiclcpp/ParameterSet.h"
26 
27 // artdaq
28 #include "artdaq-core/Data/Fragment.hh"
29 
30 // online
31 #include "LArIATFragments/LariatFragment.h"
32 
33 // nova
34 #include "RawData/RawBeamline.h"
36 
37 // stl
38 #include <string>
39 #include <libgen.h>
40 
41 // root
42 #include "TFile.h"
43 #include "TTree.h"
44 #include "TBranch.h"
45 
46 // -----------------------------------------------------------------------
47 namespace daq2raw {
48  class BeamlineUnpack;
49  class SpillWrapper;
50  class BeamlineEvent;
51 }
52 
53 // -----------------------------------------------------------------------
54 namespace rawdata {
55  class BeamlineRawDigit;
56  class BeamlineRawTrigger;
57  class BeamlineRawWC;
58 }
59 
60 // -----------------------------------------------------------------------
61 namespace daq2raw {
62 
63  // -----------------------------------------------------------------------
64  /// Class to fill the constraints on a template argument to
65  /// the class, art::Source
67 
68  public:
69 
70  // Required constructor
73  const art::SourceHelper& pm);
75 
76  // Required by art::Source
77  void closeCurrentFile();
78  bool readFile(const std::string& filename,
79  art::FileBlock*& fileblock);
80  bool readNext(art::RunPrincipal* const& inR,
81  art::SubRunPrincipal* const& inSR,
82  art::RunPrincipal*& outR,
83  art::SubRunPrincipal*& outSR,
84  art::EventPrincipal*& outE);
85 
86  // art
87  void reconfigure(const fhicl::ParameterSet& pset);
88 
89  private:
90 
91  /// start a new run
92  void commenceRun(art::RunPrincipal*& outRun);
93 
94  /// start a new subrun
95  void commenceSubRun(art::SubRunPrincipal*& outSubRun);
96 
97  /// load the artdaq spill fragments from the input file
98  LariatFragment* loadSpillFragments(TBranch* fragBranch, unsigned int index);
99 
100  /// load the artdaq TDU fragments from the input file
101  std::vector<TDUFragment*> loadTDUFragments(TBranch* tduBranch, unsigned int index);
102 
103  /// get the lariat fragment from the artdaq fragments
104  LariatFragment* getSpillFrag(const SpillWrapper* spillWrapper);
105 
106  /// make a new spill
107  bool makeSpill(art::RunPrincipal* const& inRun,
108  art::SubRunPrincipal* const& inSubRun,
109  art::RunPrincipal*& outRun,
110  art::SubRunPrincipal*& outSubRun);
111 
112  /// make a new event and place the digits within
113  void makeEvent(art::EventPrincipal*& outEvent);
114 
115  // beamline config
127 
129 
130  // file information
132  std::unique_ptr<TFile> fCurrentFile;
133  TBranch* fSpillBranch;
134  TBranch* fTDUBranch;
135  TBranch* fEventAuxBranch;
136  unsigned int fNumSpillsInFile;
138 
139  // running parameters
143 
144  // run, subrun and event numbers
147 
148  // timestamp for event
149  std::uint64_t fTimestamp;
150 
151  // algorithms
152  std::unique_ptr<daq2raw::BeamlineUnpack> fBeamlineUnpack;
153 
154  }; // BeamlineRawInputDriver
155 
156 } // namespace
157 
158 #endif /* DAQ2RAWDIGIT_BEAMLINERAWINPUTDRIVER_H */
std::unique_ptr< daq2raw::BeamlineUnpack > fBeamlineUnpack
string filename
Definition: shutoffs.py:106
Definition of connection map class.
Definition: CMap.h:19
const art::SourceHelper & fSourceHelper
IDNumber_t< Level::SubRun > SubRunNumber_t
Definition: IDNumber.h:118
A module to produce rawdata::RawDigits from NOvADDT DAQHits.
Methods to interface with the DAQ-formatted output file for the beamline components of the test beam ...
std::unique_ptr< TFile > fCurrentFile
Raw data definitions for beamline data used in NOvA test beam experiment.
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:119
enum BeamMode string