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.

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  }

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_.

Member Function Documentation

◆ function() [1/2]

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

Definition at line 50 of file HistoChiSquare.h.

50 { return *t_; }

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

◆ function() [2/2]

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

Definition at line 51 of file HistoChiSquare.h.

51 { return *t_; }

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

◆ numberOfBins()

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

Definition at line 41 of file HistoChiSquare.h.

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  }

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

◆ operator()()

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

Definition at line 24 of file HistoChiSquare.h.

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  }

References hltPixelTracks_cff::chi2, fit::HistoChiSquare< T >::cont_, fit::HistoChiSquare< T >::deltaX_, fit::HistoChiSquare< T >::err_, mps_fire::i, fit::HistoChiSquare< T >::nBins_, alignCSCRings::r, fit::HistoChiSquare< T >::rangeMax_, fit::HistoChiSquare< T >::rangeMin_, and fit::HistoChiSquare< T >::xMin_.

◆ setHistos()

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

Definition at line 35 of file HistoChiSquare.h.

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

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

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

◆ 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
fit::HistoChiSquare::deltaX_
double deltaX_
Definition: HistoChiSquare.h:57
mps_fire.i
i
Definition: mps_fire.py:428
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:278
fit::HistoChiSquare::xMax_
double xMax_
Definition: HistoChiSquare.h:57
DDAxes::x
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
fit::HistoChiSquare::nBins_
size_t nBins_
Definition: HistoChiSquare.h:56
fit::HistoChiSquare::cont_
std::vector< double > cont_
Definition: HistoChiSquare.h:58
fit::HistoChiSquare::rangeMax_
double rangeMax_
Definition: HistoChiSquare.h:55
fit::HistoChiSquare::rangeMin_
double rangeMin_
Definition: HistoChiSquare.h:55
fit::HistoChiSquare::t_
T * t_
Definition: HistoChiSquare.h:54
fit::HistoChiSquare::xMin_
double xMin_
Definition: HistoChiSquare.h:57
alignCSCRings.r
r
Definition: alignCSCRings.py:93
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
fit::HistoChiSquare::err_
std::vector< double > err_
Definition: HistoChiSquare.h:59