CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
fit::HistoChiSquare< T > Class Template Reference

#include <HistoChiSquare.h>

Public Member Functions

Tfunction ()
 
const Tfunction () const
 
 HistoChiSquare ()
 
 HistoChiSquare (T &t, TH1 *histo, double rangeMin, double rangeMax)
 
size_t numberOfBins () const
 
double operator() () const
 
void setHistos (TH1 *histo)
 

Private Attributes

std::vector< double > cont_
 
double deltaX_
 
std::vector< double > err_
 
size_t nBins_
 
double rangeMax_
 
double rangeMin_
 
Tt_
 
double xMax_
 
double xMin_
 

Detailed Description

template<typename T>
class fit::HistoChiSquare< T >

Definition at line 10 of file HistoChiSquare.h.

Constructor & Destructor Documentation

◆ HistoChiSquare() [1/2]

template<typename T>
fit::HistoChiSquare< T >::HistoChiSquare ( )
inline

Definition at line 12 of file HistoChiSquare.h.

12 {}

◆ HistoChiSquare() [2/2]

template<typename T>
fit::HistoChiSquare< T >::HistoChiSquare ( T t,
TH1 *  histo,
double  rangeMin,
double  rangeMax 
)
inline

Definition at line 13 of file HistoChiSquare.h.

References fit::HistoChiSquare< T >::cont_, fit::HistoChiSquare< T >::deltaX_, fit::HistoChiSquare< T >::err_, timingPdfMaker::histo, mps_fire::i, fit::HistoChiSquare< T >::nBins_, fit::HistoChiSquare< T >::xMax_, and fit::HistoChiSquare< T >::xMin_.

14  : t_(&t), rangeMin_(rangeMin), rangeMax_(rangeMax) {
15  nBins_ = histo->GetNbinsX();
16  xMin_ = histo->GetXaxis()->GetXmin();
17  xMax_ = histo->GetXaxis()->GetXmax();
18  deltaX_ = (xMax_ - xMin_) / nBins_;
19  for (size_t i = 0; i < nBins_; ++i) {
20  cont_.push_back(histo->GetBinContent(i + 1));
21  err_.push_back(histo->GetBinError(i + 1));
22  }
23  }
std::vector< double > cont_
std::vector< double > err_

Member Function Documentation

◆ function() [1/2]

template<typename T>
T& fit::HistoChiSquare< T >::function ( )
inline

Definition at line 50 of file HistoChiSquare.h.

References fit::HistoChiSquare< T >::t_.

50 { return *t_; }

◆ function() [2/2]

template<typename T>
const T& fit::HistoChiSquare< T >::function ( ) const
inline

Definition at line 51 of file HistoChiSquare.h.

References fit::HistoChiSquare< T >::t_.

51 { return *t_; }

◆ numberOfBins()

template<typename T>
size_t fit::HistoChiSquare< T >::numberOfBins ( ) const
inline

Definition at line 41 of file HistoChiSquare.h.

References fit::HistoChiSquare< T >::deltaX_, mps_fire::i, fit::HistoChiSquare< T >::nBins_, fit::HistoChiSquare< T >::rangeMin_, x, and fit::HistoChiSquare< T >::xMin_.

41  {
42  size_t fullBins = 0;
43  for (size_t i = 0; i < nBins_; ++i) {
44  double x = xMin_ + (i + .5) * deltaX_;
45  if ((x > rangeMin_) && (x < rangeMax_) && (err_[i] > 0))
46  fullBins++;
47  }
48  return fullBins;
49  }

◆ operator()()

template<typename T>
double fit::HistoChiSquare< T >::operator() ( ) const
inline

Definition at line 24 of file HistoChiSquare.h.

References isoTrack_cff::chi2, fit::HistoChiSquare< T >::cont_, fit::HistoChiSquare< T >::deltaX_, fit::HistoChiSquare< T >::err_, mps_fire::i, fit::HistoChiSquare< T >::nBins_, fit::HistoChiSquare< T >::rangeMin_, x, and fit::HistoChiSquare< T >::xMin_.

24  {
25  double chi2 = 0;
26  for (size_t i = 0; i < nBins_; ++i) {
27  double x = xMin_ + (i + .5) * deltaX_;
28  if ((x > rangeMin_) && (x < rangeMax_) && (err_[i] > 0)) {
29  double r = (cont_[i] - (*t_)(x)) / err_[i];
30  chi2 += (r * r);
31  }
32  }
33  return chi2;
34  }
std::vector< double > cont_
std::vector< double > err_

◆ setHistos()

template<typename T>
void fit::HistoChiSquare< T >::setHistos ( TH1 *  histo)
inline

Definition at line 35 of file HistoChiSquare.h.

References fit::HistoChiSquare< T >::deltaX_, timingPdfMaker::histo, fit::HistoChiSquare< T >::nBins_, fit::HistoChiSquare< T >::xMax_, and fit::HistoChiSquare< T >::xMin_.

35  {
36  nBins_ = histo->GetNbinsX();
37  xMin_ = histo->GetXaxis()->GetXmin();
38  xMax_ = histo->GetXaxis()->GetXmax();
39  deltaX_ = (xMax_ - xMin_) / nBins_;
40  }

Member Data Documentation

◆ cont_

template<typename T>
std::vector<double> fit::HistoChiSquare< T >::cont_
private

◆ deltaX_

template<typename T>
double fit::HistoChiSquare< T >::deltaX_
private

◆ err_

template<typename T>
std::vector<double> fit::HistoChiSquare< T >::err_
private

◆ nBins_

template<typename T>
size_t fit::HistoChiSquare< T >::nBins_
private

◆ rangeMax_

template<typename T>
double fit::HistoChiSquare< T >::rangeMax_
private

Definition at line 55 of file HistoChiSquare.h.

◆ rangeMin_

template<typename T>
double fit::HistoChiSquare< T >::rangeMin_
private

◆ t_

template<typename T>
T* fit::HistoChiSquare< T >::t_
private

Definition at line 54 of file HistoChiSquare.h.

Referenced by fit::HistoChiSquare< T >::function().

◆ xMax_

template<typename T>
double fit::HistoChiSquare< T >::xMax_
private

◆ xMin_

template<typename T>
double fit::HistoChiSquare< T >::xMin_
private