23 #include "cetlib/BasicPluginFactory.h" 37 using namespace fhicl;
40 using std::chrono::steady_clock;
50 limitsConfig().maxEvents()};
52 limitsConfig().maxSubRuns()};
56 "If specified, the 'maxTime' parameter indicates the maximum " 58 "wall-clock time (in seconds) for which new events may be created.\n" 59 "This option is mutually exclusive with the 'maxEvents' and " 61 "configuration parameters."),
62 std::numeric_limits<uint32_t>::max()};
64 Name(
"eventCreationDelay"),
65 Comment(
"The 'eventCreationDelay' parameter is an integral value\n" 66 "in the range [0, 1000000), corresponding to microseconds.\n" 67 "If specified, the input source will sleep for the specified " 69 "of time before each new event, subrun, or run is created.\n"),
76 Name(
"timestampPlugin"),
78 "The 'timestampPlugin' parameter must be a FHiCL table\n" 80 " timestampPlugin: {\n" 81 " plugin_type: <plugin specification>\n" 84 "See the notes in art/Framework/Core/EmptyEventTimestampPlugin.h\n" 85 "for more details.")};
91 return {
"module_label"};
106 unique_ptr<RangeSetHandler> runRangeSetHandler()
override;
107 unique_ptr<RangeSetHandler> subRunRangeSetHandler()
override;
108 void doBeginJob()
override;
109 void doEndJob()
override;
110 void skipEvents(
int offset)
override;
111 unique_ptr<FileBlock> readFile()
override;
112 void closeFile()
override;
113 unique_ptr<RunPrincipal> readRun()
override;
115 unique_ptr<SubRunPrincipal> readSubRun(
116 cet::exempt_ptr<RunPrincipal const>)
override;
117 unique_ptr<EventPrincipal> readEvent(
118 cet::exempt_ptr<SubRunPrincipal const>)
override;
122 unique_ptr<EmptyEventTimestampPlugin> makePlugin_(
128 steady_clock::time_point
const beginTime_{steady_clock::now()};
131 unsigned numberEventsInThisRun_{};
132 unsigned numberEventsInThisSubRun_{};
135 bool firstTime_{
true};
138 bool newSubRun_{
true};
140 cet::BasicPluginFactory pluginFactory_{};
141 unique_ptr<EmptyEventTimestampPlugin>
plugin_;
152 config().numberEventsInSubRun())}
160 auto const& pset = config.get_PSet();
161 if (pset.has_key(
"maxTime") &&
162 (pset.has_key(
"maxEvents") || pset.has_key(
"maxSubRuns"))) {
165 "An error occurred while configuring the EmptyEvent source.\n"}
166 <<
"The 'maxTime' parameter cannot be used with the 'maxEvents' or " 167 "'maxSubRuns' parameters.\n" 168 "Type 'art --print-description EmptyEvent' for the allowed " 173 bool haveFirstRun = config().firstRun(firstRun);
175 bool haveFirstSubRun = config().firstSubRun(firstSubRun);
177 bool haveFirstEvent = config().firstEvent(firstEvent);
179 SubRunID firstSubRunID = haveFirstSubRun ?
284 unique_ptr<art::FileBlock>
287 return make_unique<FileBlock>();
294 unique_ptr<art::RunPrincipal>
305 plugin_->doBeginRun(std::as_const(*result).makeRun(mc));
310 unique_ptr<art::SubRunPrincipal>
319 result->setRunPrincipal(rp);
322 plugin_->doBeginSubRun(std::as_const(*result).makeSubRun(mc));
328 unique_ptr<art::EventPrincipal>
334 auto result = make_unique<EventPrincipal>(eventAux,
337 make_unique<NoDelayedReader>(),
340 result->setSubRunPrincipal(srp);
345 unique_ptr<art::RangeSetHandler>
348 return make_unique<OpenRangeSetHandler>(
eventID_.
run());
351 unique_ptr<art::RangeSetHandler>
354 return make_unique<OpenRangeSetHandler>(
eventID_.
run());
373 std::unique_ptr<art::EmptyEventTimestampPlugin>
382 auto const libspec = pset->
get<std::string>(
"plugin_type");
387 .makePlugin<std::unique_ptr<EmptyEventTimestampPlugin>>(libspec, *pset);
390 <<
"unrecognized plugin type " << pluginType <<
"for plugin " << libspec
395 <<
"Exception caught while processing plugin spec.\n";
402 for (; offset < 0; ++offset) {
405 for (; offset > 0; --offset) {
RunID const & runID() const
SubRunID const & subRunID() const
std::chrono::microseconds const eventCreationDelay_
std::optional< T > get_if_present() const
EmptyEvent(Parameters const &config, InputSourceDescription &desc)
unsigned numberEventsInThisRun_
unique_ptr< EmptyEventTimestampPlugin > makePlugin_(OptionalDelegatedParameter const &maybeConfig)
unsigned const numberEventsInRun_
void closeFile() override
input::ItemType nextItemType()
ModuleType module_type(std::string const &full_key)
microsecond microseconds
Alias for common language habits.
unique_ptr< RangeSetHandler > runRangeSetHandler() override
steady_clock::time_point const beginTime_
unique_ptr< EventPrincipal > readEvent(cet::exempt_ptr< SubRunPrincipal const >) override
unique_ptr< FileBlock > readFile() override
second seconds
Alias for common language habits.
unsigned const numberEventsInSubRun_
std::chrono::seconds const maxTime_
input::ItemType nextItemType() override
T get(std::string const &key) const
cet::BasicPluginFactory pluginFactory_
IDNumber_t< Level::SubRun > SubRunNumber_t
EventID nextSubRun(EventNumber_t first=IDNumber< Level::Event >::first()) const
unique_ptr< EmptyEventTimestampPlugin > plugin_
static SubRunID firstSubRun()
TableFragment< ProcessingLimits::Config > limitsConfig
static constexpr Timestamp invalidTimestamp()
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::set< std::string > operator()() const
IDNumber_t< Level::Event > EventNumber_t
EventNumber_t event() const
SubRunNumber_t subRun() const
bool const resetEventOnSubRun_
void doBeginJob() override
static EventID firstEvent()
unique_ptr< SubRunPrincipal > readSubRun(cet::exempt_ptr< RunPrincipal const >) override
SubRunNumber_t subRun() const
void update(EventID const &id)
cet::coded_exception< error, detail::translate > exception
input::ItemType nextItemType_()
unique_ptr< RunPrincipal > readRun() override
unsigned numberEventsInThisSubRun_
unique_ptr< RangeSetHandler > subRunRangeSetHandler() override
void skipEvents(int offset) override
IDNumber_t< Level::Run > RunNumber_t