Belle II Software  release-08-01-10
Chi2MinimumFinder1D Class Reference

Minimum finder using tabulated chi^2 values in one dimension. More...

#include <Chi2MinimumFinder1D.h>

Collaboration diagram for Chi2MinimumFinder1D:

Classes

struct  Minimum
 Result of minimum finder. More...
 

Public Member Functions

 Chi2MinimumFinder1D ()
 Default constructor.
 
 Chi2MinimumFinder1D (int nbins, double xmin, double xmax)
 Class constructor, similar to 1D histogram. More...
 
 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. More...
 
Chi2MinimumFinder1Dadd (const Chi2MinimumFinder1D &other)
 Add data from another finder Finders must be defined with the same range and binning. More...
 
double getXmin () const
 Returns lower limit of search region. More...
 
double getXmax () const
 Returns upper limit of search region. More...
 
int getNbins () const
 Returns number of bins. More...
 
double getBinSize () const
 Returns bin (or step) size. More...
 
const std::vector< double > & getBinCenters () const
 Returns vector of bin centers. More...
 
const std::vector< double > & getChi2Values () const
 Returns vector of chi^2. More...
 
double getMinChi2 () const
 Returns minimum chi2 value. More...
 
int getEntries () const
 Returns number of entries (counted for bin 0) More...
 
const MinimumgetMinimum ()
 Returns parabolic minimum.
 
TH1F getHistogram (std::string name, std::string title) const
 Returns chi^2 packed into 1D histogram. More...
 

Private Member Functions

void findMinimum ()
 Finds minimum.
 
Minimum getMinimum (double yLeft, double yCenter, double yRight) const
 Calculates minimum using parabolic interpolation. More...
 

Private Attributes

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
 

Detailed Description

Minimum finder using tabulated chi^2 values in one dimension.

Definition at line 28 of file Chi2MinimumFinder1D.h.

Constructor & Destructor Documentation

◆ Chi2MinimumFinder1D()

Chi2MinimumFinder1D ( int  nbins,
double  xmin,
double  xmax 
)

Class constructor, similar to 1D histogram.

Parameters
nbinsnumber of points the search region is divided to
xminlower limit of the search region
xmaxupper limit of the search region

Definition at line 22 of file Chi2MinimumFinder1D.cc.

22  :
23  m_xmin(xmin), m_xmax(xmax)
24  {
25  if (nbins <= 0) {
26  B2ERROR("Chi2MinimumFinder1D: nbins must be positive integer");
27  return;
28  }
29  if (m_xmax <= m_xmin) {
30  B2ERROR("Chi2MinimumFinder1D: search range max < min");
31  return;
32  }
33  m_dx = (m_xmax - m_xmin) / nbins;
34  double x = m_xmin + m_dx / 2;
35  while (x < m_xmax) {
36  m_x.push_back(x);
37  x += m_dx;
38  }
39  m_chi2.resize(m_x.size(), 0);
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

Member Function Documentation

◆ add() [1/2]

Chi2MinimumFinder1D & add ( const Chi2MinimumFinder1D other)

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.

◆ add() [2/2]

void add ( unsigned  i,
double  chi2 
)

Add chi^2 value to bin i.

Parameters
ibin index (0-based)
chi2value to be added

Definition at line 62 of file Chi2MinimumFinder1D.cc.

◆ getBinCenters()

const std::vector<double>& getBinCenters ( ) const
inline

Returns vector of bin centers.

Returns
bin centers

Definition at line 121 of file Chi2MinimumFinder1D.h.

121 {return m_x;}

◆ getBinSize()

double getBinSize ( ) const
inline

Returns bin (or step) size.

Returns
bin size

Definition at line 115 of file Chi2MinimumFinder1D.h.

◆ getChi2Values()

const std::vector<double>& getChi2Values ( ) const
inline

Returns vector of chi^2.

Returns
chi^2 values

Definition at line 127 of file Chi2MinimumFinder1D.h.

◆ getEntries()

int getEntries ( ) const
inline

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
namehistogram name
titlehistogram title

Definition at line 126 of file Chi2MinimumFinder1D.cc.

◆ getMinChi2()

double getMinChi2 ( ) const
inline

Returns minimum chi2 value.

Returns
minimum chi2 value

Definition at line 134 of file Chi2MinimumFinder1D.h.

◆ getMinimum()

Chi2MinimumFinder1D::Minimum getMinimum ( double  yLeft,
double  yCenter,
double  yRight 
) const
private

Calculates minimum using parabolic interpolation.

Parameters
yLeftbin content of left-to-minimal bin
yCenterbin content of minimal bin
yRightbin 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.

◆ getNbins()

int getNbins ( ) const
inline

Returns number of bins.

Returns
number of bins

Definition at line 109 of file Chi2MinimumFinder1D.h.

◆ getXmax()

double getXmax ( ) const
inline

Returns upper limit of search region.

Returns
xmax

Definition at line 103 of file Chi2MinimumFinder1D.h.

◆ getXmin()

double getXmin ( ) const
inline

Returns lower limit of search region.

Returns
xmin

Definition at line 97 of file Chi2MinimumFinder1D.h.


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