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

This class holds the prior distribution for a single particle species. More...

#include <PIDPriorsTable.h>

Collaboration diagram for PIDPriorsTable:

Public Member Functions

void setBinEdges (const std::vector< float > &binEdgesX, const std::vector< float > &binEdgesY)
 Sets the bin edges arrays. More...
 
void setPriorsTable (const std::vector< float > &priors)
 Sets the priors table from a 2D std::vector. More...
 
void setErrorsTable (const std::vector< float > &errors)
 Sets the priors error table from a 2D std::vector. More...
 
void setPriorValue (float x, float y, float value)
 Sets the prior value for a single bin. More...
 
void setErrorValue (float x, float y, float value)
 Sets the error on the prior value for a single bin. More...
 
void setAxisLabels (const std::string &labelX, const std::string &labelY)
 Sets axes labels. More...
 
float getPriorInBin (int iX, int iY) const
 Returns the prior probability for a given bin. More...
 
float getErrorInBin (int iX, int iY) const
 Returns the error on prior probability for a given bin. More...
 
float getPriorValue (float x, float y) const
 Returns the prior probability for a given value of (x,y). More...
 
float getErrorValue (float x, float y) const
 Returns the error on the prior probability for a given value of (x,y). More...
 
std::string getXAxisLabel () const
 Returns the X axis label. More...
 
std::string getYAxisLabel () const
 Returns the Y axis label. More...
 
void printPrior () const
 Prints the content of the table and the axes.
 
void printError () const
 Prints the content of the error table and the axes.
 

Private Member Functions

bool checkRange (const std::string &text, float val, const std::vector< float > &edges) const
 Checks if a value is within the range of an array. More...
 
short findBin (float val, std::vector< float > array) const
 This function returns the position of a number in a sorted array of bin edges. More...
 
short findBinFast (float val, std::vector< float > array) const
 This function returns the position of a number in a sorted array of bin edges This implementation should be more clever than the binary search implemented in findBin, but at the very end it seems to be slower. More...
 
short findBinWithFixedWidth (float val, std::vector< float > array) const
 This function returns the position of a number in a sorted array of bin edges, assuming that the latter are equally spaced. More...
 

Private Attributes

std::vector< float > m_binEdgesX = {}
 The array containing the bin edges for the X axis.
 
std::vector< float > m_binEdgesY = {}
 The array containing the bin edges for the Y axis.
 
std::vector< float > m_priors
 The matrix with the prior probabilities.
 
std::vector< float > m_errors
 The matrix with the errors on the prior probabilities.
 
std::string m_xAxisLabel = ""
 label of the X axis, indicating which variable is represented here
 
std::string m_yAxisLabel = ""
 label of the Y axis, indicating which variable is represented here
 

Detailed Description

This class holds the prior distribution for a single particle species.

Its basic data members are two 2D matrices of floats (one for the probability, one for it uncertainties) plus two arrays for the bins edges. All these elements, including the matrices, are implemented as 1 dimensional vectors. The PIDPriors class that is stored in the database is basically nothing but a collection of 6 of these objects, one per particle species.

Definition at line 27 of file PIDPriorsTable.h.

Member Function Documentation

◆ checkRange()

bool checkRange ( const std::string &  text,
float  val,
const std::vector< float > &  edges 
) const
private

Checks if a value is within the range of an array.

Parameters
texttext to display in the warning message
valthe value
edgesthe vector of bin edge values the val has to be found in
Returns
the position of the last edge below the input value

Definition at line 152 of file PIDPriorsTable.cc.

153 {
154  const float& min = edges.front();
155  const float& max = edges.back();
156  if (val > max || val < min) {
157  B2WARNING("PriorsTable: " << text << LogVar("value", val) << LogVar("min", min) << LogVar("max", max));
158  return false;
159  }
160  return true;
161 };
Class to store variables with their name which were sent to the logging service.

◆ findBin()

short findBin ( float  val,
std::vector< float >  array 
) const
private

This function returns the position of a number in a sorted array of bin edges.

Parameters
valthe value
arraythe std::vector the val has to be found
Returns
the position of the last edge below the input value

Definition at line 164 of file PIDPriorsTable.cc.

◆ findBinFast()

short findBinFast ( float  val,
std::vector< float >  array 
) const
private

This function returns the position of a number in a sorted array of bin edges This implementation should be more clever than the binary search implemented in findBin, but at the very end it seems to be slower.

It's kept in here just in case someone passes by and finds a way to speed it up.

