Public Member Functions | Private Attributes | List of all members
arttest::EventProcessorTestSource Class Reference
Inheritance diagram for arttest::EventProcessorTestSource:
art::InputSource

Public Member Functions

 EventProcessorTestSource (fhicl::ParameterSet const &ps, art::InputSourceDescription &isd)
 
std::unique_ptr< art::FileBlockreadFile () override
 
void closeFile () override
 
art::input::ItemType nextItemType () override
 
std::unique_ptr< art::RunPrincipalreadRun () override
 
std::unique_ptr< art::SubRunPrincipalreadSubRun (cet::exempt_ptr< art::RunPrincipal const > rp) override
 
std::unique_ptr< art::EventPrincipalreadEvent (cet::exempt_ptr< art::SubRunPrincipal const > srp) override
 
std::unique_ptr< art::RangeSetHandlerrunRangeSetHandler () override
 
std::unique_ptr< art::RangeSetHandlersubRunRangeSetHandler () override
 
- Public Member Functions inherited from art::InputSource
virtual ~InputSource () noexcept
 
 InputSource (ModuleDescription const &)
 
 InputSource (InputSource const &)=delete
 
 InputSource (InputSource &&)=delete
 
InputSourceoperator= (InputSource const &)=delete
 
InputSourceoperator= (InputSource &&)=delete
 
virtual void doBeginJob ()
 
virtual void doEndJob ()
 
virtual void skipEvents (int n)
 
virtual void rewind ()
 
ModuleDescription const & moduleDescription () const
 
ProcessConfiguration const & processConfiguration () const
 

Private Attributes

art::ProcessConfiguration const pc_
 
std::ifstream inputFile_ {}
 
std::string currentName_ {}
 
std::vector< std::stringfileNames_ {}
 
art::RunID run_ {}
 
art::SubRunID subRun_ {}
 
art::EventID event_ {}
 

Additional Inherited Members

- Public Types inherited from art::InputSource
enum  ProcessingMode { Runs, RunsAndSubRuns, RunsSubRunsAndEvents }
 

Detailed Description

Definition at line 123 of file EventProcessorTestSource_source.cc.

Constructor & Destructor Documentation

arttest::EventProcessorTestSource::EventProcessorTestSource ( fhicl::ParameterSet const &  ps,
art::InputSourceDescription isd 
)
inline

Definition at line 125 of file EventProcessorTestSource_source.cc.

129  , fileNames_{ps.get<std::vector<std::string>>("fileNames")}
130  {}
InputSource(ModuleDescription const &)
Definition: InputSource.cc:8
static constexpr double ps
Definition: Units.h:99
ProcessConfiguration const & processConfiguration() const
ModuleDescription const & moduleDescription

Member Function Documentation

void arttest::EventProcessorTestSource::closeFile ( )
inlineoverridevirtual

Implements art::InputSource.

Definition at line 142 of file EventProcessorTestSource_source.cc.

143  {
144  inputFile_.close();
145  }
art::input::ItemType arttest::EventProcessorTestSource::nextItemType ( )
inlineoverridevirtual

Implements art::InputSource.

Definition at line 148 of file EventProcessorTestSource_source.cc.

149  {
152  if (std::getline(inputFile_, action)) {
153  if (action[0] == 'r') {
154  auto const r = number(action);
157  art::RunID{r};
159  } else if (action[0] == 's') {
160  auto const sr = number(action);
165  } else if (action[0] == 'e') {
166  auto const e = number(action);
170  // a special value for test purposes only
171  if (event_.event() != 7) {
173  }
174  } else {
176  << "Test pattern \"" << action << "\" not recognized.";
177  }
178  } else if (!fileNames_.empty()) {
179  currentName_ = fileNames_.front();
180  fileNames_.erase(cbegin(fileNames_));
181  return art::input::IsFile;
182  }
183  return rc;
184  }
static constexpr EventID flushEvent() noexcept
Definition: EventID.h:221
std::string string
Definition: nybbler.cc:12
const double e
static constexpr RunID flushRun() noexcept
Definition: RunID.h:122
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
static constexpr SubRunID flushSubRun() noexcept
Definition: SubRunID.h:171
decltype(auto) constexpr cbegin(T &&obj)
ADL-aware version of std::cbegin.
Definition: StdUtils.h:82
EventNumber_t event() const
Definition: EventID.h:116
static constexpr double sr
Definition: Units.h:166
std::unique_ptr<art::EventPrincipal> arttest::EventProcessorTestSource::readEvent ( cet::exempt_ptr< art::SubRunPrincipal const >  srp)
inlineoverridevirtual

