11 #include <top/utilities/Chi2MinimumFinder1D.h>
13 #include <framework/logging/Logger.h>
25 m_xmin(xmin), m_xmax(xmax)
28 B2ERROR(
"Chi2MinimumFinder1D: nbins must be positive integer");
31 if (m_xmax <= m_xmin) {
32 B2ERROR(
"Chi2MinimumFinder1D: search range max < min");
35 m_dx = (m_xmax - m_xmin) / nbins;
36 double x = m_xmin + m_dx / 2;
41 m_chi2.resize(m_x.size(), 0);
46 m_xmin = h->GetXaxis()->GetXmin();
47 m_xmax = h->GetXaxis()->GetXmax();
48 m_dx = h->GetBinWidth(1);
49 for (
int i = 0; i < h->GetNbinsX(); i++) {
50 m_x.push_back(h->GetBinCenter(i + 1));
51 m_chi2.push_back(h->GetBinContent(i + 1));
53 m_entries = h->GetEntries() / h->GetNbinsX();
58 for (
auto& chi2 :
m_chi2) chi2 = 0;
71 B2WARNING(
"Chi2MinimumFinder1D::add: index out of range");
80 B2ERROR(
"Chi2MinimumFinder1D::add: finders with different ranges or binning "
85 for (
unsigned i = 0; i <
m_chi2.size(); i++) {
103 for (
unsigned i = i0; i <
m_chi2.size() - 1; i++) {
116 double DL = yLeft - yCenter;
117 double DR = yRight - yCenter;
118 double A = (DR + DL) / 2;
119 if (A <= 0)
return Minimum(0, 0, yCenter,
false);
120 double B = (DR - DL) / 2;
121 double x = - B / 2 / A;
122 double chi2_min = A * x * x + B * x + yCenter;
123 return Minimum(x, sqrt(1 / A), chi2_min,
true);
130 for (
unsigned i = 0; i <
m_chi2.size(); i++) {