9#include <framework/modules/core/EventInfoSetterModule.h>
11#include <framework/core/Environment.h>
12#include <framework/utilities/Utils.h>
31 const char* production = getenv(
"BELLE2_PRODUCTION");
37 "Sets the event meta data information (exp, run, evt). You must use this "
38 "module to tell basf2 about the number of events you want to generate, "
39 "unless you have an input module that already does so. Note that all "
40 "experiment/run combinations specified must be unique."
44 addParam(
"expList",
m_expList,
"List of experiment numbers. Can be overridden via --experiment argument to basf2.",
m_expList);
47 "should be processed. Can be overridden via -n argument to basf2.",
50 "starting. Equivalent to running over this many events without performing "
51 "any action, to allow starting at higher event numbers.",
m_eventsToSkip);
53 "the specified (experiment, run, event number) occurs. This parameter "
54 "is useful for debugging to start with a specific event.",
m_skipToEvent);
68 if (numEventsArgument > 0 or runOverride >= 0 or expOverride >= 0) {
70 B2ERROR(
"The -n/--events, --run, and --experiment options cannot be used when multiple runs are specified for EventInfoSetter!");
80 if (skipNEventsOverride != 0)
84 unsigned int defListSize =
m_expList.size();
86 B2ERROR(
"Parameters are inconsistent. The exp, run and evt lists must have the same number of entries.");
87 }
else if (defListSize == 0) {
88 B2ERROR(
"There are no events to be processed!");
90 set<pair<int, int>> expRunSet;
91 for (
unsigned int i = 0; i < defListSize; i++) {
94 B2ERROR(
"Exp " << ret.first->first <<
", run " << ret.first->second <<
95 " used more than once! Please make sure all experiment/run combinations are unique.");
98 B2ERROR(
"Experiment " <<
m_expList[i] <<
" is out of range, should be in [0, 1023]!");
100 B2ERROR(
"Run " <<
m_runList[i] <<
" is out of range, should be >= 0!");
102 if (nevents == std::numeric_limits<unsigned int>::max()) {
103 B2ERROR(
"Invalid number of events (valid range: 0.." << std::numeric_limits<unsigned int>::max() - 1 <<
")!");
111 B2ERROR(
"skipToEvent must be a list of three values: experiment, run, event number");
116 B2ERROR(
"You cannot supply a number of events to skip (skipNEvents) and an "
117 "event to skip to (skipToEvent) at the same time, ignoring skipNEvents");
127 unsigned int totalevents = 0;
129 while (copy.advanceEventCounter()) {
133 B2DEBUG(100,
"EventInfoSetter: will process " << totalevents <<
" events in total.");
134 if (totalevents == 0) {
135 B2FATAL(
"Total processed number of events is 0, please check your inputs, -n and --skip-events arguments!");
179 unsigned int nskip = 1;
205 auto time = std::chrono::high_resolution_clock::now().time_since_epoch();
206 m_eventMetaDataPtr->setTime(std::chrono::duration_cast<std::chrono::nanoseconds>(time).count());
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
unsigned int getSkipEventsOverride() const
Get skipNEvents override, or 0 if unset.
int getExperimentOverride() const
Get experiment override, or -1 if unset.
int getRunOverride() const
Get run override, or -1 if unset.
static Environment & Instance()
Static method to get a reference to the Environment instance.
unsigned int getNumberEventsOverride() const
Returns number of events in run 1 for EventInfoSetter module, or 0 for no override.
void setNumberOfMCEvents(unsigned int n)
Set number of generated events (for EventInfoSetter).
Module to set event, run, experiment numbers.
std::vector< unsigned int > m_evtNumList
The list (column) of the number of events which should be processed.
virtual void initialize() override
Initializes the Module.
std::vector< int > m_runList
The list (column) of runs.
virtual void event() override
Stores the event meta data into the DataStore.
virtual ~EventInfoSetterModule()
Destructor.
unsigned int m_evtNumber
The current event number.
int m_production
The production number.
unsigned int m_eventsToSkip
skip this many events before starting.
StoreObjPtr< EventMetaData > m_eventMetaDataPtr
Output object.
std::vector< int > m_skipToEvent
The (expNo, runNo, evtNo) tuple to skip to, empty if not used.
std::vector< int > m_expList
The list (column) of experiments.
bool advanceEventCounter()
Advances member variables to the next event (which is given by m_evtNumber).
int m_colIndex
The current index for the exp and run lists.
EventInfoSetterModule()
Constructor.
void setDescription(const std::string &description)
Sets the description of the module.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define branch_unlikely(x)
A macro to tell the compiler that the argument x will be very likely be false.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.