LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 26 of file LArRawInputDriver.h.

Member Typedef Documentation

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

Definition at line 47 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 212 of file LArRawInputDriver.cxx.

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

215  :
216  principalMaker_(pm)
217  , currentDir_ ()
218  , inputfiles_ ( )
219  , nextfile_ ( inputfiles_.begin() )
220  , filesdone_ ( inputfiles_.end() )
221  , currentSubRunID_ ( )
222  {
223  helper.reconstitutes<raw::DAQHeader, art::InEvent>("daq");
224  helper.reconstitutes<std::vector<raw::RawDigit>, art::InEvent>("daq");
225  helper.reconstitutes<sumdata::RunData, art::InRun> ("daq");
226  }
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 228 of file LArRawInputDriver.cxx.

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

Definition at line 233 of file LArRawInputDriver.cxx.

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

235  {
236  // Get the list of event files for this directory.
237  currentDir_ = name;
238  inputfiles_ = getsortedfiles(currentDir_);
239  nextfile_ = inputfiles_.begin();
240  filesdone_ = inputfiles_.end();
242 
243  // Fill and return a new Fileblock.
244  fb = new art::FileBlock(art::FileFormatVersion(1, "LArRawInput 2011a"),
245  currentDir_);
246  }
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 248 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().

253  {
254  if (inputfiles_.empty() || nextfile_ == filesdone_ ) return false;
255 
256  // Create empty result, then fill it from current filename:
257  std::unique_ptr<std::vector<raw::RawDigit> > rdcol ( new std::vector<raw::RawDigit> );
258 
259  raw::DAQHeader daqHeader;
260  bool firstEventInRun = (nextfile_ == inputfiles_.begin());
261 
262  process_LAr_file( currentDir_, *nextfile_++, *rdcol, daqHeader );
263  std::unique_ptr<raw::DAQHeader> daqcol( new raw::DAQHeader(daqHeader) );
264 
265  art::RunNumber_t rn = daqHeader.GetRun();
266  art::Timestamp tstamp = daqHeader.GetTimeStamp();
267 
268  if (firstEventInRun){
269  std::unique_ptr<sumdata::RunData> rundata(new sumdata::RunData("argoneut") );
271  outR = principalMaker_.makeRunPrincipal(rn, tstamp);
274  tstamp);
275  art::put_product_in_principal(std::move(rundata), *outR, "daq");
276  }
277  else if (rn != currentSubRunID_.run()){
278  throw cet::exception("InconsistentEventStream")
279  << "Encountered run #" << rn
280  << " while processing events from run #" << currentSubRunID_.run()
281  << "\n";
282  }
283 
286  daqHeader.GetEvent(),
287  tstamp);
288 
289  // Put products in the event.
290  art::put_product_in_principal(std::move(rdcol),
291  *outE,
292  "daq"); // Module label
293  art::put_product_in_principal(std::move(daqcol),
294  *outE,
295  "daq"); // Module label
296 
297  return true;
298  }
art::SubRunID currentSubRunID_
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={})
stringvec_t::const_iterator nextfile_
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary const &subRunAux) const
Definition: SourceHelper.cc:59
art::SourceHelper const & principalMaker_
RunPrincipal * makeRunPrincipal(RunAuxiliary const &runAux) const
Definition: SourceHelper.cc:36
RunNumber_t run() const
Definition: SubRunID.h:84
stringvec_t::const_iterator filesdone_
unsigned short GetRun() const
Definition: DAQHeader.h:105
unsigned short GetEvent() const
Definition: DAQHeader.h:107
SubRunNumber_t subRun() const
Definition: SubRunID.h:90
EventPrincipal * makeEventPrincipal(EventAuxiliary const &eventAux, std::shared_ptr< History > &&history) const
Definition: SourceHelper.cc:83
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
time_t GetTimeStamp() const
Definition: DAQHeader.h:108
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:119

Member Data Documentation

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

Definition at line 50 of file LArRawInputDriver.h.

Referenced by readFile(), and readNext().

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

Definition at line 54 of file LArRawInputDriver.h.

Referenced by readFile(), and readNext().

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

Definition at line 53 of file LArRawInputDriver.h.

Referenced by readFile(), and readNext().

stringvec_t lris::LArRawInputDriver::inputfiles_
private

Definition at line 51 of file LArRawInputDriver.h.

Referenced by readFile(), and readNext().

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

Definition at line 52 of file LArRawInputDriver.h.

Referenced by readFile(), and readNext().

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

Definition at line 49 of file LArRawInputDriver.h.

Referenced by readNext().


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