Public Member Functions | Protected Member Functions | Private Attributes | List of all members
daq2raw::NOvARawInputDriver Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-28/DAQ2RawDigit/NOvARawInputDriver.h"

Inheritance diagram for daq2raw::NOvARawInputDriver:
daq2raw::NOvAInputDriverBase

Public Member Functions

 NOvARawInputDriver (fhicl::ParameterSet const &pset, art::ProductRegistryHelper &help, art::SourceHelper const &pm)
 
void closeCurrentFile ()
 
void readFile (std::string const &name, art::FileBlock *&fb)
 
bool readNext (art::RunPrincipal *const &inR, art::SubRunPrincipal *const &inSR, art::RunPrincipal *&outR, art::SubRunPrincipal *&outSR, art::EventPrincipal *&outE)
 

Protected Member Functions

std::string getDetectorGDML (const int detid) const
 

Private Attributes

art::SourceHelper const & fSourceHelper
 Class to help with {Run, SubRun, Event}Principal construction. More...
 
std::string fCurrentFilename
 Hang on to the current filename. More...
 
art::SubRunID fCurrentSubRunID
 Keep track of the current subRun details. More...
 
rawfileparser::RawFileParser fParser
 Online raw file parsing utility. More...
 
size_t fMaxEventSize
 Will not try to read an event bigger than this. More...
 
bool fFilterCorruptedNanoslices
 Filter the corrupted nanaslices in the unpacking? More...
 
bool fDoFillFlatDAQData
 Do we need to fill FlatDAQData object? More...
 

Detailed Description

Definition at line 38 of file NOvARawInputDriver.h.

Constructor & Destructor Documentation

daq2raw::NOvARawInputDriver::NOvARawInputDriver ( fhicl::ParameterSet const &  pset,
art::ProductRegistryHelper help,
art::SourceHelper const &  pm 
)

Class to fill the constraints on a template argument to the class, art::Source

Definition at line 38 of file NOvARawInputDriver.cxx.

References fDoFillFlatDAQData, fParser, art::InEvent, art::InRun, art::ProductRegistryHelper::reconstitutes(), and rawfileparser::RawFileParser::setDebug().

43  : NOvAInputDriverBase(pset.get<std::string>("GDMLFileBase",""))
44  , fSourceHelper(pm)
46  , fCurrentSubRunID(-1, -1) ///< Has to be distinguished from the ones that are acually used
47  , fParser()
48  , fMaxEventSize(pset.get<size_t>("maxEventSizeK", 65536) * 1024)
49  , fFilterCorruptedNanoslices(pset.get<bool>("FilterCorruptedNanoslices"))
50  , fDoFillFlatDAQData(pset.get<bool>("DoFillFlatDAQData"))
51  {
52  // Declare products that *may* be in the event (or run, or subRun)
53  // here. Note the use of "reconstitutes" vs "produces": this is what
54  // allows us to specify module label, process name and (optionally)
55  // instance label for each product.
56  helper.reconstitutes<rawdata::DAQHeader, art::InEvent>("daq");
57  helper.reconstitutes<std::vector<rawdata::RawDigit>, art::InEvent>("daq");
58  helper.reconstitutes<std::vector<rawdata::RawTrigger>, art::InEvent>("daq");
59  helper.reconstitutes<std::vector<rawdata::RawSumDropMB>, art::InEvent>("daq");
60  helper.reconstitutes<std::vector<rawdata::RawSumDCM>, art::InEvent>("daq");
61  if(fDoFillFlatDAQData) helper.reconstitutes<std::vector<rawdata::FlatDAQData>, art::InEvent>("daq");
62  helper.reconstitutes<sumdata::RunData, art::InRun >("daq");
63  // Turn off printf messages in the parser.
64  fParser.setDebug(false);
65  }
void setDebug(bool f)
Close any currently open file.
Definition: RawFileParser.h:65
rawfileparser::RawFileParser fParser
Online raw file parsing utility.
size_t fMaxEventSize
Will not try to read an event bigger than this.
art::SourceHelper const & fSourceHelper
Class to help with {Run, SubRun, Event}Principal construction.
std::string fCurrentFilename
Hang on to the current filename.
NOvAInputDriverBase(std::string gdmlBase="")
art::SubRunID fCurrentSubRunID
Keep track of the current subRun details.
bool fDoFillFlatDAQData
Do we need to fill FlatDAQData object?
bool fFilterCorruptedNanoslices
Filter the corrupted nanaslices in the unpacking?
enum BeamMode string

