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

Constructor & Destructor Documentation

◆ GaussianPlusLinearFitter()

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

Definition at line 281 of file GenericTnPFitter.h.

References dqmTnP::AbstractFitter::simPdf.

283  gaussian("gaussian", "gaussian", mass, mean, sigma),
284  slopeFail("slopeFail", "slopeFail", 0., -1., 1.),
285  linearFail("linearFail", "linearFail", mass, slopeFail),
286  slopePass("slopePass", "slopePass", 0., -1., 1.),
287  linearPass("linearPass", "linearPass", mass, slopePass),
288  pdfFail("pdfFail", "pdfFail", RooArgList(gaussian, linearFail), RooArgList(nSignalFail, nBackgroundFail)),
289  pdfPass("pdfPass", "pdfPass", RooArgList(gaussian, linearPass), RooArgList(nSignalPass, nBackgroundPass)) {
290  simPdf.addPdf(pdfFail, "fail");
291  simPdf.addPdf(pdfPass, "pass");
292  };
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 295 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().

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

◆ linearFail

RooChebychev dqmTnP::GaussianPlusLinearFitter::linearFail
protected

Definition at line 274 of file GenericTnPFitter.h.

◆ linearPass

RooChebychev dqmTnP::GaussianPlusLinearFitter::linearPass
protected

Definition at line 276 of file GenericTnPFitter.h.

◆ pdfFail

RooAddPdf dqmTnP::GaussianPlusLinearFitter::pdfFail
protected

Definition at line 277 of file GenericTnPFitter.h.

◆ pdfPass

RooAddPdf dqmTnP::GaussianPlusLinearFitter::pdfPass
protected

Definition at line 278 of file GenericTnPFitter.h.

◆ slopeFail

RooRealVar dqmTnP::GaussianPlusLinearFitter::slopeFail
protected

Definition at line 273 of file GenericTnPFitter.h.

◆ slopePass

RooRealVar dqmTnP::GaussianPlusLinearFitter::slopePass
protected

Definition at line 275 of file GenericTnPFitter.h.