10 #include <analysis/modules/ParticleWeightingLookUpCreator/ParticleWeightingLookUpCreatorModule.h>
13 #include <framework/core/ModuleParam.templateDetails.h>
14 #include <framework/database/DBImportObjPtr.h>
15 #include <framework/logging/Logger.h>
39 setDescription(
"Creates test LookUp table");
41 addParam(
"tableIDNotSpec", m_tableIDNotSpec,
"Bin:weight info map without specific bin-numbering scheme", empty_noid_list);
43 addParam(
"tableIDSpec", m_tableIDSpec,
"Bin:weight info map with specific bin-numbering scheme", empty_specificid_list);
44 addParam(
"tableName", m_tableName,
"Name of the LookUp table");
45 addParam(
"outOfRangeWeight", m_outOfRangeWeight,
"Weight info for out-of-range partiles");
46 addParam(
"experimentLow", m_experimentLow,
"Interval of validity, ex.low");
47 addParam(
"experimentHigh", m_experimentHigh,
"Interval of validity, ex.high");
48 addParam(
"runLow", m_runLow,
"Interval of validity, run low");
49 addParam(
"runHigh", m_runHigh,
"Interval of validity, run high");
55 NDBin ParticleWeightingLookUpCreatorModule::NDBinTupleToNDBin(
const NDBinTuple& bin_tuple)
58 for (
auto bin_1d : bin_tuple) {
59 std::string axis_name = bin_1d.first;
60 double min_val = std::get<0>(bin_1d.second);
61 double max_val = std::get<1>(bin_1d.second);
63 binning.insert(std::make_pair(axis_name, lims));
68 void ParticleWeightingLookUpCreatorModule::initialize()
72 if (!m_outOfRangeWeight.empty()) {
73 table.defineOutOfRangeWeight(m_outOfRangeWeight);
76 if (!m_tableIDNotSpec.empty() and m_tableIDSpec.empty()) {
77 for (
auto entry : m_tableIDNotSpec) {
79 NDBin bin = NDBinTupleToNDBin(std::get<1>(entry));
80 table.addEntry(info, bin);
82 }
else if (!m_tableIDSpec.empty() and m_tableIDNotSpec.empty()) {
83 for (
auto entry : m_tableIDSpec) {
85 double bin_id = std::get<1>(entry);
87 NDBin bin = NDBinTupleToNDBin(std::get<1>(noid));
88 table.addEntry(info, bin, bin_id);
91 B2ERROR(
"Please define one table: with OR without specific bin IDs");
94 if (!m_outOfRangeWeight.empty()) {
95 table.defineOutOfRangeWeight(m_outOfRangeWeight);
97 B2INFO(
"Printing LookUp table");
98 table.printParticleWeightingLookUpTable();
101 importer.construct(table);
106 void ParticleWeightingLookUpCreatorModule::terminate()
108 if (lims !=
nullptr) {
Class for importing a single object to the database.
A class that describes the interval of experiments/runs for which an object in the database is valid.
Just pair of numbers - min and max values of bin border.
Module that creates LookUpTable and upload it to the DB.
Class for handling LookUp tables.
std::tuple< WeightInfo, NDBinTuple > noIdEntry
the ID
std::vector< specificIDEntry > listOfSpecificIDEntries
List of entries for table to be created from with specified ID.
std::map< std::string, BinLimitsTuple > NDBinTuple
the NDimensional tuple of bin limits
std::vector< noIdEntry > listOfNoIdEntries
List of entries for table to be created from without specified ID.
std::map< std::string, ParticleWeightingBinLimits * > NDBin
N-dim bin: pairs of bin limits with name of the axis variable.
std::map< std::string, double > WeightInfo
Weight information: a line from the weight lookup table.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.