CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes
dqmTnP::GaussianPlusLinearFitter Class Reference

#include <GenericTnPFitter.h>

Inheritance diagram for dqmTnP::GaussianPlusLinearFitter:
dqmTnP::AbstractFitter

Public Member Functions

void fit (TH1 *pass, TH1 *all) override
 
 GaussianPlusLinearFitter (bool verbose=false)
 
 ~GaussianPlusLinearFitter () override=default
 
- Public Member Functions inherited from dqmTnP::AbstractFitter
 AbstractFitter (bool verbose_=false)
 
TString calculateEfficiency (TH3 *pass, TH3 *all, int massDimension, TProfile2D *&eff, TProfile2D *&effChi2, const TString &plotName="")
 
TString calculateEfficiency (TH2 *pass, TH2 *all, int massDimension, TProfile *&eff, TProfile *&effChi2, const TString &plotName="")
 
double getChi2 ()
 
double getEfficiency ()
 
double getEfficiencyError ()
 
void savePlot (const TString &name)
 
void setup (double expectedMean_, double massLow, double massHigh, double expectedSigma_)
 
virtual ~AbstractFitter ()=default
 

Protected Attributes

RooGaussian gaussian
 
RooChebychev linearFail
 
RooChebychev linearPass
 
RooAddPdf pdfFail
 
RooAddPdf pdfPass
 
RooRealVar slopeFail
 
RooRealVar slopePass
 
- Protected Attributes inherited from dqmTnP::AbstractFitter
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
 

Detailed Description

Definition at line 240 of file GenericTnPFitter.h.

Constructor & Destructor Documentation

dqmTnP::GaussianPlusLinearFitter::GaussianPlusLinearFitter ( bool  verbose = false)
inline

Definition at line 250 of file GenericTnPFitter.h.

References dqmTnP::AbstractFitter::simPdf.

250  :
252  gaussian("gaussian","gaussian",mass,mean,sigma),
253  slopeFail("slopeFail","slopeFail",0.,-1.,1.),
254  linearFail("linearFail","linearFail",mass,slopeFail),
255  slopePass("slopePass","slopePass",0.,-1.,1.),
256  linearPass("linearPass","linearPass",mass,slopePass),
257  pdfFail("pdfFail","pdfFail", RooArgList(gaussian,linearFail), RooArgList(nSignalFail,nBackgroundFail)),
258  pdfPass("pdfPass","pdfPass", RooArgList(gaussian,linearPass), RooArgList(nSignalPass,nBackgroundPass))
259  {
260  simPdf.addPdf(pdfFail,"fail");
261  simPdf.addPdf(pdfPass,"pass");
262  };
AbstractFitter(bool verbose_=false)
RooSimultaneous simPdf
dqmTnP::GaussianPlusLinearFitter::~GaussianPlusLinearFitter ( )
overridedefault

Member Function Documentation

void dqmTnP::GaussianPlusLinearFitter::fit ( TH1 *  pass,
TH1 *  all 
)
inlineoverridevirtual

Implements dqmTnP::AbstractFitter.

Definition at line 264 of file GenericTnPFitter.h.

References Vispa.Plugins.EdmBrowser.EdmDataAccessor::all(), dqmTnP::AbstractFitter::category, dqmTnP::AbstractFitter::chi2, dqmTnP::AbstractFitter::data, dqmTnP::AbstractFitter::efficiency, dqmTnP::AbstractFitter::expectedMean, dqmTnP::AbstractFitter::expectedSigma, cmsPerfPublish::fail(), dqmTnP::AbstractFitter::mass, dqmTnP::AbstractFitter::mean, dqmTnP::AbstractFitter::nBackgroundFail, dqmTnP::AbstractFitter::nBackgroundPass, dqmTnP::AbstractFitter::nSignalAll, dqmTnP::AbstractFitter::sigma, dqmTnP::AbstractFitter::simPdf, and JetPlusTrackCorrections_cfi::Verbose.

Referenced by trackingPlots.Iteration::modules().

264  {
265  using namespace RooFit;
266  all->Add(pass,-1);
267  TH1* &fail = all;
268  if(!data) delete data;
269  data = new RooDataHist("data", "data", mass, Index(category), Import("fail",*fail), Import("pass",*pass) );
270  if(pass->Integral()+fail->Integral() < 5){
271  efficiency.setVal(0.5);
272  efficiency.setError(0.5);
273  chi2 = 0;
274  return;
275  }
276  mean.setVal(expectedMean);
277  sigma.setVal(expectedSigma);
278  efficiency.setVal(pass->Integral()/(pass->Integral()+fail->Integral()));
279  nSignalAll.setVal(0.5*(fail->Integral()+pass->Integral()));
280  nBackgroundFail.setVal(0.5*fail->Integral());
281  nBackgroundPass.setVal(0.5*pass->Integral());
282  slopeFail.setVal(0.);
283  slopePass.setVal(0.);
284  if(verbose){
285  simPdf.fitTo( *data );
286  }else{
287  simPdf.fitTo( *data, Verbose(kFALSE), PrintLevel(-1), Warnings(kFALSE), PrintEvalErrors(-1) );
288  }
289  RooDataHist dataFail("fail", "fail", mass, fail );
290  RooDataHist dataPass("pass", "pass", mass, pass );
291  chi2 = ( RooChi2Var("chi2Fail","chi2Fail",pdfFail,dataFail,DataError(RooAbsData::Poisson)).getVal()
292  +RooChi2Var("chi2Pass","chi2Pass",pdfPass,dataPass,DataError(RooAbsData::Poisson)).getVal() )/(2*pass->GetNbinsX()-8);
293  if(chi2>3){
294  efficiency.setVal(0.5);
295  efficiency.setError(0.5);
296  }
297  }
def fail(errstr="")
RooSimultaneous simPdf

Member Data Documentation

RooGaussian dqmTnP::GaussianPlusLinearFitter::gaussian
protected

Definition at line 242 of file GenericTnPFitter.h.

RooChebychev dqmTnP::GaussianPlusLinearFitter::linearFail
protected

Definition at line 244 of file GenericTnPFitter.h.

RooChebychev dqmTnP::GaussianPlusLinearFitter::linearPass
protected

Definition at line 246 of file GenericTnPFitter.h.

RooAddPdf dqmTnP::GaussianPlusLinearFitter::pdfFail
protected

Definition at line 247 of file GenericTnPFitter.h.

RooAddPdf dqmTnP::GaussianPlusLinearFitter::pdfPass
protected

Definition at line 248 of file GenericTnPFitter.h.

RooRealVar dqmTnP::GaussianPlusLinearFitter::slopeFail
protected

Definition at line 243 of file GenericTnPFitter.h.

RooRealVar dqmTnP::GaussianPlusLinearFitter::slopePass
protected

Definition at line 245 of file GenericTnPFitter.h.