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

Constructor & Destructor Documentation

◆ VoigtianPlusExponentialFitter()

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

Definition at line 347 of file GenericTnPFitter.h.

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

349  width("width", "width", 2.5, "GeV"),
350  voigtian("voigtian", "voigtian", mass, mean, width, sigma),
351  slopeFail("slopeFail", "slopeFail", 0., -1., 0.),
352  exponentialFail("linearFail", "linearFail", mass, slopeFail),
353  slopePass("slopePass", "slopePass", 0., -1., 0.),
354  exponentialPass("linearPass", "linearPass", mass, slopePass),
355  pdfFail(
356  "pdfFail", "pdfFail", RooArgList(voigtian, exponentialFail), RooArgList(nSignalFail, nBackgroundFail)),
357  pdfPass(
358  "pdfPass", "pdfPass", RooArgList(voigtian, exponentialPass), RooArgList(nSignalPass, nBackgroundPass)) {
359  width.setConstant(kTRUE);
360  simPdf.addPdf(pdfFail, "fail");
361  simPdf.addPdf(pdfPass, "pass");
362  };
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 372 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().

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

◆ exponentialPass

RooExponential dqmTnP::VoigtianPlusExponentialFitter::exponentialPass
protected

Definition at line 342 of file GenericTnPFitter.h.

◆ pdfFail

RooAddPdf dqmTnP::VoigtianPlusExponentialFitter::pdfFail
protected

Definition at line 343 of file GenericTnPFitter.h.

◆ pdfPass

RooAddPdf dqmTnP::VoigtianPlusExponentialFitter::pdfPass
protected

Definition at line 344 of file GenericTnPFitter.h.

◆ slopeFail

RooRealVar dqmTnP::VoigtianPlusExponentialFitter::slopeFail
protected

Definition at line 339 of file GenericTnPFitter.h.

◆ slopePass

RooRealVar dqmTnP::VoigtianPlusExponentialFitter::slopePass
protected

Definition at line 341 of file GenericTnPFitter.h.

◆ voigtian

RooVoigtian dqmTnP::VoigtianPlusExponentialFitter::voigtian
protected

Definition at line 338 of file GenericTnPFitter.h.

◆ width

RooRealVar dqmTnP::VoigtianPlusExponentialFitter::width
protected