12 #include <analysis/modules/ParticleWeightingLookUpCreator/ParticleWeightingLookUpCreatorModule.h>
15 #include <framework/core/ModuleParam.templateDetails.h>
16 #include <framework/database/DBImportObjPtr.h>
17 #include <framework/logging/Logger.h>
41 setDescription(
"Creates test LookUp table");
43 addParam(
"tableIDNotSpec", m_tableIDNotSpec,
"Bin:weight info map without specific bin-numbering scheme", empty_noid_list);
45 addParam(
"tableIDSpec", m_tableIDSpec,
"Bin:weight info map with specific bin-numbering scheme", empty_specificid_list);
46 addParam(
"tableName", m_tableName,
"Name of the LookUp table");
47 addParam(
"outOfRangeWeight", m_outOfRangeWeight,
"Weight info for out-of-range partiles");
48 addParam(
"experimentLow", m_experimentLow,
"Interval of validity, ex.low");
49 addParam(
"experimentHigh", m_experimentHigh,
"Interval of validity, ex.high");
50 addParam(
"runLow", m_runLow,
"Interval of validity, run low");
51 addParam(
"runHigh", m_runHigh,
"Interval of validity, run high");
57 NDBin ParticleWeightingLookUpCreatorModule::NDBinTupleToNDBin(
const NDBinTuple& bin_tuple)
60 for (
auto bin_1d : bin_tuple) {
61 std::string axis_name = bin_1d.first;
62 double min_val = std::get<0>(bin_1d.second);
63 double max_val = std::get<1>(bin_1d.second);
65 binning.insert(std::make_pair(axis_name, lims));
70 void ParticleWeightingLookUpCreatorModule::initialize()
74 if (!m_outOfRangeWeight.empty()) {
75 table.defineOutOfRangeWeight(m_outOfRangeWeight);
78 if (!m_tableIDNotSpec.empty() and m_tableIDSpec.empty()) {
79 for (
auto entry : m_tableIDNotSpec) {
81 NDBin bin = NDBinTupleToNDBin(std::get<1>(entry));
82 table.addEntry(info, bin);
84 }
else if (!m_tableIDSpec.empty() and m_tableIDNotSpec.empty()) {
85 for (
auto entry : m_tableIDSpec) {
87 double bin_id = std::get<1>(entry);
89 NDBin bin = NDBinTupleToNDBin(std::get<1>(noid));
90 table.addEntry(info, bin, bin_id);
93 B2ERROR(
"Please define one table: with OR without specific bin IDs");
96 if (!m_outOfRangeWeight.empty()) {
97 table.defineOutOfRangeWeight(m_outOfRangeWeight);
99 B2INFO(
"Printing LookUp table");
100 table.printParticleWeightingLookUpTable();
103 importer.construct(table);
108 void ParticleWeightingLookUpCreatorModule::terminate()