Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
RooNormalizedPdf.h
Go to the documentation of this file.
1/*
2 * Project: RooFit
3 * Authors:
4 * Jonas Rembser, CERN 2022
5 *
6 * Copyright (c) 2022, CERN
7 *
8 * Redistribution and use in source and binary forms,
9 * with or without modification, are permitted according to the terms
10 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)
11 */
12
13#ifndef RooFit_RooNormalizedPdf_h
14#define RooFit_RooNormalizedPdf_h
15
16#include <RooAbsPdf.h>
17#include <RooRealProxy.h>
18
19namespace RooFit::Detail {
20
22public:
24 : _pdf("numerator", "numerator", this, pdf),
26 "denominator", "denominator", this,
27 std::unique_ptr<RooAbsReal>{pdf.createIntegral(normSet, *pdf.getIntegratorConfig(), pdf.normRange())}, true,
28 false),
29 _normSet{normSet}
30 {
31 auto name = std::string(pdf.GetName()) + "_over_" + _normIntegral->GetName();
32 SetName(name.c_str());
33 SetTitle(name.c_str());
34 _normRange = pdf.normRange(); // so that e.g. RooAddPdf can query over what we are normalized
35 }
36
37 RooNormalizedPdf(const RooNormalizedPdf &other, const char *name)
38 : RooAbsPdf(other, name),
39 _pdf("numerator", this, other._pdf),
40 _normIntegral("denominator", this, other._normIntegral),
41 _normSet{other._normSet}
42 {
43 }
44
45 TObject *clone(const char *newname) const override { return new RooNormalizedPdf(*this, newname); }
46
47 bool selfNormalized() const override { return true; }
48
49 inline double getCorrection() const override { return _pdf->getCorrection(); }
50
51 bool forceAnalyticalInt(const RooAbsArg & /*dep*/) const override { return true; }
52 /// Forward determination of analytical integration capabilities to input p.d.f
53 Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet,
54 const char *rangeName = nullptr) const override
55 {
56 return _pdf->getAnalyticalIntegralWN(allVars, analVars, normSet ? normSet : &_normSet, rangeName);
57 }
58 /// Forward calculation of analytical integrals to input p.d.f
59 double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName = nullptr) const override
60 {
61 return _pdf->analyticalIntegralWN(code, normSet ? normSet : &_normSet, rangeName);
62 }
63
64 ExtendMode extendMode() const override { return static_cast<RooAbsPdf &>(*_pdf).extendMode(); }
65 double expectedEvents(const RooArgSet * /*nset*/) const override { return _pdf->expectedEvents(&_normSet); }
66
67 std::unique_ptr<RooAbsReal> createExpectedEventsFunc(const RooArgSet * /*nset*/) const override
68 {
69 return _pdf->createExpectedEventsFunc(&_normSet);
70 }
71
72 bool canComputeBatchWithCuda() const override { return true; }
73
74 RooAbsPdf const &pdf() const { return *_pdf; }
75 RooAbsReal const &normIntegral() const { return *_normIntegral; }
76
77protected:
78 void doEval(RooFit::EvalContext &) const override;
79 double evaluate() const override
80 {
81 // The evaluate() function should not be called in the BatchMode, but we
82 // still need it to support printing of the object.
83 return getValV(nullptr);
84 }
85 double getValV(const RooArgSet * normSet) const override;
86
87private:
91
93};
94
95} // namespace RooFit::Detail
96
97#endif
RooTemplateProxy< RooAbsReal > RooRealProxy
Compatibility typedef replacing the old RooRealProxy class.
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
char name[80]
Definition TGX11.cxx:148
void SetName(const char *name) override
Set the name of the TNamed.
RooAbsArg()
Default constructor.
TString _normRange
Normalization range.
Definition RooAbsPdf.h:336
const char * normRange() const
Definition RooAbsPdf.h:246
RooAbsPdf()
Default constructor.
friend class RooAbsReal
Definition RooAbsPdf.h:342
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
RooAbsReal const & normIntegral() const
bool selfNormalized() const override
Shows if a PDF is self-normalized, which means that no attempt is made to add a normalization term.
bool canComputeBatchWithCuda() const override
bool forceAnalyticalInt(const RooAbsArg &) const override
double expectedEvents(const RooArgSet *) const override
Return expected number of events to be used in calculation of extended likelihood.
double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Forward calculation of analytical integrals to input p.d.f.
RooAbsPdf const & pdf() const
RooNormalizedPdf(const RooNormalizedPdf &other, const char *name)
RooTemplateProxy< RooAbsPdf > _pdf
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Forward determination of analytical integration capabilities to input p.d.f.
double getValV(const RooArgSet *normSet) const override
Return current value, normalized by integrating over the observables in nset.
RooNormalizedPdf(RooAbsPdf &pdf, RooArgSet const &normSet)
std::unique_ptr< RooAbsReal > createExpectedEventsFunc(const RooArgSet *) const override
Returns an object that represents the expected number of events for a given normalization set,...
TObject * clone(const char *newname) const override
double getCorrection() const override
This function returns the penalty term.
void doEval(RooFit::EvalContext &) const override
Base function for computing multiple values of a RooAbsReal.
ExtendMode extendMode() const override
Returns ability of PDF to provide extended likelihood terms.
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:173
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
TObject()
TObject constructor.
Definition TObject.h:259
STL class.