Member Function Documentation

void daq2raw::NOvARawInputDriver::closeCurrentFile ( )

Definition at line 69 of file NOvARawInputDriver.cxx.

References rawfileparser::RawFileParser::close(), and fParser.

69  {
70  fParser.close(); // Ignore error return
71  }
rawfileparser::RawFileParser fParser
Online raw file parsing utility.
int close()
Open a file for parsing.
std::string daq2raw::NOvAInputDriverBase::getDetectorGDML ( const int  detid) const
protectedinherited

Definition at line 22 of file NOvAInputDriverBase.cxx.

References daq2raw::NOvAInputDriverBase::fGDMLBase, novadaq::cnv::kFARDET, novadaq::cnv::kNDOS, novadaq::cnv::kNEARDET, novadaq::cnv::kTESTBEAM, and string.

Referenced by daq2raw::DAQHit2Raw::beginRun(), readNext(), daq2raw::NOvASocketInputDriver::readNext(), and daq2raw::TestBeamRawInputDriver::readNext().

22  {
23 
24  // get the base form of the geometry file for the current detector
25  if(!fGDMLBase.empty()) return fGDMLBase;
26 
27  //\todo at some point we should query a database to get this, especially
28  //\todo when we have instances of only part of a detector working
29  std::string detFileBase("");
30  if (detid == novadaq::cnv::kNDOS)
31  detFileBase = "ndos-2x3-4block_nomc-xtru-vacuum";
32  else if (detid == novadaq::cnv::kNEARDET)
33  detFileBase = "neardet-3x3-8block-xtru-vacuum-stagger";
34  else if(detid == novadaq::cnv::kFARDET)
35  detFileBase = "fardet-12x12-28block-xtru-vacuum-stagger-pivoter";
36  else if(detid == novadaq::cnv::kTESTBEAM)
37  detFileBase = "testbeam-2x2-2block-xtru-vacuum-stagger";
38 
39  return detFileBase;
40  }
Far Detector at Ash River, MN.
Prototype Near Detector on the surface at FNAL.
Near Detector in the NuMI cavern.
enum BeamMode string
void daq2raw::NOvARawInputDriver::readFile ( std::string const &  name,
art::FileBlock *&  fb 
)

Definition at line 77 of file NOvARawInputDriver.cxx.

References errno, fCurrentFilename, fd, art::errors::FileOpenError, fParser, and rawfileparser::RawFileParser::open().

