9#include <framework/core/Module.h>
10#include <framework/core/Path.h>
11#include <framework/core/Environment.h>
12#include <framework/core/ModuleManager.h>
13#include <framework/logging/LogConfig.h>
14#include <framework/core/InputController.h>
15#include <framework/datastore/StoreObjPtr.h>
16#include <framework/dataobjects/FileMetaData.h>
25namespace fs = std::filesystem;
47 if (numEventsFromArgument != 0
48 && (numEventsFromInput == 0 || numEventsFromArgument < numEventsFromInput))
49 return numEventsFromArgument;
51 return numEventsFromInput;
57 if (fileMetaData)
return fileMetaData->isMC();
71 B2WARNING(
"Module '" << module <<
"' requested to handle -o which has already been handled by '" << module <<
"', ignoring");
88 m_numberEventsOverride(0),
89 m_inputFilesOverride(),
90 m_secondaryInputFilesOverride(),
91 m_entrySequencesOverride(),
92 m_outputFileOverride(
""),
93 m_numberProcessesOverride(-1),
95 m_visualizeDataFlow(false),
101 m_runType(
Const::c_Beam),
103 m_writeSimSteps(false)
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.");
114 const char* envarSubDir = getenv(
"BELLE2_SUBDIR");
116 B2FATAL(
"The environment variable BELLE2_SUBDIR is not set. Please execute the 'setuprel' script first.");
119 const char* envarExtDir = getenv(
"BELLE2_EXTERNALS_DIR");
121 B2FATAL(
"The environment variable BELLE2_EXTERNALS_DIR is not set. Please execute the 'setuprel' script first.");
125 std::string added_dirs = fs::current_path().string();
128 if (envarAnalysisDir) {
129 const string analysisModules = (fs::path(envarAnalysisDir) /
"modules" / envarSubDir).
string();
131 added_dirs +=
" " + analysisModules;
135 const string localModules = (fs::path(envarLocalDir) /
"modules" / envarSubDir).
string();
137 added_dirs +=
" " + localModules;
140 if (envarReleaseDir) {
141 const string centralModules = (fs::path(envarReleaseDir) /
"modules" / envarSubDir).
string();
143 added_dirs +=
" " + centralModules;
147 B2ERROR(
"No modules found! Did you forget to run 'scons'? Module paths added: " << added_dirs);
159#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
163 const std::list<ModulePtr>& modules = path->buildModulePathList(
true);
167 std::vector<std::string> inputFiles = m->getFileNames(
false);
168 for (
const string& file : inputFiles) {
173 std::vector<std::string> outputFiles = m->getFileNames(
true);
174 for (
const string& file : outputFiles) {
This class provides a set of constants for the framework.
@ c_Persistent
Object is available during entire execution time.
This class stores all environment information required to run the framework, such as module or data f...
Environment()
Set up environment from standard BELLE2_ environment variables.
std::string consumeOutputFileOverride(const std::string &moduleName)
Return overriden output file name, or "" if none was set.
const std::list< std::string > & getModuleSearchPaths() const
Returns a list of file paths searched for module libraries.
unsigned int getNumberOfEvents() const
Return the number of events, from either input or EventInfoSetter, or -n command line override (if le...
bool isMC() const
Do we have generated, not real data?
~Environment()
The Environment destructor.
std::string m_jobInfoOutput
Output for printJobInformation(), generated by setJobInformation().
void setRealm(LogConfig::ELogRealm realm)
Set the basf2 execution realm.
void setJobInformation(const std::shared_ptr< Path > &path)
Set info from path executed by the framework.
std::string m_outputFileOverride
Override name of output file for output module.
unsigned int m_mcEvents
counter for number of generated events.
void setExternalsPath(const std::string &externalsPath)
Sets the path which points to the externals directory of the framework.
std::string m_outputFileOverrideModule
Name of the module which consumed the output file Override if any was given.
void printJobInformation() const
Print information on input/output files in current steering file, used by –dry-run.
LogConfig::ELogRealm m_realm
The realm in which basf2 is executed.
static Environment & Instance()
Static method to get a reference to the Environment instance.
unsigned int getNumberEventsOverride() const
Returns number of events in run 1 for EventInfoSetter module, or 0 for no override.
static const char * logRealmToString(ELogRealm realm)
Converts a log realm type to a string.
ELogRealm
Definition of the supported execution realms.
const std::list< std::string > & getModuleSearchPaths() const
Returns a reference to the list of the modules search filepaths.
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.
@ c_Input
This module is an input module (reads data).
@ c_Output
This module is an output module (writes data).
Type-safe access to single objects in the data store.
std::shared_ptr< Module > ModulePtr
Defines a pointer to a module object as a boost shared pointer.
Abstract base class for different kinds of events.