Belle II Software light-2405-quaxo
Environment Class Reference

This class stores all environment information required to run the framework, such as module or data filepaths, number of processes to be used in parallel processing etc. More...

#include <Environment.h>

Collaboration diagram for Environment:

Public Member Functions

const std::list< std::string > & getModuleSearchPaths () const
 Returns a list of file paths searched for module libraries.
 
void setExternalsPath (const std::string &externalsPath)
 Sets the path which points to the externals directory of the framework.
 
const std::string & getExternalsPath () const
 Returns the path which points to the externals directory of the framework.
 
void setNumberEventsOverride (unsigned int nevents)
 Override the number of events in run 1 for EventInfoSetter module.
 
unsigned int getNumberEventsOverride () const
 Returns number of events in run 1 for EventInfoSetter module, or 0 for no override.
 
void setEntrySequencesOverride (const std::vector< std::string > &sequences)
 Override the number sequences (e.g.
 
std::vector< std::string > getEntrySequencesOverride () const
 Returns the number sequences (e.g.
 
unsigned int getNumberOfEvents () const
 Return the number of events, from either input or EventInfoSetter, or -n command line override (if less).
 
void setRunExperimentOverride (int run, int experiment)
 Override run and experiment for EventInfoSetter.
 
int getRunOverride () const
 Get run override, or -1 if unset.
 
int getExperimentOverride () const
 Get experiment override, or -1 if unset.
 
void setSkipEventsOverride (unsigned int skipEvents)
 Set skipNEvents override.
 
unsigned int getSkipEventsOverride () const
 Get skipNEvents override, or 0 if unset.
 
bool isMC () const
 Do we have generated, not real data?
 
unsigned int getNumberOfMCEvents () const
 Number of generated events (from EventInfoSetter).
 
void setNumberOfMCEvents (unsigned int n)
 Set number of generated events (for EventInfoSetter).
 
void setInputFilesOverride (const std::vector< std::string > &names)
 Override input file names for modules.
 
const std::vector< std::string > & getInputFilesOverride () const
 Return overriden input file names, or empty vector if none were set.
 
void setSecondaryInputFilesOverride (const std::vector< std::string > &names)
 Override secondary input file names for modules.
 
const std::vector< std::string > & getSecondaryInputFilesOverride () const
 Return overriden secondary input file names, or empty vector if none were set.
 
void setOutputFileOverride (const std::string &name)
 Override output file name for modules.
 
const std::string & getOutputFileOverride () const
 Return overriden output file name, or "" if none was set.
 
std::string consumeOutputFileOverride (const std::string &moduleName)
 Return overriden output file name, or "" if none was set.
 
const std::string & getOutputFileOverrideModule () const
 Return the name of the module which consumed the OutputFileOverride, "" if no output file override was set or no other module consumed it.
 
void setNumberProcessesOverride (int nproc)
 Override number of processes to run in parallel.
 
void setNumberProcesses (int number)
 Sets the number of processes which should be used for the parallel processing.
 
int getNumberProcesses () const
 Returns the number of worker processes which should be used for the parallel processing.
 
void setPicklePath (const std::string &path)
 Sets the path to the file where the pickled path is stored.
 
std::string getPicklePath () const
 Returns the path to the file where the pickled path is stored.
 
void setSteering (const std::string &steering)
 Sets the steering file content.
 
const std::string & getSteering () const
 Returns the steering file content.
 
void setVisualizeDataFlow (bool on)
 Wether to generate DOT files with data store inputs/outputs of each module.
 
bool getVisualizeDataFlow () const
 Wether to generate DOT files with data store inputs/outputs of each module.
 
void setNoStats (bool noStats)
 Disable collection of statistics during event processing.
 
bool getNoStats () const
 Disable collection of statistics during event processing.
 
void setDryRun (bool dryRun)
 Read steering file, but do not start any actually start any event processing.
 
bool getDryRun () const
 Read steering file, but do not start any actually start any event processing.
 
void setJobInformation (const std::shared_ptr< Path > &path)
 Set info from path executed by the framework.
 
void setRealm (LogConfig::ELogRealm realm)
 Set the basf2 execution realm.
 
LogConfig::ELogRealm getRealm () const
 Get the basf2 execution realm.
 
void setWriteSimSteps (const bool writeSimSteps)
 Set the flag for writing the simulation steps into an output csv file.
 
bool getWriteSimSteps () const
 Get the flag for writing the simulation steps into an output csv file.
 
void printJobInformation () const
 Print information on input/output files in current steering file, used by –dry-run.
 
void setProfileModuleName (const std::string &name)
 Set the name of a module to be profiled.
 
std::string getProfileModuleName () const
 Return the name of the module to be profiled, empty if no profiling was requested.
 
void setLogLevelOverride (int level)
 Override global log level if != LogConfig::c_Default.
 
int getLogLevelOverride () const
 Get log level override.
 
void setStreamingObjects (const std::vector< std::string > &strobjs)
 Set list of streaming objects.
 
const std::vector< std::string > & getStreamingObjects () const
 Get list of streaming objects.
 
bool getUseZMQ () const
 Flag if ZMQ should be used instead of the RingBuffer multiprocesing implementation.
 
void setUseZMQ (bool useZMQ)
 Set the flag if ZMQ should be used instead of the RingBuffer multiprocessing implementation.
 
const std::string & getZMQSocketAddress () const
 Socket address to use in ZMQ.
 
void setZMQSocketAddress (const std::string &zmqSocketAddress)
 Socket address to use in ZMQ.
 
unsigned int getZMQMaximalWaitingTime () const
 Maximal waiting time of any ZMQ module for any communication in ms.
 
void setZMQMaximalWaitingTime (unsigned int zmqMaximalWaitingTime)
 Maximal waiting time of any ZMQ module for any communication in ms.
 
unsigned int getZMQEventBufferSize () const
 Number of events to keep in flight for every worker.
 
void setZMQEventBufferSize (unsigned int zmqEventBufferSize)
 Number of events to keep in flight for every worker.
 
unsigned int getZMQWorkerTimeout () const
 How long should a worker maximally need to process all of his events in the queue. Set to 0 to disable the check.
 
void setZMQWorkerTimeout (unsigned int zmqWorkerTimeout)
 How long should a worker maximally need to process all of his events in the queue. Set to 0 to disable the check.
 
bool getZMQUseEventBackup () const
 If a worker dies, store its events in a backup.
 
void setZMQUseEventBackup (bool zmqUseEventBackup)
 If a worker dies, store its events in a backup.
 
bool getZMQRestartFailedWorkers () const
 If a worker dies, restart it.
 
void setZMQRestartFailedWorkers (bool zmqRestartFailedWorkers)
 If a worker dies, restart it.
 
bool getZMQFailOnFailedWorkers () const
 If a worker dies, fail also.
 
void setZMQFailOnFailedWorkers (bool zmqFailOnFailedWorkers)
 If a worker dies, fail also.
 
bool getZMQDAQEnvironment () const
 obtain current environment (DAQ or not)
 
void setZMQDAQEnvironment (bool zmqDAQ)
 Set DAQ environment.
 
int getZMQDAQFirstEventExp () const
 get the exp number for DAQ first event
 
void setZMQDAQFirstEventExp (int exp)
 set the exp number for DAQ first event
 
int getZMQDAQFirstEventRun () const
 get run number for DAQ first event
 
void setZMQDAQFirstEventRun (int run)
 set run number for DAQ first event
 
bool isZMQDAQFirstEvent (int exp, int run)
 checks the exp/run is DAQ first event
 

Static Public Member Functions

static EnvironmentInstance ()
 Static method to get a reference to the Environment instance.
 

Private Member Functions

 Environment ()
 Set up environment from standard BELLE2_ environment variables.
 
 Environment (const Environment &)=delete
 Disable/Hide the copy constructor.
 
Environmentoperator= (const Environment &)=delete
 Disable/Hide the copy assignment operator.
 
 ~Environment ()
 The Environment destructor.
 

Private Attributes

std::string m_externalsPath
 The path in which the externals are located.
 
int m_numberProcesses
 The number of worker processes that should be used for the parallel processing.
 
std::string m_steering
 The content of the steering file.
 
unsigned int m_numberEventsOverride
 Override number of events in the first run.
 
std::vector< std::string > m_inputFilesOverride
 Override input file names for input modules.
 
std::vector< std::string > m_secondaryInputFilesOverride
 Override secondary input file names for input modules.
 
std::vector< std::string > m_entrySequencesOverride
 A number sequence (e.g.
 
std::string m_outputFileOverride
 Override name of output file for output module.
 
std::string m_outputFileOverrideModule {""}
 Name of the module which consumed the output file Override if any was given.
 
int m_numberProcessesOverride
 Override m_numberProcesses if >= 0.
 
int m_logLevelOverride
 Override global log level if != LogConfig::c_Default.
 
bool m_visualizeDataFlow
 Wether to generate DOT files with data store inputs/outputs of each module.
 
bool m_noStats
 Disable collection of statistics during event processing.
 
bool m_dryRun
 Read steering file, but do not start any actually start any event processing.
 
std::string m_jobInfoOutput
 Output for printJobInformation(), generated by setJobInformation().
 
std::string m_profileModuleName
 Name of the module which should be profiled, empty if no profiling requested.
 
std::string m_picklePath
 Path to the file where the pickled path is stored.
 
std::vector< std::string > m_streamingObjects
 objects to be streamed in Tx module (all if empty)
 
unsigned int m_mcEvents
 counter for number of generated events.
 
int m_run
 override run for EventInfoSetter.
 
int m_experiment
 override experiment for EventInfoSetter.
 
unsigned int m_skipNEvents
 override skipNEvents for EventInfoSetter/RootInput.
 
LogConfig::ELogRealm m_realm = LogConfig::c_None
 The realm in which basf2 is executed.
 
bool m_writeSimSteps
 bool for writing out the simulation steps into a csv file.
 
bool m_useZMQ = false
 Set to true to use ZMQ instead of RingBuffer.
 
std::string m_zmqSocketAddress = ""
 Socket address to use in ZMQ.
 
unsigned int m_zmqMaximalWaitingTime
 Maximal waiting time of any ZMQ module for any communication in ms.
 
unsigned int m_zmqEventBufferSize = 1
 Number of events to keep in flight for every worker.
 
unsigned int m_zmqWorkerTimeout
 How long should a worker maximally need to process all of his events in the queue.
 
bool m_zmqUseEventBackup = true
 If a worker dies, store its events in a backup.
 
bool m_zmqRestartFailedWorkers = true
 If a worker dies, restart it.
 
bool m_zmqFailOnFailedWorkers = true
 If a worker dies, fail also.
 
bool m_zmqDAQEnvironment = false
 True in DAQ environment.
 
int m_zmqDAQFirstEventExp = 42
 Exp no.
 
int m_zmqDAQFirstEventRun = 8
 Exp no.
 

Detailed Description

This class stores all environment information required to run the framework, such as module or data filepaths, number of processes to be used in parallel processing etc.

Usually, this information is set by the steering file.

This class is designed as a singleton.

Definition at line 32 of file Environment.h.

Constructor & Destructor Documentation

◆ Environment()

Environment ( )
private

Set up environment from standard BELLE2_ environment variables.

Ends with B2FATAL if something goes wrong.

Definition at line 85 of file Environment.cc.

85 :
87 m_steering(""),
96 m_noStats(false),
97 m_dryRun(false),
98 m_mcEvents(0),
99 m_run(-1),
100 m_experiment(-1),
101 m_skipNEvents(0),
102 m_writeSimSteps(false)
103{
104 // Check for environment variables set by setuprel
105 const char* envarReleaseDir = getenv("BELLE2_RELEASE_DIR");
106 const char* envarLocalDir = getenv("BELLE2_LOCAL_DIR");
107 const char* envarAnalysisDir = getenv("BELLE2_ANALYSIS_DIR");
108 if (!envarReleaseDir and !envarLocalDir) {
109 B2FATAL("The basf2 environment is not set up. Please execute the 'setuprel' script first.");
110 }
111
112 //also set when just sourcing setup_belle2.sh (which is why we also check for local/release dir)
113 const char* envarSubDir = getenv("BELLE2_SUBDIR");
114 if (!envarSubDir) {
115 B2FATAL("The environment variable BELLE2_SUBDIR is not set. Please execute the 'setuprel' script first.");
116 }
117
118 const char* envarExtDir = getenv("BELLE2_EXTERNALS_DIR");
119 if (!envarExtDir) {
120 B2FATAL("The environment variable BELLE2_EXTERNALS_DIR is not set. Please execute the 'setuprel' script first.");
121 }
122
123 // add module directories for current build options, starting with the working directory on program startup
124 std::string added_dirs = fs::current_path().string();
126
127 if (envarAnalysisDir) {
128 const string analysisModules = (fs::path(envarAnalysisDir) / "modules" / envarSubDir).string();
130 added_dirs += " " + analysisModules;
131 }
132
133 if (envarLocalDir) {
134 const string localModules = (fs::path(envarLocalDir) / "modules" / envarSubDir).string();
136 added_dirs += " " + localModules;
137 }
138
139 if (envarReleaseDir) {
140 const string centralModules = (fs::path(envarReleaseDir) / "modules" / envarSubDir).string();
142 added_dirs += " " + centralModules;
143 }
144
145 if (ModuleManager::Instance().getAvailableModules().empty()) {
146 B2ERROR("No modules found! Did you forget to run 'scons'? Module paths added: " << added_dirs);
147 }
148
149 //set path to external software
150 setExternalsPath(envarExtDir);
151}
std::string m_steering
The content of the steering file.
Definition: Environment.h:381
std::vector< std::string > m_entrySequencesOverride
A number sequence (e.g.
Definition: Environment.h:386
int m_numberProcesses
The number of worker processes that should be used for the parallel processing.
Definition: Environment.h:380
bool m_noStats
Disable collection of statistics during event processing.
Definition: Environment.h:392
std::string m_outputFileOverride
Override name of output file for output module.
Definition: Environment.h:387
unsigned int m_mcEvents
counter for number of generated events.
Definition: Environment.h:398
std::vector< std::string > m_inputFilesOverride
Override input file names for input modules.
Definition: Environment.h:383
bool m_writeSimSteps
bool for writing out the simulation steps into a csv file.
Definition: Environment.h:403
void setExternalsPath(const std::string &externalsPath)
Sets the path which points to the externals directory of the framework.
Definition: Environment.h:53
unsigned int m_numberEventsOverride
Override number of events in the first run.
Definition: Environment.h:382
bool m_visualizeDataFlow
Wether to generate DOT files with data store inputs/outputs of each module.
Definition: Environment.h:391
int m_experiment
override experiment for EventInfoSetter.
Definition: Environment.h:400
int m_logLevelOverride
Override global log level if != LogConfig::c_Default.
Definition: Environment.h:390
int m_numberProcessesOverride
Override m_numberProcesses if >= 0.
Definition: Environment.h:389
std::vector< std::string > m_secondaryInputFilesOverride
Override secondary input file names for input modules.
Definition: Environment.h:384
bool m_dryRun
Read steering file, but do not start any actually start any event processing.
Definition: Environment.h:393
unsigned int m_skipNEvents
override skipNEvents for EventInfoSetter/RootInput.
Definition: Environment.h:401
int m_run
override run for EventInfoSetter.
Definition: Environment.h:399
@ c_Default
Default: use globally configured log level.
Definition: LogConfig.h:32
static ModuleManager & Instance()
Exception is thrown if the requested module could not be created by the ModuleManager.
void addModuleSearchPath(const std::string &path)
Adds a new filepath to the list of filepaths which are searched for a requested module.

Member Function Documentation

◆ consumeOutputFileOverride()

std::string consumeOutputFileOverride ( const std::string &  moduleName)

Return overriden output file name, or "" if none was set.

Note that this will remove the current value to avoid reuse. (e.g. subsequent calls will always return "")

Definition at line 67 of file Environment.cc.

68{
69 std::string s{""};
70 if (!m_outputFileOverrideModule.empty()) {
71 B2WARNING("Module '" << module << "' requested to handle -o which has already been handled by '" << module << "', ignoring");
72 return s;
73 }
74 if (!m_outputFileOverride.empty()) {
76 std::swap(s, m_outputFileOverride);
77 }
78 return s;
79}
std::string m_outputFileOverrideModule
Name of the module which consumed the output file Override if any was given.
Definition: Environment.h:388

◆ getDryRun()

bool getDryRun ( ) const
inline

Read steering file, but do not start any actually start any event processing.

Prints information on input/output files and number of events that that would be used during normal execution.

Definition at line 191 of file Environment.h.

191{ return m_dryRun; }

◆ getEntrySequencesOverride()

std::vector< std::string > getEntrySequencesOverride ( ) const
inline

Returns the number sequences (e.g.

23:42,101) defining the entry which are processed for each filename given in inputFilesOverride

Definition at line 72 of file Environment.h.

◆ getExperimentOverride()

int getExperimentOverride ( ) const
inline

Get experiment override, or -1 if unset.

Definition at line 83 of file Environment.h.

83{ return m_experiment; }

◆ getExternalsPath()

const std::string & getExternalsPath ( ) const
inline

Returns the path which points to the externals directory of the framework.

Returns
externals path, without trailing slash

Definition at line 60 of file Environment.h.

60{ return m_externalsPath; };
std::string m_externalsPath
The path in which the externals are located.
Definition: Environment.h:379

◆ getInputFilesOverride()

const std::vector< std::string > & getInputFilesOverride ( ) const
inline

Return overriden input file names, or empty vector if none were set.

Definition at line 103 of file Environment.h.

103{ return m_inputFilesOverride; }

◆ getLogLevelOverride()

int getLogLevelOverride ( ) const
inline

Get log level override.

Definition at line 226 of file Environment.h.

226{ return m_logLevelOverride; }

◆ getModuleSearchPaths()

const list< string > & getModuleSearchPaths ( ) const

Returns a list of file paths searched for module libraries.

Definition at line 34 of file Environment.cc.

35{
37}
const std::list< std::string > & getModuleSearchPaths() const
Returns a reference to the list of the modules search filepaths.

◆ getNoStats()

bool getNoStats ( ) const
inline

Disable collection of statistics during event processing.

Definition at line 187 of file Environment.h.

187{ return m_noStats; }

◆ getNumberEventsOverride()

unsigned int getNumberEventsOverride ( ) const
inline

Returns number of events in run 1 for EventInfoSetter module, or 0 for no override.

Definition at line 66 of file Environment.h.

66{ return m_numberEventsOverride; }

◆ getNumberOfEvents()

unsigned int getNumberOfEvents ( ) const

Return the number of events, from either input or EventInfoSetter, or -n command line override (if less).

Definition at line 39 of file Environment.cc.

40{
41 // for EventInfoSetter, -n is already taken into account
42 if (m_mcEvents != 0)
43 return m_mcEvents;
44
45 unsigned int numEventsFromInput = InputController::getNumEntriesToProcess();
46 unsigned int numEventsFromArgument = getNumberEventsOverride();
47 if (numEventsFromArgument != 0
48 && (numEventsFromInput == 0 || numEventsFromArgument < numEventsFromInput))
49 return numEventsFromArgument;
50 else
51 return numEventsFromInput;
52}
unsigned int getNumberEventsOverride() const
Returns number of events in run 1 for EventInfoSetter module, or 0 for no override.
Definition: Environment.h:66
static long getNumEntriesToProcess()
Necessary to make sure the ProgressModule shows reasonable output.

◆ getNumberOfMCEvents()

unsigned int getNumberOfMCEvents ( ) const
inline

Number of generated events (from EventInfoSetter).

Definition at line 94 of file Environment.h.

94{ return m_mcEvents; }

◆ getNumberProcesses()

int getNumberProcesses ( ) const
inline

Returns the number of worker processes which should be used for the parallel processing.

Definition at line 145 of file Environment.h.

146 {
149 else
150 return m_numberProcesses;
151 }

◆ getOutputFileOverride()

const std::string & getOutputFileOverride ( ) const
inline

Return overriden output file name, or "" if none was set.

Definition at line 115 of file Environment.h.

115{ return m_outputFileOverride; }

◆ getOutputFileOverrideModule()

const std::string & getOutputFileOverrideModule ( ) const
inline

Return the name of the module which consumed the OutputFileOverride, "" if no output file override was set or no other module consumed it.

Definition at line 126 of file Environment.h.

◆ getPicklePath()

std::string getPicklePath ( ) const
inline

Returns the path to the file where the pickled path is stored.

Returns
The path to the file where the pickled path is stored.

Definition at line 165 of file Environment.h.

165{ return m_picklePath; }
std::string m_picklePath
Path to the file where the pickled path is stored.
Definition: Environment.h:396

◆ getProfileModuleName()

std::string getProfileModuleName ( ) const
inline

Return the name of the module to be profiled, empty if no profiling was requested.

Definition at line 220 of file Environment.h.

220{ return m_profileModuleName; }
std::string m_profileModuleName
Name of the module which should be profiled, empty if no profiling requested.
Definition: Environment.h:395

◆ getRealm()

LogConfig::ELogRealm getRealm ( ) const
inline

Get the basf2 execution realm.

Definition at line 199 of file Environment.h.

199{ return m_realm; }
LogConfig::ELogRealm m_realm
The realm in which basf2 is executed.
Definition: Environment.h:402

◆ getRunOverride()

int getRunOverride ( ) const
inline

Get run override, or -1 if unset.

Definition at line 81 of file Environment.h.

81{ return m_run; }

◆ getSecondaryInputFilesOverride()

const std::vector< std::string > & getSecondaryInputFilesOverride ( ) const
inline

Return overriden secondary input file names, or empty vector if none were set.

Definition at line 109 of file Environment.h.

◆ getSkipEventsOverride()

unsigned int getSkipEventsOverride ( ) const
inline

Get skipNEvents override, or 0 if unset.

Definition at line 88 of file Environment.h.

88{ return m_skipNEvents; }

◆ getSteering()

const std::string & getSteering ( ) const
inline

Returns the steering file content.

Definition at line 175 of file Environment.h.

175{ return m_steering; };

◆ getStreamingObjects()

const std::vector< std::string > & getStreamingObjects ( ) const
inline

Get list of streaming objects.

Definition at line 232 of file Environment.h.

232{ return m_streamingObjects; }
std::vector< std::string > m_streamingObjects
objects to be streamed in Tx module (all if empty)
Definition: Environment.h:397

◆ getUseZMQ()

bool getUseZMQ ( ) const
inline

Flag if ZMQ should be used instead of the RingBuffer multiprocesing implementation.

Definition at line 236 of file Environment.h.

237 {
238 return m_useZMQ;
239 }
bool m_useZMQ
Set to true to use ZMQ instead of RingBuffer.
Definition: Environment.h:406

◆ getVisualizeDataFlow()

bool getVisualizeDataFlow ( ) const
inline

Wether to generate DOT files with data store inputs/outputs of each module.

Definition at line 181 of file Environment.h.

181{ return m_visualizeDataFlow; }

◆ getWriteSimSteps()

bool getWriteSimSteps ( ) const
inline

Get the flag for writing the simulation steps into an output csv file.

Definition at line 207 of file Environment.h.

207{ return m_writeSimSteps; }

◆ getZMQDAQEnvironment()

bool getZMQDAQEnvironment ( ) const
inline

obtain current environment (DAQ or not)

Definition at line 333 of file Environment.h.

334 {
335 return m_zmqDAQEnvironment;
336 }
bool m_zmqDAQEnvironment
True in DAQ environment.
Definition: Environment.h:416

◆ getZMQDAQFirstEventExp()

int getZMQDAQFirstEventExp ( ) const
inline

get the exp number for DAQ first event

Definition at line 345 of file Environment.h.

346 {
348 }
int m_zmqDAQFirstEventExp
Exp no.
Definition: Environment.h:417

◆ getZMQDAQFirstEventRun()

int getZMQDAQFirstEventRun ( ) const
inline

get run number for DAQ first event

Definition at line 357 of file Environment.h.

358 {
360 }
int m_zmqDAQFirstEventRun
Exp no.
Definition: Environment.h:418

◆ getZMQEventBufferSize()

unsigned int getZMQEventBufferSize ( ) const
inline

Number of events to keep in flight for every worker.

Definition at line 272 of file Environment.h.

273 {
275 }
unsigned int m_zmqEventBufferSize
Number of events to keep in flight for every worker.
Definition: Environment.h:410

◆ getZMQFailOnFailedWorkers()

bool getZMQFailOnFailedWorkers ( ) const
inline

If a worker dies, fail also.

Definition at line 320 of file Environment.h.

321 {
323 }
bool m_zmqFailOnFailedWorkers
If a worker dies, fail also.
Definition: Environment.h:415

◆ getZMQMaximalWaitingTime()

unsigned int getZMQMaximalWaitingTime ( ) const
inline

Maximal waiting time of any ZMQ module for any communication in ms.

Definition at line 260 of file Environment.h.

261 {
263 }
unsigned int m_zmqMaximalWaitingTime
Maximal waiting time of any ZMQ module for any communication in ms.
Definition: Environment.h:408

◆ getZMQRestartFailedWorkers()

bool getZMQRestartFailedWorkers ( ) const
inline

If a worker dies, restart it.

Definition at line 308 of file Environment.h.

309 {
311 }
bool m_zmqRestartFailedWorkers
If a worker dies, restart it.
Definition: Environment.h:414

◆ getZMQSocketAddress()

const std::string & getZMQSocketAddress ( ) const
inline

Socket address to use in ZMQ.

Definition at line 248 of file Environment.h.

249 {
250 return m_zmqSocketAddress;
251 }
std::string m_zmqSocketAddress
Socket address to use in ZMQ.
Definition: Environment.h:407

◆ getZMQUseEventBackup()

bool getZMQUseEventBackup ( ) const
inline

If a worker dies, store its events in a backup.

Definition at line 296 of file Environment.h.

297 {
298 return m_zmqUseEventBackup;
299 }
bool m_zmqUseEventBackup
If a worker dies, store its events in a backup.
Definition: Environment.h:413

◆ getZMQWorkerTimeout()

unsigned int getZMQWorkerTimeout ( ) const
inline

How long should a worker maximally need to process all of his events in the queue. Set to 0 to disable the check.

Definition at line 284 of file Environment.h.

285 {
286 return m_zmqWorkerTimeout;
287 }
unsigned int m_zmqWorkerTimeout
How long should a worker maximally need to process all of his events in the queue.
Definition: Environment.h:411

◆ Instance()

Environment & Instance ( )
static

Static method to get a reference to the Environment instance.

Returns
A reference to an instance of this class.

Definition at line 28 of file Environment.cc.

29{
30 static Environment instance;
31 return instance;
32}
This class stores all environment information required to run the framework, such as module or data f...
Definition: Environment.h:32

◆ isMC()

bool isMC ( ) const

Do we have generated, not real data?

Definition at line 54 of file Environment.cc.

55{
57 if (fileMetaData) return fileMetaData->isMC();
58 return true;
59}
@ c_Persistent
Object is available during entire execution time.
Definition: DataStore.h:60
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96

◆ isZMQDAQFirstEvent()

bool isZMQDAQFirstEvent ( int  exp,
int  run 
)
inline

checks the exp/run is DAQ first event

Definition at line 369 of file Environment.h.

370 {
371 if (exp == m_zmqDAQFirstEventExp && run == m_zmqDAQFirstEventRun)
372 return true;
373 else
374 return false;
375 }

◆ printJobInformation()

void printJobInformation ( ) const

Print information on input/output files in current steering file, used by –dry-run.

Function only relies on information available during module construction, but requires that Framework::process() has been called to set a path.

Definition at line 180 of file Environment.cc.

181{
182 cout << m_jobInfoOutput;
183}
std::string m_jobInfoOutput
Output for printJobInformation(), generated by setJobInformation().
Definition: Environment.h:394

◆ setDryRun()

void setDryRun ( bool  dryRun)
inline

Read steering file, but do not start any actually start any event processing.

Prints information on input/output files and number of events that that would be used during normal execution.

Definition at line 189 of file Environment.h.

189{ m_dryRun = dryRun; }

◆ setEntrySequencesOverride()

void setEntrySequencesOverride ( const std::vector< std::string > &  sequences)
inline

Override the number sequences (e.g.

23:42,101) defining the entries which are processed for each filename given in inputFilesOverride

Definition at line 69 of file Environment.h.

69{ m_entrySequencesOverride = sequences; }

◆ setExternalsPath()

void setExternalsPath ( const std::string &  externalsPath)
inline

Sets the path which points to the externals directory of the framework.

Parameters
externalsPathPath in which the externals of the framework are located.

Definition at line 53 of file Environment.h.

53{ m_externalsPath = externalsPath; };

◆ setInputFilesOverride()

void setInputFilesOverride ( const std::vector< std::string > &  names)
inline

Override input file names for modules.

Definition at line 100 of file Environment.h.

100{ m_inputFilesOverride = names; }

◆ setJobInformation()

void setJobInformation ( const std::shared_ptr< Path > &  path)

Set info from path executed by the framework.

Definition at line 160 of file Environment.cc.

161{
162 const std::list<ModulePtr>& modules = path->buildModulePathList(true);
163
164 for (const ModulePtr& m : modules) {
165 if (m->hasProperties(Module::c_Input)) {
166 std::vector<std::string> inputFiles = m->getFileNames(false);
167 for (const string& file : inputFiles) {
168 m_jobInfoOutput += "INPUT FILE: " + file + "\n";
169 }
170 }
171 if (m->hasProperties(Module::c_Output)) {
172 std::vector<std::string> outputFiles = m->getFileNames(true);
173 for (const string& file : outputFiles) {
174 m_jobInfoOutput += "OUTPUT FILE: " + file + "\n";
175 }
176 }
177 }
178}
@ c_Input
This module is an input module (reads data).
Definition: Module.h:78
@ c_Output
This module is an output module (writes data).
Definition: Module.h:79
std::shared_ptr< Module > ModulePtr
Defines a pointer to a module object as a boost shared pointer.
Definition: Module.h:43

◆ setLogLevelOverride()

void setLogLevelOverride ( int  level)
inline

Override global log level if != LogConfig::c_Default.

Definition at line 223 of file Environment.h.

223{ m_logLevelOverride = level; }

◆ setNoStats()

void setNoStats ( bool  noStats)
inline

Disable collection of statistics during event processing.

Definition at line 184 of file Environment.h.

184{ m_noStats = noStats; }

◆ setNumberEventsOverride()

void setNumberEventsOverride ( unsigned int  nevents)
inline

Override the number of events in run 1 for EventInfoSetter module.

Definition at line 63 of file Environment.h.

63{ m_numberEventsOverride = nevents; }

◆ setNumberOfMCEvents()

void setNumberOfMCEvents ( unsigned int  n)
inline

Set number of generated events (for EventInfoSetter).

Definition at line 97 of file Environment.h.

97{ m_mcEvents = n; }

◆ setNumberProcesses()

void setNumberProcesses ( int  number)
inline

Sets the number of processes which should be used for the parallel processing.

If the value is set to 0, no parallel processing will be used in the event loop.

Parameters
numberThe number of processes used for the parallel processing.

Definition at line 140 of file Environment.h.

140{ m_numberProcesses = number; }

◆ setNumberProcessesOverride()

void setNumberProcessesOverride ( int  nproc)
inline

Override number of processes to run in parallel.

Only values >= 0 will change the result of getNumberProcesses().

Definition at line 132 of file Environment.h.

132{ m_numberProcessesOverride = nproc; }

◆ setOutputFileOverride()

void setOutputFileOverride ( const std::string &  name)
inline

Override output file name for modules.

Definition at line 112 of file Environment.h.

112{ m_outputFileOverride = name; }

◆ setPicklePath()

void setPicklePath ( const std::string &  path)
inline

Sets the path to the file where the pickled path is stored.

Parameters
pathThe path to the file where the pickled path is stored.

Definition at line 158 of file Environment.h.

158{ m_picklePath = path; }

◆ setProfileModuleName()

void setProfileModuleName ( const std::string &  name)
inline

Set the name of a module to be profiled.

Definition at line 217 of file Environment.h.

217{ m_profileModuleName = name; }

◆ setRealm()

void setRealm ( LogConfig::ELogRealm  realm)

Set the basf2 execution realm.

Definition at line 61 of file Environment.cc.

62{
63 m_realm = realm;
64 B2INFO("Execution realm: " << LogConfig::logRealmToString(realm));
65}
static const char * logRealmToString(ELogRealm realm)
Converts a log realm type to a string.
Definition: LogConfig.cc:49

◆ setRunExperimentOverride()

void setRunExperimentOverride ( int  run,
int  experiment 
)
inline

Override run and experiment for EventInfoSetter.

Definition at line 78 of file Environment.h.

78{ m_run = run; m_experiment = experiment; }

◆ setSecondaryInputFilesOverride()

void setSecondaryInputFilesOverride ( const std::vector< std::string > &  names)
inline

Override secondary input file names for modules.

Definition at line 106 of file Environment.h.

◆ setSkipEventsOverride()

void setSkipEventsOverride ( unsigned int  skipEvents)
inline

Set skipNEvents override.

Definition at line 86 of file Environment.h.

86{ m_skipNEvents = skipEvents; }

◆ setSteering()

void setSteering ( const std::string &  steering)
inline

Sets the steering file content.

Definition at line 170 of file Environment.h.

170{ m_steering = steering; };

◆ setStreamingObjects()

void setStreamingObjects ( const std::vector< std::string > &  strobjs)
inline

Set list of streaming objects.

Definition at line 229 of file Environment.h.

229{ m_streamingObjects = strobjs; }

◆ setUseZMQ()

void setUseZMQ ( bool  useZMQ)
inline

Set the flag if ZMQ should be used instead of the RingBuffer multiprocessing implementation.

Definition at line 242 of file Environment.h.

243 {
244 m_useZMQ = useZMQ;
245 }

◆ setVisualizeDataFlow()

void setVisualizeDataFlow ( bool  on)
inline

Wether to generate DOT files with data store inputs/outputs of each module.

Definition at line 178 of file Environment.h.

178{ m_visualizeDataFlow = on; }

◆ setWriteSimSteps()

void setWriteSimSteps ( const bool  writeSimSteps)
inline

Set the flag for writing the simulation steps into an output csv file.

This is useful for simulating events for the Belle II Virtual Reality application.

Definition at line 205 of file Environment.h.

205{ m_writeSimSteps = writeSimSteps; }

◆ setZMQDAQEnvironment()

void setZMQDAQEnvironment ( bool  zmqDAQ)
inline

Set DAQ environment.

Definition at line 339 of file Environment.h.

340 {
341 m_zmqDAQEnvironment = zmqDAQ;
342 }

◆ setZMQDAQFirstEventExp()

void setZMQDAQFirstEventExp ( int  exp)
inline

set the exp number for DAQ first event

Definition at line 351 of file Environment.h.

352 {
354 }

◆ setZMQDAQFirstEventRun()

void setZMQDAQFirstEventRun ( int  run)
inline

set run number for DAQ first event

Definition at line 363 of file Environment.h.

364 {
366 }

◆ setZMQEventBufferSize()

void setZMQEventBufferSize ( unsigned int  zmqEventBufferSize)
inline

Number of events to keep in flight for every worker.

Definition at line 278 of file Environment.h.

279 {
280 m_zmqEventBufferSize = zmqEventBufferSize;
281 }

◆ setZMQFailOnFailedWorkers()

void setZMQFailOnFailedWorkers ( bool  zmqFailOnFailedWorkers)
inline

If a worker dies, fail also.

Definition at line 326 of file Environment.h.

327 {
328 m_zmqFailOnFailedWorkers = zmqFailOnFailedWorkers;
329 }

◆ setZMQMaximalWaitingTime()

void setZMQMaximalWaitingTime ( unsigned int  zmqMaximalWaitingTime)
inline

Maximal waiting time of any ZMQ module for any communication in ms.

Definition at line 266 of file Environment.h.

267 {
268 m_zmqMaximalWaitingTime = zmqMaximalWaitingTime;
269 }

◆ setZMQRestartFailedWorkers()

void setZMQRestartFailedWorkers ( bool  zmqRestartFailedWorkers)
inline

If a worker dies, restart it.

Definition at line 314 of file Environment.h.

315 {
316 m_zmqRestartFailedWorkers = zmqRestartFailedWorkers;
317 }

◆ setZMQSocketAddress()

void setZMQSocketAddress ( const std::string &  zmqSocketAddress)
inline

Socket address to use in ZMQ.

Definition at line 254 of file Environment.h.

255 {
256 m_zmqSocketAddress = zmqSocketAddress;
257 }

◆ setZMQUseEventBackup()

void setZMQUseEventBackup ( bool  zmqUseEventBackup)
inline

If a worker dies, store its events in a backup.

Definition at line 302 of file Environment.h.

303 {
304 m_zmqUseEventBackup = zmqUseEventBackup;
305 }

◆ setZMQWorkerTimeout()

void setZMQWorkerTimeout ( unsigned int  zmqWorkerTimeout)
inline

How long should a worker maximally need to process all of his events in the queue. Set to 0 to disable the check.

Definition at line 290 of file Environment.h.

291 {
292 m_zmqWorkerTimeout = zmqWorkerTimeout;
293 }

Member Data Documentation

◆ m_dryRun

bool m_dryRun
private

Read steering file, but do not start any actually start any event processing.

Prints information on input/output files that that would be used during normal execution.

Definition at line 393 of file Environment.h.

◆ m_entrySequencesOverride

std::vector<std::string> m_entrySequencesOverride
private

A number sequence (e.g.

23:42,101) defining the entries which are processed for each input file in m_inputFilesOverride.

Definition at line 386 of file Environment.h.

◆ m_experiment

int m_experiment
private

override experiment for EventInfoSetter.

Definition at line 400 of file Environment.h.

◆ m_externalsPath

std::string m_externalsPath
private

The path in which the externals are located.

Definition at line 379 of file Environment.h.

◆ m_inputFilesOverride

std::vector<std::string> m_inputFilesOverride
private

Override input file names for input modules.

Definition at line 383 of file Environment.h.

◆ m_jobInfoOutput

std::string m_jobInfoOutput
private

Output for printJobInformation(), generated by setJobInformation().

Definition at line 394 of file Environment.h.

◆ m_logLevelOverride

int m_logLevelOverride
private

Override global log level if != LogConfig::c_Default.

Definition at line 390 of file Environment.h.

◆ m_mcEvents

unsigned int m_mcEvents
private

counter for number of generated events.

Definition at line 398 of file Environment.h.

◆ m_noStats

bool m_noStats
private

Disable collection of statistics during event processing.

Useful for very high-rate applications.

Definition at line 392 of file Environment.h.

◆ m_numberEventsOverride

unsigned int m_numberEventsOverride
private

Override number of events in the first run.

Definition at line 382 of file Environment.h.

◆ m_numberProcesses

int m_numberProcesses
private

The number of worker processes that should be used for the parallel processing.

Definition at line 380 of file Environment.h.

◆ m_numberProcessesOverride

int m_numberProcessesOverride
private

Override m_numberProcesses if >= 0.

Definition at line 389 of file Environment.h.

◆ m_outputFileOverride

std::string m_outputFileOverride
private

Override name of output file for output module.

Definition at line 387 of file Environment.h.

◆ m_outputFileOverrideModule

std::string m_outputFileOverrideModule {""}
private

Name of the module which consumed the output file Override if any was given.

Definition at line 388 of file Environment.h.

◆ m_picklePath

std::string m_picklePath
private

Path to the file where the pickled path is stored.

Definition at line 396 of file Environment.h.

◆ m_profileModuleName

std::string m_profileModuleName
private

Name of the module which should be profiled, empty if no profiling requested.

Definition at line 395 of file Environment.h.

◆ m_realm

The realm in which basf2 is executed.

Definition at line 402 of file Environment.h.

◆ m_run

int m_run
private

override run for EventInfoSetter.

Definition at line 399 of file Environment.h.

◆ m_secondaryInputFilesOverride

std::vector<std::string> m_secondaryInputFilesOverride
private

Override secondary input file names for input modules.

Definition at line 384 of file Environment.h.

◆ m_skipNEvents

unsigned int m_skipNEvents
private

override skipNEvents for EventInfoSetter/RootInput.

Definition at line 401 of file Environment.h.

◆ m_steering

std::string m_steering
private

The content of the steering file.

Definition at line 381 of file Environment.h.

◆ m_streamingObjects

std::vector<std::string> m_streamingObjects
private

objects to be streamed in Tx module (all if empty)

Definition at line 397 of file Environment.h.

◆ m_useZMQ

bool m_useZMQ = false
private

Set to true to use ZMQ instead of RingBuffer.

Definition at line 406 of file Environment.h.

◆ m_visualizeDataFlow

bool m_visualizeDataFlow
private

Wether to generate DOT files with data store inputs/outputs of each module.

Definition at line 391 of file Environment.h.

◆ m_writeSimSteps

bool m_writeSimSteps
private

bool for writing out the simulation steps into a csv file.

Definition at line 403 of file Environment.h.

◆ m_zmqDAQEnvironment

bool m_zmqDAQEnvironment = false
private

True in DAQ environment.

Definition at line 416 of file Environment.h.

◆ m_zmqDAQFirstEventExp

int m_zmqDAQFirstEventExp = 42
private

Exp no.

for the special first event

Definition at line 417 of file Environment.h.

◆ m_zmqDAQFirstEventRun

int m_zmqDAQFirstEventRun = 8
private

Exp no.

for the special first event

Definition at line 418 of file Environment.h.

◆ m_zmqEventBufferSize

unsigned int m_zmqEventBufferSize = 1
private

Number of events to keep in flight for every worker.

Definition at line 410 of file Environment.h.

◆ m_zmqFailOnFailedWorkers

bool m_zmqFailOnFailedWorkers = true
private

If a worker dies, fail also.

Will not be used if restartFailedWorkers is true.

Definition at line 415 of file Environment.h.

◆ m_zmqMaximalWaitingTime

unsigned int m_zmqMaximalWaitingTime
private
Initial value:
= (3600 * 24) *
1000

Maximal waiting time of any ZMQ module for any communication in ms.

Definition at line 408 of file Environment.h.

◆ m_zmqRestartFailedWorkers

bool m_zmqRestartFailedWorkers = true
private

If a worker dies, restart it.

Definition at line 414 of file Environment.h.

◆ m_zmqSocketAddress

std::string m_zmqSocketAddress = ""
private

Socket address to use in ZMQ.

If not set, uses a random IPC connection.

Definition at line 407 of file Environment.h.

◆ m_zmqUseEventBackup

bool m_zmqUseEventBackup = true
private

If a worker dies, store its events in a backup.

Definition at line 413 of file Environment.h.

◆ m_zmqWorkerTimeout

unsigned int m_zmqWorkerTimeout
private
Initial value:
=
0

How long should a worker maximally need to process all of his events in the queue.

Set to 0 to disable the check.

Definition at line 411 of file Environment.h.


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