Parameters
valthe value
arraythe std::vector the val has to be found
Returns
the position of the last edge below the input value

Definition at line 171 of file PIDPriorsTable.cc.

◆ findBinWithFixedWidth()

short findBinWithFixedWidth ( float  val,
std::vector< float >  array 
) const
private

This function returns the position of a number in a sorted array of bin edges, assuming that the latter are equally spaced.

Parameters
valthe value
arraythe std::vector the val has to be found
Returns
the position of the last edge below the input value

Definition at line 191 of file PIDPriorsTable.cc.

◆ getErrorInBin()

float getErrorInBin ( int  iX,
int  iY 
) const
inline

Returns the error on prior probability for a given bin.

If the bin is outside of the table boundaries, 0 will be returned.

Parameters
iXbin number on the X axis
iYbin number on the Y axis
Returns
the error on the prior probability value

Definition at line 111 of file PIDPriorsTable.h.

112  {
113  return m_errors[iX + (m_binEdgesX.size() - 1) * iY];
114  };
std::vector< float > m_errors
The matrix with the errors on the prior probabilities.
std::vector< float > m_binEdgesX
The array containing the bin edges for the X axis.

◆ getErrorValue()

float getErrorValue ( float  x,
float  y 
) const

Returns the error on the prior probability for a given value of (x,y).

If the bin is outside of the table boundaries, 0 will be returned.

Parameters
xthe x-value of the x coordinate
ythe y-value of the y coordinate
Returns
value the error on the prior probability value

Definition at line 89 of file PIDPriorsTable.cc.

◆ getPriorInBin()

float getPriorInBin ( int  iX,
int  iY 
) const
inline

Returns the prior probability for a given bin.

If the bin is outside of the table boundaries, 0 will be returned.

Parameters
iXbin number on the X axis
iYbin number on the Y axis
Returns
value the prior probability value

Definition at line 99 of file PIDPriorsTable.h.

◆ getPriorValue()

float getPriorValue ( float  x,
float  y 
) const

Returns the prior probability for a given value of (x,y).

If the bin is outside of the table boundaries, 0 will be returned.

Parameters
xthe x-value of the x coordinate
ythe y-value of the y coordinate
Returns
the value the prior probability value

Definition at line 79 of file PIDPriorsTable.cc.

◆ getXAxisLabel()

std::string getXAxisLabel ( ) const
inline

Returns the X axis label.

Returns
the X axis label

Definition at line 139 of file PIDPriorsTable.h.

◆ getYAxisLabel()

std::string getYAxisLabel ( ) const
inline

Returns the Y axis label.

Returns
the Y axis label

Definition at line 148 of file PIDPriorsTable.h.

◆ setAxisLabels()

void setAxisLabels ( const std::string &  labelX,
const std::string &  labelY 
)
inline

Sets axes labels.

Parameters
labelXthe label of the X axis
labelYthe label of the X axis

Definition at line 85 of file PIDPriorsTable.h.

◆ setBinEdges()

void setBinEdges ( const std::vector< float > &  binEdgesX,
const std::vector< float > &  binEdgesY 
)

Sets the bin edges arrays.

Please notice that setting the axes will also automatically clear the tables.

Parameters
binEdgesXthe vector of bin edges for the X axis
binEdgesYthe vector of bin edges for the Y axis

Definition at line 17 of file PIDPriorsTable.cc.

◆ setErrorsTable()

void setErrorsTable ( const std::vector< float > &  errors)
inline

Sets the priors error table from a 2D std::vector.

Parameters
errors2D std:vector of floats containing the error on the prior probability for each bin

Definition at line 55 of file PIDPriorsTable.h.

◆ setErrorValue()

void setErrorValue ( float  x,
float  y,
float  value 
)

Sets the error on the prior value for a single bin.

Parameters
xthe x-value of the x coordinate
ythe y-value of the y coordinate
valuethe x-value of the prior probability error associated to x and y

Definition at line 67 of file PIDPriorsTable.cc.

◆ setPriorsTable()

void setPriorsTable ( const std::vector< float > &  priors)
inline

Sets the priors table from a 2D std::vector.

Parameters
priors2D std:vector of floats containing the prior probability for each bin

Definition at line 44 of file PIDPriorsTable.h.

◆ setPriorValue()

void setPriorValue ( float  x,
float  y,
float  value 
)

Sets the prior value for a single bin.

Parameters
xthe x-value of the x coordinate
ythe y-value of the y coordinate
valuethe x-value of the prior probability associated to x and y

Definition at line 52 of file PIDPriorsTable.cc.


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