Belle II Software  release-05-01-25
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 lables. 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 is a values is withing 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 atter 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 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 matrixes of floats (one for the probablity, one for it uncertainties) plus two arrays for the bins edges. All these elements, including the matrixes, 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 37 of file PIDPriorsTable.h.

Member Function Documentation

◆ checkRange()

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

Checks is a values is withing the range of an array.

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 153 of file PIDPriorsTable.cc.

154 {
155  const float& min = edges.front();
156  const float& max = edges.back();
157  if (val > max || val < min) {
158  B2WARNING("PriorsTable: " << text << LogVar("value", val) << LogVar("min", min) << LogVar("max", max));
159  return false;
160  }
161  return true;
162 };

◆ 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 165 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 172 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 atter 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 192 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 121 of file PIDPriorsTable.h.

◆ 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 90 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 109 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 80 of file PIDPriorsTable.cc.

◆ getXAxisLabel()

std::string getXAxisLabel ( ) const
inline

Returns the X axis label.

Returns
the X axis label

Definition at line 149 of file PIDPriorsTable.h.

◆ getYAxisLabel()

std::string getYAxisLabel ( ) const
inline

Returns the Y axis label.

Returns
the Y axis label

Definition at line 158 of file PIDPriorsTable.h.

◆ setAxisLabels()

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

Sets axes lables.

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

Definition at line 95 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 18 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 probaiblity for each bin

Definition at line 65 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 68 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 probaiblity for each bin

Definition at line 54 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 53 of file PIDPriorsTable.cc.


The documentation for this class was generated from the following files:
LogVar
Class to store variables with their name which were sent to the logging service.
Definition: LogVariableStream.h:24