Belle II Software  release-05-02-19
Module.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Andreas Moll, Martin Heck *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <boost/python/register_ptr_to_python.hpp>
12 #include <boost/python/class.hpp>
13 #include <boost/python/list.hpp>
14 #include <boost/python/dict.hpp>
15 #include <boost/python/copy_const_reference.hpp>
16 #include <boost/python/overloads.hpp>
17 #include <boost/python/enum.hpp>
18 #include <boost/python/docstring_options.hpp>
19 #include <utility>
20 
21 #include <framework/core/Module.h>
22 #include <framework/core/ModuleCondition.h>
23 #include <framework/core/PyModule.h>
24 #include <framework/core/ModuleManager.h>
25 #include <framework/core/Path.h>
26 
27 #include <framework/logging/Logger.h>
28 
29 using namespace Belle2;
30 using namespace boost::python;
31 
33  m_name(),
34  m_type(),
35  m_description("Not set by the author"),
36  m_propertyFlags(0),
37  m_logConfig(),
38  m_hasReturnValue(false),
39  m_returnValue(0)
40 {
41 }
42 
43 const std::string& Module::getType() const
44 {
45  if (m_type.empty())
46  B2FATAL("Module type not set for " << getName());
47  return m_type;
48 }
49 
50 void Module::setType(const std::string& type)
51 {
52  if (!m_type.empty())
53  B2FATAL("Trying to change module type from " << m_type << " is not allowed, the value is assumed to be fixed.");
54  m_type = type;
55 }
56 
57 void Module::setLogLevel(int logLevel)
58 {
59  m_logConfig.setLogLevel(static_cast<LogConfig::ELogLevel>(logLevel));
60 }
61 
62 
63 void Module::setDebugLevel(int debugLevel)
64 {
65  m_logConfig.setDebugLevel(debugLevel);
66 }
67 
68 
69 void Module::setAbortLevel(int abortLevel)
70 {
71  m_logConfig.setAbortLevel(static_cast<LogConfig::ELogLevel>(abortLevel));
72 }
73 
74 
75 void Module::setLogInfo(int logLevel, unsigned int logInfo)
76 {
77  m_logConfig.setLogInfo(static_cast<LogConfig::ELogLevel>(logLevel), logInfo);
78 }
79 
80 
81 void Module::if_value(const std::string& expression, const std::shared_ptr<Path>& path, EAfterConditionPath afterConditionPath)
82 {
83  m_conditions.emplace_back(expression, path, afterConditionPath);
84 }
85 
86 
87 void Module::if_false(const std::shared_ptr<Path>& path, EAfterConditionPath afterConditionPath)
88 {
89  if_value("<1", path, afterConditionPath);
90 }
91 
92 void Module::if_true(const std::shared_ptr<Path>& path, EAfterConditionPath afterConditionPath)
93 {
94  if_value(">=1", path, afterConditionPath);
95 }
96 
97 
99 {
100  if (m_conditions.empty()) return false;
101 
102  //okay, a condition was set for this Module...
103  if (!m_hasReturnValue) {
104  B2FATAL("A condition was set for '" << getName() << "', but the module did not set a return value!");
105  }
106 
107  for (const auto& condition : m_conditions) {
108  if (condition.evaluate(m_returnValue)) {
109  return true;
110  }
111  }
112  return false;
113 }
114 
115 std::shared_ptr<Path> Module::getConditionPath() const
116 {
117  PathPtr p;
118  if (m_conditions.empty()) return p;
119 
120  //okay, a condition was set for this Module...
121  if (!m_hasReturnValue) {
122  B2FATAL("A condition was set for '" << getName() << "', but the module did not set a return value!");
123  }
124 
125  for (const auto& condition : m_conditions) {
126  if (condition.evaluate(m_returnValue)) {
127  return condition.getPath();
128  }
129  }
130 
131  // if none of the conditions were true, return a null pointer.
132  return p;
133 }
134 
136 {
137  if (m_conditions.empty()) return EAfterConditionPath::c_End;
138 
139  //okay, a condition was set for this Module...
140  if (!m_hasReturnValue) {
141  B2FATAL("A condition was set for '" << getName() << "', but the module did not set a return value!");
142  }
143 
144  for (const auto& condition : m_conditions) {
145  if (condition.evaluate(m_returnValue)) {
146  return condition.getAfterConditionPath();
147  }
148  }
149 
151 }
152 std::vector<std::shared_ptr<Path>> Module::getAllConditionPaths() const
153 {
154  std::vector<std::shared_ptr<Path>> allConditionPaths;
155  for (const auto& condition : m_conditions) {
156  allConditionPaths.push_back(condition.getPath());
157  }
158 
159  return allConditionPaths;
160 }
161 
162 bool Module::hasProperties(unsigned int propertyFlags) const
163 {
164  return (propertyFlags & m_propertyFlags) == propertyFlags;
165 }
166 
167 
169 {
170  auto missing = m_moduleParamList.getUnsetForcedParams();
171  std::string allMissing = "";
172  for (const auto& s : missing)
173  allMissing += s + " ";
174  if (!missing.empty())
175  B2ERROR("The following required parameters of Module '" << getName() << "' were not specified: " << allMissing <<
176  "\nPlease add them to your steering file.");
177  return !missing.empty();
178 }
179 
180 
181 std::shared_ptr<PathElement> Module::clone() const
182 {
184  newModule->m_moduleParamList.setParameters(getParamList());
185  newModule->setName(getName());
186  newModule->m_package = m_package;
187  newModule->m_propertyFlags = m_propertyFlags;
188  newModule->m_logConfig = m_logConfig;
189  newModule->m_conditions = m_conditions;
190 
191  return newModule;
192 }
193 
194 std::string Module::getPathString() const
195 {
196 
197  std::string output = getName();
198 
199  for (const auto& condition : m_conditions) {
200  output += condition.getString();
201  }
202 
203  return output;
204 }
205 
206 //============================================================================
207 // Protected methods
208 //============================================================================
209 
210 void Module::setPropertyFlags(unsigned int propertyFlags)
211 {
212  m_propertyFlags = propertyFlags;
213 }
214 
215 
216 void Module::setDescription(const std::string& description)
217 {
218  m_description = description;
219 }
220 
221 
222 void Module::setReturnValue(int value)
223 {
224  m_hasReturnValue = true;
225  m_returnValue = value;
226 }
227 
228 
229 void Module::setReturnValue(bool value)
230 {
231  m_hasReturnValue = true;
232  m_returnValue = value;
233 }
234 
235 
236 void Module::setParamPython(const std::string& name, const boost::python::object& pyObj)
237 {
238  LogSystem& logSystem = LogSystem::Instance();
239  logSystem.updateModule(&(getLogConfig()), getName());
240  try {
241  m_moduleParamList.setParamPython(name, pyObj);
242  } catch (std::runtime_error& e) {
243  throw std::runtime_error("Cannot set parameter '" + name + "' for module '"
244  + m_name + "': " + e.what());
245  }
246 
247  logSystem.updateModule(nullptr);
248 }
249 
250 
251 void Module::setParamPythonDict(const boost::python::dict& dictionary)
252 {
253 
254  LogSystem& logSystem = LogSystem::Instance();
255  logSystem.updateModule(&(getLogConfig()), getName());
256 
257  boost::python::list dictKeys = dictionary.keys();
258  int nKey = boost::python::len(dictKeys);
259 
260  //Loop over all keys in the dictionary
261  for (int iKey = 0; iKey < nKey; ++iKey) {
262  boost::python::object currKey = dictKeys[iKey];
263  boost::python::extract<std::string> keyProxy(currKey);
264 
265  if (keyProxy.check()) {
266  const boost::python::object& currValue = dictionary[currKey];
267  setParamPython(keyProxy, currValue);
268  } else {
269  B2ERROR("Setting the module parameters from a python dictionary: invalid key in dictionary!");
270  }
271  }
272 
273  logSystem.updateModule(nullptr);
274 }
275 
276 
277 //=====================================================================
278 // Python API
279 //=====================================================================
280 
281 std::shared_ptr<boost::python::list> Module::getParamInfoListPython() const
282 {
284 }
285 
286 namespace {
288  boost::python::list _getParamInfoListPython(const Module* m)
289  {
290  return *(m->getParamInfoListPython().get()); //copy the list object
291  }
292  boost::python::list _getAllConditionPathsPython(const Module* m)
293  {
294  boost::python::list allConditionPaths;
295  for (const auto& conditionPath : m->getAllConditionPaths()) {
296  allConditionPaths.append(boost::python::object(conditionPath));
297  }
298 
299  return allConditionPaths;
300  }
301  boost::python::list _getAllConditionsPython(const Module* m)
302  {
303  boost::python::list allConditions;
304  for (const auto& condition : m->getAllConditions()) {
305  allConditions.append(boost::python::object(boost::ref(condition)));
306  }
307 
308  return allConditions;
309  }
310 }
311 
312 #if !defined(__GNUG__) || defined(__ICC)
313 #else
314 #pragma GCC diagnostic push
315 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
316 #endif
317 // cppcheck-suppress unknownMacro
318 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(if_value_overloads, if_value, 2, 3)
319 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(if_false_overloads, if_false, 1, 2)
320 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(if_true_overloads, if_true, 1, 2)
321 #if !defined(__GNUG__) || defined(__ICC)
322 #else
323 #pragma GCC diagnostic pop
324 #endif
325 
326 
328 {
329  // to avoid confusion between std::arg and boost::python::arg we want a shorthand namespace as well
330  namespace bp = boost::python;
331 
332  docstring_options options(true, true, false); //userdef, py sigs, c++ sigs
333 
334  void (Module::*setReturnValueInt)(int) = &Module::setReturnValue;
335 
336  enum_<Module::EAfterConditionPath>("AfterConditionPath",
337  R"(Determines execution behaviour after a conditional path has been executed:
338 
339 .. attribute:: END
340 
341  End processing of this path after the conditional path. (this is the default for if_value() etc.)
342 
343 .. attribute:: CONTINUE
344 
345  After the conditional path, resume execution after this module.)")
347  .value("CONTINUE", Module::EAfterConditionPath::c_Continue)
348  ;
349 
350  /* Do not change the names of >, <, ... we use them to serialize conditional pathes */
351  enum_<Belle2::ModuleCondition::EConditionOperators>("ConditionOperator")
352  .value(">", Belle2::ModuleCondition::EConditionOperators::c_GT)
353  .value("<", Belle2::ModuleCondition::EConditionOperators::c_ST)
354  .value(">=", Belle2::ModuleCondition::EConditionOperators::c_GE)
355  .value("<=", Belle2::ModuleCondition::EConditionOperators::c_SE)
356  .value("==", Belle2::ModuleCondition::EConditionOperators::c_EQ)
357  .value("!=", Belle2::ModuleCondition::EConditionOperators::c_NE)
358  ;
359 
360  enum_<Module::EModulePropFlags>("ModulePropFlags",
361  R"(Flags to indicate certain low-level features of modules, see :func:`Module.set_property_flags()`, :func:`Module.has_properties()`. Most useful flags are:
362 
363 .. attribute:: PARALLELPROCESSINGCERTIFIED
364 
365  This module can be run in parallel processing mode safely (All I/O must be done through the data store, in particular, the module must not write any files.)
366 
367 .. attribute:: HISTOGRAMMANAGER
368 
369  This module is used to manage histograms accumulated by other modules
370 
371 .. attribute:: TERMINATEINALLPROCESSES
372 
373  When using parallel processing, call this module's terminate() function in all processes. This will also ensure that there is exactly one process (single-core if no parallel modules found) or at least one input, one main and one output process.
374 )")
375  .value("INPUT", Module::EModulePropFlags::c_Input)
376  .value("OUTPUT", Module::EModulePropFlags::c_Output)
377  .value("PARALLELPROCESSINGCERTIFIED", Module::EModulePropFlags::c_ParallelProcessingCertified)
378  .value("HISTOGRAMMANAGER", Module::EModulePropFlags::c_HistogramManager)
379  .value("INTERNALSERIALIZER", Module::EModulePropFlags::c_InternalSerializer)
380  .value("TERMINATEINALLPROCESSES", Module::EModulePropFlags::c_TerminateInAllProcesses)
381  ;
382 
383  //Python class definition
384  class_<Module, PyModule> module("Module", R"(
385 Base class for Modules.
386 
387 A module is the smallest building block of the framework.
388 A typical event processing chain consists of a Path containing
389 modules. By inheriting from this base class, various types of
390 modules can be created. To use a module, please refer to
391 :func:`Path.add_module()`. A list of modules is available by running
392 ``basf2 -m`` or ``basf2 -m package``, detailed information on parameters is
393 given by e.g. ``basf2 -m RootInput``.
394 
395 The 'Module Development' section in the manual provides detailed information
396 on how to create modules, setting parameters, or using return values/conditions:
397 https://confluence.desy.de/display/BI/Software+Basf2manual#Module_Development
398 
399 )");
400  module
401  .def("__str__", &Module::getPathString)
402  .def("name", &Module::getName, return_value_policy<copy_const_reference>(),
403  "Returns the name of the module. Can be changed via :func:`set_name() <Module.set_name()>`, use :func:`type() <Module.type()>` for identifying a particular module class.")
404  .def("type", &Module::getType, return_value_policy<copy_const_reference>(),
405  "Returns the type of the module (i.e. class name minus 'Module')")
406  .def("set_name", &Module::setName, args("name"), R"(
407 Set custom name, e.g. to distinguish multiple modules of the same type.
408 
409 >>> path.add_module('EventInfoSetter')
410 >>> ro = path.add_module('RootOutput', branchNames=['EventMetaData'])
411 >>> ro.set_name('RootOutput_metadata_only')
412 >>> print(path)
413 [EventInfoSetter -> RootOutput_metadata_only]
414 
415 )")
416  .def("description", &Module::getDescription, return_value_policy<copy_const_reference>(),
417  "Returns the description of this module.")
418  .def("package", &Module::getPackage, return_value_policy<copy_const_reference>(),
419  "Returns the package this module belongs to.")
420  .def("available_params", &_getParamInfoListPython,
421  "Return list of all module parameters as `ModuleParamInfo` instances")
422  .def("has_properties", &Module::hasProperties, (bp::arg("properties")),
423  R"DOCSTRING(Allows to check if the module has the given properties out of `ModulePropFlags` set.
424 
425 >>> if module.has_properties(ModulePropFlags.PARALLELPROCESSINGCERTIFIED):
426 >>> ...
427 
428 Parameters:
429  properties (int): bitmask of `ModulePropFlags` to check for.
430 )DOCSTRING")
431  .def("set_property_flags", &Module::setPropertyFlags, args("property_mask"),
432  "Set module properties in the form of an OR combination of `ModulePropFlags`.");
433  {
434  // python signature is too crowded, make ourselves
435  docstring_options subOptions(true, false, false); //userdef, py sigs, c++ sigs
436  module
437  .def("if_value", &Module::if_value,
438  (bp::arg("expression"), bp::arg("condition_path"), bp::arg("after_condition_path")= Module::EAfterConditionPath::c_End),
439  R"DOCSTRING(if_value(expression, condition_path, after_condition_path=AfterConditionPath.END)
440 
441 Sets a conditional sub path which will be executed after this
442 module if the return value set in the module passes the given ``expression``.
443 
444 Modules can define a return value (int or bool) using ``setReturnValue()``,
445 which can be used in the steering file to split the Path based on this value, for example
446 
447 >>> module_with_condition.if_value("<1", another_path)
448 
449 In case the return value of the ``module_with_condition`` for a given event is
450 less than 1, the execution will be diverted into ``another_path`` for this event.
451 
452 You could for example set a special return value if an error occurs, and divert
453 the execution into a path containing :b2:mod:`RootOutput` if it is found;
454 saving only the data producing/produced by the error.
455 
456 After a conditional path has executed, basf2 will by default stop processing
457 the path for this event. This behaviour can be changed by setting the
458 ``after_condition_path`` argument.
459 
460 Parameters:
461  expression (str): Expression to determine if the conditional path should be executed.
462  This should be one of the comparison operators ``<``, ``>``, ``<=``,
463  ``>=``, ``==``, or ``!=`` followed by a numerical value for the return value
464  condition_path (Path): path to execute in case the expression is fulfilled
465  after_condition_path (AfterConditionPath): What to do once the ``condition_path`` has been executed.
466 )DOCSTRING")
467  .def("if_false", &Module::if_false,
468  (bp::arg("condition_path"), bp::arg("after_condition_path")= Module::EAfterConditionPath::c_End),
469  R"DOC(if_false(condition_path, after_condition_path=AfterConditionPath.END)
470 
471 Sets a conditional sub path which will be executed after this module if
472 the return value of the module evaluates to False. This is equivalent to
473 calling `if_value` with ``expression=\"<1\"``)DOC")
474  .def("if_true", &Module::if_true,
475  (bp::arg("condition_path"), bp::arg("after_condition_path")= Module::EAfterConditionPath::c_End),
476  R"DOC(if_true(condition_path, after_condition_path=AfterConditionPath.END)
477 
478 Sets a conditional sub path which will be executed after this module if
479 the return value of the module evaluates to True. It is equivalent to
480 calling `if_value` with ``expression=\">=1\"``)DOC");
481  }
482  module
483  .def("has_condition", &Module::hasCondition,
484  "Return true if a conditional path has been set for this module "
485  "using `if_value`, `if_true` or `if_false`")
486  .def("get_all_condition_paths", &_getAllConditionPathsPython,
487  "Return a list of all conditional paths set for this module using "
488  "`if_value`, `if_true` or `if_false`")
489  .def("get_all_conditions", &_getAllConditionsPython,
490  "Return a list of all conditional path expressions set for this module using "
491  "`if_value`, `if_true` or `if_false`")
492  .add_property("logging", make_function(&Module::getLogConfig, return_value_policy<reference_existing_object>()),
494  .def("return_value", setReturnValueInt, bp::arg("value"), \
495  "Set a return value. Can be used by custom modules to set the return value "
496  "used to determine if conditional paths are executed")
497  .def("set_log_level", &Module::setLogLevel, bp::arg("log_level"),
498  "Set the log level for this module. Messages below that level will be suppressed\n\n"
499  "Parameters:\n log_level (LogLevel): Minimum level for messages to be displayed")
500  .def("set_debug_level", &Module::setDebugLevel, bp::arg("debug_level"),
501  "Set the debug level for this module. Debug messages with a higher level will "
502  "be suppressed. This function has no visible effect if the log level is "
503  "not set to `DEBUG <LogLevel.DEBUG>`\n\n"
504  "Parameters:\n debug_level (int): Maximum debug level for messages to be displayed.")
505  .def("set_abort_level", &Module::setAbortLevel, bp::arg("abort_level"),
506  "Set the log level which will cause processing to be aborted. Usually "
507  "processing is only aborted for `FATAL <LogLevel.FATAL>` messages "
508  "but with this function it's possible to set this to a lower value\n\n"
509  "Parameters:\n abort_level (LogLevel): log level which will cause processing to be aborted.")
510  .def("set_log_info", &Module::setLogInfo, args("log_info"),
511  "Set a `LogInfo` configuration object for this module to determine how log messages should be formatted")
512  //tell python about the default implementations of virtual functions
513  .def("initialize", &Module::def_initialize,
514  "This function is called by the processing just once before processing any data "
515  "is processed. Modules can override this method to perform some actions at "
516  "startup once all parameters are set")
517  .def("beginRun", &Module::def_beginRun,
518  "This function is called by the processing just before a new run of data "
519  "is processed. Modules can override this method to perform actions which "
520  "are run dependent")
521  .def("event", &Module::def_event,
522  "This function is called by the processing once for each event."
523  "Modules should override this method to perform actions during event processing")
524  .def("endRun", &Module::def_endRun,
525  "This function is called by the processing just after a new run of data "
526  "is processed. Modules can override this method to perform actions which "
527  "are run dependent")
528  .def("terminate", &Module::def_terminate,
529  "This function is called by the processing once after all data "
530  "is processed. Modules can override this method to perform some cleanup at "
531  "shutdown. The terminate functions of all modules are called in reverse "
532  "order of the `initialize` calls.")
533  ;
534  {
535  // The param function is overloaded with different signatures which makes
536  // the boost docstring very useless so we handcraft a docstring
537  docstring_options param_options(true, false, false); //userdef, py sigs, c++ sigs
538  module
539  .def("param", &Module::setParamPython)
540  .def("param", &Module::setParamPythonDict, R"DOCSTRING(param(key, value=None)
541 This method can be used to set module parameters. There are two ways of
542 calling this function:
543 
544 1. With two arguments where the first is the name of the parameter and the second is the value.
545 
546  >>> module.param("parameterName", "parameterValue")
547 
548 2. Or with just one parameter which is a dictionary mapping multiple parameter names to their values
549 
550  >>> module.param({"parameter1": "value1", "parameter2": True})
551 )DOCSTRING")
552  ;
553  }
554 
555  register_ptr_to_python<ModulePtr>();
556 }
557 
558 //=====================================================================
559 // ModuleProxyBase
560 //=====================================================================
561 
562 ModuleProxyBase::ModuleProxyBase(std::string moduleType, std::string package) : m_moduleType(std::move(moduleType)),
563  m_package(std::move(package))
564 {
566 }
Belle2::Module::getAfterConditionPath
Module::EAfterConditionPath getAfterConditionPath() const
What to do after the conditional path is finished.
Definition: Module.cc:135
Belle2::Module::getConditionPath
std::shared_ptr< Path > getConditionPath() const
Returns the path of the last true condition (if there is at least one, else reaturn a null pointer).
Definition: Module.cc:115
Belle2::Module::if_false
void if_false(const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
A simplified version to add a condition to the module.
Definition: Module.cc:87
Belle2::Module::setLogLevel
void setLogLevel(int logLevel)
Configure the log level.
Definition: Module.cc:57
Belle2::Module::setParamPython
void setParamPython(const std::string &name, const boost::python::object &pyObj)
Implements a method for setting boost::python objects.
Definition: Module.cc:236
Belle2::ModuleManager::registerModule
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.
Definition: ModuleManager.cc:84
Belle2::Module::if_true
void if_true(const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
A simplified version to set the condition of the module.
Definition: Module.cc:92
Belle2::Module::setDescription
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:216
Belle2::ModuleManager::Instance
static ModuleManager & Instance()
Exception is thrown if the requested module could not be created by the ModuleManager.
Definition: ModuleManager.cc:28
Belle2::Module::getParamInfoListPython
std::shared_ptr< boost::python::list > getParamInfoListPython() const
Returns a python list of all parameters.
Definition: Module.cc:281
Belle2::Module::m_returnValue
int m_returnValue
The return value.
Definition: Module.h:521
Belle2::Module::hasCondition
bool hasCondition() const
Returns true if at least one condition was set for the module.
Definition: Module.h:313
Belle2::Module::m_logConfig
LogConfig m_logConfig
The log system configuration of the module.
Definition: Module.h:516
Belle2::LogConfig::setLogLevel
void setLogLevel(ELogLevel logLevel)
Configure the log level.
Definition: LogConfig.cc:27
Belle2::Module::def_initialize
virtual void def_initialize()
Wrappers to make the methods without "def_" prefix callable from Python.
Definition: Module.h:422
Belle2::ModuleCondition::EAfterConditionPath::c_End
@ c_End
End current event after the conditional path.
Belle2::Module::m_package
std::string m_package
Package this module is found in (may be empty).
Definition: Module.h:512
Belle2::Module::exposePythonAPI
static void exposePythonAPI()
Exposes methods of the Module class to Python.
Definition: Module.cc:327
Belle2::Module::getType
const std::string & getType() const
Returns the type of the module (i.e.
Definition: Module.cc:43
Belle2::LogConfig::setAbortLevel
void setAbortLevel(ELogLevel abortLevel)
Configure the abort level.
Definition: LogConfig.h:108
Belle2::ModuleProxyBase::ModuleProxyBase
ModuleProxyBase(std::string moduleType, std::string package)
The constructor of the ModuleProxyBase class.
Definition: Module.cc:499
Belle2::LogConfig::ELogLevel
ELogLevel
Definition of the supported log levels.
Definition: LogConfig.h:36
Belle2::Module::if_value
void if_value(const std::string &expression, const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
Add a condition to the module.
Definition: Module.cc:81
Belle2::ModuleManager::registerModuleProxy
void registerModuleProxy(ModuleProxyBase *moduleProxy)
Registers a module proxy.
Definition: ModuleManager.cc:35
Belle2::Module::getPackage
const std::string & getPackage() const
Returns the package this module is in.
Definition: Module.h:199
Belle2::Module::setAbortLevel
void setAbortLevel(int abortLevel)
Configure the abort log level.
Definition: Module.cc:69
Belle2::Module::setDebugLevel
void setDebugLevel(int debugLevel)
Configure the debug messaging level.
Definition: Module.cc:63
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::Module::hasUnsetForcedParams
bool hasUnsetForcedParams() const
Returns true and prints error message if the module has unset parameters which the user has to set in...
Definition: Module.cc:168
Belle2::Module::setPropertyFlags
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:210
Belle2::Module::getDescription
const std::string & getDescription() const
Returns the description of the module.
Definition: Module.h:204
Belle2::Module::clone
std::shared_ptr< PathElement > clone() const override
Create an independent copy of this module.
Definition: Module.cc:181
Belle2::ModuleParamList::getUnsetForcedParams
std::vector< std::string > getUnsetForcedParams() const
Returns list of unset parameters (if they are required to have a value.
Definition: ModuleParamList.cc:56
Belle2::ModuleCondition::EAfterConditionPath::c_Continue
@ c_Continue
After the conditional path, resume execution after this module.
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::LogSystem
Class for logging debug, info and error messages.
Definition: LogSystem.h:56
Belle2::Module::setType
void setType(const std::string &type)
Set the module type.
Definition: Module.cc:50
Belle2::PathPtr
std::shared_ptr< Path > PathPtr
Defines a pointer to a path object as a boost shared pointer.
Definition: Path.h:30
Belle2::Module::m_hasReturnValue
bool m_hasReturnValue
True, if the return value is set.
Definition: Module.h:520
Belle2::ModulePtr
std::shared_ptr< Module > ModulePtr
Defines a pointer to a module object as a boost shared pointer.
Definition: Module.h:42
Belle2::Module::m_moduleParamList
ModuleParamList m_moduleParamList
List storing and managing all parameter of the module.
Definition: Module.h:518
Belle2::Module::m_name
std::string m_name
The name of the module, saved as a string (user-modifiable)
Definition: Module.h:510
Belle2::Module::setReturnValue
void setReturnValue(int value)
Sets the return value for this module as integer.
Definition: Module.cc:222
Belle2::LogSystem::updateModule
void updateModule(const LogConfig *moduleLogConfig=nullptr, const std::string &moduleName="")
Sets the log configuration to the given module log configuration and sets the module name This method...
Definition: LogSystem.h:201
Belle2::Module::def_endRun
virtual void def_endRun()
This method can receive that the current run ends as a call from the Python side.
Definition: Module.h:441
Belle2::Module::m_type
std::string m_type
The type of the module, saved as a string.
Definition: Module.h:511
Belle2::Module::setLogInfo
void setLogInfo(int logLevel, unsigned int logInfo)
Configure the printed log information for the given level.
Definition: Module.cc:75
Belle2::Module::m_conditions
std::vector< ModuleCondition > m_conditions
Module condition, only non-null if set.
Definition: Module.h:523
Belle2::ModuleParamList::setParamPython
void setParamPython(const std::string &name, const PythonObject &pyObj)
Implements a method for setting boost::python objects.
Definition: ModuleParamList.templateDetails.h:114
Belle2::LogSystem::Instance
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
Definition: LogSystem.cc:33
Belle2::Module::Module
Module()
Constructor.
Definition: Module.cc:32
Belle2::LogConfig::setLogInfo
void setLogInfo(ELogLevel logLevel, unsigned int logInfo)
Configure the printed log information for the given level.
Definition: LogConfig.h:123
Belle2::Module::getParamList
const ModuleParamList & getParamList() const
Return module param list.
Definition: Module.h:365
Belle2::ModuleCondition::EAfterConditionPath
EAfterConditionPath
Different options for behaviour after a conditional path was executed.
Definition: ModuleCondition.h:35
Belle2::Module::def_terminate
virtual void def_terminate()
Wrapper method for the virtual function terminate() that has the implementation to be used in a call ...
Definition: Module.h:447
Belle2::Module::def_beginRun
virtual void def_beginRun()
Wrapper method for the virtual function beginRun() that has the implementation to be used in a call f...
Definition: Module.h:428
Belle2::Module::m_propertyFlags
unsigned int m_propertyFlags
The properties of the module as bitwise or (with |) of EModulePropFlags.
Definition: Module.h:514
Belle2::Module::def_event
virtual void def_event()
Wrapper method for the virtual function event() that has the implementation to be used in a call from...
Definition: Module.h:434
Belle2::Module::m_description
std::string m_description
The description of the module.
Definition: Module.h:513
Belle2::Module::getName
const std::string & getName() const
Returns the name of the module.
Definition: Module.h:189
Belle2::Module::setName
void setName(const std::string &name)
Set the name of the module.
Definition: Module.h:216
Belle2::Module::getLogConfig
LogConfig & getLogConfig()
Returns the log system configuration.
Definition: Module.h:227
Belle2::Module::evalCondition
bool evalCondition() const
If at least one condition was set, it is evaluated and true returned if at least one condition return...
Definition: Module.cc:98
Belle2::ModuleParamList::getParamInfoListPython
std::shared_ptr< boost::python::list > getParamInfoListPython() const
Returns a python list of all parameters.
Definition: ModuleParamList.cc:66
Belle2::Module::setParamPythonDict
void setParamPythonDict(const boost::python::dict &dictionary)
Implements a method for reading the parameter values from a boost::python dictionary.
Definition: Module.cc:251
Belle2::Module::getPathString
std::string getPathString() const override
return the module name.
Definition: Module.cc:194
Belle2::Module::getAllConditionPaths
std::vector< std::shared_ptr< Path > > getAllConditionPaths() const
Return all condition paths currently set (no matter if the condition is true or not).
Definition: Module.cc:152
Belle2::Module::setLogConfig
void setLogConfig(const LogConfig &logConfig)
Set the log system configuration.
Definition: Module.h:232
Belle2::LogConfig::setDebugLevel
void setDebugLevel(int debugLevel)
Configure the debug messaging level.
Definition: LogConfig.h:94
Belle2::Module::hasProperties
bool hasProperties(unsigned int propertyFlags) const
Returns true if all specified property flags are available in this module.
Definition: Module.cc:162