Belle II Software development
ParticleWeightingLookUpTable Class Reference

Class for handling LookUp tables. More...

#include <ParticleWeightingLookUpTable.h>

Inheritance diagram for ParticleWeightingLookUpTable:

Public Member Functions

 ParticleWeightingLookUpTable ()
 Constructor.
 
void addEntry (WeightInfo entryValue, NDBin bin)
 Adds entry to the LookUp table and also adds entry to key table if needed.
 
void addEntry (WeightInfo entryValue, NDBin bin, int key_ID)
 Adds entry to the LookUp table and also adds entry to key table with predefined bin ID if needed.
 
void defineOutOfRangeWeight (const WeightInfo &entryValue)
 Define reweight info for particles out of range.
 
std::vector< std::string > getAxesNames () const
 Get axes names.
 
WeightInfo getInfo (std::map< std::string, double > values) const
 Get axes names.
 
void printParticleWeightingLookUpTable () const
 Print content of LookUpTable.
 

Private Member Functions

 ClassDef (ParticleWeightingLookUpTable, 1)
 ClassDef as this is a TObject.
 

Private Attributes

ParticleWeightingKeyMap m_KeyMap
 LookUp table matches bins of the key map with the LookUp info.
 
WeightMap m_WeightMap
 Collection of weight infos for global bins.
 
const int m_OutOfRangeBinID = -1
 out-of-range bin ID
 

Detailed Description

Class for handling LookUp tables.

Definition at line 28 of file ParticleWeightingLookUpTable.h.

Constructor & Destructor Documentation

◆ ParticleWeightingLookUpTable()

Constructor.

Definition at line 45 of file ParticleWeightingLookUpTable.h.

45{};

Member Function Documentation

◆ addEntry() [1/2]

void addEntry ( WeightInfo  entryValue,
NDBin  bin 
)

Adds entry to the LookUp table and also adds entry to key table if needed.

Parameters
entryValueis a line from LookUp table
bincontains bin limits for given LookUp table values

Definition at line 16 of file ParticleWeightingLookUpTable.cc.

17{
18 int id = m_WeightMap.size();
19 this->addEntry(std::move(entryValue), std::move(bin), id);
20}
void addEntry(WeightInfo entryValue, NDBin bin)
Adds entry to the LookUp table and also adds entry to key table if needed.
WeightMap m_WeightMap
Collection of weight infos for global bins.

◆ addEntry() [2/2]

void addEntry ( WeightInfo  entryValue,
NDBin  bin,
int  key_ID 
)

Adds entry to the LookUp table and also adds entry to key table with predefined bin ID if needed.

Parameters
entryValueis a line from LookUp table
bincontains bin limits for given LookUp table values
key_IDis bin ID. You might want to use it to make several bins with the same ID or for non-square bins.

Definition at line 22 of file ParticleWeightingLookUpTable.cc.

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}
int addKey(NDBin bin, int key_ID)
Adding predefined ID to the table.
ParticleWeightingKeyMap m_KeyMap
LookUp table matches bins of the key map with the LookUp info.

◆ defineOutOfRangeWeight()

void defineOutOfRangeWeight ( const WeightInfo entryValue)

Define reweight info for particles out of range.

This info is stored in bin -1.

Parameters
entryValueis a line from LookUp table

Definition at line 30 of file ParticleWeightingLookUpTable.cc.

31{
32 m_WeightMap.insert(std::make_pair(m_OutOfRangeBinID, entryValue));
33}

◆ getAxesNames()

std::vector< std::string > getAxesNames ( ) const

Get axes names.

Returns
vector of axes names

Definition at line 36 of file ParticleWeightingLookUpTable.cc.

37{
38 return m_KeyMap.getNames();
39}
std::vector< std::string > getNames() const
Get vector of names ParticleWeightingKeyMap.

◆ getInfo()

WeightInfo getInfo ( std::map< std::string, double >  values) const

Get axes names.

Parameters
valuesmap of axes names with values along corresponding names
Returns
vector of axes names

Definition at line 41 of file ParticleWeightingLookUpTable.cc.

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}
double getKey(std::map< std::string, double > values) const
Get global bin ID for given observable values.

◆ printParticleWeightingLookUpTable()

void printParticleWeightingLookUpTable ( ) const

Print content of LookUpTable.

Definition at line 53 of file ParticleWeightingLookUpTable.cc.

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}
void printKeyMap() const
Print content of the key map.
std::map< std::string, double > WeightInfo
Weight information: a line from the weight lookup table.

Member Data Documentation

◆ m_KeyMap

ParticleWeightingKeyMap m_KeyMap
private

LookUp table matches bins of the key map with the LookUp info.

This matching is paired with the key map. Key map

Definition at line 33 of file ParticleWeightingLookUpTable.h.

◆ m_OutOfRangeBinID

const int m_OutOfRangeBinID = -1
private

out-of-range bin ID

Definition at line 37 of file ParticleWeightingLookUpTable.h.

◆ m_WeightMap

WeightMap m_WeightMap
private

Collection of weight infos for global bins.

Definition at line 34 of file ParticleWeightingLookUpTable.h.


The documentation for this class was generated from the following files: