CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
DTResidualFitter Class Reference

#include <DTResidualFitter.h>

Public Member Functions

 DTResidualFitter (bool debug=false)
 
DTResidualFitResult fitResiduals (TH1F &histo, int nSigmas=1)
 
 ~DTResidualFitter ()
 

Private Attributes

bool debug_
 

Detailed Description

Definition at line 23 of file DTResidualFitter.h.

Constructor & Destructor Documentation

DTResidualFitter::DTResidualFitter ( bool  debug = false)

Definition at line 15 of file DTResidualFitter.cc.

15 :debug_(debug) {}
#define debug
Definition: HDRShower.cc:19
DTResidualFitter::~DTResidualFitter ( )

Definition at line 17 of file DTResidualFitter.cc.

17 {}

Member Function Documentation

DTResidualFitResult DTResidualFitter::fitResiduals ( TH1F &  histo,
int  nSigmas = 1 
)

Definition at line 19 of file DTResidualFitter.cc.

References debug_, and TSGForRoadSearch_cfi::option.

Referenced by dtCalibration::DTVDriftSegment::compute().

19  {
20 
21  TString option("R");
22  if(!debug_) option += "Q";
23 
24  float under = histo.GetBinContent(0)/histo.GetEntries();
25  float over = histo.GetBinContent(histo.GetNbinsX()+1)/histo.GetEntries();
26  float minFit = histo.GetMean() - histo.GetRMS();
27  float maxFit = histo.GetMean() + histo.GetRMS();
28 
29  if ((under>0.1) || (over>0.1))
30  edm::LogError("DTResidualFitter") << "WARNING in histogram: " << histo.GetName() << "\n"
31  << " entries: " << histo.GetEntries() << "\n"
32  << " underflow: " << under*100. << "% \n"
33  << " overflow: " << over*100. << "%";
34 
35  TString funcName = TString(histo.GetName()) + "_gaus";
36  TF1* fitFunc = new TF1(funcName,"gaus",minFit,maxFit);
37 
38  histo.Fit(fitFunc,option);
39 
40  minFit = fitFunc->GetParameter(1) - nSigmas*fitFunc->GetParameter(2);
41  maxFit = fitFunc->GetParameter(1) + nSigmas*fitFunc->GetParameter(2);
42  fitFunc->SetRange(minFit,maxFit);
43  histo.Fit(fitFunc,option);
44 
45  return DTResidualFitResult( fitFunc->GetParameter(1),
46  fitFunc->GetParError(1),
47  fitFunc->GetParameter(2),
48  fitFunc->GetParError(2) );
49 }

Member Data Documentation

bool DTResidualFitter::debug_
private

Definition at line 31 of file DTResidualFitter.h.

Referenced by fitResiduals().