9 #include <alignment/modules/AlignmentGenerator/AlignmentGeneratorModule.h>
11 #include <alignment/dbobjects/VXDAlignment.h>
12 #include <framework/database/Database.h>
13 #include <vxd/dataobjects/VxdID.h>
14 #include <vxd/geometry/GeoCache.h>
18 #include <boost/algorithm/string.hpp>
33 std::vector<std::string> emptyData;
34 std::vector<int> infiniteIov{0, 0, -1, -1};
39 "Generated alignment overrides any existing one in reconstruction if done with this module. "
40 "The generated object can also be stored as payload in the (local) DB, to keep track of it."
45 "of four numbers: first experiment, first run, last experiment, "
46 "last run", infiniteIov);
49 "Data for alignment in format ['layer.ladder.sensor, parameter_no, distribution=fix|gaus|uniform, value', ...]",
51 addParam(
"payloadName",
m_payloadName,
"Name of generated alignment payload in database. If empty, default is used",
61 for (
auto paramData :
m_data) {
62 std::vector<std::string> paramDataParts;
63 boost::algorithm::split(paramDataParts, paramData, boost::is_any_of(
","));
64 if (paramDataParts.size() != 4)
65 B2FATAL(
"Error parsing alignment data.");
67 boost::trim(paramDataParts[0]);
68 boost::trim(paramDataParts[1]);
69 boost::trim(paramDataParts[2]);
70 boost::trim(paramDataParts[3]);
72 VxdID idMask(paramDataParts[0]);
73 int paramID = std::stoi(paramDataParts[1]);
74 std::string distro = paramDataParts[2];
75 double value = std::stod(paramDataParts[3]);
77 double generatedValue = 0.;
78 if (distro ==
"fix") generatedValue = value;
79 else if (distro ==
"gaus") generatedValue = gRandom->Gaus(0., value);
80 else if (distro ==
"uniform") generatedValue = gRandom->Uniform(-value, value);
81 else B2FATAL(
"Unknown distribution for parameter generation: " << distro <<
" Valid options are fix|gaus|uniform");
87 data->set(
id, paramID, generatedValue);
93 B2WARNING(
"Overriding VXDAlignment in DBStore with new object. This will affect reconstruction if done in this job.");
98 B2FATAL(
"Payload IoV incorrect. Should be list of four numbers.");
100 B2INFO(
"Storing VXDAlignment payload in DB.");
bool m_createPayload
Whether to create and store the payload in database.
virtual void initialize() override
Generate misalignment and store in database.
std::string m_payloadName
Name of generated misalignment in database.
std::vector< int > m_payloadIov
IoV for the payload.
std::vector< std::string > m_data
Data for misalignment generation.
AlignmentGeneratorModule()
Constructor: Sets the description, the properties and the parameters of the module.
A class that describes the interval of experiments/runs for which an object in the database is valid.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
VXD alignment (and maybe some calibration) parameters.
static GeoCache & getInstance()
Return a reference to the singleton instance.
Class to uniquely identify a any structure of the PXD and SVD.
baseType getSensorNumber() const
Get the sensor id.
baseType getLadderNumber() const
Get the ladder id.
baseType getLayerNumber() const
Get the layer id.
REG_MODULE(arichBtest)
Register the Module.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
static Database & Instance()
Instance of a singleton Database.
static DBStore & Instance()
Instance of a singleton DBStore.
bool storeData(const std::string &name, TObject *object, const IntervalOfValidity &iov)
Store an object in the database.
void addConstantOverride(const std::string &name, TObject *obj, bool oneRun=false)
Add constant override payload.
Abstract base class for different kinds of events.