9#include <top/utilities/Chi2MinimumFinder1D.h>
11#include <framework/logging/Logger.h>
23 m_xmin(xmin), m_xmax(xmax)
26 B2ERROR(
"Chi2MinimumFinder1D: nbins must be positive integer");
30 B2ERROR(
"Chi2MinimumFinder1D: search range max < min");
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));
51 m_entries = h->GetEntries() / h->GetNbinsX();
56 for (
auto& chi2 :
m_chi2) chi2 = 0;
69 B2WARNING(
"Chi2MinimumFinder1D::add: index out of range");
80 for (
unsigned i = 0; i <
m_chi2.size(); i++) {
86 B2ERROR(
"Chi2MinimumFinder1D::add: finders with different ranges or binning can't be added");
102 for (
unsigned i = i0; i <
m_chi2.size() - 1; i++) {
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;
129 for (
unsigned i = 0; i <
m_chi2.size(); i++) {
Minimum finder using tabulated chi^2 values in one dimension.
const std::vector< double > & getBinCenters() const
Returns vector of bin centers.
double m_xmin
lower limit of search region
void findMinimum()
Finds minimum.
TH1F getHistogram(std::string name, std::string title) const
Returns chi^2 packed into 1D histogram.
int m_entries
number of entries (counted for bin 0)
Chi2MinimumFinder1D()
Default constructor.
Minimum m_minimum
result: global minimum
bool m_searched
internal flag
void add(unsigned i, double chi2)
Add chi^2 value to bin i.
double m_xmax
upper limit of search region
int getEntries() const
Returns number of entries (counted for bin 0)
double getXmax() const
Returns upper limit of search region.
std::vector< double > m_chi2
chi^2 values at bin centers
const Minimum & getMinimum()
Returns parabolic minimum.
void clear()
Set chi^2 values to zero.
double getXmin() const
Returns lower limit of search region.
std::vector< double > m_x
bin centers
const std::vector< double > & getChi2Values() const
Returns vector of chi^2.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.
Result of minimum finder.
double error
error on the position
double chi2
chi2 at minimum
double position
position of the minimum