78  {
80 
81  int fd = fParser.open(fCurrentFilename.c_str());
82  if (fd == -1) { // Failure
84  << "Unable to open file "
85  << name
86  << " due to system error, \""
87  << strerror(errno)
88  << "\"\n";
89  }
90 
91  fb = new art::FileBlock(art::FileFormatVersion(1, "NOvARawInput 2011a"),
93  }
int open(const char *filename)
General initialization and reinitialization.
const XML_Char * name
Definition: expat.h:151
rawfileparser::RawFileParser fParser
Online raw file parsing utility.
std::string fCurrentFilename
Hang on to the current filename.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
int errno
Definition: errno.cpp:12
bool daq2raw::NOvARawInputDriver::readNext ( art::RunPrincipal *const &  inR,
art::SubRunPrincipal *const &  inSR,
art::RunPrincipal *&  outR,
art::SubRunPrincipal *&  outSR,
art::EventPrincipal *&  outE 
)

Define data structures, which will be filled by OnlineUnpack::ProcessRawEvent

Fill the data structures for this event.

Put FlatDAQData object

Definition at line 97 of file NOvARawInputDriver.cxx.

References novadaq::timeutils::convertNovaTimeToUnixTime(), geo::GeometryBase::ExtractGDML(), fCurrentFilename, fCurrentSubRunID, fDoFillFlatDAQData, fFilterCorruptedNanoslices, daq2raw::OnlineUnpack::fFilterCorruptedNanoslices, fParser, fSourceHelper, rawdata::RawTrigger::fTriggerTimingMarker_TimeStart, daq2raw::NOvAInputDriverBase::getDetectorGDML(), daq2raw::OnlineUnpack::getDetId(), daq2raw::OnlineUnpack::getEventNumber(), daq2raw::OnlineUnpack::getRunNumber(), daq2raw::OnlineUnpack::getSubrunNumber(), art::SourceHelper::makeEventPrincipal(), art::SourceHelper::makeRunPrincipal(), art::SourceHelper::makeSubRunPrincipal(), daq2raw::OnlineUnpack::ProcessRawEvent(), art::put_product_in_principal(), art::SubRunID::runID(), string, and msf_helper::timespec.

102  {
103  ////////////////////////////////////
104  // Unpack the data.
105 
106  // NOTE: As of OnlineUnpack.cxx r1.9, the histogram pointers required
107  // in the constructor are *not* filled. In the event that one *does*
108  // want this kind of information, the data to be histogrammed should
109  // be put into event products (not necessarily written out to file)
110  // and turned into histograms by a downstream analyzer. This will
111  // enable easy management of different histograms for diferent runs,
112  // subruns, etc, etc and trivial control of whether histograns are
113  // actually wanted or not.
114  daq2raw::OnlineUnpack up(nullptr, nullptr, nullptr, &fCurrentFilename);
115  up.fFilterCorruptedNanoslices = fFilterCorruptedNanoslices;
116 
117  /// Define data structures, which will be filled by OnlineUnpack::ProcessRawEvent
118  std::unique_ptr<std::vector<rawdata::RawDigit> > digits(new std::vector<rawdata::RawDigit>);
119  rawdata::RawTrigger raw_trigger;
120  rawdata::RawSumDropMB raw_sumDropMB;
121  rawdata::RawSumDCM raw_sumDCM;
122  rawdata::FlatDAQData flat_daq_data;
123  rawdata::DAQHeader daq_header;
124 
125  /// Fill the data structures for this event.
126  if (!up.ProcessRawEvent(fParser, digits.get(), &raw_trigger, &raw_sumDropMB, &raw_sumDCM, &flat_daq_data, &daq_header)) return false;
127 
128  // Get the actual timestamp here - use the current time as the
129  // default, maybe the default should really be a ridiculous value
130  struct timespec ts;
131 
134 
135  // art::Timestamp has the seconds since the beginning of the epoch
136  // in the upper 32 bits and the fractional seconds in the lower 32
137  // bits.
138  art::Timestamp tstamp = (ts.tv_sec << 32) | ts.tv_nsec;
139 
140  ////////////////////////////////////
141  // Assemble new principals as required.
142  art::SubRunID newID(up.getRunNumber(), up.getSubrunNumber());
143  if (inR == nullptr || fCurrentSubRunID.runID() != newID.runID()) { // New Run fragment
144  outR = fSourceHelper.makeRunPrincipal(up.getRunNumber(), tstamp);
145 
146  // get the base form of the geometry file for the current detector
147  //\todo at some point we should query a database to get this, especially
148  //\todo when we have instances of only part of a detector working
149  std::string detFileBase = getDetectorGDML(up.getDetId());
150  std::unique_ptr<sumdata::RunData> rundata(new sumdata::RunData(novadaq::cnv::DetId(up.getDetId()), detFileBase, geo::GeometryBase::ExtractGDML(detFileBase+".gdml", false)));
151  art::put_product_in_principal(std::move(rundata),
152  *outR,
153  "daq"); // Module label
154  }
155  if (inSR == nullptr || fCurrentSubRunID != newID) { // New SubRun fragment
156  outSR = fSourceHelper.makeSubRunPrincipal(up.getRunNumber(),
157  up.getSubrunNumber(),
158  tstamp);
159  fCurrentSubRunID = newID;
160  }
161  outE = fSourceHelper.makeEventPrincipal(up.getRunNumber(),
162  up.getSubrunNumber(),
163  up.getEventNumber(),
164  tstamp);
165 
166  ////////////////////////////////////
167  // Add the event products to the event:
168 
169  // Digitized data:
170  art::put_product_in_principal(std::move(digits), *outE, "daq");
171 
172  // Trigger data:
173  std::unique_ptr<std::vector<rawdata::RawTrigger> > rtcol(new std::vector<rawdata::RawTrigger>);
174  rtcol->push_back(raw_trigger); // Read one, product is a vector.
175  art::put_product_in_principal(std::move(rtcol),
176  *outE,
177  "daq"); // Module label
178 
179  // RawSumDropMB data:
180  std::unique_ptr<std::vector<rawdata::RawSumDropMB> > rtcol_MB(new std::vector<rawdata::RawSumDropMB>);
181  rtcol_MB->push_back(raw_sumDropMB); // Read one, product is a vector.
182  art::put_product_in_principal(std::move(rtcol_MB),
183  *outE,
184  "daq"); // Module label
185 
186  // RawSumDCM data:
187  std::unique_ptr<std::vector<rawdata::RawSumDCM> > rtcol_DCM(new std::vector<rawdata::RawSumDCM>);
188  rtcol_DCM->push_back(raw_sumDCM); // Read one, product is a vector.
189  art::put_product_in_principal(std::move(rtcol_DCM),
190  *outE,
191  "daq"); // Module label
192 
193  // DAQ header:
194  std::unique_ptr<rawdata::DAQHeader > daqcol(new rawdata::DAQHeader(daq_header));
195  art::put_product_in_principal(std::move(daqcol),
196  *outE,
197  "daq"); // Module label
198 
199  /// Put FlatDAQData object
200  if(fDoFillFlatDAQData) {
201  std::unique_ptr<std::vector<rawdata::FlatDAQData> > flatcol(new std::vector<rawdata::FlatDAQData>);
202  flatcol->push_back(flat_daq_data); // Read one, product is a vector.
203  art::put_product_in_principal(std::move(flatcol),
204  *outE,
205  "daq"); // Module label
206  }
207 
208  return true;
209  }
std::string getDetectorGDML(const int detid) const
EventPrincipal * makeEventPrincipal(EventAuxiliary const &eventAux, std::shared_ptr< History > &&history) 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={})
rawfileparser::RawFileParser fParser
Online raw file parsing utility.
bool convertNovaTimeToUnixTime(uint64_t const &inputNovaTime, struct timespec &outputUnixTime)
RunID const & runID() const
Definition: SubRunID.h:77
art::SourceHelper const & fSourceHelper
Class to help with {Run, SubRun, Event}Principal construction.
std::string fCurrentFilename
Hang on to the current filename.
RunPrincipal * makeRunPrincipal(RunAuxiliary const &runAux) const
art::SubRunID fCurrentSubRunID
Keep track of the current subRun details.
bool fDoFillFlatDAQData
Do we need to fill FlatDAQData object?
unsigned long long fTriggerTimingMarker_TimeStart
Definition: RawTrigger.h:38
bool fFilterCorruptedNanoslices
Filter the corrupted nanaslices in the unpacking?
std::string ExtractGDML() const
Extract contents from fGDMLFile and return as a string.
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary const &subRunAux) const
enum BeamMode string

