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 (TH2 *pass, TH2 *all, int massDimension, TProfile *&eff, TProfile *&effChi2, const TString &plotName="")
 
TString calculateEfficiency (TH3 *pass, TH3 *all, int massDimension, TProfile2D *&eff, TProfile2D *&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.

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  };

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

◆ ~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.

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  chi2 = (RooChi2Var("chi2Fail", "chi2Fail", pdfFail, dataFail, DataError(RooAbsData::Poisson)).getVal() +
400  RooChi2Var("chi2Pass", "chi2Pass", pdfPass, dataPass, DataError(RooAbsData::Poisson)).getVal()) /
401  (2 * all->GetNbinsX() - 8);
402  if (chi2 > 3) {
403  efficiency.setVal(0.5);
404  efficiency.setError(0.5);
405  }
406  }

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().

◆ setup()

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

Definition at line 364 of file GenericTnPFitter.h.

364  {
365  expectedMean = expectedMean_;
366  expectedSigma = expectedSigma_;
367  mass.setRange(massLow, massHigh);
368  mean.setRange(massLow, massHigh);
369  width.setVal(width_);
370  }

References dqmTnP::AbstractFitter::expectedMean, dqmTnP::AbstractFitter::expectedSigma, dqmTnP::AbstractFitter::mass, EgHLTOffHistBins_cfi::massHigh, dqmTnP::AbstractFitter::mean, and ApeEstimator_cff::width.

Referenced by DQMGenericTnPClient::calculateEfficiency().

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
dqmTnP::AbstractFitter::nSignalPass
RooFormulaVar nSignalPass
Definition: GenericTnPFitter.h:32
dqmTnP::AbstractFitter::AbstractFitter
AbstractFitter(bool verbose_=false)
Definition: GenericTnPFitter.h:43
dqmTnP::AbstractFitter::nBackgroundPass
RooRealVar nBackgroundPass
Definition: GenericTnPFitter.h:35
dqmTnP::AbstractFitter::simPdf
RooSimultaneous simPdf
Definition: GenericTnPFitter.h:37
dqmTnP::AbstractFitter::expectedMean
double expectedMean
Definition: GenericTnPFitter.h:27
EgHLTOffHistBins_cfi.massHigh
massHigh
Definition: EgHLTOffHistBins_cfi.py:35
dqmTnP::VoigtianPlusExponentialFitter::exponentialPass
RooExponential exponentialPass
Definition: GenericTnPFitter.h:341
dqmTnP::AbstractFitter::nSignalAll
RooRealVar nSignalAll
Definition: GenericTnPFitter.h:31
dqmTnP::AbstractFitter::mass
RooRealVar mass
Definition: GenericTnPFitter.h:25
dqmTnP::VoigtianPlusExponentialFitter::voigtian
RooVoigtian voigtian
Definition: GenericTnPFitter.h:337
python.cmstools.all
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
dqmTnP::AbstractFitter::nBackgroundFail
RooRealVar nBackgroundFail
Definition: GenericTnPFitter.h:34
dqmTnP::VoigtianPlusExponentialFitter::slopePass
RooRealVar slopePass
Definition: GenericTnPFitter.h:340
EcalTangentSkim_cfg.Verbose
Verbose
Definition: EcalTangentSkim_cfg.py:30
dqmTnP::AbstractFitter::verbose
bool verbose
Definition: GenericTnPFitter.h:40
dqmTnP::AbstractFitter::mean
RooRealVar mean
Definition: GenericTnPFitter.h:26
dqmTnP::AbstractFitter::efficiency
RooRealVar efficiency
Definition: GenericTnPFitter.h:30
dqmTnP::AbstractFitter::nSignalFail
RooFormulaVar nSignalFail
Definition: GenericTnPFitter.h:33
dqmTnP::AbstractFitter::data
RooDataHist * data
Definition: GenericTnPFitter.h:38
dqmTnP::AbstractFitter::category
RooCategory category
Definition: GenericTnPFitter.h:36
dqmTnP::VoigtianPlusExponentialFitter::slopeFail
RooRealVar slopeFail
Definition: GenericTnPFitter.h:338
dqmTnP::AbstractFitter::expectedSigma
double expectedSigma
Definition: GenericTnPFitter.h:29
dqmTnP::VoigtianPlusExponentialFitter::width
RooRealVar width
Definition: GenericTnPFitter.h:336
dqmTnP::VoigtianPlusExponentialFitter::exponentialFail
RooExponential exponentialFail
Definition: GenericTnPFitter.h:339
dqmTnP::AbstractFitter::chi2
double chi2
Definition: GenericTnPFitter.h:39
dqmTnP::AbstractFitter::sigma
RooRealVar sigma
Definition: GenericTnPFitter.h:28
dqmTnP::VoigtianPlusExponentialFitter::pdfFail
RooAddPdf pdfFail
Definition: GenericTnPFitter.h:342
dqmTnP::VoigtianPlusExponentialFitter::pdfPass
RooAddPdf pdfPass
Definition: GenericTnPFitter.h:343