From b243b048ea2c2af0dd7fe862b2f7c49b690dc687 Mon Sep 17 00:00:00 2001 From: Carsten Burgard Date: Fri, 13 Jan 2023 15:49:56 +0100 Subject: [PATCH] added new constructor for RooExtendPdf --- roofit/roofitcore/inc/RooExtendPdf.h | 4 +++- roofit/roofitcore/src/RooExtendPdf.cxx | 25 ++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/roofit/roofitcore/inc/RooExtendPdf.h b/roofit/roofitcore/inc/RooExtendPdf.h index 78afdb645fc03..bc21b69d6ce3f 100644 --- a/roofit/roofitcore/inc/RooExtendPdf.h +++ b/roofit/roofitcore/inc/RooExtendPdf.h @@ -24,7 +24,9 @@ class RooExtendPdf : public RooAbsPdf { RooExtendPdf() ; RooExtendPdf(const char *name, const char *title, RooAbsPdf& pdf, - RooAbsReal& norm, const char* rangeName=nullptr) ; + RooAbsReal& norm, const char* rangeName=nullptr) ; + RooExtendPdf(const char *name, const char *title, RooAbsPdf& pdf, + double norm, const char* rangeName=nullptr) ; RooExtendPdf(const RooExtendPdf& other, const char* name=nullptr) ; TObject* clone(const char* newname) const override { return new RooExtendPdf(*this,newname) ; } ~RooExtendPdf() override ; diff --git a/roofit/roofitcore/src/RooExtendPdf.cxx b/roofit/roofitcore/src/RooExtendPdf.cxx index 62ec65898dd36..8ee1b8a20e1bb 100644 --- a/roofit/roofitcore/src/RooExtendPdf.cxx +++ b/roofit/roofitcore/src/RooExtendPdf.cxx @@ -69,7 +69,7 @@ RooExtendPdf::RooExtendPdf() : _rangeName(0) /// \param[in] rangeName If given, the number of events denoted by `norm` is interpreted as /// the number of events in this range only RooExtendPdf::RooExtendPdf(const char *name, const char *title, RooAbsPdf& pdf, - RooAbsReal& norm, const char* rangeName) : + RooAbsReal& norm, const char* rangeName) : RooAbsPdf(name,title), _pdf("pdf", "PDF", this, pdf), _n("n","Normalization",this,norm), @@ -81,6 +81,29 @@ RooExtendPdf::RooExtendPdf(const char *name, const char *title, RooAbsPdf& pdf, setPlotLabel(_pdf->getPlotLabel()) ; } +/// Constructor. The ExtendPdf behaves identical to the supplied input pdf, +/// but adds an extended likelihood term. expectedEvents() will return +/// `norm` if `rangeName` remains empty. If `rangeName` is not empty, +/// `norm` will refer to this range, and expectedEvents will return the +/// total number of events over the full range of the observables. +/// \param[in] name Name of the pdf +/// \param[in] title Title of the pdf (for plotting) +/// \param[in] pdf The pdf to be extended +/// \param[in] norm Expected number of events +/// \param[in] rangeName If given, the number of events denoted by `norm` is interpreted as +/// the number of events in this range only +RooExtendPdf::RooExtendPdf(const char *name, const char *title, RooAbsPdf& pdf, + double norm, const char* rangeName) : + RooAbsPdf(name,title), + _pdf("pdf", "PDF", this, pdf), + _n("n","Normalization",this,*new RooRealVar(TString::Format("%s_norm",name),TString::Format("%s_norm",title),norm),true, false, true), + _rangeName(RooNameReg::ptr(rangeName)) +{ + // Copy various setting from pdf + setUnit(_pdf->getUnit()) ; + setPlotLabel(_pdf->getPlotLabel()) ; +} + RooExtendPdf::RooExtendPdf(const RooExtendPdf& other, const char* name) :