LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lris::LArRawInputDriver Class Reference

#include "LArRawInputDriver.h"

Public Member Functions

 LArRawInputDriver (fhicl::ParameterSet const &pset, art::ProductRegistryHelper &helper, 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)
 

Private Types

typedef std::vector< std::string > stringvec_t
 

Private Attributes

art::SourceHelper const & principalMaker_
 
std::string currentDir_
 
stringvec_t inputfiles_
 
stringvec_t::const_iterator nextfile_
 
stringvec_t::const_iterator filesdone_
 
art::SubRunID currentSubRunID_
 

Detailed Description

Definition at line 30 of file LArRawInputDriver.h.

Member Typedef Documentation

typedef std::vector<std::string> lris::LArRawInputDriver::stringvec_t
private

Definition at line 50 of file LArRawInputDriver.h.

Constructor & Destructor Documentation

lris::LArRawInputDriver::LArRawInputDriver ( fhicl::ParameterSet const &  pset,
art::ProductRegistryHelper helper,
art::SourceHelper const &  pm 
)

Class to fill the constraints on a template argument to the class, FileReaderSource

Definition at line 216 of file LArRawInputDriver.cxx.

References art::InEvent, art::InRun, and art::ProductRegistryHelper::reconstitutes().

219  : principalMaker_(pm)
220  , currentDir_()
221  , inputfiles_()
222  , nextfile_(inputfiles_.begin())
223  , filesdone_(inputfiles_.end())
224  , currentSubRunID_()
225  {
226  helper.reconstitutes<raw::DAQHeader, art::InEvent>("daq");
227  helper.reconstitutes<std::vector<raw::RawDigit>, art::InEvent>("daq");
228  helper.reconstitutes<sumdata::RunData, art::InRun>("daq");
229  }
art::SubRunID currentSubRunID_
stringvec_t::const_iterator nextfile_
art::SourceHelper const & principalMaker_
TypeLabel const & reconstitutes(std::string const &modLabel, std::string const &instanceName={})
stringvec_t::const_iterator filesdone_

Member Function Documentation

void lris::LArRawInputDriver::closeCurrentFile ( )

Definition at line 231 of file LArRawInputDriver.cxx.

232  {
233  // Nothing to do (See EventFileSentry).
234  }
void lris::LArRawInputDriver::readFile ( std::string const &  name,
art::FileBlock *&  fb 
)

Definition at line 236 of file LArRawInputDriver.cxx.

References currentDir_, currentSubRunID_, filesdone_, inputfiles_, and nextfile_.

237  {
238  // Get the list of event files for this directory.
239  currentDir_ = name;
240  inputfiles_ = getsortedfiles(currentDir_);
241  nextfile_ = inputfiles_.begin();
242  filesdone_ = inputfiles_.end();
244 
245  // Fill and return a new Fileblock.
246  fb = new art::FileBlock(art::FileFormatVersion(1, "LArRawInput 2011a"), currentDir_);
247  }
art::SubRunID currentSubRunID_
stringvec_t::const_iterator nextfile_
stringvec_t::const_iterator filesdone_
bool lris::LArRawInputDriver::readNext ( art::RunPrincipal *const &  inR,
art::SubRunPrincipal *const &  inSR,
art::RunPrincipal *&  outR,
art::SubRunPrincipal *&  outSR,
art::EventPrincipal *&  outE 
)

Definition at line 249 of file LArRawInputDriver.cxx.

References currentDir_, currentSubRunID_, filesdone_, raw::DAQHeader::GetEvent(), raw::DAQHeader::GetRun(), raw::DAQHeader::GetTimeStamp(), inputfiles_, art::SourceHelper::makeEventPrincipal(), art::SourceHelper::makeRunPrincipal(), art::SourceHelper::makeSubRunPrincipal(), nextfile_, principalMaker_, art::put_product_in_principal(), art::SubRunID::run(), and art::SubRunID::subRun().

254  {
255  if (inputfiles_.empty() || nextfile_ == filesdone_) return false;
256 
257  // Create empty result, then fill it from current filename:
258  std::unique_ptr<std::vector<raw::RawDigit>> rdcol(new std::vector<raw::RawDigit>);
259 
260  raw::DAQHeader daqHeader;
261  bool firstEventInRun = (nextfile_ == inputfiles_.begin());
262 
263  process_LAr_file(currentDir_, *nextfile_++, *rdcol, daqHeader);
264  std::unique_ptr<raw::DAQHeader> daqcol(new raw::DAQHeader(daqHeader));
265 
266  art::RunNumber_t rn = daqHeader.GetRun();
267  art::Timestamp tstamp = daqHeader.GetTimeStamp();
268 
269  if (firstEventInRun) {
270  std::unique_ptr<sumdata::RunData> rundata(new sumdata::RunData("argoneut"));
272  outR = principalMaker_.makeRunPrincipal(rn, tstamp);
274  art::put_product_in_principal(std::move(rundata), *outR, "daq");
275  }
276  else if (rn != currentSubRunID_.run()) {
277  throw cet::exception("InconsistentEventStream")
278  << "Encountered run #" << rn << " while processing events from run #"
279  << currentSubRunID_.run() << "\n";
280  }
281 
283  currentSubRunID_.run(), currentSubRunID_.subRun(), daqHeader.GetEvent(), tstamp);
284 
285  // Put products in the event.
286  art::put_product_in_principal(std::move(rdcol), *outE,
287  "daq"); // Module label
288  art::put_product_in_principal(std::move(daqcol), *outE,
289  "daq"); // Module label
290 
291  return true;
292  }
art::SubRunID currentSubRunID_
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary subRunAux) const
stringvec_t::const_iterator nextfile_
EventPrincipal * makeEventPrincipal(EventAuxiliary eventAux) const
art::SourceHelper const & principalMaker_
RunNumber_t run() const
Definition: SubRunID.h:85
stringvec_t::const_iterator filesdone_
RunPrincipal * makeRunPrincipal(RunAuxiliary runAux) const
Definition: SourceHelper.cc:89
std::enable_if_t<!detail::range_sets_supported(P::branch_type)> put_product_in_principal(std::unique_ptr< T > &&product, P &principal, std::string const &module_label, std::string const &instance_name={})
unsigned short GetRun() const
Definition: DAQHeader.h:141
unsigned short GetEvent() const
Definition: DAQHeader.h:149
SubRunNumber_t subRun() const
Definition: SubRunID.h:91
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
time_t GetTimeStamp() const
Definition: DAQHeader.h:153
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:120

Member Data Documentation

std::string lris::LArRawInputDriver::currentDir_
private

Definition at line 53 of file LArRawInputDriver.h.

Referenced by readFile(), and readNext().

art::SubRunID lris::LArRawInputDriver::currentSubRunID_
private

Definition at line 57 of file LArRawInputDriver.h.

Referenced by readFile(), and readNext().

stringvec_t::const_iterator lris::LArRawInputDriver::filesdone_
private

Definition at line 56 of file LArRawInputDriver.h.

Referenced by readFile(), and readNext().

stringvec_t lris::LArRawInputDriver::inputfiles_
private

Definition at line 54 of file LArRawInputDriver.h.

Referenced by readFile(), and readNext().

stringvec_t::const_iterator lris::LArRawInputDriver::nextfile_
private

Definition at line 55 of file LArRawInputDriver.h.

Referenced by readFile(), and readNext().

art::SourceHelper const& lris::LArRawInputDriver::principalMaker_
private

Definition at line 52 of file LArRawInputDriver.h.

Referenced by readNext().


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