CMS 3D CMS Logo

Public Member Functions | Private Attributes

fit::HistoChiSquare< T > Class Template Reference

#include <HistoChiSquare.h>

List of all members.

Public Member Functions

Tfunction ()
const Tfunction () const
 HistoChiSquare (T &t, TH1 *histo, double rangeMin, double rangeMax)
 HistoChiSquare ()
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.

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

                                                                       : 
      t_(&t), rangeMin_(rangeMin), rangeMax_(rangeMax) { 
      nBins_ = histo->GetNbinsX();
      xMin_ = histo->GetXaxis()->GetXmin();
      xMax_ = histo->GetXaxis()->GetXmax();
      deltaX_ =(xMax_ - xMin_) / nBins_;
      for(size_t i = 0; i < nBins_; ++i) { 
        cont_.push_back( histo->GetBinContent(i+1) );
        err_.push_back( histo->GetBinError(i+1) );
      }
    }

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

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

{ 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().

                                {
      size_t fullBins = 0;
      for(size_t i = 0; i < nBins_; ++i) { 
        double x = xMin_ + ( i +.5 ) * deltaX_;
        if((x > rangeMin_)&&(x < rangeMax_)&&(err_[i] > 0))  
          fullBins++;
      }
      return fullBins; 
    }
template<typename T>
double fit::HistoChiSquare< T >::operator() ( ) const [inline]

Definition at line 24 of file HistoChiSquare.h.

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

                              { 
      double chi2 = 0;
      for(size_t i = 0; i < nBins_; ++i) { 
        double x = xMin_ + ( i +.5 ) * deltaX_;
        if((x > rangeMin_)&&(x < rangeMax_)&&(err_[i] > 0)) { 
          double r = ( cont_[i] - (*t_)(x) )/err_[i];
          chi2 += (r * r);
        }
      }
     return chi2;
    }
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_.

                               { 
      nBins_ = histo->GetNbinsX();
      xMin_ = histo->GetXaxis()->GetXmin();
      xMax_ = histo->GetXaxis()->GetXmax();
      deltaX_ =(xMax_ - xMin_) / nBins_;
    }

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]