Belle II Software  release-08-01-10
ParticleWeightingAxis Class Reference

Class for handling LookUp tables. More...

#include <ParticleWeightingAxis.h>

Collaboration diagram for ParticleWeightingAxis:

Public Member Functions

 ParticleWeightingAxis ()
 Constructor.
 
std::string getName () const
 Returns name of an axis.
 
void setName (const std::string &name)
 Sets name of an axis. More...
 
int addBin (ParticleWeightingBinLimits *bin)
 Check if bin exists and creates it if not. More...
 
int findBin (ParticleWeightingBinLimits *bin) const
 Returns id of bin with given bin limits Returns out-of-range binID if can't find. More...
 
int findBin (double value) const
 Returns id of bin containing value. More...
 
void printAxis () const
 Prints axis information to the B2INFO stream.
 

Private Member Functions

bool isOverlappingBin (ParticleWeightingBinLimits *bin)
 Return TRUE if bin exists or overlaps with existing. More...
 

Private Attributes

BinMap m_unnamedAxis
 Named axis with bins.
 
std::string m_axisName
 Axis name.
 
const int m_outOfRangeBinID = -1
 ID of out-of-range bin.
 

Detailed Description

Class for handling LookUp tables.

Definition at line 26 of file ParticleWeightingAxis.h.

Member Function Documentation

◆ addBin()

int addBin ( ParticleWeightingBinLimits bin)

Check if bin exists and creates it if not.

Returns bin ID Issues fatal error in case of overlapping bins.

Parameters
binbin limits
Returns
key ID

Definition at line 46 of file ParticleWeightingAxis.cc.

47 {
48  int existing_id = this->findBin(bin);
49  if (existing_id != m_outOfRangeBinID) {
50  return existing_id;
51  }
52  if (this->isOverlappingBin(bin)) {
53  B2FATAL("Attempting to add overlapping or existing bin");
54  } else {
55  int id = m_unnamedAxis.size() + 1;
56  m_unnamedAxis.insert(std::make_pair(id, bin));
57  return id;
58  }
59 }
int findBin(ParticleWeightingBinLimits *bin) const
Returns id of bin with given bin limits Returns out-of-range binID if can't find.
BinMap m_unnamedAxis
Named axis with bins.
const int m_outOfRangeBinID
ID of out-of-range bin.
bool isOverlappingBin(ParticleWeightingBinLimits *bin)
Return TRUE if bin exists or overlaps with existing.

◆ findBin() [1/2]

int findBin ( double  value) const

Returns id of bin containing value.

Parameters
valuevalue
Returns
key ID

Definition at line 73 of file ParticleWeightingAxis.cc.

◆ findBin() [2/2]

int findBin ( ParticleWeightingBinLimits bin) const

Returns id of bin with given bin limits Returns out-of-range binID if can't find.

Parameters
binbin limits
Returns
key ID

Definition at line 62 of file ParticleWeightingAxis.cc.

◆ isOverlappingBin()

bool isOverlappingBin ( ParticleWeightingBinLimits bin)
private

Return TRUE if bin exists or overlaps with existing.

Parameters
bin- tested bin
Returns
is this bin overlapping with existing bins or not

Checking if lower border is within some bin existing binning: | | new binning: | |

Checking if upper border is within some bin existing binning: | | new binning: | |

Checking if new bin covers existing bin completely existing binning: | | new binning: | |

Definition at line 14 of file ParticleWeightingAxis.cc.

◆ setName()

void setName ( const std::string &  name)
inline

Sets name of an axis.

Parameters
nameaxis name

Definition at line 57 of file ParticleWeightingAxis.h.

57 { m_axisName = name;}

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