CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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

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

Definition at line 346 of file GenericTnPFitter.h.

References dqmTnP::AbstractFitter::simPdf.

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
dqmTnP::VoigtianPlusExponentialFitter::~VoigtianPlusExponentialFitter ( )
overridedefault

Member Function Documentation

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  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  }
def all
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
RooSimultaneous simPdf
void dqmTnP::VoigtianPlusExponentialFitter::setup ( double  expectedMean_,
double  massLow,
double  massHigh,
double  expectedSigma_,
double  width_ 
)
inline

Definition at line 364 of file GenericTnPFitter.h.

References dqmTnP::AbstractFitter::expectedMean, dqmTnP::AbstractFitter::expectedSigma, dqmTnP::AbstractFitter::mass, and dqmTnP::AbstractFitter::mean.

Referenced by DQMGenericTnPClient::calculateEfficiency().

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

Member Data Documentation

RooExponential dqmTnP::VoigtianPlusExponentialFitter::exponentialFail
protected

Definition at line 339 of file GenericTnPFitter.h.

RooExponential dqmTnP::VoigtianPlusExponentialFitter::exponentialPass
protected

Definition at line 341 of file GenericTnPFitter.h.

RooAddPdf dqmTnP::VoigtianPlusExponentialFitter::pdfFail
protected

Definition at line 342 of file GenericTnPFitter.h.

RooAddPdf dqmTnP::VoigtianPlusExponentialFitter::pdfPass
protected

Definition at line 343 of file GenericTnPFitter.h.

RooRealVar dqmTnP::VoigtianPlusExponentialFitter::slopeFail
protected

Definition at line 338 of file GenericTnPFitter.h.

RooRealVar dqmTnP::VoigtianPlusExponentialFitter::slopePass
protected

Definition at line 340 of file GenericTnPFitter.h.

RooVoigtian dqmTnP::VoigtianPlusExponentialFitter::voigtian
protected

Definition at line 337 of file GenericTnPFitter.h.

RooRealVar dqmTnP::VoigtianPlusExponentialFitter::width
protected