Implements art::InputSource.

Definition at line 216 of file EventProcessorTestSource_source.cc.

217  {
218  if (event_.event() == throw_value('e')) {
219  throw art::Exception{
221  "There was an exception while reading an event from the input file."};
222  }
223 
224  art::EventAuxiliary const aux{event_, nullTimestamp(), true};
225  auto ep = std::make_unique<art::EventPrincipal>(aux, pc_, nullptr);
226  ep->setSubRunPrincipal(srp);
227  return ep;
228  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
EventNumber_t event() const
Definition: EventID.h:116
std::unique_ptr<art::FileBlock> arttest::EventProcessorTestSource::readFile ( )
inlineoverridevirtual

Implements art::InputSource.

Definition at line 133 of file EventProcessorTestSource_source.cc.

134  {
135  inputFile_.open(currentName_);
136  return std::make_unique<art::FileBlock>(
137  art::FileFormatVersion{1, "EventProcessorTestSource_2017a"},
138  currentName_);
139  }
std::unique_ptr<art::RunPrincipal> arttest::EventProcessorTestSource::readRun ( )
inlineoverridevirtual

Implements art::InputSource.

Definition at line 187 of file EventProcessorTestSource_source.cc.

188  {
189  if (run_.run() == throw_value('r')) {
190  throw art::Exception{
192  "There was an exception while reading a run from the input file."};
193  }
194 
195  art::RunAuxiliary const aux{run_, nullTimestamp(), nullTimestamp()};
196  auto rp = std::make_unique<art::RunPrincipal>(aux, pc_, nullptr);
197  return rp;
198  }
RunNumber_t run() const
Definition: RunID.h:64
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::unique_ptr<art::SubRunPrincipal> arttest::EventProcessorTestSource::readSubRun ( cet::exempt_ptr< art::RunPrincipal const >  rp)
inlineoverridevirtual

Implements art::InputSource.

Definition at line 201 of file EventProcessorTestSource_source.cc.

202  {
203  if (subRun_.subRun() == throw_value('s')) {
204  throw art::Exception{
206  "There was an exception while reading a subrun from the input file."};
207  }
208 
209  art::SubRunAuxiliary const aux{subRun_, nullTimestamp(), nullTimestamp()};
210  auto srp = std::make_unique<art::SubRunPrincipal>(aux, pc_, nullptr);
211  srp->setRunPrincipal(rp);
212  return srp;
213  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
SubRunNumber_t subRun() const
Definition: SubRunID.h:91
std::unique_ptr<art::RangeSetHandler> arttest::EventProcessorTestSource::runRangeSetHandler ( )
inlineoverridevirtual

Implements art::InputSource.

Definition at line 231 of file EventProcessorTestSource_source.cc.

232  {
233  return std::make_unique<art::OpenRangeSetHandler>(run_.run());
234  }
RunNumber_t run() const
Definition: RunID.h:64
std::unique_ptr<art::RangeSetHandler> arttest::EventProcessorTestSource::subRunRangeSetHandler ( )
inlineoverridevirtual

Implements art::InputSource.

Definition at line 237 of file EventProcessorTestSource_source.cc.

238  {
239  return std::make_unique<art::OpenRangeSetHandler>(subRun_.run());
240  }
RunNumber_t run() const
Definition: SubRunID.h:85

Member Data Documentation

std::string arttest::EventProcessorTestSource::currentName_ {}
private

Definition at line 245 of file EventProcessorTestSource_source.cc.

art::EventID arttest::EventProcessorTestSource::event_ {}
private

Definition at line 249 of file EventProcessorTestSource_source.cc.

std::vector<std::string> arttest::EventProcessorTestSource::fileNames_ {}
private

Definition at line 246 of file EventProcessorTestSource_source.cc.

std::ifstream arttest::EventProcessorTestSource::inputFile_ {}
private

Definition at line 244 of file EventProcessorTestSource_source.cc.

art::ProcessConfiguration const arttest::EventProcessorTestSource::pc_
private

Definition at line 243 of file EventProcessorTestSource_source.cc.

art::RunID arttest::EventProcessorTestSource::run_ {}
private

Definition at line 247 of file EventProcessorTestSource_source.cc.

art::SubRunID arttest::EventProcessorTestSource::subRun_ {}
private

Definition at line 248 of file EventProcessorTestSource_source.cc.


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