Member Data Documentation

std::string daq2raw::NOvARawInputDriver::fCurrentFilename
private

Hang on to the current filename.

Definition at line 60 of file NOvARawInputDriver.h.

Referenced by readFile(), and readNext().

art::SubRunID daq2raw::NOvARawInputDriver::fCurrentSubRunID
private

Keep track of the current subRun details.

Definition at line 61 of file NOvARawInputDriver.h.

Referenced by readNext().

bool daq2raw::NOvARawInputDriver::fDoFillFlatDAQData
private

Do we need to fill FlatDAQData object?

Definition at line 65 of file NOvARawInputDriver.h.

Referenced by NOvARawInputDriver(), and readNext().

bool daq2raw::NOvARawInputDriver::fFilterCorruptedNanoslices
private

Filter the corrupted nanaslices in the unpacking?

Definition at line 64 of file NOvARawInputDriver.h.

Referenced by readNext().

size_t daq2raw::NOvARawInputDriver::fMaxEventSize
private

Will not try to read an event bigger than this.

Definition at line 63 of file NOvARawInputDriver.h.

rawfileparser::RawFileParser daq2raw::NOvARawInputDriver::fParser
private

Online raw file parsing utility.

Definition at line 62 of file NOvARawInputDriver.h.

Referenced by closeCurrentFile(), NOvARawInputDriver(), readFile(), and readNext().

art::SourceHelper const& daq2raw::NOvARawInputDriver::fSourceHelper
private

Class to help with {Run, SubRun, Event}Principal construction.

Definition at line 59 of file NOvARawInputDriver.h.

Referenced by readNext().


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