9#include <framework/modules/gearbox/GearboxModule.h>
10#include <framework/gearbox/Gearbox.h>
11#include <framework/datastore/StoreObjPtr.h>
12#include <framework/dataobjects/EventMetaData.h>
14#include <framework/core/ModuleParam.templateDetails.h>
28GearboxModule::GearboxModule() :
Module()
31 setDescription(
"Loads the Belle II detector parameters from an XML document.");
32 setPropertyFlags(c_ParallelProcessingCertified);
35 m_backends.emplace_back(
"file:");
38 addParam(
"backends", m_backends,
"The backends to use when looking for xml "
39 "data. A backend can also contain a search path after ':'. (If none "
40 "is given, '/data' will be used.)", m_backends);
41 addParam(
"fileName", m_fileName,
"The filename of the main xml file",
42 string(
"geometry/Belle2.xml"));
43 addParam(
"override", m_unitOverrides,
"Override single values from the XML "
44 "file. This should be a list of tuples containing an xpath "
45 "expression, a value and a unit (which can be empty). The xpath "
46 "expression must resolve to exactly one node in the XML tree which "
47 "does not contain any children except text. The supplied value and "
48 "unit will be set for this node. See "
49 "framework/examples/gearbox_override.py", m_unitOverrides);
50 addParam(
"overrideMultiple", m_multipleOverrides,
"Same as override but the "
51 "xpath expression may evaluate to more than one node in which case "
52 "all occurances are set to the supplied value and unit",
54 addParam(
"overridePrefix", m_overridePrefix,
"Common prefix which is "
55 "prepended to all overrides. Beware that '//' has a special meaning "
56 "meaning in xpath so be careful with leading and trailing slashes "
57 "in the overrides and the prefix respectively", std::string(
"/Detector"));
69 poverride.
value = std::get<1>(unit);
70 poverride.
unit = std::get<2>(unit);
71 gearbox.addOverride(poverride);
76 poverride.
value = std::get<1>(multiple);
77 poverride.
unit = std::get<2>(multiple);
79 gearbox.addOverride(poverride);
void initialize() override
Define backends.
std::vector< std::tuple< std::string, std::string, std::string > > m_multipleOverrides
overrides to override the value and unit of many parameters
std::string m_fileName
The toplevel filename for the parameters.
std::vector< std::tuple< std::string, std::string, std::string > > m_unitOverrides
overrides to override the value and unit of a parameter
void beginRun() override
Load the (possibly rundependent) parameters from the chosen backends.
std::string m_overridePrefix
common prefix for all value overrides
std::vector< std::string > m_backends
The backend specifier.
Singleton class responsible for loading detector parameters from an XML file.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Type-safe access to single objects in the data store.
static Gearbox & getInstance()
Return reference to the Gearbox instance.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.
Struct to override a path in the XML file with a custom value.
bool multiple
if true, override all nodes when more than one node matches the XPath expression, bail otherwise
std::string path
XPath expression of the path to override.
std::string value
New value.