Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
art::EmptyEvent Class Referencefinal
Inheritance diagram for art::EmptyEvent:
art::DecrepitRelicInputSourceImplementation art::InputSource

Classes

struct  Config
 

Public Types

using Parameters = fhicl::WrappedTable< Config, Config::KeysToIgnore >
 
- Public Types inherited from art::InputSource
enum  ProcessingMode { Runs, RunsAndSubRuns, RunsSubRunsAndEvents }
 

Public Member Functions

 EmptyEvent (Parameters const &config, InputSourceDescription &desc)
 
 EmptyEvent (EmptyEvent const &)=delete
 
 EmptyEvent (EmptyEvent &&)=delete
 
EmptyEventoperator= (EmptyEvent const &)=delete
 
EmptyEventoperator= (EmptyEvent &&)=delete
 
- Public Member Functions inherited from art::DecrepitRelicInputSourceImplementation
 DecrepitRelicInputSourceImplementation (fhicl::TableFragment< Config > const &, ModuleDescription const &)
 
virtual ~DecrepitRelicInputSourceImplementation () noexcept=0
 
 DecrepitRelicInputSourceImplementation (DecrepitRelicInputSourceImplementation &&)=delete
 
DecrepitRelicInputSourceImplementationoperator= (DecrepitRelicInputSourceImplementation const &)=delete
 
DecrepitRelicInputSourceImplementationoperator= (DecrepitRelicInputSourceImplementation &&)=delete
 
virtual void finish ()
 
virtual input::ItemType nextItemType () override
 
virtual void closeFile () override
 
std::unique_ptr< FileBlockreadFile () override
 Read next file. More...
 
virtual std::unique_ptr< RunPrincipalreadRun () override
 
virtual std::unique_ptr< SubRunPrincipalreadSubRun (cet::exempt_ptr< RunPrincipal const >) override
 
virtual std::unique_ptr< EventPrincipalreadEvent (cet::exempt_ptr< SubRunPrincipal const >) override
 
virtual void doBeginJob () override
 
virtual void doEndJob () override
 
virtual void skipEvents (int offset) override
 
virtual void rewind () override
 
ProcessingMode processingMode () const
 
int maxEvents () const
 
int remainingEvents () const
 
int maxSubRuns () const
 
int remainingSubRuns () const
 
void repeat_ ()
 
void issueReports (EventID const &eventID)
 
- 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
 
ModuleDescription const & moduleDescription () const
 
ProcessConfiguration const & processConfiguration () const
 

Private Member Functions

unique_ptr< RangeSetHandlerrunRangeSetHandler () override
 
unique_ptr< RangeSetHandlersubRunRangeSetHandler () override
 
input::ItemType getNextItemType () override
 
unique_ptr< RunPrincipalreadRun_ () override
 
unique_ptr< SubRunPrincipalreadSubRun_ (cet::exempt_ptr< RunPrincipal const >) override
 
unique_ptr< EventPrincipalreadEvent_ () override
 
unique_ptr< EmptyEventTimestampPluginmakePlugin_ (OptionalDelegatedParameter const &maybeConfig)
 
void beginJob () override
 
void endJob () override
 
void skip (int offset) override
 
void rewind_ () override
 

Private Attributes

unsigned const numberEventsInRun_
 
unsigned const numberEventsInSubRun_
 
steady_clock::time_point const beginTime_ {steady_clock::now()}
 
std::chrono::seconds const maxTime_
 
std::chrono::microseconds const eventCreationDelay_
 
unsigned numberEventsInThisRun_ {}
 
unsigned numberEventsInThisSubRun_ {}
 
EventID origEventID_ {}
 
EventID eventID_ {}
 
bool firstTime_ {true}
 
bool newFile_ {true}
 
bool newRun_ {true}
 
bool newSubRun_ {true}
 
bool const resetEventOnSubRun_
 
cet::BasicPluginFactory pluginFactory_ {}
 
unique_ptr< EmptyEventTimestampPluginplugin_
 

Additional Inherited Members

- Protected Member Functions inherited from art::DecrepitRelicInputSourceImplementation
input::ItemType state () const
 
void setState (input::ItemType)
 
void reset ()
 

Detailed Description

Definition at line 44 of file EmptyEvent_source.cc.

Member Typedef Documentation

