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 Member Functions | Private Attributes
StabilizedGauss Class Reference

#include <CompMethods.h>

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

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

Definition at line 84 of file CompMethods.h.

References func_.

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

23  :
25  funcName_ (funcName ),
26  lowerBound_(lowerBound),
27  upperBound_(upperBound)
28 {
29  if(funcType_==0){
30  func_ = new TF1(funcName_, Gauss, lowerBound_, upperBound_, 3);
31  func_->SetParNames( "Const", "Mean", "Sigma" );
32  }
33  else{
34  std::cout << "Sorry: not yet implemented" << std::endl;
35  }
36 }
double Gauss(double *x, double *par)
Definition: fitUtilities.h:225
const char * funcName_
Definition: CompMethods.h:104
double upperBound_
Definition: CompMethods.h:106
tuple cout
Definition: gather_cfg.py:41
double lowerBound_
Definition: CompMethods.h:105
StabilizedGauss::~StabilizedGauss ( )
inline

Definition at line 86 of file CompMethods.h.

References func_.

86 { delete func_;};

Member Function Documentation

double StabilizedGauss::error ( TH1F &  hist,
int  target 
)
inlineprivate

Definition at line 96 of file CompMethods.h.

References funcName_.

Referenced by spreadError(), and valueError().

96 { return (hist.GetFunction( funcName_) ? hist.GetFunction( funcName_)->GetParError (target) : 0.); }
const char * funcName_
Definition: CompMethods.h:104
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().

40 {
41  //set start values for first iteration
42  if(funcType_==0){
43  double maxValue=hist.GetBinCenter(hist.GetMaximumBin());
44  func_->SetParameter(1, maxValue);
45  func_->SetParameter(2, hist.GetRMS());
46  }
47 
48  //set parameter limits
49  if(funcType_==0){
50  func_->SetParLimits(1, lowerBound_, upperBound_);
51  func_->SetParLimits(2, 0., 5.*hist.GetRMS());
52  }
53 
54  //do the fit
55  mean_ = func_->GetParameter(1);
56  sigma_= func_->GetParameter(2);
57 
58  hist.Fit( "func", "RE0", "", (mean_-2.*sigma_), (mean_+2.*sigma_) );
59  if(hist.GetFunction("func")){
60  //get mean and sigma
61  //from first iteration
62  mean_ = hist.GetFunction("func")->GetParameter(1);
63  sigma_= hist.GetFunction("func")->GetParameter(2);
64 
65  //set start values for
66  //second iteration
67  func_->SetParameter(1, mean_ );
68  func_->SetParameter(2, sigma_);
69  hist.Fit( func_, "MEL", "", (mean_-1.5*sigma_), (mean_+1.5*sigma_) );
70  }
71  else{
72  std::cout << "sorry... no fit function found..." << std::endl;
73  }
74 }
double upperBound_
Definition: CompMethods.h:106
tuple cout
Definition: gather_cfg.py:41
double lowerBound_
Definition: CompMethods.h:105
double StabilizedGauss::spread ( TH1F &  hist)
inline

Definition at line 90 of file CompMethods.h.

References value().

Referenced by FitHist::fillTargetHistogramBin().

90 { return value(hist, 2); };
double value(TH1F &hist)
Definition: CompMethods.h:88
double StabilizedGauss::spreadError ( TH1F &  hist)
inline

Definition at line 91 of file CompMethods.h.

References error().

Referenced by FitHist::fillTargetHistogramBin().

91 { return error(hist, 2); };
double error(TH1F &hist, int target)
Definition: CompMethods.h:96
double StabilizedGauss::value ( TH1F &  hist)
inline

Definition at line 88 of file CompMethods.h.

References value().

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

88 { return value(hist, 1); };
double value(TH1F &hist)
Definition: CompMethods.h:88
double StabilizedGauss::value ( TH1F &  hist,
int  target 
)
inlineprivate

Definition at line 95 of file CompMethods.h.

References funcName_.

95 { return (hist.GetFunction( funcName_) ? hist.GetFunction( funcName_)->GetParameter(target) : 0.); }
const char * funcName_
Definition: CompMethods.h:104
double StabilizedGauss::valueError ( TH1F &  hist)
inline

Definition at line 89 of file CompMethods.h.

References error().

Referenced by FitHist::fillTargetHistogramBin().

89 { return error(hist, 1); };
double error(TH1F &hist, int target)
Definition: CompMethods.h:96

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

int StabilizedGauss::funcType_
private

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