Belle II Software light-2406-ragdoll
PIDPriors Class Reference

A database class to hold the prior probability for the particle identification. More...

#include <PIDPriors.h>

Inheritance diagram for PIDPriors:
Collaboration diagram for PIDPriors:

Public Member Functions

 PIDPriors ()
 Default constructor.
 
void setPriors (const Const::ChargedStable &particle, const PIDPriorsTable &table)
 Sets the prior table for a particle species from a PIDPriorsTable object.
 
void setPriors (const Const::ChargedStable &particle, std::vector< float > xAxisEdges, std::vector< float > yAxisEdges, std::vector< float > priorsTable, std::vector< float > errorsTable)
 Sets the prior table for a particle species from the std::vectors of the bin edges and the probability values.
 
void setPriors (const Const::ChargedStable &particle, TH2F *priorHistogram)
 Sets the prior table for a particle species from a TH2F.
 
void setPriors (const Const::ChargedStable &particle, TH2F *counts, TH2F *normalization)
 Sets the prior table for a particle species starting from a TH2F of the counts and a TH2F of the normalization.
 
void setPriorsAxes (const Const::ChargedStable &particle, std::vector< float > xAxisEdges, std::vector< float > yAxisEdges)
 Sets the axes for the priors table of the selected species.
 
void setPriorsTable (const Const::ChargedStable &particle, std::vector< float > priorsTable)
 Sets the probability table for the priors of the selected particle species.
 
void setErrorsTable (const Const::ChargedStable &particle, std::vector< float > errorsTable)
 Sets the probability error table for the priors of the selected particle species.
 
void setAxisLabels (const Const::ChargedStable &particle, std::string xAxisLabel, std::string yAxisLabel)
 Sets the axis labels for the priors of the selected particle species.
 
PIDPriorsTable getPriorsTable (const Const::ChargedStable &particle) const
 Returns the priors table of the selected particle species.
 
float getPriorValue (const Const::ChargedStable &particle, float x, float y) const
 Returns the prior probability associated to a particle with defined species and parameters.
 
float getPriorError (const Const::ChargedStable &particle, float x, float y) const
 Returns the error on the prior probability associated to a particle with defined species and parameters.
 
std::string getXAxisLabel (const Const::ChargedStable &particle) const
 Returns the X axis label of the prior.
 
std::string getYAxisLabel (const Const::ChargedStable &particle) const
 Returns the Y axis label of the prior.
 

Private Member Functions

 ClassDef (PIDPriors, 1)
 Class revision number.
 

Private Attributes

PIDPriorsTable m_priors [Const::ChargedStable::c_SetSize]
 The array of PIDPiorsTable, one per particle species.
 

Detailed Description

A database class to hold the prior probability for the particle identification.

This prior probability for each particle species is stored as PIDPriorsTable object, that allows to bin it in 2 dimensions defined by two kinematic variables. This class provides a container for 6 PIDPriorsTable objects, some wrappers around the most used getters and setters, and some setters that allow the user to load the priors starting from a TH2 object.

Definition at line 31 of file PIDPriors.h.

Constructor & Destructor Documentation

◆ PIDPriors()

PIDPriors ( )
inline

Default constructor.

Definition at line 44 of file PIDPriors.h.

44{};

Member Function Documentation

◆ getPriorError()

float getPriorError ( const Const::ChargedStable particle,
float  x,
float  y 
) const
inline

Returns the error on the prior probability associated to a particle with defined species and parameters.

Parameters
particlethe charged stable type of the prior's species
xthe value of the x-axis coordinate
ythe value of the y-axis coordinate
Returns
the prior probability error

Definition at line 191 of file PIDPriors.h.

192 {
193 auto index = particle.getIndex();
194 return m_priors[index].getErrorValue(x, y);
195 }
float getErrorValue(float x, float y) const
Returns the error on the prior probability for a given value of (x,y).
PIDPriorsTable m_priors[Const::ChargedStable::c_SetSize]
The array of PIDPiorsTable, one per particle species.
Definition: PIDPriors.h:222

◆ getPriorsTable()

PIDPriorsTable getPriorsTable ( const Const::ChargedStable particle) const
inline

Returns the priors table of the selected particle species.

Parameters
particlethe charged stable type of the prior's species
Returns
the priors table

Definition at line 163 of file PIDPriors.h.

164 {
165 auto index = particle.getIndex();
166 return m_priors[index];
167 }

◆ getPriorValue()

float getPriorValue ( const Const::ChargedStable particle,
float  x,
float  y 
) const
inline

