9#include <analysis/dbobjects/ParticleWeightingKeyMap.h>
10#include <framework/logging/Logger.h>
21 m_axes.insert(std::make_pair(name, axis));
29 B2FATAL(
"You are trying create bin with ID identical to out-of-range Bin : " <<
m_outOfRangeBin);
34 for (
const auto& i_1dbin : bin) {
39 if (bin.size() !=
m_axes.size()) {
40 B2FATAL(
"Inconsistent dimensionality of added bin");
44 std::vector<int> bin_id_collection;
45 for (
auto i_axis :
m_axes) {
46 auto it = bin.find(i_axis.first);
47 if (it != bin.end()) {
48 bin_id_collection.push_back(i_axis.second->addBin(it->second));
50 B2FATAL(
"Names of bin and existing axes don't match");
55 for (
auto i_bin :
m_bins) {
56 if (std::equal(i_bin.first.begin(), i_bin.first.end(), bin_id_collection.begin())) {
57 B2FATAL(
"You tried to overwrite existing bin " + std::to_string(i_bin.second) +
" with new ID " + std::to_string(key_ID));
62 m_bins.emplace_back(bin_id_collection, key_ID);
75 if (values.size() !=
m_axes.size()) {
76 B2FATAL(
"Inconsistent dimensionality of requested value map");
79 std::vector<int> bin_id_collection;
80 for (
auto i_axis :
m_axes) {
81 auto it = values.find(i_axis.first);
82 if (it != values.end()) {
83 bin_id_collection.push_back(i_axis.second->findBin(it->second));
85 B2FATAL(
"Names of bin and existing axes don't match");
89 for (
auto i_bin :
m_bins) {
90 if (std::equal(i_bin.first.begin(), i_bin.first.end(), bin_id_collection.begin())) {
100 std::vector<std::string> names;
101 for (
const auto& i_axis :
m_axes) {
102 names.push_back(i_axis.first);
110 std::string axes_names =
"";
111 for (
auto i_axis :
m_axes) {
112 axes_names +=
"'" + i_axis.first +
"' bin;";
113 i_axis.second->printAxis();
115 B2INFO(
"Bin map \n <" + axes_names +
"> : <global ID>");
116 for (
const auto& i_bin :
m_bins) {
117 std::string binIDs =
"";
118 for (
auto i_binid : i_bin.first) {
119 binIDs += std::to_string(i_binid) +
"; ";
121 B2INFO(binIDs +
" : " + std::to_string(i_bin.second));
Class for handling LookUp tables.
std::map< std::string, ParticleWeightingAxis * > m_axes
Axes mapped with their names.
const int m_outOfRangeBin
We assign unique bin ID for out-of-range bin.
double getKey(std::map< std::string, double > values) const
Get global bin ID for given observable values.
std::vector< MultiDimBin > m_bins
Vector of keys.
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.
void addAxis(const std::string &name)
Add axis.
std::map< std::string, ParticleWeightingBinLimits * > NDBin
N-dim bin: pairs of bin limits with name of the axis variable.
Abstract base class for different kinds of events.