#include <GenericTnPFitter.h>
Public Member Functions | |
AbstractFitter (bool verbose_=false) | |
TString | calculateEfficiency (TH3 *pass, TH3 *all, int massDimension, TProfile2D *&eff, TProfile2D *&effChi2, TString plotName="") |
TString | calculateEfficiency (TH2 *pass, TH2 *all, int massDimension, TProfile *&eff, TProfile *&effChi2, TString plotName="") |
virtual void | fit (TH1 *num, TH1 *den)=0 |
double | getChi2 () |
double | getEfficiency () |
double | getEfficiencyError () |
void | savePlot (TString name) |
void | setup (double expectedMean_, double massLow, double massHigh, double expectedSigma_) |
virtual | ~AbstractFitter () |
Protected Attributes | |
RooCategory | category |
double | chi2 |
RooDataHist * | data |
RooRealVar | efficiency |
double | expectedMean |
double | expectedSigma |
RooRealVar | mass |
RooRealVar | mean |
RooRealVar | nBackgroundFail |
RooRealVar | nBackgroundPass |
RooRealVar | nSignalAll |
RooFormulaVar | nSignalFail |
RooFormulaVar | nSignalPass |
RooRealVar | sigma |
RooSimultaneous | simPdf |
bool | verbose |
Definition at line 23 of file GenericTnPFitter.h.
dqmTnP::AbstractFitter::AbstractFitter | ( | bool | verbose_ = false | ) | [inline] |
Definition at line 43 of file GenericTnPFitter.h.
: mass("mass","mass",0.,100.,"GeV"), mean("mean","mean",0.,100.,"GeV"), sigma("sigma","sigma",0.,100.,"GeV"), efficiency("efficiency","efficiency",0.5,0.0,1.0), nSignalAll("nSignalAll","nSignalAll",0.,1e10), nSignalPass("nSignalPass","nSignalAll*efficiency",RooArgList(nSignalAll,efficiency)), nSignalFail("nSignalFail","nSignalAll*(1-efficiency)",RooArgList(nSignalAll,efficiency)), nBackgroundFail("nBackgroundFail","nBackgroundFail",0.,1e10), nBackgroundPass("nBackgroundPass","nBackgroundPass",0.,1e10), category("category","category"), simPdf("simPdf","simPdf",category), data(0), verbose(verbose_) { //turn on/off default messaging of roofit RooMsgService::instance().setSilentMode( !verbose?kTRUE:kFALSE ); for(int i=0; i<RooMsgService::instance().numStreams(); i++){ RooMsgService::instance().setStreamStatus( i, verbose?kTRUE:kFALSE ); } category.defineType("pass"); category.defineType("fail"); };
virtual dqmTnP::AbstractFitter::~AbstractFitter | ( | ) | [inline, virtual] |
Definition at line 66 of file GenericTnPFitter.h.
{};
TString dqmTnP::AbstractFitter::calculateEfficiency | ( | TH3 * | pass, |
TH3 * | all, | ||
int | massDimension, | ||
TProfile2D *& | eff, | ||
TProfile2D *& | effChi2, | ||
TString | plotName = "" |
||
) | [inline] |
Definition at line 90 of file GenericTnPFitter.h.
References fit(), getChi2(), getEfficiency(), getEfficiencyError(), getHLTprescales::index, mass, savePlot(), and mathSSE::sqrt().
{ //sort out the TAxis TAxis *par1Axis, *par2Axis, *massAxis; int par1C, par2C, massC; if(massDimension==1){ massAxis = all->GetXaxis(); massC = 1; par1Axis = all->GetYaxis(); par1C = all->GetXaxis()->GetNbins()+2; par2Axis = all->GetZaxis(); par2C = (all->GetXaxis()->GetNbins()+2)*(all->GetYaxis()->GetNbins()+2); }else if(massDimension==2){ par1Axis = all->GetXaxis(); par1C = 1; massAxis = all->GetYaxis(); massC = all->GetXaxis()->GetNbins()+2; par2Axis = all->GetZaxis(); par2C = (all->GetXaxis()->GetNbins()+2)*(all->GetYaxis()->GetNbins()+2); }else if(massDimension==3){ par1Axis = all->GetXaxis(); par1C = 1; par2Axis = all->GetYaxis(); par2C = all->GetXaxis()->GetNbins()+2; massAxis = all->GetZaxis(); massC = (all->GetXaxis()->GetNbins()+2)*(all->GetYaxis()->GetNbins()+2); }else{ return "massDimension > 3 !, skipping..."; } //create eff and effChi2 TProfiles if(!par1Axis || !par2Axis) return "No par1Axis or par2Axis!"; if( par1Axis->GetXbins()->GetSize()==0 && par2Axis->GetXbins()->GetSize()==0 ){ eff = new TProfile2D("efficiency","efficiency",par1Axis->GetNbins(),par1Axis->GetXmin(),par1Axis->GetXmax(),par2Axis->GetNbins(),par2Axis->GetXmin(),par2Axis->GetXmax()); }else if( par1Axis->GetXbins()->GetSize()==0 ){ eff = new TProfile2D("efficiency","efficiency",par1Axis->GetNbins(),par1Axis->GetXmin(),par1Axis->GetXmax(),par2Axis->GetNbins(),par2Axis->GetXbins()->GetArray()); }else if( par2Axis->GetXbins()->GetSize()==0 ){ eff = new TProfile2D("efficiency","efficiency",par1Axis->GetNbins(),par1Axis->GetXbins()->GetArray(),par2Axis->GetNbins(),par2Axis->GetXmin(),par2Axis->GetXmax()); }else{ eff = new TProfile2D("efficiency","efficiency",par1Axis->GetNbins(),par1Axis->GetXbins()->GetArray(),par2Axis->GetNbins(),par2Axis->GetXbins()->GetArray()); } eff->SetTitle(""); eff->SetXTitle( par1Axis->GetTitle() ); eff->SetYTitle( par2Axis->GetTitle() ); eff->SetStats(kFALSE); effChi2 = (TProfile2D*)eff->Clone("efficiencyChi2"); eff->SetZTitle("Efficiency"); eff->SetOption("colztexte"); eff->GetZaxis()->SetRangeUser(-0.001,1.001); effChi2->SetZTitle("Chi^2/NDF"); effChi2->SetOption("colztext"); //create the 1D mass distribution container histograms TH1D* all1D = (massAxis->GetXbins()->GetSize()==0) ? new TH1D("all1D","all1D",massAxis->GetNbins(),massAxis->GetXmin(),massAxis->GetXmax()): new TH1D("all1D","all1D",massAxis->GetNbins(),massAxis->GetXbins()->GetArray()); TH1D* pass1D = (TH1D *)all1D->Clone("pass1D"); //for each parameter bin fit the mass distributions for(int par1=1; par1<=par1Axis->GetNbins(); par1++){ for(int par2=1; par2<=par2Axis->GetNbins(); par2++){ for(int mass=1; mass<=massAxis->GetNbins(); mass++){ int index = par1*par1C + par2*par2C + mass*massC; all1D->SetBinContent(mass,all->GetBinContent(index)); pass1D->SetBinContent(mass,pass->GetBinContent(index)); } fit( pass1D, all1D ); int index = par1 + par2*(par1Axis->GetNbins()+2); eff->SetBinContent( index, getEfficiency() ); eff->SetBinEntries( index, 1 ); eff->SetBinError( index, sqrt( getEfficiency()*getEfficiency() + getEfficiencyError()*getEfficiencyError() ) ); effChi2->SetBinContent( index, getChi2() ); effChi2->SetBinEntries( index, 1 ); if(plotName!=""){ savePlot( TString::Format("%s_%d_%d",plotName.Data(),par1,par2) ); } } } delete all1D; delete pass1D; return "";//OK }
TString dqmTnP::AbstractFitter::calculateEfficiency | ( | TH2 * | pass, |
TH2 * | all, | ||
int | massDimension, | ||
TProfile *& | eff, | ||
TProfile *& | effChi2, | ||
TString | plotName = "" |
||
) | [inline] |
Definition at line 172 of file GenericTnPFitter.h.
References fit(), getChi2(), getEfficiency(), getEfficiencyError(), getHLTprescales::index, mass, savePlot(), and mathSSE::sqrt().
{ //sort out the TAxis TAxis *par1Axis, *massAxis; int par1C, massC; if(massDimension==1){ massAxis = all->GetXaxis(); massC = 1; par1Axis = all->GetYaxis(); par1C = all->GetXaxis()->GetNbins()+2; }else if(massDimension==2){ par1Axis = all->GetXaxis(); par1C = 1; massAxis = all->GetYaxis(); massC = all->GetXaxis()->GetNbins()+2; }else{ return "massDimension > 2 !, skipping..."; } //create eff and effChi2 TProfiles if(!par1Axis) return "No par1Axis!"; eff = (par1Axis->GetXbins()->GetSize()==0)? new TProfile("efficiency","efficiency",par1Axis->GetNbins(),par1Axis->GetXmin(),par1Axis->GetXmax()): new TProfile("efficiency","efficiency",par1Axis->GetNbins(),par1Axis->GetXbins()->GetArray()); eff->SetTitle(""); eff->SetXTitle( par1Axis->GetTitle() ); eff->SetLineColor(2); eff->SetLineWidth(2); eff->SetMarkerStyle(20); eff->SetMarkerSize(0.8); eff->SetStats(kFALSE); effChi2 = (TProfile*)eff->Clone("efficiencyChi2"); eff->SetYTitle("Efficiency"); eff->SetOption("PE"); eff->GetYaxis()->SetRangeUser(-0.001,1.001); effChi2->SetYTitle("Chi^2/NDF"); effChi2->SetOption("HIST"); //create the 1D mass distribution container histograms TH1D * all1D = (massAxis->GetXbins()->GetSize()==0) ? new TH1D("all1D","all1D",massAxis->GetNbins(),massAxis->GetXmin(),massAxis->GetXmax()): new TH1D("all1D","all1D",massAxis->GetNbins(),massAxis->GetXbins()->GetArray()); TH1D * pass1D = (TH1D *)all1D->Clone("pass1D"); //for each parameter bin fit the mass distributions for(int par1=1; par1<=par1Axis->GetNbins(); par1++){ for(int mass=1; mass<=massAxis->GetNbins(); mass++){ int index = par1*par1C + mass*massC; all1D->SetBinContent(mass,all->GetBinContent(index)); pass1D->SetBinContent(mass,pass->GetBinContent(index)); } fit( pass1D, all1D ); int index = par1; eff->SetBinContent( index, getEfficiency() ); eff->SetBinEntries( index, 1 ); eff->SetBinError( index, sqrt( getEfficiency()*getEfficiency() + getEfficiencyError()*getEfficiencyError() ) ); effChi2->SetBinContent( index, getChi2() ); effChi2->SetBinEntries( index, 1 ); if(plotName!=""){ savePlot( TString::Format("%s_%d",plotName.Data(),par1) ); } } delete all1D; delete pass1D; return "";//OK }
virtual void dqmTnP::AbstractFitter::fit | ( | TH1 * | num, |
TH1 * | den | ||
) | [pure virtual] |
Implemented in dqmTnP::GaussianPlusLinearFitter, and dqmTnP::VoigtianPlusExponentialFitter.
Referenced by calculateEfficiency().
double dqmTnP::AbstractFitter::getChi2 | ( | ) | [inline] |
Definition at line 76 of file GenericTnPFitter.h.
References chi2.
Referenced by calculateEfficiency().
{ return chi2; }
double dqmTnP::AbstractFitter::getEfficiency | ( | ) | [inline] |
Definition at line 74 of file GenericTnPFitter.h.
References efficiency.
Referenced by calculateEfficiency().
{ return efficiency.getVal(); }
double dqmTnP::AbstractFitter::getEfficiencyError | ( | ) | [inline] |
Definition at line 75 of file GenericTnPFitter.h.
References efficiency.
Referenced by calculateEfficiency().
{ return efficiency.getError(); }
void dqmTnP::AbstractFitter::savePlot | ( | TString | name | ) | [inline] |
Definition at line 77 of file GenericTnPFitter.h.
References category, data, mass, and simPdf.
Referenced by calculateEfficiency().
{ using namespace RooFit; RooPlot* frame = mass.frame(Name(name), Title("Failing and Passing Probe Distributions")); data->plotOn(frame,Cut("category==category::pass"),LineColor(kGreen),MarkerColor(kGreen)); data->plotOn(frame,Cut("category==category::fail"),LineColor(kRed),MarkerColor(kRed)); simPdf.plotOn(frame,Slice(category,"pass"),ProjWData(category,*data),LineColor(kGreen)); simPdf.plotOn(frame,Slice(category,"fail"),ProjWData(category,*data),LineColor(kRed)); simPdf.paramOn(frame,Layout(0.58,0.99,0.99)); data->statOn(frame,Layout(0.70,0.99,0.5)); frame->Write(); delete frame; }
void dqmTnP::AbstractFitter::setup | ( | double | expectedMean_, |
double | massLow, | ||
double | massHigh, | ||
double | expectedSigma_ | ||
) | [inline] |
Definition at line 67 of file GenericTnPFitter.h.
References expectedMean, expectedSigma, mass, and mean.
Referenced by DQMGenericTnPClient::calculateEfficiency().
{ expectedMean = expectedMean_; expectedSigma = expectedSigma_; mass.setRange(massLow,massHigh); mean.setRange(massLow,massHigh); }
RooCategory dqmTnP::AbstractFitter::category [protected] |
Definition at line 36 of file GenericTnPFitter.h.
Referenced by AbstractFitter(), dqmTnP::GaussianPlusLinearFitter::fit(), dqmTnP::VoigtianPlusExponentialFitter::fit(), and savePlot().
double dqmTnP::AbstractFitter::chi2 [protected] |
Definition at line 39 of file GenericTnPFitter.h.
Referenced by dqmTnP::GaussianPlusLinearFitter::fit(), dqmTnP::VoigtianPlusExponentialFitter::fit(), and getChi2().
RooDataHist* dqmTnP::AbstractFitter::data [protected] |
Definition at line 38 of file GenericTnPFitter.h.
Referenced by dqmTnP::GaussianPlusLinearFitter::fit(), dqmTnP::VoigtianPlusExponentialFitter::fit(), and savePlot().
RooRealVar dqmTnP::AbstractFitter::efficiency [protected] |
Definition at line 30 of file GenericTnPFitter.h.
Referenced by dqmTnP::GaussianPlusLinearFitter::fit(), dqmTnP::VoigtianPlusExponentialFitter::fit(), getEfficiency(), and getEfficiencyError().
double dqmTnP::AbstractFitter::expectedMean [protected] |
Definition at line 27 of file GenericTnPFitter.h.
Referenced by dqmTnP::GaussianPlusLinearFitter::fit(), dqmTnP::VoigtianPlusExponentialFitter::fit(), dqmTnP::VoigtianPlusExponentialFitter::setup(), and setup().
double dqmTnP::AbstractFitter::expectedSigma [protected] |
Definition at line 29 of file GenericTnPFitter.h.
Referenced by dqmTnP::GaussianPlusLinearFitter::fit(), dqmTnP::VoigtianPlusExponentialFitter::fit(), dqmTnP::VoigtianPlusExponentialFitter::setup(), and setup().
RooRealVar dqmTnP::AbstractFitter::mass [protected] |
Definition at line 25 of file GenericTnPFitter.h.
Referenced by calculateEfficiency(), dqmTnP::GaussianPlusLinearFitter::fit(), dqmTnP::VoigtianPlusExponentialFitter::fit(), savePlot(), dqmTnP::VoigtianPlusExponentialFitter::setup(), and setup().
RooRealVar dqmTnP::AbstractFitter::mean [protected] |
Definition at line 26 of file GenericTnPFitter.h.
Referenced by dqmTnP::GaussianPlusLinearFitter::fit(), dqmTnP::VoigtianPlusExponentialFitter::fit(), dqmTnP::VoigtianPlusExponentialFitter::setup(), and setup().
RooRealVar dqmTnP::AbstractFitter::nBackgroundFail [protected] |
Definition at line 34 of file GenericTnPFitter.h.
Referenced by dqmTnP::GaussianPlusLinearFitter::fit(), and dqmTnP::VoigtianPlusExponentialFitter::fit().
RooRealVar dqmTnP::AbstractFitter::nBackgroundPass [protected] |
Definition at line 35 of file GenericTnPFitter.h.
Referenced by dqmTnP::GaussianPlusLinearFitter::fit(), and dqmTnP::VoigtianPlusExponentialFitter::fit().
RooRealVar dqmTnP::AbstractFitter::nSignalAll [protected] |
Definition at line 31 of file GenericTnPFitter.h.
Referenced by dqmTnP::GaussianPlusLinearFitter::fit(), and dqmTnP::VoigtianPlusExponentialFitter::fit().
RooFormulaVar dqmTnP::AbstractFitter::nSignalFail [protected] |
Definition at line 33 of file GenericTnPFitter.h.
RooFormulaVar dqmTnP::AbstractFitter::nSignalPass [protected] |
Definition at line 32 of file GenericTnPFitter.h.
RooRealVar dqmTnP::AbstractFitter::sigma [protected] |
Definition at line 28 of file GenericTnPFitter.h.
Referenced by dqmTnP::GaussianPlusLinearFitter::fit(), and dqmTnP::VoigtianPlusExponentialFitter::fit().
RooSimultaneous dqmTnP::AbstractFitter::simPdf [protected] |
Definition at line 37 of file GenericTnPFitter.h.
Referenced by dqmTnP::GaussianPlusLinearFitter::fit(), dqmTnP::VoigtianPlusExponentialFitter::fit(), dqmTnP::GaussianPlusLinearFitter::GaussianPlusLinearFitter(), savePlot(), and dqmTnP::VoigtianPlusExponentialFitter::VoigtianPlusExponentialFitter().
bool dqmTnP::AbstractFitter::verbose [protected] |
Definition at line 40 of file GenericTnPFitter.h.