Returns the prior probability associated to a particle with defined species and parameters.

Parameters
particlethe charged stable type of the prior's species
xthe value of the x-axis coordinate
ythe value of the y-axis coordinate
Returns
the prior probability value

Definition at line 177 of file PIDPriors.h.

178 {
179 auto index = particle.getIndex();
180 return m_priors[index].getPriorValue(x, y);
181 }
float getPriorValue(float x, float y) const
Returns the prior probability for a given value of (x,y).

◆ getXAxisLabel()

std::string getXAxisLabel ( const Const::ChargedStable particle) const
inline

Returns the X axis label of the prior.

Parameters
particlethe charged stable type of the prior's species
Returns
the X axis label for the prior table of the selected particle species

Definition at line 203 of file PIDPriors.h.

204 {
205 auto index = particle.getIndex();
206 return m_priors[index].getXAxisLabel();
207 }
std::string getXAxisLabel() const
Returns the X axis label.

◆ getYAxisLabel()

std::string getYAxisLabel ( const Const::ChargedStable particle) const
inline

Returns the Y axis label of the prior.

Parameters
particlethe charged stable type of the prior's species
Returns
the Y axis label for the prior table of the selected particle species

Definition at line 215 of file PIDPriors.h.

216 {
217 auto index = particle.getIndex();
218 return m_priors[index].getYAxisLabel();
219 }
std::string getYAxisLabel() const
Returns the Y axis label.

◆ setAxisLabels()

void setAxisLabels ( const Const::ChargedStable particle,
std::string  xAxisLabel,
std::string  yAxisLabel 
)
inline

Sets the axis labels for the priors of the selected particle species.

Parameters
particlethe charged stable type of the prior's species
xAxisLabelthe label of the X axis
yAxisLabelthe label of the Y axis

Definition at line 150 of file PIDPriors.h.

151 {
152 auto index = particle.getIndex();
153 m_priors[index].setAxisLabels(xAxisLabel, yAxisLabel);
154 return;
155 }
void setAxisLabels(const std::string &labelX, const std::string &labelY)
Sets axes labels.

◆ setErrorsTable()

void setErrorsTable ( const Const::ChargedStable particle,
std::vector< float >  errorsTable 
)
inline

Sets the probability error table for the priors of the selected particle species.

Effectively this is just a wrapper around PIDPriorsTable::setErrorssTable()

Parameters
particlethe charged stable type of the prior's species
errorsTablea 2D vector containing the prior probabilities

Definition at line 136 of file PIDPriors.h.

137 {
138 auto index = particle.getIndex();
139 m_priors[index].setErrorsTable(errorsTable);
140 return;
141 }
void setErrorsTable(const std::vector< float > &errors)
Sets the priors error table from a 2D std::vector.

◆ setPriors() [1/4]

void setPriors ( const Const::ChargedStable particle,
const PIDPriorsTable table 
)
inline

Sets the prior table for a particle species from a PIDPriorsTable object.

Parameters
particlethe charged stable type of the particle
tablethe priors table

Definition at line 52 of file PIDPriors.h.

53 {
54 auto index = particle.getIndex();
55 m_priors[index] = table;
56 return;
57 }

◆ setPriors() [2/4]

void setPriors ( const Const::ChargedStable particle,
std::vector< float >  xAxisEdges,
std::vector< float >  yAxisEdges,
std::vector< float >  priorsTable,
std::vector< float >  errorsTable 
)
inline

Sets the prior table for a particle species from the std::vectors of the bin edges and the probability values.

Parameters
particlethe charged stable type of the particle
xAxisEdgesthe std::vector<float> containing the bin edges of the X axis
yAxisEdgesthe std::vector<float> containing the bin edges of the Y axis
priorsTablethe 2D std::vector<float> containing the prior probabilities
errorsTablethe 2D std::vector<float> containing the errors on prior probabilities

Definition at line 68 of file PIDPriors.h.

70 {
71 auto index = particle.getIndex();
72 m_priors[index].setBinEdges(xAxisEdges, yAxisEdges);
73 m_priors[index].setBinEdges(xAxisEdges, yAxisEdges);
74 m_priors[index].setPriorsTable(priorsTable);
75 m_priors[index].setErrorsTable(errorsTable);
76 return;
77 }
void setBinEdges(const std::vector< float > &binEdgesX, const std::vector< float > &binEdgesY)
Sets the bin edges arrays.
void setPriorsTable(const std::vector< float > &priors)
Sets the priors table from a 2D std::vector.

