Belle II Software light-2607-kasei
Framework Class Reference

This class combines all subsystems of the framework, and exports the main interface to Python. More...

#include <Framework.h>

Public Member Functions

 Framework ()
 Constructor.
 
virtual ~Framework ()
 Destructor.
 

Static Public Member Functions

static void addModuleSearchPath (const std::string &path)
 Adds a new filepath to the list of filepaths which are searched for modules.
 
static void setExternalsPath (const std::string &path)
 Sets the path in which the externals of the framework are located.
 
static ModulePtr registerModule (const std::string &moduleName)
 Registers a new module to the framework and returns a shared pointer.
 
static ModulePtr registerModule (const std::string &moduleName, const std::string &sharedLibPath)
 Registers a new module to the framework and returns a shared pointer.
 
static void process (PathPtr startPath, long maxEvent=0)
 Processes up to maxEvent events by starting with the first module in the specified path.
 
static void setNumberProcesses (int numProcesses)
 Function to set number of worker processes for parallel processing.
 
static int getNumberProcesses ()
 Function to get number of worker processes for parallel processing.
 
static void setPicklePath (const std::string &path)
 Function to set the path to the file where the pickled path is stored.
 
static std::string getPicklePath ()
 Function to get the path to the file where the pickled path is stored.
 
static void setStreamingObjects (const boost::python::list &streamingObjects)
 Function to set streaming objects for Tx module.
 
static void setRealm (const std::string &realm)
 Function to set the execution realm.
 
static void setRunType (const Const::ERunType runType)
 Function to set the run type (beam or cosmic)
 
static void setCosmicRun ()
 Function to set that the script is running on cosmics data (by default it runs on beam data)
 
static void setBeamRun ()
 Function to set that the script is running on beam data (by default it runs on beam data, no need to use it if the run type has not been changed before).
 
static void writeSimulationSteps ()
 Function for writing the simulation steps of each event into csv files.
 
static std::string findFile (const std::string &filename, const std::string &type, bool ignore_errors=false)
 Find a file.
 
static boost::python::list getModuleSearchPathsPython ()
 Returns a list of all module search paths known to the framework.
 
static boost::python::dict getAvailableModulesPython ()
 Returns a dictionary containing the found modules and the filenames of the shared libraries in which they can be found.
 
static boost::python::list getRegisteredModulesPython ()
 Returns a list of all registered modules.
 
static void exposePythonAPI ()
 Exposes methods of the Framework class to Python.
 

Detailed Description

This class combines all subsystems of the framework, and exports the main interface to Python.

Definition at line 28 of file Framework.h.

Constructor & Destructor Documentation

◆ Framework()

Framework ( )

Constructor.

Definition at line 39 of file Framework.cc.

40{
43
46 }
48}
static bool s_DoCleanup
Global flag to to decide if we can do normal cleanup.
Definition DataStore.h:100
static Environment & Instance()
Static method to get a reference to the Environment instance.
void enableErrorSummary(bool on)
enable/disable error/warning summary after successful execution and B2FATAL.
Definition LogSystem.h:190
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
Definition LogSystem.cc:28
static bool isInitialized()
Truth that the random number generator has been initialized.
static void initialize()
Initialize the random number generator with a unique random seed;.

◆ ~Framework()

~Framework ( )
virtual

Destructor.

Definition at line 51 of file Framework.cc.

52{
53 //empty module manager of modules
54 //since modules may contain shared pointers of Path objects created in Python,
55 //these shared pointers have special cleanup hooks that can cause crashes if run
56 //after Py_Finalize(). The framework object is cleaned up before, so this is a good place.
59 //Also the database configuration has things to cleanup before Py_Finalize()
61}
static Configuration & getInstance()
Get a reference to the instance which will be used when the Database is initialized.
void reset()
Reset to default values.
static ModuleManager & Instance()
Exception is thrown if the requested module could not be created by the ModuleManager.
void reset()
Delete all created modules.

Member Function Documentation

◆ addModuleSearchPath()

void addModuleSearchPath ( const std::string & path)
static

Adds a new filepath to the list of filepaths which are searched for modules.

If a module is requested by the method registerModule(), all module search paths are scanned for shared libraries or map files which contain the requested module.

