Belle II Software light-2406-ragdoll
PIDPriorsTable.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <vector>
12#include <string>
13
14namespace Belle2 {
28
29 public:
30
37 void setBinEdges(const std::vector<float>& binEdgesX, const std::vector<float>& binEdgesY);
38
39
44 void setPriorsTable(const std::vector<float>& priors)
45 {
46 m_priors = priors;
47 return;
48 };
49
50
55 void setErrorsTable(const std::vector<float>& errors)
56 {
57 m_errors = errors;
58 return;
59 };
60
61
68 void setPriorValue(float x, float y, float value);
69
70
77 void setErrorValue(float x, float y, float value);
78
79
85 void setAxisLabels(const std::string& labelX, const std::string& labelY)
86 {
87 m_xAxisLabel = labelX;
88 m_yAxisLabel = labelY;
89 return ;
90 }
91
92
99 float getPriorInBin(int iX, int iY) const
100 {
101 return m_priors[iX + (m_binEdgesX.size() - 1) * iY];
102 };
103
104
111 float getErrorInBin(int iX, int iY) const
112 {
113 return m_errors[iX + (m_binEdgesX.size() - 1) * iY];
114 };
115
116
123 float getPriorValue(float x, float y) const;
124
125
132 float getErrorValue(float x, float y) const;
133
134
139 std::string getXAxisLabel() const
140 {
141 return m_xAxisLabel;
142 };
143
148 std::string getYAxisLabel() const
149 {
150 return m_yAxisLabel;
151 };
152
153
157 void printPrior() const;
158
162 void printError() const;
163
164
165 private:
166
167 std::vector<float> m_binEdgesX = {};
168 std::vector<float> m_binEdgesY = {};
169 std::vector<float> m_priors;
170 std::vector<float> m_errors;
171 std::string m_xAxisLabel = "" ;
172 std::string m_yAxisLabel = "" ;
182 bool checkRange(const std::string& text, float val, const std::vector<float>& edges) const;
183
190 short findBin(float val, std::vector<float> array) const;
191
202 // cppcheck-suppress unusedPrivateFunction
203 short findBinFast(float val, std::vector<float> array) const;
204
212 // cppcheck-suppress unusedPrivateFunction
213 short findBinWithFixedWidth(float val, std::vector<float> array) const;
214
215
216 };
218} // Belle2 namespace
This class holds the prior distribution for a single particle species.
void setErrorsTable(const std::vector< float > &errors)
Sets the priors error table from a 2D std::vector.
void printPrior() const
Prints the content of the table and the axes.
std::vector< float > m_errors
The matrix with the errors on the prior probabilities.
std::vector< float > m_binEdgesY
The array containing the bin edges for the Y axis.
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.
void setBinEdges(const std::vector< float > &binEdgesX, const std::vector< float > &binEdgesY)
Sets the bin edges arrays.
std::vector< float > m_priors
The matrix with the prior probabilities.
float getPriorValue(float x, float y) const
Returns the prior probability for a given value of (x,y).
std::string m_yAxisLabel
label of the Y axis, indicating which variable is represented here
std::string getXAxisLabel() const
Returns the X axis label.
void setPriorValue(float x, float y, float value)
Sets the prior value for a single bin.
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 sho...
std::string m_xAxisLabel
label of the X axis, indicating which variable is represented here
void printError() const
Prints the content of the error table and the axes.
float getErrorValue(float x, float y) const
Returns the error on the prior probability for a given value of (x,y).
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 latt...
std::vector< float > m_binEdgesX
The array containing the bin edges for the X axis.
void setPriorsTable(const std::vector< float > &priors)
Sets the priors table from a 2D std::vector.
std::string getYAxisLabel() const
Returns the Y axis label.
void setAxisLabels(const std::string &labelX, const std::string &labelY)
Sets axes labels.
void setErrorValue(float x, float y, float value)
Sets the error on the prior value for a single bin.
float getPriorInBin(int iX, int iY) const
Returns the prior probability for a given bin.
short findBin(float val, std::vector< float > array) const
This function returns the position of a number in a sorted array of bin edges.
float getErrorInBin(int iX, int iY) const
Returns the error on prior probability for a given bin.
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24