using art::EmptyEvent::Parameters = fhicl::WrappedTable<Config, Config::KeysToIgnore>

Definition at line 97 of file EmptyEvent_source.cc.

Constructor & Destructor Documentation

art::EmptyEvent::EmptyEvent ( Parameters const &  config,
InputSourceDescription desc 
)

Definition at line 141 of file EmptyEvent_source.cc.

144  desc.moduleDescription}
145  , numberEventsInRun_{static_cast<uint32_t>(config().numberEventsInRun())}
146  , numberEventsInSubRun_{static_cast<uint32_t>(
148  , maxTime_{config().maxTime()}
151  , plugin_{makePlugin_(config().timestampPlugin)}
152 {
153  // Additional configuration checking which is cumbersome to do with
154  // the FHiCL validation system.
155  auto const& pset = config.get_PSet();
156  if (pset.has_key("maxTime") &&
157  (pset.has_key("maxEvents") || pset.has_key("maxSubRuns"))) {
158  throw Exception{
160  "An error occurred while configuring the EmptyEvent source.\n"}
161  << "The 'maxTime' parameter cannot be used with the 'maxEvents' or "
162  "'maxSubRuns' parameters.\n"
163  "Type 'art --print-description EmptyEvent' for the allowed "
164  "configuration.\n";
165  }
166 
167  RunNumber_t firstRun{};
168  bool haveFirstRun = config().firstRun(firstRun);
169  SubRunNumber_t firstSubRun{};
170  bool haveFirstSubRun = config().firstSubRun(firstSubRun);
171  EventNumber_t firstEvent{};
172  bool haveFirstEvent = config().firstEvent(firstEvent);
173  RunID firstRunID = haveFirstRun ? RunID(firstRun) : RunID::firstRun();
174  SubRunID firstSubRunID = haveFirstSubRun ?
175  SubRunID(firstRunID.run(), firstSubRun) :
176  SubRunID::firstSubRun(firstRunID);
177  origEventID_ =
178  haveFirstEvent ?
179  EventID(firstSubRunID.run(), firstSubRunID.subRun(), firstEvent) :
180  EventID::firstEvent(firstSubRunID);
182 }
OptionalAtom< EventNumber_t > firstEvent
std::chrono::microseconds const eventCreationDelay_
OptionalAtom< RunNumber_t > firstRun
TableFragment< DRISI::Config > drisi_config
unique_ptr< EmptyEventTimestampPlugin > makePlugin_(OptionalDelegatedParameter const &maybeConfig)
unsigned const numberEventsInRun_
OptionalAtom< SubRunNumber_t > firstSubRun
static Config * config
Definition: config.cpp:1054
unsigned const numberEventsInSubRun_
std::chrono::seconds const maxTime_
DecrepitRelicInputSourceImplementation(fhicl::TableFragment< Config > const &, ModuleDescription const &)
IDNumber_t< Level::SubRun > SubRunNumber_t
Definition: IDNumber.h:119
unique_ptr< EmptyEventTimestampPlugin > plugin_
static SubRunID firstSubRun()
Definition: SubRunID.h:153
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:118
bool const resetEventOnSubRun_
static EventID firstEvent()
Definition: EventID.h:190
Atom< uint32_t > eventCreationDelay
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:120
art::EmptyEvent::EmptyEvent ( EmptyEvent const &  )
delete
art::EmptyEvent::EmptyEvent ( EmptyEvent &&  )
delete

Member Function Documentation

void art::EmptyEvent::beginJob ( )
overrideprivatevirtual

Reimplemented from art::DecrepitRelicInputSourceImplementation.

Definition at line 347 of file EmptyEvent_source.cc.

348 {
349  if (plugin_) {
350  plugin_->doBeginJob();
351  }
352 }
unique_ptr< EmptyEventTimestampPlugin > plugin_
void art::EmptyEvent::endJob ( )
overrideprivatevirtual

Reimplemented from art::DecrepitRelicInputSourceImplementation.

Definition at line 355 of file EmptyEvent_source.cc.

356 {
357  if (plugin_) {
358  plugin_->doEndJob();
359  }
360 }
unique_ptr< EmptyEventTimestampPlugin > plugin_
art::input::ItemType art::EmptyEvent::getNextItemType ( )
overrideprivatevirtual

Implements art::DecrepitRelicInputSourceImplementation.

Definition at line 185 of file EmptyEvent_source.cc.

186 {
187  // Trigger framework stop if max allowed time is exceeded.
188  // N.B. Since the begin time corresponds to source construction and
189  // not the actual event loop, there will be minor differences wrt
190  // the time reported for executing a given job.
192  return input::IsStop;
193  }
194  // First check for sanity because skip(offset) can be abused and so can the
195  // ctor.
196  if (!eventID_.runID().isValid()) {
197  return input::IsStop;
198  }
199  if (!eventID_.subRunID().isValid()) {
200  return input::IsStop;
201  }
202  if (!eventID_.isValid()) {
203  return input::IsStop;
204  }
205  if (newFile_) {
206  newFile_ = false;
207  return input::IsFile;
208  }
209  if (newRun_) {
210  newRun_ = false;
211  if (eventCreationDelay_ > 0ms) {
212  std::this_thread::sleep_for(eventCreationDelay_);
213  }
214  return input::IsRun;
215  }
216  if (newSubRun_) {
217  newSubRun_ = false;
218  if (eventCreationDelay_ > 0ms) {
219  std::this_thread::sleep_for(eventCreationDelay_);
220  }
221  return input::IsSubRun;
222  }
223  if ((numberEventsInRun_ > 0) &&
225  // Time to switch runs.
226  newRun_ = false;
227  newSubRun_ = true;
230  eventID_ = EventID(
232  firstTime_ = true;
233  if (eventCreationDelay_ > 0ms) {
234  std::this_thread::sleep_for(eventCreationDelay_);
235  }
236  return input::IsRun;
237  }
238  if ((numberEventsInSubRun_ > 0) &&
240  // Time to switch subruns.
241  newRun_ = false;
242  newSubRun_ = false;
244  if (resetEventOnSubRun_) {
246  } else {
248  }
249  firstTime_ = true;
250  if (eventCreationDelay_ > 0ms) {
251  std::this_thread::sleep_for(eventCreationDelay_);
252  }
253  return input::IsSubRun;
254  }
255  // same run and subrun
256  if (!firstTime_) {
257  eventID_ = eventID_.next();
258  if (!eventID_.runID().isValid()) {
259  return input::IsStop;
260  }
261  }
262  firstTime_ = false;
265  if (eventCreationDelay_ > 0ms) {
266  std::this_thread::sleep_for(eventCreationDelay_);
267  }
268  return input::IsEvent;
269 }
bool isValid() const
Definition: EventID.h:122
RunID const & runID() const
Definition: EventID.h:92
SubRunID const & subRunID() const
Definition: EventID.h:104
std::chrono::microseconds const eventCreationDelay_
EventID next() const
Definition: EventID.h:134
unsigned numberEventsInThisRun_
unsigned const numberEventsInRun_
RunNumber_t run() const
Definition: EventID.h:98
bool isValid() const
Definition: SubRunID.h:97
steady_clock::time_point const beginTime_
static constexpr double ms
Definition: Units.h:96
unsigned const numberEventsInSubRun_
std::chrono::seconds const maxTime_
EventID nextSubRun(EventNumber_t first=IDNumber< Level::Event >::first()) const
Definition: EventID.h:147
bool isValid() const
Definition: RunID.h:70
EventNumber_t event() const
Definition: EventID.h:116
bool const resetEventOnSubRun_
EventID nextRun() const
Definition: EventID.h:153
SubRunNumber_t subRun() const
Definition: EventID.h:110
unsigned numberEventsInThisSubRun_
std::unique_ptr< art::EmptyEventTimestampPlugin > art::EmptyEvent::makePlugin_ ( OptionalDelegatedParameter const &  maybeConfig)
private

Definition at line 363 of file EmptyEvent_source.cc.

364 {
365  std::unique_ptr<EmptyEventTimestampPlugin> result;
366  try {
367  ParameterSet pset;
368  if (maybeConfig.get_if_present(pset)) {
369  auto const libspec = pset.get<std::string>("plugin_type");
370  auto const pluginType = pluginFactory_.pluginType(libspec);
371  if (pluginType ==
373  result = pluginFactory_.makePlugin<decltype(result)>(libspec, pset);
374  } else {
375  throw Exception(errors::Configuration, "EmptyEvent: ")
376  << "unrecognized plugin type " << pluginType << "for plugin "
377  << libspec << ".\n";
378  }
379  }
380  }
381  catch (cet::exception& e) {
382  throw Exception(errors::Configuration, "EmptyEvent: ", e)
383  << "Exception caught while processing plugin spec.\n";
384  }
385  return result;
386 }
static QCString result
std::string string
Definition: nybbler.cc:12
std::enable_if_t<!std::is_function_v< RESULT_TYPE >, RESULT_TYPE > makePlugin(std::string const &libspec, ARGS &&...args) const
const double e
T get(std::string const &key) const
Definition: ParameterSet.h:271
cet::BasicPluginFactory pluginFactory_
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::string pluginType(std::string const &libspec) const
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
EmptyEvent& art::EmptyEvent::operator= ( EmptyEvent const &  )
delete
EmptyEvent& art::EmptyEvent::operator= ( EmptyEvent &&  )
delete
unique_ptr< art::EventPrincipal > art::EmptyEvent::readEvent_ ( )
overrideprivatevirtual

Implements art::DecrepitRelicInputSourceImplementation.

Definition at line 313 of file EmptyEvent_source.cc.

314 {
315  unique_ptr<EventPrincipal> result;
317  return result;
318  }
319  auto timestamp = plugin_ ? plugin_->doEventTimestamp(eventID_) :
321  EventAuxiliary const eventAux{
322  eventID_, timestamp, false, EventAuxiliary::Any};
323  result = make_unique<EventPrincipal>(eventAux,
325  nullptr,
326  make_unique<History>(),
327  make_unique<NoDelayedReader>(),
330  assert(result.get() != nullptr);
331  return result;
332 }
static QCString result
unsigned const numberEventsInSubRun_
unique_ptr< EmptyEventTimestampPlugin > plugin_
static constexpr Timestamp invalidTimestamp()
Definition: Timestamp.h:82
ProcessConfiguration const & processConfiguration() const
Definition: InputSource.cc:18
unsigned numberEventsInThisSubRun_
unique_ptr< art::RunPrincipal > art::EmptyEvent::readRun_ ( )
overrideprivatevirtual

Implements art::DecrepitRelicInputSourceImplementation.

Definition at line 272 of file EmptyEvent_source.cc.

273 {
274  unique_ptr<RunPrincipal> result;
275  auto ts = plugin_ ? plugin_->doBeginRunTimestamp(eventID_.runID()) :
277  RunAuxiliary const runAux{
279  result = make_unique<RunPrincipal>(runAux, processConfiguration(), nullptr);
280  assert(result.get() != nullptr);
281  if (plugin_) {
282  ModuleContext const mc{moduleDescription()};
283  Run const r{*result, mc};
284  plugin_->doBeginRun(r);
285  }
286  return result;
287 }
RunID const & runID() const
Definition: EventID.h:92
static QCString result
ModuleDescription const & moduleDescription() const
Definition: InputSource.cc:12
unique_ptr< EmptyEventTimestampPlugin > plugin_
static constexpr Timestamp invalidTimestamp()
Definition: Timestamp.h:82
ProcessConfiguration const & processConfiguration() const
Definition: InputSource.cc:18
unique_ptr< art::SubRunPrincipal > art::EmptyEvent::readSubRun_ ( cet::exempt_ptr< RunPrincipal const >  rp)
overrideprivatevirtual

Implements art::DecrepitRelicInputSourceImplementation.

Definition at line 290 of file EmptyEvent_source.cc.

291 {
292  unique_ptr<SubRunPrincipal> result;
293  if (processingMode() == Runs) {
294  return result;
295  }
296  auto ts = plugin_ ? plugin_->doBeginSubRunTimestamp(eventID_.subRunID()) :
298  SubRunAuxiliary const subRunAux{
300  result =
301  make_unique<SubRunPrincipal>(subRunAux, processConfiguration(), nullptr);
302  assert(result.get() != nullptr);
303  result->setRunPrincipal(rp);
304  if (plugin_) {
305  ModuleContext const mc{moduleDescription()};
306  SubRun const sr{*result, mc};
307  plugin_->doBeginSubRun(sr);
308  }
309  return result;
310 }
SubRunID const & subRunID() const
Definition: EventID.h:104
static QCString result
ModuleDescription const & moduleDescription() const
Definition: InputSource.cc:12
unique_ptr< EmptyEventTimestampPlugin > plugin_
static constexpr Timestamp invalidTimestamp()
Definition: Timestamp.h:82
ProcessConfiguration const & processConfiguration() const
Definition: InputSource.cc:18
static constexpr double sr
Definition: Units.h:166
void art::EmptyEvent::rewind_ ( )
overrideprivatevirtual

Reimplemented from art::DecrepitRelicInputSourceImplementation.

Definition at line 400 of file EmptyEvent_source.cc.

401 {
402  if (plugin_) {
403  plugin_->doRewind();
404  }
405  firstTime_ = true;
406  newFile_ = true;
407  newRun_ = true;
408  newSubRun_ = true;
412 }
unsigned numberEventsInThisRun_
unique_ptr< EmptyEventTimestampPlugin > plugin_
unsigned numberEventsInThisSubRun_
unique_ptr< art::RangeSetHandler > art::EmptyEvent::runRangeSetHandler ( )
overrideprivatevirtual

Implements art::InputSource.

Definition at line 335 of file EmptyEvent_source.cc.

336 {
337  return make_unique<OpenRangeSetHandler>(eventID_.run());
338 }
RunNumber_t run() const
Definition: EventID.h:98
void art::EmptyEvent::skip ( int  offset)
overrideprivatevirtual

Reimplemented from art::DecrepitRelicInputSourceImplementation.

Definition at line 389 of file EmptyEvent_source.cc.

390 {
391  for (; offset < 0; ++offset) {
393  }
394  for (; offset > 0; --offset) {
395  eventID_ = eventID_.next();
396  }
397 }
EventID previous() const
Definition: EventID.h:159
EventID next() const
Definition: EventID.h:134
unique_ptr< art::RangeSetHandler > art::EmptyEvent::subRunRangeSetHandler ( )
overrideprivatevirtual

Implements art::InputSource.

Definition at line 341 of file EmptyEvent_source.cc.

342 {
343  return make_unique<OpenRangeSetHandler>(eventID_.run());
344 }
RunNumber_t run() const
Definition: EventID.h:98

Member Data Documentation

steady_clock::time_point const art::EmptyEvent::beginTime_ {steady_clock::now()}
private

Definition at line 123 of file EmptyEvent_source.cc.

std::chrono::microseconds const art::EmptyEvent::eventCreationDelay_
private

Definition at line 125 of file EmptyEvent_source.cc.

EventID art::EmptyEvent::eventID_ {}
private

Definition at line 129 of file EmptyEvent_source.cc.

bool art::EmptyEvent::firstTime_ {true}
private

Definition at line 130 of file EmptyEvent_source.cc.

std::chrono::seconds const art::EmptyEvent::maxTime_
private

Definition at line 124 of file EmptyEvent_source.cc.

bool art::EmptyEvent::newFile_ {true}
private

Definition at line 131 of file EmptyEvent_source.cc.

bool art::EmptyEvent::newRun_ {true}
private

Definition at line 132 of file EmptyEvent_source.cc.

bool art::EmptyEvent::newSubRun_ {true}
private

Definition at line 133 of file EmptyEvent_source.cc.

unsigned const art::EmptyEvent::numberEventsInRun_
private

Definition at line 121 of file EmptyEvent_source.cc.

unsigned const art::EmptyEvent::numberEventsInSubRun_
private

Definition at line 122 of file EmptyEvent_source.cc.

unsigned art::EmptyEvent::numberEventsInThisRun_ {}
private

Definition at line 126 of file EmptyEvent_source.cc.

unsigned art::EmptyEvent::numberEventsInThisSubRun_ {}
private

Definition at line 127 of file EmptyEvent_source.cc.

EventID art::EmptyEvent::origEventID_ {}
private

Definition at line 128 of file EmptyEvent_source.cc.

unique_ptr<EmptyEventTimestampPlugin> art::EmptyEvent::plugin_
private

Definition at line 136 of file EmptyEvent_source.cc.

cet::BasicPluginFactory art::EmptyEvent::pluginFactory_ {}
private

Definition at line 135 of file EmptyEvent_source.cc.

bool const art::EmptyEvent::resetEventOnSubRun_
private

Definition at line 134 of file EmptyEvent_source.cc.


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