Belle II Software light-2406-ragdoll
ParticleWeightingLookUpTable.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <analysis/dbobjects/ParticleWeightingLookUpTable.h>
10#include <framework/logging/Logger.h>
11
12#include <utility>
13
14using namespace Belle2;
15
17{
18 int id = m_WeightMap.size();
19 this->addEntry(std::move(entryValue), std::move(bin), id);
20}
21
23{
24 int id = m_KeyMap.addKey(std::move(bin), key_ID);
25 entryValue.insert(std::make_pair("binID", id));
26 m_WeightMap.insert(std::make_pair(id, entryValue));
27}
28
29
31{
32 m_WeightMap.insert(std::make_pair(m_OutOfRangeBinID, entryValue));
33}
34
35
36std::vector<std::string> ParticleWeightingLookUpTable::getAxesNames() const
37{
38 return m_KeyMap.getNames();
39}
40
41WeightInfo ParticleWeightingLookUpTable::getInfo(std::map<std::string, double> values) const
42{
43 int id = m_KeyMap.getKey(std::move(values));
44 auto it = m_WeightMap.find(id);
45 if (it != m_WeightMap.end()) {
46 return m_WeightMap.at(id);
47 } else {
48 B2FATAL("Attempt to access undeclared bin");
50 }
51}
52
54{
56 B2INFO("Printing the table");
57 for (const auto& entry : m_WeightMap) {
58 int key_ID = entry.first;
59 WeightInfo info = entry.second;
60 std::string bin_info = "";
61 std::string bin_id = "";
62 for (const auto& line : info) {
63 bin_info += line.first + " " + std::to_string(line.second) + " ; ";
64 }
65 if (key_ID == m_OutOfRangeBinID) {
66 bin_id += "Out of range bin " + std::to_string(key_ID) + " : ";
67 } else {
68 bin_id += "Bin " + std::to_string(key_ID) + " : ";
69 }
70 B2INFO(bin_id + bin_info);
71 }
72}
double getKey(std::map< std::string, double > values) const
Get global bin ID for given observable values.
void printKeyMap() const
Print content of the key map.
int addKey(NDBin bin, int key_ID)
Adding predefined ID to the table.
std::vector< std::string > getNames() const
Get vector of names ParticleWeightingKeyMap.
WeightInfo getInfo(std::map< std::string, double > values) const
Get axes names.
void addEntry(WeightInfo entryValue, NDBin bin)
Adds entry to the LookUp table and also adds entry to key table if needed.
std::vector< std::string > getAxesNames() const
Get axes names.
WeightMap m_WeightMap
Collection of weight infos for global bins.
void defineOutOfRangeWeight(const WeightInfo &entryValue)
Define reweight info for particles out of range.
ParticleWeightingKeyMap m_KeyMap
LookUp table matches bins of the key map with the LookUp info.
void printParticleWeightingLookUpTable() const
Print content of LookUpTable.
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.
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24