CMS 3D CMS Logo

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

#include <GenericTnPFitter.h>

Inheritance diagram for dqmTnP::VoigtianPlusExponentialFitter:
dqmTnP::AbstractFitter

Public Member Functions

void fit (TH1 *pass, TH1 *all) override
 
void setup (double expectedMean_, double massLow, double massHigh, double expectedSigma_, double width_)
 
 VoigtianPlusExponentialFitter (bool verbose=false)
 
 ~VoigtianPlusExponentialFitter () 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

RooExponential exponentialFail
 
RooExponential exponentialPass
 
RooAddPdf pdfFail
 
RooAddPdf pdfPass
 
RooRealVar slopeFail
 
RooRealVar slopePass
 
RooVoigtian voigtian
 
RooRealVar width
 
- 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 334 of file GenericTnPFitter.h.

Constructor & Destructor Documentation

◆ VoigtianPlusExponentialFitter()

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

Definition at line 346 of file GenericTnPFitter.h.

References dqmTnP::AbstractFitter::simPdf, and ApeEstimator_cff::width.

348  width("width", "width", 2.5, "GeV"),
349  voigtian("voigtian", "voigtian", mass, mean, width, sigma),
350  slopeFail("slopeFail", "slopeFail", 0., -1., 0.),
351  exponentialFail("linearFail", "linearFail", mass, slopeFail),
352  slopePass("slopePass", "slopePass", 0., -1., 0.),
353  exponentialPass("linearPass", "linearPass", mass, slopePass),
354  pdfFail(
355  "pdfFail", "pdfFail", RooArgList(voigtian, exponentialFail), RooArgList(nSignalFail, nBackgroundFail)),
356  pdfPass(
357  "pdfPass", "pdfPass", RooArgList(voigtian, exponentialPass), RooArgList(nSignalPass, nBackgroundPass)) {
358  width.setConstant(kTRUE);
359  simPdf.addPdf(pdfFail, "fail");
360  simPdf.addPdf(pdfPass, "pass");
361  };
AbstractFitter(bool verbose_=false)
RooSimultaneous simPdf

◆ ~VoigtianPlusExponentialFitter()

dqmTnP::VoigtianPlusExponentialFitter::~VoigtianPlusExponentialFitter ( )
overridedefault

Member Function Documentation

◆ fit()

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

Implements dqmTnP::AbstractFitter.

Definition at line 371 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().

371  {
372  using namespace RooFit;
373  all->Add(pass, -1);
374  TH1*& fail = all;
375  if (!data)
376  delete data;
377  data = new RooDataHist("data", "data", mass, Index(category), Import("fail", *fail), Import("pass", *pass));
378  if (pass->Integral() + fail->Integral() < 5) {
379  efficiency.setVal(0.5);
380  efficiency.setError(0.5);
381  chi2 = 0;
382  return;
383  }
384  mean.setVal(expectedMean);
385  sigma.setVal(expectedSigma);
386  efficiency.setVal(pass->Integral() / (pass->Integral() + fail->Integral()));
387  nSignalAll.setVal(0.5 * (fail->Integral() + pass->Integral()));
388  nBackgroundFail.setVal(0.5 * fail->Integral());
389  nBackgroundPass.setVal(0.5 * pass->Integral());
390  slopeFail.setVal(0.);
391  slopePass.setVal(0.);
392  if (verbose) {
393  simPdf.fitTo(*data);
394  } else {
395  simPdf.fitTo(*data, Verbose(kFALSE), PrintLevel(-1), Warnings(kFALSE), PrintEvalErrors(-1));
396  }
397  RooDataHist dataFail("fail", "fail", mass, fail);
398  RooDataHist dataPass("pass", "pass", mass, pass);
399  using AbsRealPtr = std::unique_ptr<RooAbsReal>;
400  const double chi2Fail = AbsRealPtr(pdfFail.createChi2(dataFail, DataError(RooAbsData::Poisson)))->getVal();
401  const double chi2Pass = AbsRealPtr(pdfPass.createChi2(dataPass, DataError(RooAbsData::Poisson)))->getVal();
402  chi2 = (chi2Fail + chi2Pass) / (2 * all->GetNbinsX() - 8);
403  if (chi2 > 3) {
404  efficiency.setVal(0.5);
405  efficiency.setError(0.5);
406  }
407  }
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
RooSimultaneous simPdf

◆ setup()

void dqmTnP::VoigtianPlusExponentialFitter::setup ( double  expectedMean_,
double  massLow,
double  massHigh,
double  expectedSigma_,
double  width_ 
)
inline

Member Data Documentation

◆ exponentialFail

RooExponential dqmTnP::VoigtianPlusExponentialFitter::exponentialFail
protected

Definition at line 339 of file GenericTnPFitter.h.

◆ exponentialPass

RooExponential dqmTnP::VoigtianPlusExponentialFitter::exponentialPass
protected

Definition at line 341 of file GenericTnPFitter.h.

◆ pdfFail

RooAddPdf dqmTnP::VoigtianPlusExponentialFitter::pdfFail
protected

Definition at line 342 of file GenericTnPFitter.h.

◆ pdfPass

RooAddPdf dqmTnP::VoigtianPlusExponentialFitter::pdfPass
protected

Definition at line 343 of file GenericTnPFitter.h.

◆ slopeFail

RooRealVar dqmTnP::VoigtianPlusExponentialFitter::slopeFail
protected

Definition at line 338 of file GenericTnPFitter.h.

◆ slopePass

RooRealVar dqmTnP::VoigtianPlusExponentialFitter::slopePass
protected

Definition at line 340 of file GenericTnPFitter.h.

◆ voigtian

RooVoigtian dqmTnP::VoigtianPlusExponentialFitter::voigtian
protected

Definition at line 337 of file GenericTnPFitter.h.

◆ width

RooRealVar dqmTnP::VoigtianPlusExponentialFitter::width
protected