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 269 of file GenericTnPFitter.h.

Constructor & Destructor Documentation

◆ GaussianPlusLinearFitter()

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

Definition at line 280 of file GenericTnPFitter.h.

References dqmTnP::AbstractFitter::simPdf.

282  gaussian("gaussian", "gaussian", mass, mean, sigma),
283  slopeFail("slopeFail", "slopeFail", 0., -1., 1.),
284  linearFail("linearFail", "linearFail", mass, slopeFail),
285  slopePass("slopePass", "slopePass", 0., -1., 1.),
286  linearPass("linearPass", "linearPass", mass, slopePass),
287  pdfFail("pdfFail", "pdfFail", RooArgList(gaussian, linearFail), RooArgList(nSignalFail, nBackgroundFail)),
288  pdfPass("pdfPass", "pdfPass", RooArgList(gaussian, linearPass), RooArgList(nSignalPass, nBackgroundPass)) {
289  simPdf.addPdf(pdfFail, "fail");
290  simPdf.addPdf(pdfPass, "pass");
291  };
AbstractFitter(bool verbose_=false)
RooSimultaneous simPdf

◆ ~GaussianPlusLinearFitter()

dqmTnP::GaussianPlusLinearFitter::~GaussianPlusLinearFitter ( )
overridedefault

Member Function Documentation

◆ fit()

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

Implements dqmTnP::AbstractFitter.

Definition at line 294 of file GenericTnPFitter.h.

References python.cmstools::all(), dqmTnP::AbstractFitter::category, dqmTnP::AbstractFitter::chi2, dqmTnP::AbstractFitter::data, dqmTnP::AbstractFitter::efficiency, dqmTnP::AbstractFitter::expectedMean, dqmTnP::AbstractFitter::expectedSigma, dqmTnP::AbstractFitter::mass, dqmTnP::AbstractFitter::mean, dqmTnP::AbstractFitter::nBackgroundFail, dqmTnP::AbstractFitter::nBackgroundPass, dqmTnP::AbstractFitter::nSignalAll, dqmTnP::AbstractFitter::sigma, dqmTnP::AbstractFitter::simPdf, EcalTangentSkim_cfg::Verbose, and dqmTnP::AbstractFitter::verbose.

Referenced by trackingPlots.Iteration::modules().

294  {
295  using namespace RooFit;
296  all->Add(pass, -1);
297  TH1*& fail = all;
298  if (!data)
299  delete data;
300  data = new RooDataHist("data", "data", mass, Index(category), Import("fail", *fail), Import("pass", *pass));
301  if (pass->Integral() + fail->Integral() < 5) {
302  efficiency.setVal(0.5);
303  efficiency.setError(0.5);
304  chi2 = 0;
305  return;
306  }
307  mean.setVal(expectedMean);
308  sigma.setVal(expectedSigma);
309  efficiency.setVal(pass->Integral() / (pass->Integral() + fail->Integral()));
310  nSignalAll.setVal(0.5 * (fail->Integral() + pass->Integral()));
311  nBackgroundFail.setVal(0.5 * fail->Integral());
312  nBackgroundPass.setVal(0.5 * pass->Integral());
313  slopeFail.setVal(0.);
314  slopePass.setVal(0.);
315  if (verbose) {
316  simPdf.fitTo(*data);
317  } else {
318  simPdf.fitTo(*data, Verbose(kFALSE), PrintLevel(-1), Warnings(kFALSE), PrintEvalErrors(-1));
319  }
320  RooDataHist dataFail("fail", "fail", mass, fail);
321  RooDataHist dataPass("pass", "pass", mass, pass);
322  using AbsRealPtr = std::unique_ptr<RooAbsReal>;
323  const double chi2Fail = AbsRealPtr(pdfFail.createChi2(dataFail, DataError(RooAbsData::Poisson)))->getVal();
324  const double chi2Pass = AbsRealPtr(pdfPass.createChi2(dataPass, DataError(RooAbsData::Poisson)))->getVal();
325  chi2 = (chi2Fail + chi2Pass) / (2 * pass->GetNbinsX() - 8);
326  if (chi2 > 3) {
327  efficiency.setVal(0.5);
328  efficiency.setError(0.5);
329  }
330  }
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
RooSimultaneous simPdf

Member Data Documentation

◆ gaussian

RooGaussian dqmTnP::GaussianPlusLinearFitter::gaussian
protected

Definition at line 271 of file GenericTnPFitter.h.

◆ linearFail

RooChebychev dqmTnP::GaussianPlusLinearFitter::linearFail
protected

Definition at line 273 of file GenericTnPFitter.h.

◆ linearPass

RooChebychev dqmTnP::GaussianPlusLinearFitter::linearPass
protected

Definition at line 275 of file GenericTnPFitter.h.

◆ pdfFail

RooAddPdf dqmTnP::GaussianPlusLinearFitter::pdfFail
protected

Definition at line 276 of file GenericTnPFitter.h.

◆ pdfPass

RooAddPdf dqmTnP::GaussianPlusLinearFitter::pdfPass
protected

Definition at line 277 of file GenericTnPFitter.h.

◆ slopeFail

RooRealVar dqmTnP::GaussianPlusLinearFitter::slopeFail
protected

Definition at line 272 of file GenericTnPFitter.h.

◆ slopePass

RooRealVar dqmTnP::GaussianPlusLinearFitter::slopePass
protected

Definition at line 274 of file GenericTnPFitter.h.