9#include <framework/modules/core/EventInfoSetterModule.h>
11#include <framework/core/Environment.h>
12#include <framework/utilities/Utils.h>
31 if (getenv(
"BELLE2_PRODUCTION"))
36 "Sets the event meta data information (exp, run, evt). You must use this "
37 "module to tell basf2 about the number of events you want to generate, "
38 "unless you have an input module that already does so. Note that all "
39 "experiment/run combinations specified must be unique."
43 addParam(
"expList",
m_expList,
"List of experiment numbers. Can be overridden via --experiment argument to basf2.",
m_expList);
46 "should be processed. Can be overridden via -n argument to basf2.",
49 "starting. Equivalent to running over this many events without performing "
50 "any action, to allow starting at higher event numbers.",
m_eventsToSkip);
52 "the specified (experiment, run, event number) occurs. This parameter "
53 "is useful for debugging to start with a specific event.",
m_skipToEvent);
67 if (numEventsArgument > 0 or runOverride >= 0 or expOverride >= 0) {
69 B2ERROR(
"The -n/--events, --run, and --experiment options cannot be used when multiple runs are specified for EventInfoSetter!");
79 if (skipNEventsOverride != 0)
83 unsigned int defListSize =
m_expList.size();
85 B2ERROR(
"Parameters are inconsistent. The exp, run and evt lists must have the same number of entries.");
86 }
else if (defListSize == 0) {
87 B2ERROR(
"There are no events to be processed!");
89 set<pair<int, int>> expRunSet;
90 for (
unsigned int i = 0; i < defListSize; i++) {
93 B2ERROR(
"Exp " << ret.first->first <<
", run " << ret.first->second <<
94 " used more than once! Please make sure all experiment/run combinations are unique.");
97 B2ERROR(
"Experiment " <<
m_expList[i] <<
" is out of range, should be in [0, 1023]!");
99 B2ERROR(
"Run " <<
m_runList[i] <<
" is out of range, should be >= 0!");
101 if (nevents == std::numeric_limits<unsigned int>::max()) {
102 B2ERROR(
"Invalid number of events (valid range: 0.." << std::numeric_limits<unsigned int>::max() - 1 <<
")!");
110 B2ERROR(
"skipToEvent must be a list of three values: experiment, run, event number");
115 B2ERROR(
"You cannot supply a number of events to skip (skipNEvents) and an "
116 "event to skip to (skipToEvent) at the same time, ignoring skipNEvents");
126 unsigned int totalevents = 0;
128 while (copy.advanceEventCounter()) {
132 B2DEBUG(100,
"EventInfoSetter: will process " << totalevents <<
" events in total.");
133 if (totalevents == 0) {
134 B2FATAL(
"Total processed number of events is 0, please check your inputs, -n and --skip-events arguments!");
178 unsigned int nskip = 1;
204 auto time = std::chrono::high_resolution_clock::now().time_since_epoch();
205 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.