CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

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

Definition at line 12 of file HistoChiSquare.h.

12 { }
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_, i, fit::HistoChiSquare< T >::nBins_, fit::HistoChiSquare< T >::xMax_, and fit::HistoChiSquare< T >::xMin_.

13  :
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  }
int i
Definition: DBlmapReader.cc:9
std::vector< double > cont_
std::vector< double > err_

Member Function Documentation

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_; }
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_; }
template<typename T>
size_t fit::HistoChiSquare< T >::numberOfBins ( ) const
inline

Definition at line 41 of file HistoChiSquare.h.

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

Referenced by fit::RootMinuitResultPrinter< HistoChiSquare< T > >::print().

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  }
int i
Definition: DBlmapReader.cc:9
template<typename T>
double fit::HistoChiSquare< T >::operator() ( ) const
inline

Definition at line 24 of file HistoChiSquare.h.

References beam_dqm_sourceclient-live_cfg::chi2, fit::HistoChiSquare< T >::cont_, fit::HistoChiSquare< T >::deltaX_, fit::HistoChiSquare< T >::err_, i, fit::HistoChiSquare< T >::nBins_, alignCSCRings::r, 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  }
int i
Definition: DBlmapReader.cc:9
std::vector< double > cont_
std::vector< double > err_
template<typename T>
void fit::HistoChiSquare< T >::setHistos ( TH1 *  histo)
inline

Definition at line 35 of file HistoChiSquare.h.

References fit::HistoChiSquare< T >::deltaX_, 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

template<typename T>
std::vector<double> fit::HistoChiSquare< T >::cont_
private
template<typename T>
double fit::HistoChiSquare< T >::deltaX_
private
template<typename T>
std::vector<double> fit::HistoChiSquare< T >::err_
private
template<typename T>
size_t fit::HistoChiSquare< T >::nBins_
private
template<typename T>
double fit::HistoChiSquare< T >::rangeMax_
private

Definition at line 54 of file HistoChiSquare.h.

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

Definition at line 53 of file HistoChiSquare.h.

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

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