Belle II Software light-2406-ragdoll
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?
 
void setRunType (Const::ERunType runType)
 Set the run type (beam or cosmic).
 
Const::ERunType getRunType () const
 Get the run type (beam or cosmic)
 
bool isCosmicRun () const
 Is the run for cosmics data?
 
bool isBeamRun () const
 Is the run for beam 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.
 
Const::ERunType m_runType = Const::c_Beam
 Flag which tells if the run is beam (default: c_Beam) or cosmic (c_Cosmic).
 
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 33 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_runType(Const::c_Beam),
102 m_skipNEvents(0),
103 m_writeSimSteps(false)
104{
105 // Check for environment variables set by setuprel
106 const char* envarReleaseDir = getenv("BELLE2_RELEASE_DIR");
107 const char* envarLocalDir = getenv("BELLE2_LOCAL_DIR");
108 const char* envarAnalysisDir = getenv("BELLE2_ANALYSIS_DIR");
109 if (!envarReleaseDir and !envarLocalDir) {
110 B2FATAL("The basf2 environment is not set up. Please execute the 'setuprel' script first.");
111 }
112
113 //also set when just sourcing setup_belle2.sh (which is why we also check for local/release dir)
114 const char* envarSubDir = getenv("BELLE2_SUBDIR");
115 if (!envarSubDir) {
116 B2FATAL("The environment variable BELLE2_SUBDIR is not set. Please execute the 'setuprel' script first.");
117 }
118
119 const char* envarExtDir = getenv("BELLE2_EXTERNALS_DIR");
120 if (!envarExtDir) {
121 B2FATAL("The environment variable BELLE2_EXTERNALS_DIR is not set. Please execute the 'setuprel' script first.");
122 }
123
124 // add module directories for current build options, starting with the working directory on program startup
125 std::string added_dirs = fs::current_path().string();
127
128 if (envarAnalysisDir) {
129 const string analysisModules = (fs::path(envarAnalysisDir) / "modules" / envarSubDir).string();
131 added_dirs += " " + analysisModules;
132 }
133
134 if (envarLocalDir) {
135 const string localModules = (fs::path(envarLocalDir) / "modules" / envarSubDir).string();
137 added_dirs += " " + localModules;
138 }
139
140 if (envarReleaseDir) {
141 const string centralModules = (fs::path(envarReleaseDir) / "modules" / envarSubDir).string();
143 added_dirs += " " + centralModules;
144 }
145
146 if (ModuleManager::Instance().getAvailableModules().empty()) {
147 B2ERROR("No modules found! Did you forget to run 'scons'? Module paths added: " << added_dirs);
148 }
149
150 //set path to external software
151 setExternalsPath(envarExtDir);
152}
std::string m_steering
The content of the steering file.
Definition: Environment.h:393
std::vector< std::string > m_entrySequencesOverride
A number sequence (e.g.
Definition: Environment.h:398
int m_numberProcesses
The number of worker processes that should be used for the parallel processing.
Definition: Environment.h:392
bool m_noStats
Disable collection of statistics during event processing.
Definition: Environment.h:404
Const::ERunType m_runType
Flag which tells if the run is beam (default: c_Beam) or cosmic (c_Cosmic).
Definition: Environment.h:413
std::string m_outputFileOverride
Override name of output file for output module.
Definition: Environment.h:399
unsigned int m_mcEvents
counter for number of generated events.
Definition: Environment.h:410
std::vector< std::string > m_inputFilesOverride
Override input file names for input modules.
Definition: Environment.h:395
bool m_writeSimSteps
bool for writing out the simulation steps into a csv file.
Definition: Environment.h:416
void setExternalsPath(const std::string &externalsPath)
Sets the path which points to the externals directory of the framework.
Definition: Environment.h:54
unsigned int m_numberEventsOverride
Override number of events in the first run.
Definition: Environment.h:394
bool m_visualizeDataFlow
Wether to generate DOT files with data store inputs/outputs of each module.
Definition: Environment.h:403
int m_experiment
override experiment for EventInfoSetter.
Definition: Environment.h:412
int m_logLevelOverride
Override global log level if != LogConfig::c_Default.
Definition: Environment.h:402
int m_numberProcessesOverride
Override m_numberProcesses if >= 0.
Definition: Environment.h:401
std::vector< std::string > m_secondaryInputFilesOverride
Override secondary input file names for input modules.
Definition: Environment.h:396
bool m_dryRun
Read steering file, but do not start any actually start any event processing.
Definition: Environment.h:405
unsigned int m_skipNEvents
override skipNEvents for EventInfoSetter/RootInput.
Definition: Environment.h:414
int m_run
override run for EventInfoSetter.
Definition: Environment.h:411
@ 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:400

◆ 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 203 of file Environment.h.

203{ 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 73 of file Environment.h.

◆ getExperimentOverride()

int getExperimentOverride ( ) const
inline

Get experiment override, or -1 if unset.

Definition at line 84 of file Environment.h.

84{ 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 61 of file Environment.h.

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

◆ getInputFilesOverride()

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

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

Definition at line 115 of file Environment.h.

115{ return m_inputFilesOverride; }

◆ getLogLevelOverride()

int getLogLevelOverride ( ) const
inline

Get log level override.

Definition at line 238 of file Environment.h.

238{ 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 199 of file Environment.h.

199{ 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 67 of file Environment.h.

67{ 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:67
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 106 of file Environment.h.

106{ 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 157 of file Environment.h.

158 {
161 else
162 return m_numberProcesses;
163 }

◆ getOutputFileOverride()

const std::string & getOutputFileOverride ( ) const
inline

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

Definition at line 127 of file Environment.h.

127{ 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 138 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 177 of file Environment.h.

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

◆ getProfileModuleName()

std::string getProfileModuleName ( ) const
inline

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

Definition at line 232 of file Environment.h.

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

◆ getRealm()

LogConfig::ELogRealm getRealm ( ) const
inline

Get the basf2 execution realm.

Definition at line 211 of file Environment.h.

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

◆ getRunOverride()

int getRunOverride ( ) const
inline

Get run override, or -1 if unset.

Definition at line 82 of file Environment.h.

82{ return m_run; }

◆ getRunType()

Const::ERunType getRunType ( ) const
inline

Get the run type (beam or cosmic)

Definition at line 97 of file Environment.h.

97{ return m_runType; }

◆ 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 121 of file Environment.h.

◆ getSkipEventsOverride()

unsigned int getSkipEventsOverride ( ) const
inline

Get skipNEvents override, or 0 if unset.

Definition at line 89 of file Environment.h.

89{ return m_skipNEvents; }

◆ getSteering()

const std::string & getSteering ( ) const
inline

Returns the steering file content.

Definition at line 187 of file Environment.h.

187{ return m_steering; };

◆ getStreamingObjects()

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

Get list of streaming objects.

Definition at line 244 of file Environment.h.

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

◆ getUseZMQ()

bool getUseZMQ ( ) const
inline

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

Definition at line 248 of file Environment.h.

249 {
250 return m_useZMQ;
251 }
bool m_useZMQ
Set to true to use ZMQ instead of RingBuffer.
Definition: Environment.h:419

◆ getVisualizeDataFlow()

bool getVisualizeDataFlow ( ) const
inline

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

Definition at line 193 of file Environment.h.

193{ return m_visualizeDataFlow; }

◆ getWriteSimSteps()

bool getWriteSimSteps ( ) const
inline

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

Definition at line 219 of file Environment.h.

219{ return m_writeSimSteps; }

◆ getZMQDAQEnvironment()

bool getZMQDAQEnvironment ( ) const
inline

obtain current environment (DAQ or not)

Definition at line 345 of file Environment.h.

346 {
347 return m_zmqDAQEnvironment;
348 }
bool m_zmqDAQEnvironment
True in DAQ environment.
Definition: Environment.h:429

◆ getZMQDAQFirstEventExp()

int getZMQDAQFirstEventExp ( ) const
inline

get the exp number for DAQ first event

Definition at line 357 of file Environment.h.

358 {
360 }
int m_zmqDAQFirstEventExp
Exp no.
Definition: Environment.h:430

◆ getZMQDAQFirstEventRun()

int getZMQDAQFirstEventRun ( ) const
inline

get run number for DAQ first event

Definition at line 369 of file Environment.h.

370 {
372 }
int m_zmqDAQFirstEventRun
Exp no.
Definition: Environment.h:431

◆ getZMQEventBufferSize()

unsigned int getZMQEventBufferSize ( ) const
inline

Number of events to keep in flight for every worker.

Definition at line 284 of file Environment.h.

285 {
287 }
unsigned int m_zmqEventBufferSize
Number of events to keep in flight for every worker.
Definition: Environment.h:423

◆ getZMQFailOnFailedWorkers()

bool getZMQFailOnFailedWorkers ( ) const
inline

If a worker dies, fail also.

Definition at line 332 of file Environment.h.

333 {
335 }
bool m_zmqFailOnFailedWorkers
If a worker dies, fail also.
Definition: Environment.h:428

◆ getZMQMaximalWaitingTime()

unsigned int getZMQMaximalWaitingTime ( ) const
inline

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

Definition at line 272 of file Environment.h.

273 {
275 }
unsigned int m_zmqMaximalWaitingTime
Maximal waiting time of any ZMQ module for any communication in ms.
Definition: Environment.h:421

◆ getZMQRestartFailedWorkers()

bool getZMQRestartFailedWorkers ( ) const
inline

If a worker dies, restart it.

Definition at line 320 of file Environment.h.

321 {
323 }
bool m_zmqRestartFailedWorkers
If a worker dies, restart it.
Definition: Environment.h:427

◆ getZMQSocketAddress()

const std::string & getZMQSocketAddress ( ) const
inline

Socket address to use in ZMQ.

Definition at line 260 of file Environment.h.

261 {
262 return m_zmqSocketAddress;
263 }
std::string m_zmqSocketAddress
Socket address to use in ZMQ.
Definition: Environment.h:420

◆ getZMQUseEventBackup()

bool getZMQUseEventBackup ( ) const
inline

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

Definition at line 308 of file Environment.h.

309 {
310 return m_zmqUseEventBackup;
311 }
bool m_zmqUseEventBackup
If a worker dies, store its events in a backup.
Definition: Environment.h:426

◆ 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 296 of file Environment.h.

297 {
298 return m_zmqWorkerTimeout;
299 }
unsigned int m_zmqWorkerTimeout
How long should a worker maximally need to process all of his events in the queue.
Definition: Environment.h:424

◆ 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:33

◆ isBeamRun()

bool isBeamRun ( ) const
inline

Is the run for beam data?

Definition at line 103 of file Environment.h.

103{ return (m_runType == Const::c_Beam); }

◆ isCosmicRun()

bool isCosmicRun ( ) const
inline

Is the run for cosmics data?

Definition at line 100 of file Environment.h.

100{ return (m_runType == Const::c_Cosmic); }

◆ 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 381 of file Environment.h.

382 {
383 if (exp == m_zmqDAQFirstEventExp && run == m_zmqDAQFirstEventRun)
384 return true;
385 else
386 return false;
387 }

◆ 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 181 of file Environment.cc.

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

◆ 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 201 of file Environment.h.

201{ 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 70 of file Environment.h.

70{ 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 54 of file Environment.h.

54{ m_externalsPath = externalsPath; };

◆ setInputFilesOverride()

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

Override input file names for modules.

Definition at line 112 of file Environment.h.

112{ m_inputFilesOverride = names; }

◆ setJobInformation()

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

Set info from path executed by the framework.

Definition at line 161 of file Environment.cc.

162{
163 const std::list<ModulePtr>& modules = path->buildModulePathList(true);
164
165 for (const ModulePtr& m : modules) {
166 if (m->hasProperties(Module::c_Input)) {
167 std::vector<std::string> inputFiles = m->getFileNames(false);
168 for (const string& file : inputFiles) {
169 m_jobInfoOutput += "INPUT FILE: " + file + "\n";
170 }
171 }
172 if (m->hasProperties(Module::c_Output)) {
173 std::vector<std::string> outputFiles = m->getFileNames(true);
174 for (const string& file : outputFiles) {
175 m_jobInfoOutput += "OUTPUT FILE: " + file + "\n";
176 }
177 }
178 }
179}
@ 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 235 of file Environment.h.

235{ m_logLevelOverride = level; }

◆ setNoStats()

void setNoStats ( bool  noStats)
inline

Disable collection of statistics during event processing.

Definition at line 196 of file Environment.h.

196{ m_noStats = noStats; }

◆ setNumberEventsOverride()

void setNumberEventsOverride ( unsigned int  nevents)
inline

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

Definition at line 64 of file Environment.h.

64{ m_numberEventsOverride = nevents; }

◆ setNumberOfMCEvents()

void setNumberOfMCEvents ( unsigned int  n)
inline

Set number of generated events (for EventInfoSetter).

Definition at line 109 of file Environment.h.

109{ 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 152 of file Environment.h.

152{ 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 144 of file Environment.h.

144{ m_numberProcessesOverride = nproc; }

◆ setOutputFileOverride()

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

Override output file name for modules.

Definition at line 124 of file Environment.h.

124{ 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 170 of file Environment.h.

170{ m_picklePath = path; }

◆ setProfileModuleName()

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

Set the name of a module to be profiled.

Definition at line 229 of file Environment.h.

229{ 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 79 of file Environment.h.

79{ m_run = run; m_experiment = experiment; }

◆ setRunType()

void setRunType ( Const::ERunType  runType)
inline

Set the run type (beam or cosmic).

Definition at line 95 of file Environment.h.

95{ m_runType = runType; }

◆ setSecondaryInputFilesOverride()

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

Override secondary input file names for modules.

Definition at line 118 of file Environment.h.

◆ setSkipEventsOverride()

void setSkipEventsOverride ( unsigned int  skipEvents)
inline

Set skipNEvents override.

Definition at line 87 of file Environment.h.

87{ m_skipNEvents = skipEvents; }

◆ setSteering()

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

Sets the steering file content.

Definition at line 182 of file Environment.h.

182{ m_steering = steering; };

◆ setStreamingObjects()

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

Set list of streaming objects.

Definition at line 241 of file Environment.h.

241{ 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 254 of file Environment.h.

255 {
256 m_useZMQ = useZMQ;
257 }

◆ setVisualizeDataFlow()

void setVisualizeDataFlow ( bool  on)
inline

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

Definition at line 190 of file Environment.h.

190{ 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 217 of file Environment.h.

217{ m_writeSimSteps = writeSimSteps; }

◆ setZMQDAQEnvironment()

void setZMQDAQEnvironment ( bool  zmqDAQ)
inline

Set DAQ environment.

Definition at line 351 of file Environment.h.

352 {
353 m_zmqDAQEnvironment = zmqDAQ;
354 }

◆ setZMQDAQFirstEventExp()

void setZMQDAQFirstEventExp ( int  exp)
inline

set the exp number for DAQ first event

Definition at line 363 of file Environment.h.

364 {
366 }

◆ setZMQDAQFirstEventRun()

void setZMQDAQFirstEventRun ( int  run)
inline

set run number for DAQ first event

Definition at line 375 of file Environment.h.

376 {
378 }

◆ setZMQEventBufferSize()

void setZMQEventBufferSize ( unsigned int  zmqEventBufferSize)
inline

Number of events to keep in flight for every worker.

Definition at line 290 of file Environment.h.

291 {
292 m_zmqEventBufferSize = zmqEventBufferSize;
293 }

◆ setZMQFailOnFailedWorkers()

void setZMQFailOnFailedWorkers ( bool  zmqFailOnFailedWorkers)
inline

If a worker dies, fail also.

Definition at line 338 of file Environment.h.

339 {
340 m_zmqFailOnFailedWorkers = zmqFailOnFailedWorkers;
341 }

◆ setZMQMaximalWaitingTime()

void setZMQMaximalWaitingTime ( unsigned int  zmqMaximalWaitingTime)
inline

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

Definition at line 278 of file Environment.h.

279 {
280 m_zmqMaximalWaitingTime = zmqMaximalWaitingTime;
281 }

◆ setZMQRestartFailedWorkers()

void setZMQRestartFailedWorkers ( bool  zmqRestartFailedWorkers)
inline

If a worker dies, restart it.

Definition at line 326 of file Environment.h.

327 {
328 m_zmqRestartFailedWorkers = zmqRestartFailedWorkers;
329 }

◆ setZMQSocketAddress()

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

Socket address to use in ZMQ.

Definition at line 266 of file Environment.h.

267 {
268 m_zmqSocketAddress = zmqSocketAddress;
269 }

◆ setZMQUseEventBackup()

void setZMQUseEventBackup ( bool  zmqUseEventBackup)
inline

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

Definition at line 314 of file Environment.h.

315 {
316 m_zmqUseEventBackup = zmqUseEventBackup;
317 }

◆ 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 302 of file Environment.h.

303 {
304 m_zmqWorkerTimeout = zmqWorkerTimeout;
305 }

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 405 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 398 of file Environment.h.

◆ m_experiment

int m_experiment
private

override experiment for EventInfoSetter.

Definition at line 412 of file Environment.h.

◆ m_externalsPath

std::string m_externalsPath
private

The path in which the externals are located.

Definition at line 391 of file Environment.h.

◆ m_inputFilesOverride

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

Override input file names for input modules.

Definition at line 395 of file Environment.h.

◆ m_jobInfoOutput

std::string m_jobInfoOutput
private

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

Definition at line 406 of file Environment.h.

◆ m_logLevelOverride

int m_logLevelOverride
private

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

Definition at line 402 of file Environment.h.

◆ m_mcEvents

unsigned int m_mcEvents
private

counter for number of generated events.

Definition at line 410 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 404 of file Environment.h.

◆ m_numberEventsOverride

unsigned int m_numberEventsOverride
private

Override number of events in the first run.

Definition at line 394 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 392 of file Environment.h.

◆ m_numberProcessesOverride

int m_numberProcessesOverride
private

Override m_numberProcesses if >= 0.

Definition at line 401 of file Environment.h.

◆ m_outputFileOverride

std::string m_outputFileOverride
private

Override name of output file for output module.

Definition at line 399 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 400 of file Environment.h.

◆ m_picklePath

std::string m_picklePath
private

Path to the file where the pickled path is stored.

Definition at line 408 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 407 of file Environment.h.

◆ m_realm

The realm in which basf2 is executed.

Definition at line 415 of file Environment.h.

◆ m_run

int m_run
private

override run for EventInfoSetter.

Definition at line 411 of file Environment.h.

◆ m_runType

Const::ERunType m_runType = Const::c_Beam
private

Flag which tells if the run is beam (default: c_Beam) or cosmic (c_Cosmic).

Definition at line 413 of file Environment.h.

◆ m_secondaryInputFilesOverride

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

Override secondary input file names for input modules.

Definition at line 396 of file Environment.h.

◆ m_skipNEvents

unsigned int m_skipNEvents
private

override skipNEvents for EventInfoSetter/RootInput.

Definition at line 414 of file Environment.h.

◆ m_steering

std::string m_steering
private

The content of the steering file.

Definition at line 393 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 409 of file Environment.h.

◆ m_useZMQ

bool m_useZMQ = false
private

Set to true to use ZMQ instead of RingBuffer.

Definition at line 419 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 403 of file Environment.h.

◆ m_writeSimSteps

bool m_writeSimSteps
private

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

Definition at line 416 of file Environment.h.

◆ m_zmqDAQEnvironment

bool m_zmqDAQEnvironment = false
private

True in DAQ environment.

Definition at line 429 of file Environment.h.

◆ m_zmqDAQFirstEventExp

int m_zmqDAQFirstEventExp = 42
private

Exp no.

for the special first event

Definition at line 430 of file Environment.h.

◆ m_zmqDAQFirstEventRun

int m_zmqDAQFirstEventRun = 8
private

Exp no.

for the special first event

Definition at line 431 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 423 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 428 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 421 of file Environment.h.

◆ m_zmqRestartFailedWorkers

bool m_zmqRestartFailedWorkers = true
private

If a worker dies, restart it.

Definition at line 427 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 420 of file Environment.h.

◆ m_zmqUseEventBackup

bool m_zmqUseEventBackup = true
private

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

Definition at line 426 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 424 of file Environment.h.


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