CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

StabilizedGauss Class Reference

#include <CompMethods.h>

List of all members.

Public Member Functions

void fit (TH1F &)
double spread (TH1F &hist)
double spreadError (TH1F &hist)
 StabilizedGauss ()
 StabilizedGauss (const char *name)
 StabilizedGauss (const char *, int, double, double)
double value (TH1F &hist)
double valueError (TH1F &hist)
 ~StabilizedGauss ()

Private Member Functions

double error (TH1F &hist, int target)
double value (TH1F &hist, int target)

Private Attributes

TF1 * func_
const char * funcName_
int funcType_
double lowerBound_
double mean_
double sigma_
double upperBound_

Detailed Description

Definition at line 79 of file CompMethods.h.


Constructor & Destructor Documentation

StabilizedGauss::StabilizedGauss ( ) [inline]

Definition at line 83 of file CompMethods.h.

References func_.

{ func_=new TF1(); };
StabilizedGauss::StabilizedGauss ( const char *  name) [inline]

Definition at line 84 of file CompMethods.h.

References func_.

:funcName_(name){ func_=new TF1(); };
StabilizedGauss::StabilizedGauss ( const char *  funcName,
int  funcType,
double  lowerBound,
double  upperBound 
)

Definition at line 23 of file CompMethods.cc.

References gather_cfg::cout, func_, funcName_, funcType_, Gauss(), lowerBound_, and upperBound_.

                                                                                                        :
  funcType_  (funcType  ),
  funcName_  (funcName  ),
  lowerBound_(lowerBound),
  upperBound_(upperBound)
{
  if(funcType_==0){
    func_ = new TF1(funcName_, Gauss, lowerBound_, upperBound_, 3);  
    func_->SetParNames( "Const", "Mean", "Sigma" );
  }
  else{
    std::cout << "Sorry: not yet implemented" << std::endl;
  }
}
StabilizedGauss::~StabilizedGauss ( ) [inline]

Definition at line 86 of file CompMethods.h.

References func_.

{ delete func_;};

Member Function Documentation

double StabilizedGauss::error ( TH1F &  hist,
int  target 
) [inline, private]

Definition at line 96 of file CompMethods.h.

References funcName_.

Referenced by spreadError(), and valueError().

{ return (hist.GetFunction( funcName_) ? hist.GetFunction( funcName_)->GetParError (target) : 0.); }
void StabilizedGauss::fit ( TH1F &  hist)

Definition at line 39 of file CompMethods.cc.

References gather_cfg::cout, func_, funcType_, lowerBound_, mean_, sigma_, and upperBound_.

Referenced by FitHist::fitAndDrawEps(), and FitHist::fitAndDrawPs().

{
  //set start values for first iteration
  if(funcType_==0){
    double maxValue=hist.GetBinCenter(hist.GetMaximumBin());
    func_->SetParameter(1, maxValue);
    func_->SetParameter(2, hist.GetRMS());
  }

  //set parameter limits
  if(funcType_==0){
    func_->SetParLimits(1, lowerBound_, upperBound_);
    func_->SetParLimits(2, 0., 5.*hist.GetRMS());
  }

  //do the fit
  mean_ = func_->GetParameter(1);
  sigma_= func_->GetParameter(2);

  hist.Fit( "func", "RE0", "", (mean_-2.*sigma_), (mean_+2.*sigma_) );
  if(hist.GetFunction("func")){
    //get mean and sigma 
    //from first iteration
    mean_ = hist.GetFunction("func")->GetParameter(1);
    sigma_= hist.GetFunction("func")->GetParameter(2);

    //set start values for 
    //second iteration
    func_->SetParameter(1, mean_ );
    func_->SetParameter(2, sigma_);
    hist.Fit( func_, "MEL", "", (mean_-1.5*sigma_), (mean_+1.5*sigma_) );
  }
  else{
    std::cout << "sorry... no fit function found..." << std::endl;
  }
}
double StabilizedGauss::spread ( TH1F &  hist) [inline]

Definition at line 90 of file CompMethods.h.

References value().

Referenced by FitHist::fillTargetHistogramBin().

{ return value(hist, 2); };
double StabilizedGauss::spreadError ( TH1F &  hist) [inline]

Definition at line 91 of file CompMethods.h.

References error().

Referenced by FitHist::fillTargetHistogramBin().

{ return error(hist, 2); };
double StabilizedGauss::value ( TH1F &  hist) [inline]

Definition at line 88 of file CompMethods.h.

References value().

Referenced by FitHist::fillTargetHistogramBin(), spread(), and value().

{ return value(hist, 1); };
double StabilizedGauss::value ( TH1F &  hist,
int  target 
) [inline, private]

Definition at line 95 of file CompMethods.h.

References funcName_.

{ return (hist.GetFunction( funcName_) ? hist.GetFunction( funcName_)->GetParameter(target) : 0.); }
double StabilizedGauss::valueError ( TH1F &  hist) [inline]

Definition at line 89 of file CompMethods.h.

References error().

Referenced by FitHist::fillTargetHistogramBin().

{ return error(hist, 1); };

Member Data Documentation

TF1* StabilizedGauss::func_ [private]

Definition at line 100 of file CompMethods.h.

Referenced by fit(), StabilizedGauss(), and ~StabilizedGauss().

const char* StabilizedGauss::funcName_ [private]

Definition at line 104 of file CompMethods.h.

Referenced by error(), StabilizedGauss(), and value().

Definition at line 103 of file CompMethods.h.

Referenced by fit(), and StabilizedGauss().

double StabilizedGauss::lowerBound_ [private]

Definition at line 105 of file CompMethods.h.

Referenced by fit(), and StabilizedGauss().

double StabilizedGauss::mean_ [private]

Definition at line 101 of file CompMethods.h.

Referenced by fit().

double StabilizedGauss::sigma_ [private]

Definition at line 102 of file CompMethods.h.

Referenced by fit().

double StabilizedGauss::upperBound_ [private]

Definition at line 106 of file CompMethods.h.

Referenced by fit(), and StabilizedGauss().