Parameters
pathThe module search path which should be added to the list of paths.

Definition at line 64 of file Framework.cc.

65{
67}
void addModuleSearchPath(const std::string &path)
Adds a new filepath to the list of filepaths which are searched for a requested module.

◆ exposePythonAPI()

void exposePythonAPI ( )
static

Exposes methods of the Framework class to Python.

Definition at line 314 of file Framework.cc.

315{
316 PyExc_ModuleNotCreatedError = PyErr_NewExceptionWithDoc("basf2.ModuleNotCreatedError",
317 "This exception is raised when a basf2 module could not be created for any reason",
318 PyExc_RuntimeError, nullptr);
319 scope().attr("ModuleNotCreatedError") = handle<>(borrowed(PyExc_ModuleNotCreatedError));
320 register_exception_translator<ModuleManager::ModuleNotCreatedError>(moduleNotCreatedTranslator);
321 //Overloaded methods
322 ModulePtr(*registerModule1)(const std::string&) = &Framework::registerModule;
323 ModulePtr(*registerModule2)(const std::string&, const std::string&) = &Framework::registerModule;
324
325 //don't show c++ signature in python doc to keep it simple
326 docstring_options options(true, true, false);
327
328 //Expose framework class
329 class_<Framework, std::shared_ptr<Framework>, boost::noncopyable>("Framework", "Initialize and Cleanup functions", no_init);
330 std::shared_ptr<Framework> initguard{new Framework()};
331 scope().attr("__framework") = initguard;
332
333 def("add_module_search_path", &Framework::addModuleSearchPath, R"DOCSTRING(
334Add a directory in which to search for compiled basf2 C++ `Modules <Module>`.
335
336This directory needs to contain the shared libraries containing the compiled
337modules as well as companion files ending in ``.b2modmap`` which contain a list
338of the module names contained in each library.
339
340Note:
341 The newly added path will not override existing modules
342
343Parameters:
344 path (str): directory containing the modules.
345)DOCSTRING", args("path"));
346 def("set_externals_path", &Framework::setExternalsPath, R"DOCSTRING(
347Set the path to the externals to be used.
348
349Warning:
350 This will not change the library and executable paths but will just change
351 the directory where to look for certain data files like the Evtgen particle
352 definition file. Don't use this unless you really know what you are doing.
353
354Parameters:
355 path (str): new top level directory for the externals
356)DOCSTRING", args("path"));
357 def("list_module_search_paths", &Framework::getModuleSearchPathsPython, R"DOCSTRING(
358Return a python list containing all the directories included in the module
359search Path.
360
361See:
362 `add_module_search_path`
363)DOCSTRING");
364 def("list_available_modules", &Framework::getAvailableModulesPython, R"DOCSTRING(
365Return a dictionary containing the names of all known modules
366as keys and the name of the shared library containing these modules as values.
367)DOCSTRING");
368 def("list_registered_modules", &Framework::getRegisteredModulesPython, R"DOCSTRING(
369Return a list with pointers to all previously created module instances by calling `register_module()`
370)DOCSTRING");
371 def("get_pickle_path", &Framework::getPicklePath, R"DOCSTRING(
372Return the filename where the pickled path is or should be stored
373)DOCSTRING");
374 def("set_pickle_path", &Framework::setPicklePath, R"DOCSTRING(
375Set the filename where the pickled path should be stored or retrieved from
376)DOCSTRING", args("path"));
377 def("set_nprocesses", &Framework::setNumberProcesses, R"DOCSTRING(
378Sets number of worker processes for parallel processing.
379
380Can be overridden using the ``-p`` argument to basf2.
381
382Note:
383 Setting this to 1 will have one parallel worker job which is almost always
384 slower than just running without parallel processing but is still provided to
385 allow debugging of parallel execution.
386
387Parameters:
388 nproc (int): number of worker processes. 0 to disable parallel processing.
389)DOCSTRING");
390 def("get_nprocesses", &Framework::getNumberProcesses, R"DOCSTRING(
391Gets number of worker processes for parallel processing. 0 disables parallel processing
392)DOCSTRING");
393 def("set_streamobjs", &Framework::setStreamingObjects, R"DOCSTRING(
394Set the names of all DataStore objects which should be sent between the
395parallel processes. This can be used to improve parallel processing performance
396by removing objects not required.
397)DOCSTRING");
398 {
399 // The register_module function is overloaded with different signatures which makes
400 // the boost docstring very useless so we handcraft a docstring
401 docstring_options param_options(true, false, false);
402 def("_register_module", registerModule1);
403 def("_register_module", registerModule2, R"DOCSTRING(register_module(name, library=None)
404Register a new Module.
405
406This function will try to create a new instance of a module with the given name. If no library is given it will try to find the module by itself from the module search path. Optionally one can specify the name of a shared library containing the module code then this library will be loaded
407
408See:
409 `list_module_search_paths()`, `add_module_search_path()`
410
411Parameters:
412 name (str): Type of the module to create
413 library (str): Optional, name of a shared library containing the module
414
415Returns:
416 An instance of the module if successful.
417
418Raises:
419 will raise a `ModuleNotCreatedError` if there is any problem creating the module.
420)DOCSTRING");
421 def("set_realm", &Framework::setRealm, R"DOCSTRING(
422Set the basf2 execution realm.
423
424The severity of log messages sometimes depends on where basf2 runs. This is controlled by the execution realm.
425
426Usually the realm does not have to be set explicitly. On the HLT or express reco it should be set to 'online' and for official productions to 'production'.
427)DOCSTRING", args("realm"));
428 def("declare_cosmics", &Framework::setCosmicRun, R"DOCSTRING(
429Set that the run is for cosmics data
430)DOCSTRING");
431 def("declare_beam", &Framework::setBeamRun, R"DOCSTRING(
432Set that the run is for beam data
433)DOCSTRING");
434 def("write_simulation_steps", &Framework::writeSimulationSteps, R"DOCSTRING(
435Allow basf2 to write the simulation steps of each event into csv files.
436
437This function should not be used in production jobs because the execution time will significantly increase.
438)DOCSTRING");
439 def("_process", &Framework::process, process_overloads(R"DOCSTRING(process(path, num_events=0)
440Processes up to max_events events by starting with the first module in the specified path.
441
442 This method starts processing events only if there is a module in the path
443 which is capable of specifying the end of the data flow.
444
445 Parameters:
446 path (Path): The processing starts with the first module of this path.
447 max_events (int): The maximum number of events that will be processed.
448 If the number is smaller than 1, all events will be processed (default).
449)DOCSTRING"));
450 ;
451 }
452
453 def("find_file", &Framework::findFile, (arg("filename"), arg("data_type") = "", arg("silent") = false), R"DOC(
454 Try to find a file and return its full path
455
456 If ``data_type`` is empty this function will try to find the file
457
458 1. in ``$BELLE2_LOCAL_DIR``,
459 2. in ``$BELLE2_RELEASE_DIR``
460 3. relative to the current working directory.
461
462 Other known ``data_type`` values are
463
464 ``examples``
465 Example data for examples and tutorials. Will try to find the file
466
467 1. in ``$BELLE2_EXAMPLES_DATA_DIR``
468 2. relative to the current working directory
469
470 ``validation``
471 Data for validation purposes. Will try to find the file in
472
473 1. in ``$BELLE2_VALIDATION_DATA_DIR``
474 2. relative to the current working directory
475
476 ``starterkit``
477 Data for starterkit purposes. Will try to find the file in
478
479 1. in ``$BELLE2_STARTERKIT_DATA_DIR``
480 2. relative to the current working directory
481
482 .. versionadded:: release-03-00-00
483
484 Arguments:
485 filename (str): relative filename to look for, either in a central place or
486 in the current working directory
487 data_type (str): case insensitive data type to find. Either empty string or
488 one of ``"examples"``, ``"validation"`` or "``starterkit``".
489 silent (bool): If True don't print any errors and just return an empty
490 string if the file cannot be found
491 )DOC");
492}
static boost::python::list getRegisteredModulesPython()
Returns a list of all registered modules.
Definition Framework.cc:282
static void writeSimulationSteps()
Function for writing the simulation steps of each event into csv files.
Definition Framework.cc:231
static std::string findFile(const std::string &filename, const std::string &type, bool ignore_errors=false)
Find a file.
Definition Framework.cc:239
static void setBeamRun()
Function to set that the script is running on beam data (by default it runs on beam data,...
Definition Framework.cc:226
static boost::python::list getModuleSearchPathsPython()
Returns a list of all module search paths known to the framework.
Definition Framework.cc:263
static void setNumberProcesses(int numProcesses)
Function to set number of worker processes for parallel processing.
Definition Framework.cc:168
static void setCosmicRun()
Function to set that the script is running on cosmics data (by default it runs on beam data)
Definition Framework.cc:221
static void setRealm(const std::string &realm)
Function to set the execution realm.
Definition Framework.cc:197
static boost::python::dict getAvailableModulesPython()
Returns a dictionary containing the found modules and the filenames of the shared libraries in which ...
Definition Framework.cc:273
static void setStreamingObjects(const boost::python::list &streamingObjects)
Function to set streaming objects for Tx module.
Definition Framework.cc:191
static std::string getPicklePath()
Function to get the path to the file where the pickled path is stored.
Definition Framework.cc:186
static ModulePtr registerModule(const std::string &moduleName)
Registers a new module to the framework and returns a shared pointer.
Definition Framework.cc:76
static void setPicklePath(const std::string &path)
Function to set the path to the file where the pickled path is stored.
Definition Framework.cc:180
static void setExternalsPath(const std::string &path)
Sets the path in which the externals of the framework are located.
Definition Framework.cc:70
static int getNumberProcesses()
Function to get number of worker processes for parallel processing.
Definition Framework.cc:174
Framework()
Constructor.
Definition Framework.cc:39
static void addModuleSearchPath(const std::string &path)
Adds a new filepath to the list of filepaths which are searched for modules.
Definition Framework.cc:64
static void process(PathPtr startPath, long maxEvent=0)
Processes up to maxEvent events by starting with the first module in the specified path.
Definition Framework.cc:88
std::shared_ptr< Module > ModulePtr
Defines a pointer to a module object as a boost shared pointer.
Definition Module.h:43

◆ findFile()

std::string findFile ( const std::string & filename,
const std::string & type,
bool ignore_errors = false )
static

Find a file.

This is a wrapper around FileSystem::findFile() to be able to call it nicely from python and create a FileNotFoundError if the file cannot be found.

Known types:

  • empty string: exactly like FileSystem::findFile, look in $BELLE2_LOCAL_DIR and then $BELLE2_RELEASE_DIR and then relative to local dir
  • 'examples': look for example data in $BELLE2_EXAMPLES_DATA_DIR, then relative to the local directory
  • 'validation': look for validation data in $BELLE2_VALIDATION_DATA_DIR, then relative to the local directory
  • 'starterkit': look for starterkit data in $BELLE2_STARTERKIT_DATA_DIR, then relative to the local directory
Parameters
filenamerelative filename to look for, either in a central place or in the current working directory
typeif set, specifies where to look if the file cannot be found locally
ignore_errorsif true don't print any errors and silently return None. Otherwise this function will raise a FileNotFoundError exception if the file cannot be found.
Returns
relative or absolute filename if found, empty string if not found and ignore_errors is true

Definition at line 239 of file Framework.cc.

240{
241 std::string result;
242 if (type.empty()) {
243 //behave like FileSystem.findFile by using it
244 result = FileSystem::findFile(filename, ignore_errors);
245 } else {
246 result = FileSystem::findFile(filename, type, ignore_errors);
247 }
248 if (!ignore_errors and result.empty()) {
249 // Still not found ... see if we raise an exception or not.
250 // We want a FileNotFoundError ... so lets fudge the errno to the correct
251 // error value and then create the correct exception in python
252 errno = ENOENT;
253 PyErr_SetFromErrnoWithFilename(PyExc_FileNotFoundError, filename.c_str());
254 boost::python::throw_error_already_set();
255 }
256 return result;
257}
static std::string findFile(const std::string &path, bool silent=false)
Search for given file or directory in local or central release directory, and return absolute path if...

◆ getAvailableModulesPython()

boost::python::dict getAvailableModulesPython ( )
static

Returns a dictionary containing the found modules and the filenames of the shared libraries in which they can be found.

Returns
A python dictionary dictionary containing the found modules.

Definition at line 273 of file Framework.cc.

274{
275 boost::python::dict returnDict;
276 for (const auto& modulePair : ModuleManager::Instance().getAvailableModules())
277 returnDict[boost::python::object(modulePair.first)] = boost::python::object(modulePair.second);
278 return returnDict;
279}

◆ getModuleSearchPathsPython()

boost::python::list getModuleSearchPathsPython ( )
static

Returns a list of all module search paths known to the framework.

Returns
A python list containing all module search paths known to the framework.

Definition at line 263 of file Framework.cc.

264{
265 boost::python::list returnList;
266
267 for (const std::string& path : ModuleManager::Instance().getModuleSearchPaths())
268 returnList.append(boost::python::object(path));
269 return returnList;
270}

◆ getNumberProcesses()

int getNumberProcesses ( )
static

Function to get number of worker processes for parallel processing.

Definition at line 174 of file Framework.cc.

175{
177}
int getNumberProcesses() const
Returns the number of worker processes which should be used for the parallel processing.

◆ getPicklePath()

std::string getPicklePath ( )
static

Function to get the path to the file where the pickled path is stored.

Returns
path to file where the pickled path is stored

Definition at line 186 of file Framework.cc.

187{
189}
const std::string & getPicklePath() const
Returns the path to the file where the pickled path is stored.

◆ getRegisteredModulesPython()

boost::python::list getRegisteredModulesPython ( )
static

Returns a list of all registered modules.

Returns
A python list containing all registered modules.

Definition at line 282 of file Framework.cc.

283{
284 boost::python::list returnList;
285
286 for (const ModulePtr& mod : ModuleManager::Instance().getCreatedModules())
287 returnList.append(boost::python::object(mod));
288 return returnList;
289}

◆ process()

void process ( PathPtr startPath,
long maxEvent = 0 )
static

Processes up to maxEvent events by starting with the first module in the specified path.

This method starts processing events only if there is a module in the path which is capable of specifying the end of the data flow.

Parameters
startPathThe processing starts with the first module of this path.
maxEventThe maximum number of events that will be processed. If the number is smaller than 1, all events will be processed (default).

Definition at line 88 of file Framework.cc.

89{
90 if (Environment::Instance().getDryRun()) {
92 return; //processing disabled!
93 }
94
95 static bool already_executed = false;
96 static std::set<const Module*> previously_run_modules; //not a shared pointer to not screw up ownership
97 static int errors_from_previous_run = 0;
98 const auto moduleListUnique = startPath->buildModulePathList(true);
99 if (already_executed) {
100 B2WARNING("Calling process() more than once per steering file is still experimental, please check results carefully! Python modules especially should reinitialise their state in initialise() to avoid problems");
101 if (startPath->buildModulePathList(true) != startPath->buildModulePathList(false)) {
102 B2FATAL("Your path contains the same module instance in multiple places. Calling process() multiple times is not implemented for this case.");
103 }
104
105 //were any modules in moduleListUnique already run?
106 for (const auto& m : moduleListUnique) {
107 if (previously_run_modules.count(m.get()) > 0) {
108 //only clone if modules have been run before
109 startPath = std::static_pointer_cast<Path>(startPath->clone());
110 break;
111 }
112 }
113 }
114 for (const auto& m : moduleListUnique) {
115 previously_run_modules.insert(m.get());
116 }
117
119 if (numLogError != errors_from_previous_run) {
120 B2FATAL(numLogError << " ERROR(S) occurred! The processing of events will not be started.");
121 }
122
123 try {
127
128 auto& environment = Environment::Instance();
129
130 already_executed = true;
131 if (environment.getNumberProcesses() == 0) {
132 EventProcessor processor;
133 processor.setProfileModuleName(environment.getProfileModuleName());
134 processor.process(startPath, maxEvent);
135 } else {
136 if (environment.getUseZMQ()) {
137 // If the user has not given any socket address, use a random one.
138 if (environment.getZMQSocketAddress().empty()) {
139 environment.setZMQSocketAddress(ZMQAddressUtils::randomSocketName());
140 }
141 ZMQEventProcessor processor;
142 processor.process(startPath, maxEvent);
143 } else {
144 pEventProcessor processor;
145 processor.process(startPath, maxEvent);
146 }
147 }
148 errors_from_previous_run = LogSystem::Instance().getMessageCounter(LogConfig::c_Error);
149
151 // Also, reset the Database connection itself. However don't reset the
152 // configuration, just the actual setup. In case the user runs process()
153 // again it will reinitialize correctly with the same settings.
155 } catch (std::exception& e) {
156 B2ERROR("Uncaught exception encountered: " << e.what()); //should show module name
157 DataStore::Instance().reset(); // ensure we are executed before ROOT's exit handlers
158 throw; //and let python's global handler do the rest
159 } catch (...) {
160 B2ERROR("Uncaught exception encountered!"); //should show module name
161 DataStore::Instance().reset(); // ensure we are executed before ROOT's exit handlers
162 throw; //and let python's global handler do the rest
163 //TODO: having a stack trace would be nicer, but somehow a handler I set using std::set_terminate() never gets called
164 }
165}
static DataStore & Instance()
Instance of singleton Store.
Definition DataStore.cc:53
void setInitializeActive(bool active)
Setter for m_initializeActive.
Definition DataStore.cc:93
void reset(EDurability durability)
Frees memory occupied by data store items and removes all objects from the map.
Definition DataStore.cc:85
void setJobInformation(const std::shared_ptr< Path > &path)
Set info from path executed by the framework.
void setProfileModuleName(const std::string &name)
Set the name of the module we want to profile.
void process(const PathPtr &startPath, long maxEvent=0)
Processes the full module chain, starting with the first module in the given path.
@ c_Error
Error: for things that went wrong and have to be fixed.
Definition LogConfig.h:30
void resetMessageCounter()
Resets the message counter and error log by setting all message counts to 0.
Definition LogSystem.cc:147
int getMessageCounter(LogConfig::ELogLevel logLevel) const
Returns the number of logging calls per log level.
Definition LogSystem.cc:158
std::list< std::shared_ptr< Module > > buildModulePathList(bool unique=true) const
Builds a list of all modules which could be executed during the data processing.
Definition Path.cc:67
std::shared_ptr< PathElement > clone() const override
Create an independent copy of this path, recreating all contained modules with the same parameters.
Definition Path.cc:186
static std::string randomSocketName()
Generate a random socket name in the form ipc:///socketname.
void process(const PathPtr &spath, long maxEvent)
Processes the full module chain using parallel processing, starting with the first module in the give...
void process(const PathPtr &spath, long maxEvent)
Processes the full module chain, starting with the first module in the given path.
void reset(bool keepEntries=false)
Invalidate all payloads.
Definition DBStore.cc:175
static Database & Instance()
Instance of a singleton Database.
Definition Database.cc:42
static DBStore & Instance()
Instance of a singleton DBStore.
Definition DBStore.cc:26
static void reset(bool keepConfig=false)
Reset the database instance.
Definition Database.cc:50

◆ registerModule() [1/2]

ModulePtr registerModule ( const std::string & moduleName)
static

Registers a new module to the framework and returns a shared pointer.

This method creates a new Module based on the given module name. If the shared library file containing the module was already loaded, the module is directly created. Otherwise the shared library file is dynamically loaded first.

If the module could not be registered, an exception of type ModuleNotCreatedError is thrown.

Parameters
moduleNameThe unique name of the module which should be created.
Returns
A shared pointer of the newly created and registered module.

Definition at line 76 of file Framework.cc.

77{
78 return ModuleManager::Instance().registerModule(moduleName);
79}
std::shared_ptr< Module > registerModule(const std::string &moduleName, std::string sharedLibPath="") noexcept(false)
Creates an instance of a module and registers it to the ModuleManager.

◆ registerModule() [2/2]

ModulePtr registerModule ( const std::string & moduleName,
const std::string & sharedLibPath )
static

Registers a new module to the framework and returns a shared pointer.

This method creates a new Module based on the given module name. If the shared library file containing the module was already loaded, the module is directly created. Otherwise the shared library file is dynamically loaded first.

If the module could not be registered, an exception of type ModuleNotCreatedError is thrown.

Parameters
moduleNameThe unique name of the module which should be created.
sharedLibPathOptional: The shared library from which the module should be registered (not a map file !).
Returns
A shared pointer of the newly created and registered module.

Definition at line 82 of file Framework.cc.

83{
84 return ModuleManager::Instance().registerModule(moduleName, sharedLibPath);
85}

◆ setBeamRun()

void setBeamRun ( )
static

Function to set that the script is running on beam data (by default it runs on beam data, no need to use it if the run type has not been changed before).

Definition at line 226 of file Framework.cc.

227{
228 Environment::Instance().setRunType(Const::c_Beam);
229}
void setRunType(Const::ERunType runType)
Set the run type (beam or cosmic).
Definition Environment.h:96

◆ setCosmicRun()

void setCosmicRun ( )
static

Function to set that the script is running on cosmics data (by default it runs on beam data)

Definition at line 221 of file Framework.cc.

222{
223 Environment::Instance().setRunType(Const::c_Cosmic);
224}

◆ setExternalsPath()

void setExternalsPath ( const std::string & path)
static

Sets the path in which the externals of the framework are located.

Parameters
pathThe path in which the externals of the framework are located.

Definition at line 70 of file Framework.cc.

71{
73}
void setExternalsPath(const std::string &externalsPath)
Sets the path which points to the externals directory of the framework.
Definition Environment.h:55

◆ setNumberProcesses()

void setNumberProcesses ( int numProcesses)
static

Function to set number of worker processes for parallel processing.

Definition at line 168 of file Framework.cc.

169{
171}
void setNumberProcesses(int number)
Sets the number of processes which should be used for the parallel processing.

◆ setPicklePath()

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

Function to set the path to the file where the pickled path is stored.

Parameters
pathpath to file where the pickled path is stored

Definition at line 180 of file Framework.cc.

181{
183}
void setPicklePath(const std::string &path)
Sets the path to the file where the pickled path is stored.

◆ setRealm()

void setRealm ( const std::string & realm)
static

Function to set the execution realm.

Parameters
realmbasf2 execution realm

Definition at line 197 of file Framework.cc.

198{
199 int irealm = -1;
200 std::vector<std::string> realms;
201 for (int i = LogConfig::c_None; i <= LogConfig::c_Production; i++) {
202 std::string thisRealm = LogConfig::logRealmToString((LogConfig::ELogRealm)i);
203 realms.push_back(thisRealm);
204 if (boost::iequals(realm, thisRealm)) { //case-insensitive
205 irealm = i;
206 break;
207 }
208 }
209 if (irealm < 0) {
210 B2ERROR("Invalid realm! Needs to be one of " << boost::join(realms, ", "));
211 } else {
213 }
214}
void setRealm(LogConfig::ELogRealm realm)
Set the basf2 execution realm.
static const char * logRealmToString(ELogRealm realm)
Converts a log realm type to a string.
Definition LogConfig.cc:49
ELogRealm
Definition of the supported execution realms.
Definition LogConfig.h:48
@ c_None
No specific realm.
Definition LogConfig.h:48
@ c_Production
Data production jobs.
Definition LogConfig.h:50

◆ setRunType()

void setRunType ( const Const::ERunType runType)
static

Function to set the run type (beam or cosmic)

Definition at line 216 of file Framework.cc.

217{
219}

◆ setStreamingObjects()

void setStreamingObjects ( const boost::python::list & streamingObjects)
static

Function to set streaming objects for Tx module.

Parameters
streamingObjectsobjects to be streamed

Definition at line 191 of file Framework.cc.

192{
193 auto vec = PyObjConvUtils::convertPythonObject(streamingObjects, std::vector<std::string>());
195}
void setStreamingObjects(const std::vector< std::string > &strobjs)
Set list of streaming objects.
Scalar convertPythonObject(const boost::python::object &pyObject, Scalar)
Convert from Python to given type.

◆ writeSimulationSteps()

void writeSimulationSteps ( )
static

Function for writing the simulation steps of each event into csv files.

This should not be used during production jobs, but only for producing events for the Belle II Virtual Reality application.

Definition at line 231 of file Framework.cc.

232{
233 B2WARNING("basf2 will write the simulation steps of each event into output csv files. "
234 "This is fine if you are producing events for the Belle II Virtual Reality application, "
235 "otherwise this function should not be used since the execution time will significantly increase.");
237}
void setWriteSimSteps(const bool writeSimSteps)
Set the flag for writing the simulation steps into an output csv file.

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