Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "CalibMuon/DTCalibration/interface/DTResidualFitter.h"
00011
00012 #include "TH1F.h"
00013 #include "TF1.h"
00014 #include "TString.h"
00015
00016 DTResidualFitter::DTResidualFitter(bool debug):debug_(debug) {}
00017
00018 DTResidualFitter::~DTResidualFitter() {}
00019
00020 DTResidualFitResult DTResidualFitter::fitResiduals(TH1F& histo, int nSigmas){
00021
00022 TString option("R");
00023 if(!debug_) option += "Q";
00024
00025 float minFit = histo.GetMean() - histo.GetRMS();
00026 float maxFit = histo.GetMean() + histo.GetRMS();
00027
00028 TString funcName = TString(histo.GetName()) + "_gaus";
00029 TF1* fitFunc = new TF1(funcName,"gaus",minFit,maxFit);
00030
00031 histo.Fit(fitFunc,option);
00032
00033 minFit = fitFunc->GetParameter(1) - nSigmas*fitFunc->GetParameter(2);
00034 maxFit = fitFunc->GetParameter(1) + nSigmas*fitFunc->GetParameter(2);
00035 fitFunc->SetRange(minFit,maxFit);
00036 histo.Fit(fitFunc,option);
00037
00038 return DTResidualFitResult( fitFunc->GetParameter(1),
00039 fitFunc->GetParError(1),
00040 fitFunc->GetParameter(2),
00041 fitFunc->GetParError(2) );
00042 }