◆ setPriors() [3/4]

void setPriors ( const Const::ChargedStable particle,
TH2F *  counts,
TH2F *  normalization 
)

Sets the prior table for a particle species starting from a TH2F of the counts and a TH2F of the normalization.

The counts histogram is divided by the normalization one to get the probabilities and the errors The bin edges are taken form the TH2 axes, the prior probability from the bins content and the errors from the bins error

Parameters
particlethe charged stable type of the particle
countshistogram of counts
normalizationhistogram used for normalization

Definition at line 57 of file PIDPriors.cc.

58{
59 TH2F* priorHistogram = static_cast<TH2F*>(counts->Clone());
60
61 priorHistogram->Sumw2();
62 priorHistogram->Divide(normalization);
63
64 setPriors(particle, priorHistogram);
65};
void setPriors(const Const::ChargedStable &particle, const PIDPriorsTable &table)
Sets the prior table for a particle species from a PIDPriorsTable object.
Definition: PIDPriors.h:52

◆ setPriors() [4/4]

void setPriors ( const Const::ChargedStable particle,
TH2F *  priorHistogram 
)

Sets the prior table for a particle species from a TH2F.

The bin edges are taken form the TH2 axes, the prior probability from the bins content and the errors from the bins error

Parameters
particlethe charged stable type of the particle
priorHistogramthe prior for the particle specie

Definition at line 18 of file PIDPriors.cc.

19{
20 auto index = particle.getIndex();
21
22 std::vector<float> xEdges;
23 std::vector<float> yEdges;
24
25 auto& xaxis = *(priorHistogram->GetXaxis());
26 for (int i = xaxis.GetFirst(); i <= xaxis.GetLast(); ++i) {
27 xEdges.push_back(xaxis.GetBinLowEdge(i));
28 }
29 xEdges.push_back(xaxis.GetBinUpEdge(xaxis.GetLast()));
30
31 auto& yaxis = *(priorHistogram->GetYaxis());
32 for (int i = yaxis.GetFirst(); i <= yaxis.GetLast(); ++i) {
33 yEdges.push_back(yaxis.GetBinLowEdge(i));
34 }
35 yEdges.push_back(yaxis.GetBinUpEdge(yaxis.GetLast()));
36
37
38 std::vector<float> prior;
39 std::vector<float> error;
40
41 for (int ix = 0; ix < (int)xEdges.size() - 1; ix++) {
42 for (int iy = 0; iy < (int)yEdges.size() - 1; iy++) {
43 prior.push_back(priorHistogram->GetBinContent(ix + 1, iy + 1));
44 error.push_back(priorHistogram->GetBinError(ix + 1, iy + 1));
45 }
46 }
47
48 m_priors[index].setBinEdges(xEdges, yEdges);
49 m_priors[index].setPriorsTable(prior);
50 m_priors[index].setErrorsTable(error);
51
52 return;
53};
int getIndex() const
This particle's index in the associated set.
Definition: Const.h:461

◆ setPriorsAxes()

void setPriorsAxes ( const Const::ChargedStable particle,
std::vector< float >  xAxisEdges,
std::vector< float >  yAxisEdges 
)
inline

Sets the axes for the priors table of the selected species.

Effectively this is just a wrapper around PIDPriorsTable::setBinEdges()

Parameters
particlethe charged stable type of the prior's species
xAxisEdgesthe vector of edges of the X axis
yAxisEdgesthe vector of edges of the Y axis

Definition at line 107 of file PIDPriors.h.

108 {
109 auto index = particle.getIndex();
110 m_priors[index].setBinEdges(xAxisEdges, yAxisEdges);
111 m_priors[index].setBinEdges(xAxisEdges, yAxisEdges);
112 return;
113 }

◆ setPriorsTable()

void setPriorsTable ( const Const::ChargedStable particle,
std::vector< float >  priorsTable 
)
inline

Sets the probability table for the priors of the selected particle species.

Effectively this is just a wrapper around PIDPriorsTable::setPriorsTable()

Parameters
particlethe charged stable type of the prior's species
priorsTablea 2D vector containing the prior probabilities

Definition at line 122 of file PIDPriors.h.

123 {
124 auto index = particle.getIndex();
125 m_priors[index].setPriorsTable(priorsTable);
126 return;
127 }

Member Data Documentation

◆ m_priors

The array of PIDPiorsTable, one per particle species.

Definition at line 222 of file PIDPriors.h.


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