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

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.

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

References dqmTnP::AbstractFitter::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.

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  chi2 = (RooChi2Var("chi2Fail", "chi2Fail", pdfFail, dataFail, DataError(RooAbsData::Poisson)).getVal() +
324  RooChi2Var("chi2Pass", "chi2Pass", pdfPass, dataPass, DataError(RooAbsData::Poisson)).getVal()) /
325  (2 * pass->GetNbinsX() - 8);
326  if (chi2 > 3) {
327  efficiency.setVal(0.5);
328  efficiency.setError(0.5);
329  }
330  }

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

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.

dqmTnP::AbstractFitter::nSignalPass
RooFormulaVar nSignalPass
Definition: GenericTnPFitter.h:32
dqmTnP::GaussianPlusLinearFitter::slopeFail
RooRealVar slopeFail
Definition: GenericTnPFitter.h:273
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
dqmTnP::AbstractFitter::nSignalAll
RooRealVar nSignalAll
Definition: GenericTnPFitter.h:31
dqmTnP::AbstractFitter::mass
RooRealVar mass
Definition: GenericTnPFitter.h:25
dqmTnP::GaussianPlusLinearFitter::pdfFail
RooAddPdf pdfFail
Definition: GenericTnPFitter.h:277
python.cmstools.all
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:26
dqmTnP::AbstractFitter::nBackgroundFail
RooRealVar nBackgroundFail
Definition: GenericTnPFitter.h:34
EcalTangentSkim_cfg.Verbose
Verbose
Definition: EcalTangentSkim_cfg.py:30
dqmTnP::AbstractFitter::verbose
bool verbose
Definition: GenericTnPFitter.h:40
dqmTnP::GaussianPlusLinearFitter::linearFail
RooChebychev linearFail
Definition: GenericTnPFitter.h:274
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::GaussianPlusLinearFitter::pdfPass
RooAddPdf pdfPass
Definition: GenericTnPFitter.h:278
dqmTnP::GaussianPlusLinearFitter::linearPass
RooChebychev linearPass
Definition: GenericTnPFitter.h:276
dqmTnP::AbstractFitter::category
RooCategory category
Definition: GenericTnPFitter.h:36
dqmTnP::GaussianPlusLinearFitter::slopePass
RooRealVar slopePass
Definition: GenericTnPFitter.h:275
dqmTnP::GaussianPlusLinearFitter::gaussian
RooGaussian gaussian
Definition: GenericTnPFitter.h:272
dqmTnP::AbstractFitter::expectedSigma
double expectedSigma
Definition: GenericTnPFitter.h:29
dqmTnP::AbstractFitter::chi2
double chi2
Definition: GenericTnPFitter.h:39
dqmTnP::AbstractFitter::sigma
RooRealVar sigma
Definition: GenericTnPFitter.h:28