Minimum finder using tabulated chi^2 values in one dimension.
More...
#include <Chi2MinimumFinder1D.h>
|
| Chi2MinimumFinder1D () |
| Default constructor.
|
|
| Chi2MinimumFinder1D (int nbins, double xmin, double xmax) |
| Class constructor, similar to 1D histogram.
|
|
| Chi2MinimumFinder1D (const std::shared_ptr< TH1D > h) |
| Constructor from a histogram.
|
|
void | clear () |
| Set chi^2 values to zero.
|
|
void | add (unsigned i, double chi2) |
| Add chi^2 value to bin i.
|
|
Chi2MinimumFinder1D & | add (const Chi2MinimumFinder1D &other) |
| Add data from another finder Finders must be defined with the same range and binning.
|
|
double | getXmin () const |
| Returns lower limit of search region.
|
|
double | getXmax () const |
| Returns upper limit of search region.
|
|
int | getNbins () const |
| Returns number of bins.
|
|
double | getBinSize () const |
| Returns bin (or step) size.
|
|
const std::vector< double > & | getBinCenters () const |
| Returns vector of bin centers.
|
|
const std::vector< double > & | getChi2Values () const |
| Returns vector of chi^2.
|
|
double | getMinChi2 () const |
| Returns minimum chi2 value.
|
|
int | getEntries () const |
| Returns number of entries (counted for bin 0)
|
|
const Minimum & | getMinimum () |
| Returns parabolic minimum.
|
|
TH1F | getHistogram (std::string name, std::string title) const |
| Returns chi^2 packed into 1D histogram.
|
|
|
void | findMinimum () |
| Finds minimum.
|
|
Minimum | getMinimum (double yLeft, double yCenter, double yRight) const |
| Calculates minimum using parabolic interpolation.
|
|
|
double | m_xmin = 0 |
| lower limit of search region
|
|
double | m_xmax = 0 |
| upper limit of search region
|
|
double | m_dx = 0 |
| bin size
|
|
std::vector< double > | m_x |
| bin centers
|
|
std::vector< double > | m_chi2 |
| chi^2 values at bin centers
|
|
int | m_entries = 0 |
| number of entries (counted for bin 0)
|
|
bool | m_searched = false |
| internal flag
|
|
Minimum | m_minimum |
| result: global minimum
|
|
Minimum finder using tabulated chi^2 values in one dimension.
Definition at line 28 of file Chi2MinimumFinder1D.h.
◆ Chi2MinimumFinder1D() [1/3]
◆ Chi2MinimumFinder1D() [2/3]
Class constructor, similar to 1D histogram.
- Parameters
-
nbins | number of points the search region is divided to |
xmin | lower limit of the search region |
xmax | upper limit of the search region |
Definition at line 22 of file Chi2MinimumFinder1D.cc.
22 :
24 {
25 if (nbins <= 0) {
26 B2ERROR("Chi2MinimumFinder1D: nbins must be positive integer");
27 return;
28 }
30 B2ERROR("Chi2MinimumFinder1D: search range max < min");
31 return;
32 }
38 }
40 }
double m_xmin
lower limit of search region
double m_xmax
upper limit of search region
std::vector< double > m_chi2
chi^2 values at bin centers
std::vector< double > m_x
bin centers
◆ Chi2MinimumFinder1D() [3/3]
Constructor from a histogram.
Definition at line 42 of file Chi2MinimumFinder1D.cc.
43 {
44 m_xmin = h->GetXaxis()->GetXmin();
45 m_xmax = h->GetXaxis()->GetXmax();
46 m_dx = h->GetBinWidth(1);
47 for (int i = 0; i < h->GetNbinsX(); i++) {
48 m_x.push_back(h->GetBinCenter(i + 1));
49 m_chi2.push_back(h->GetBinContent(i + 1));
50 }
51 m_entries = h->GetEntries() / h->GetNbinsX();
52 }
int m_entries
number of entries (counted for bin 0)
◆ add() [1/2]
Add data from another finder Finders must be defined with the same range and binning.
- Returns
- a reference to this finder
Definition at line 74 of file Chi2MinimumFinder1D.cc.
75 {
77 *this = other;
78 }
else if (other.getBinCenters().size() ==
m_x.size() and other.getXmin() ==
m_xmin and other.getXmax() ==
m_xmax) {
79 const auto& chi2 = other.getChi2Values();
80 for (
unsigned i = 0; i <
m_chi2.size(); i++) {
82 }
85 } else {
86 B2ERROR("Chi2MinimumFinder1D::add: finders with different ranges or binning can't be added");
87 }
88
89 return *this;
90 }
bool m_searched
internal flag
◆ add() [2/2]
void add |
( |
unsigned |
i, |
|
|
double |
chi2 |
|
) |
| |
Add chi^2 value to bin i.
- Parameters
-
i | bin index (0-based) |
chi2 | value to be added |
Definition at line 62 of file Chi2MinimumFinder1D.cc.
63 {
68 } else {
69 B2WARNING("Chi2MinimumFinder1D::add: index out of range");
70 }
71 }
◆ clear()
◆ findMinimum()
Finds minimum.
Definition at line 93 of file Chi2MinimumFinder1D.cc.
94 {
98 return;
99 }
100
101 unsigned i0 = 1;
102 for (
unsigned i = i0; i <
m_chi2.size() - 1; i++) {
104 }
107 }
Minimum m_minimum
result: global minimum
const Minimum & getMinimum()
Returns parabolic minimum.
double error
error on the position
double position
position of the minimum
◆ getBinCenters()
const std::vector< double > & getBinCenters |
( |
| ) |
const |
|
inline |
◆ getBinSize()
double getBinSize |
( |
| ) |
const |
|
inline |
◆ getChi2Values()
const std::vector< double > & getChi2Values |
( |
| ) |
const |
|
inline |
◆ getEntries()
Returns number of entries (counted for bin 0)
- Returns
- number of entries
Definition at line 140 of file Chi2MinimumFinder1D.h.
◆ getHistogram()
TH1F getHistogram |
( |
std::string |
name, |
|
|
std::string |
title |
|
) |
| const |
Returns chi^2 packed into 1D histogram.
- Parameters
-
name | histogram name |
title | histogram title |
Definition at line 126 of file Chi2MinimumFinder1D.cc.
127 {
129 for (
unsigned i = 0; i <
m_chi2.size(); i++) {
131 }
132 return h;
133 }
double chi2
chi2 at minimum
◆ getMinChi2()
double getMinChi2 |
( |
| ) |
const |
|
inline |
◆ getMinimum() [1/2]
Returns parabolic minimum.
Definition at line 145 of file Chi2MinimumFinder1D.h.
146 {
150 }
152 }
void findMinimum()
Finds minimum.
◆ getMinimum() [2/2]
Calculates minimum using parabolic interpolation.
- Parameters
-
yLeft | bin content of left-to-minimal bin |
yCenter | bin content of minimal bin |
yRight | bin content of right-to-minimal bin |
- Returns
- minimum given as a fraction of step to be added to central bin position
Definition at line 110 of file Chi2MinimumFinder1D.cc.
113 {
114
115 double DL = yLeft - yCenter;
116 double DR = yRight - yCenter;
117 double A = (DR + DL) / 2;
118 if (A <= 0) return Minimum(0, 0, yCenter, false);
119 double B = (DR - DL) / 2;
120 double x = - B / 2 / A;
121 double chi2_min = A * x * x + B * x + yCenter;
122 return Minimum(x,
sqrt(1 / A), chi2_min,
true);
123 }
double sqrt(double a)
sqrt for double
◆ getNbins()
◆ getXmax()
◆ getXmin()
◆ m_chi2
std::vector<double> m_chi2 |
|
private |
◆ m_dx
◆ m_entries
◆ m_minimum
◆ m_searched
◆ m_x
◆ m_xmax
◆ m_xmin
The documentation for this class was generated from the following files: