#include <HDQMfitUtilities.h>
Public Member Functions | |
double | doGaussFit (MonitorElement *ME) |
double | doGaussFit (TH1F *) |
double | doLanGaussFit (TH1F *) |
double | doLanGaussFit (MonitorElement *ME) |
double | getFitChi () |
int | getFitnDof () |
double | getGaussPar (std::string s) |
double | getGaussParErr (std::string s) |
double | getLanGaussConv (std::string s) |
double | getLanGaussPar (std::string s) |
double | getLanGaussParErr (std::string s) |
HDQMfitUtilities () | |
void | init () |
~HDQMfitUtilities () | |
Private Attributes | |
double | chi2GausS |
double | epGausS [3] |
double | epLanGausS [4] |
TF1 * | gausFit |
TF1 * | langausFit |
int32_t | nDofGausS |
double | pGausS [3] |
double | pLanConv [2] |
double | pLanGausS [4] |
Definition at line 29 of file HDQMfitUtilities.h.
HDQMfitUtilities::HDQMfitUtilities | ( | ) |
Definition at line 178 of file HDQMfitUtilities.cc.
References init().
:langausFit(0),gausFit(0){ init(); }
HDQMfitUtilities::~HDQMfitUtilities | ( | ) |
Definition at line 198 of file HDQMfitUtilities.cc.
References gausFit, and langausFit.
{ if ( langausFit!=0 ) delete langausFit; if ( gausFit!=0 ) delete gausFit; }
double HDQMfitUtilities::doGaussFit | ( | MonitorElement * | ME | ) | [inline] |
Definition at line 40 of file HDQMfitUtilities.h.
References doGaussFit(), and MonitorElement::getTH1F().
Referenced by doGaussFit(), and DQMHistoryServiceBase::setDBValuesForGauss().
{return doGaussFit(ME->getTH1F());}
double HDQMfitUtilities::doGaussFit | ( | TH1F * | htoFit | ) |
Definition at line 290 of file HDQMfitUtilities.cc.
References chi2GausS, epGausS, gausFit, HDQMUtil::Gauss(), i, init(), langausFit, nDofGausS, and pGausS.
{ init(); // if (htoFit->GetEntries()!=0) { if (htoFit->Integral()!=0) { // Setting fit range and start values double fr[2]; double sv[3], pllo[3], plhi[3]; fr[0]=htoFit->GetMean()-5*htoFit->GetRMS(); fr[1]=htoFit->GetMean()+5*htoFit->GetRMS(); int32_t imax=htoFit->GetMaximumBin(); double xmax=htoFit->GetBinCenter(imax); double ymax=htoFit->GetBinContent(imax); int32_t i[2]; int32_t iArea[2]; i[0]=htoFit->GetXaxis()->FindBin(fr[0]); i[1]=htoFit->GetXaxis()->FindBin(fr[1]); iArea[0]=htoFit->GetXaxis()->FindBin(fr[0]); iArea[1]=htoFit->GetXaxis()->FindBin(fr[1]); double AreaFWHM=htoFit->Integral(iArea[0],iArea[1],"width"); sv[2]=AreaFWHM/(4*ymax); sv[1]=xmax; sv[0]=htoFit->Integral(i[0],i[1],"width"); plhi[0]=1000000.0; plhi[1]=10.0; plhi[2]=10.; pllo[0]=1.5 ; pllo[1]=0.1; pllo[2]=0.3; Char_t FunName[100]; sprintf(FunName,"FitfcnLG_%s",htoFit->GetName()); gausFit = new TF1(FunName,HDQMUtil::Gauss,fr[0],fr[1],3); gausFit->SetParameters(sv); gausFit->SetParNames("Constant","GaussPeak","Sigma"); for (int32_t i=0; i<3; i++) { gausFit->SetParLimits(i,pllo[i],plhi[i]); } try{ htoFit->Fit(gausFit,"R0"); gausFit->SetRange(fr[0],fr[1]); gausFit->GetParameters(pGausS); std::memcpy((void*) epGausS, (void*) gausFit->GetParErrors(), 3*sizeof(double)); chi2GausS =langausFit->GetChisquare(); // obtain chi^2 nDofGausS = langausFit->GetNDF();// obtain ndf } catch(...){ edm::LogError("fitUtility") << "problem in fitting " << htoFit->GetTitle() << " \n\tDefault values of the parameters will be used"; pGausS[0]=-9999; pGausS[1]=-9999; pGausS[2]=-9999; epGausS[0]=-9999; epGausS[1]=-9999; epGausS[2]=-9999; chi2GausS=-9999; nDofGausS=-9999; } } else { pGausS[0]=-9999; pGausS[1]=-9999; pGausS[2]=-9999; epGausS[0]=-9999; epGausS[1]=-9999; epGausS[2]=-9999; chi2GausS=-9999; nDofGausS=-9999; } return htoFit->GetEntries(); }
double HDQMfitUtilities::doLanGaussFit | ( | MonitorElement * | ME | ) | [inline] |
Definition at line 37 of file HDQMfitUtilities.h.
References doLanGaussFit(), and MonitorElement::getTH1F().
Referenced by doLanGaussFit(), and DQMHistoryServiceBase::setDBValuesForLandau().
{return doLanGaussFit(ME->getTH1F());}
double HDQMfitUtilities::doLanGaussFit | ( | TH1F * | htoFit | ) |
Definition at line 206 of file HDQMfitUtilities.cc.
References chi2GausS, epLanGausS, i, init(), HDQMUtil::langaufun(), langaupro(), langausFit, nDofGausS, pLanConv, and pLanGausS.
{ init(); // if (htoFit->GetEntries()!=0) { // Check for the entries excluding over/underflows if (htoFit->Integral()!=0) { edm::LogInfo("fitUtility")<<"Fitting "<< htoFit->GetTitle() <<std::endl; // Setting fit range and start values double fr[2]; double sv[4], pllo[4], plhi[4]; fr[0]=0.5*htoFit->GetMean(); fr[1]=3.0*htoFit->GetMean(); // (EM) parameters setting good for signal only int32_t imax=htoFit->GetMaximumBin(); double xmax=htoFit->GetBinCenter(imax); double ymax=htoFit->GetBinContent(imax); int32_t i[2]; int32_t iArea[2]; i[0]=htoFit->GetXaxis()->FindBin(fr[0]); i[1]=htoFit->GetXaxis()->FindBin(fr[1]); iArea[0]=htoFit->GetXaxis()->FindBin(fr[0]); iArea[1]=htoFit->GetXaxis()->FindBin(fr[1]); double AreaFWHM=htoFit->Integral(iArea[0],iArea[1],"width"); sv[1]=xmax; sv[2]=htoFit->Integral(i[0],i[1],"width"); sv[3]=AreaFWHM/(4*ymax); sv[0]=sv[3]; plhi[0]=25.0; plhi[1]=200.0; plhi[2]=1000000.0; plhi[3]=50.0; pllo[0]=1.5 ; pllo[1]=10.0 ; pllo[2]=1.0 ; pllo[3]= 1.0; Char_t FunName[100]; sprintf(FunName,"FitfcnLG_%s",htoFit->GetName()); langausFit = new TF1(FunName,HDQMUtil::langaufun,fr[0],fr[1],4); langausFit->SetParameters(sv); langausFit->SetParNames("Width","MP","Area","GSigma"); for (int32_t i=0; i<4; i++) { langausFit->SetParLimits(i,pllo[i],plhi[i]); } try{ htoFit->Fit(langausFit,"R0"); // "R" fit in a range,"0" quiet fit langausFit->SetRange(fr[0],fr[1]); langausFit->GetParameters(pLanGausS); std::memcpy((void*) epLanGausS, (void*) langausFit->GetParErrors(), 4*sizeof(double)); chi2GausS =langausFit->GetChisquare(); // obtain chi^2 nDofGausS = langausFit->GetNDF(); // obtain ndf double sPeak, sFWHM; HDQMUtil::langaupro(pLanGausS,sPeak,sFWHM); pLanConv[0]=sPeak; pLanConv[1]=sFWHM; edm::LogInfo("fitUtility") << "langaupro: max " << sPeak << std::endl; edm::LogInfo("fitUtility") << "langaupro: FWHM " << sFWHM << std::endl; } catch(...){ edm::LogError("fitUtility") << "problem in fitting " << htoFit->GetTitle() << " \n\tDefault values of the parameters will be used"; pLanGausS[0]=-9999; pLanGausS[1]=-9999; pLanGausS[2]=-9999; pLanGausS[3]=-9999; epLanGausS[0]=-9999; epLanGausS[1]=-9999; epLanGausS[2]=-9999; epLanGausS[3]=-9999; pLanConv[0]=-9999; pLanConv[1]=-9999; chi2GausS=-9999; nDofGausS=-9999; } } else { pLanGausS[0]=-9999; pLanGausS[1]=-9999; pLanGausS[2]=-9999; pLanGausS[3]=-9999; epLanGausS[0]=-9999; epLanGausS[1]=-9999; epLanGausS[2]=-9999; epLanGausS[3]=-9999; pLanConv[0]=-9999; pLanConv[1]=-9999; chi2GausS=-9999; nDofGausS=-9999; } return htoFit->GetEntries(); }
double HDQMfitUtilities::getFitChi | ( | ) | [inline] |
Definition at line 50 of file HDQMfitUtilities.h.
References chi2GausS.
Referenced by DQMHistoryServiceBase::setDBValuesForGauss(), and DQMHistoryServiceBase::setDBValuesForLandau().
{return chi2GausS;}
int HDQMfitUtilities::getFitnDof | ( | ) | [inline] |
Definition at line 51 of file HDQMfitUtilities.h.
References nDofGausS.
Referenced by DQMHistoryServiceBase::setDBValuesForGauss(), and DQMHistoryServiceBase::setDBValuesForLandau().
{return nDofGausS;}
double HDQMfitUtilities::getGaussPar | ( | std::string | s | ) |
Definition at line 393 of file HDQMfitUtilities.cc.
References pGausS.
Referenced by DQMHistoryServiceBase::setDBValuesForGauss().
double HDQMfitUtilities::getGaussParErr | ( | std::string | s | ) |
double HDQMfitUtilities::getLanGaussConv | ( | std::string | s | ) |
Definition at line 384 of file HDQMfitUtilities.cc.
References pLanConv.
Referenced by DQMHistoryServiceBase::setDBValuesForLandau().
double HDQMfitUtilities::getLanGaussPar | ( | std::string | s | ) |
Definition at line 358 of file HDQMfitUtilities.cc.
References pLanGausS.
Referenced by DQMHistoryServiceBase::setDBValuesForLandau().
double HDQMfitUtilities::getLanGaussParErr | ( | std::string | s | ) |
Definition at line 371 of file HDQMfitUtilities.cc.
References epLanGausS.
Referenced by DQMHistoryServiceBase::setDBValuesForLandau().
{ if(s=="landau_width") return epLanGausS[0]; else if(s=="mpv") return epLanGausS[1]; else if(s=="area") return epLanGausS[2]; else if(s=="gauss_sigma") return epLanGausS[3]; else return -99999; }
void HDQMfitUtilities::init | ( | void | ) |
Definition at line 183 of file HDQMfitUtilities.cc.
References chi2GausS, epGausS, epLanGausS, nDofGausS, pGausS, pLanConv, and pLanGausS.
Referenced by doGaussFit(), doLanGaussFit(), and HDQMfitUtilities().
{ pLanGausS[0]=0 ; pLanGausS[1]=0; pLanGausS[2]=0; pLanGausS[3]=0; epLanGausS[0]=0; epLanGausS[1]=0; epLanGausS[2]=0; epLanGausS[3]=0; pGausS[0]=0 ; pGausS[1]=0; pGausS[2]=0; epGausS[0]=0; epGausS[1]=0; epGausS[2]=0; pLanConv[0]=0; pLanConv[1]=0; //if ( langausFit!=0 ) delete langausFit; //if ( gausFit!=0 ) delete gausFit; chi2GausS = -9999.; nDofGausS = -9999; }
double HDQMfitUtilities::chi2GausS [private] |
Definition at line 58 of file HDQMfitUtilities.h.
Referenced by doGaussFit(), doLanGaussFit(), getFitChi(), and init().
double HDQMfitUtilities::epGausS[3] [private] |
Definition at line 56 of file HDQMfitUtilities.h.
Referenced by doGaussFit(), getGaussParErr(), and init().
double HDQMfitUtilities::epLanGausS[4] [private] |
Definition at line 55 of file HDQMfitUtilities.h.
Referenced by doLanGaussFit(), getLanGaussParErr(), and init().
TF1* HDQMfitUtilities::gausFit [private] |
Definition at line 61 of file HDQMfitUtilities.h.
Referenced by doGaussFit(), and ~HDQMfitUtilities().
TF1* HDQMfitUtilities::langausFit [private] |
Definition at line 60 of file HDQMfitUtilities.h.
Referenced by doGaussFit(), doLanGaussFit(), and ~HDQMfitUtilities().
int32_t HDQMfitUtilities::nDofGausS [private] |
Definition at line 59 of file HDQMfitUtilities.h.
Referenced by doGaussFit(), doLanGaussFit(), getFitnDof(), and init().
double HDQMfitUtilities::pGausS[3] [private] |
Definition at line 56 of file HDQMfitUtilities.h.
Referenced by doGaussFit(), getGaussPar(), and init().
double HDQMfitUtilities::pLanConv[2] [private] |
Definition at line 57 of file HDQMfitUtilities.h.
Referenced by doLanGaussFit(), getLanGaussConv(), and init().
double HDQMfitUtilities::pLanGausS[4] [private] |
Definition at line 55 of file HDQMfitUtilities.h.
Referenced by doLanGaussFit(), getLanGaussPar(), and init().