Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 {
20namespace Detail {
21
23public:
25 : _pdf("numerator", "numerator", this, pdf),
27 "denominator", "denominator", this,
29 false),
31 {
32 auto name = std::string(pdf.GetName()) + "_over_" + _normIntegral->GetName();
33 SetName(name.c_str());
34 SetTitle(name.c_str());
35 _normRange = pdf.normRange(); // so that e.g. RooAddPdf can query over what we are normalized
36 }
37
40 _pdf("numerator", this, other._pdf),
41 _normIntegral("denominator", this, other._normIntegral),
43 {
44 }
45
46 TObject *clone(const char *newname) const override { return new RooNormalizedPdf(*this, newname); }
47
48 bool selfNormalized() const override { return true; }
49
50 bool forceAnalyticalInt(const RooAbsArg & /*dep*/) const override { return true; }
51 /// Forward determination of analytical integration capabilities to input p.d.f
53 const char *rangeName = nullptr) const override
54 {
55 return _pdf->getAnalyticalIntegralWN(allVars, analVars, &_normSet, rangeName);
56 }
57 /// Forward calculation of analytical integrals to input p.d.f
58 double
59 analyticalIntegralWN(Int_t code, const RooArgSet * /*normSet*/, const char *rangeName = nullptr) const override
60 {
61 return _pdf->analyticalIntegralWN(code, &_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 void translate(RooFit::Detail::CodeSquashContext &ctx) const override;
73
74 bool canComputeBatchWithCuda() const override { return true; }
75
76 RooAbsPdf const &pdf() const { return *_pdf; }
77 RooAbsReal const &normIntegral() const { return *_normIntegral; }
78
79protected:
80 void doEval(RooFit::EvalContext &) const override;
81 double evaluate() const override
82 {
83 // The evaluate() function should not be called in the BatchMode, but we
84 // still need it to support printing of the object.
85 return getValV(nullptr);
86 }
87 double getValV(const RooArgSet * /*normSet*/) const override
88 {
89 return normalizeWithNaNPacking(_pdf->getVal(), _normIntegral->getVal());
90 };
91
92private:
96
98};
99
100} // namespace Detail
101} // namespace RooFit
102
103#endif
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
char name[80]
Definition TGX11.cxx:110
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:79
void SetName(const char *name) override
Set the name of the TNamed.
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:40
TString _normRange
Normalization range.
Definition RooAbsPdf.h:342
const char * normRange() const
Definition RooAbsPdf.h:250
double normalizeWithNaNPacking(double rawVal, double normVal) const
virtual ExtendMode extendMode() const
Returns ability of PDF to provide extended likelihood terms.
Definition RooAbsPdf.h:216
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
RooFit::OwningPtr< RooAbsReal > createIntegral(const RooArgSet &iset, const RooCmdArg &arg1, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}) const
Create an object that represents the integral of the function over one or more observables listed in ...
const RooNumIntConfig * getIntegratorConfig() const
Return the numeric integration configuration used for this object.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
A class to maintain the context for squashing of RooFit models into code.
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
void translate(RooFit::Detail::CodeSquashContext &ctx) const override
This function defines a translation for each RooAbsReal based object that can be used to express the ...
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 getValV(const RooArgSet *) const override
Return current value, normalized by integrating over the observables in nset.
RooAbsPdf const & pdf() const
RooNormalizedPdf(const RooNormalizedPdf &other, const char *name)
RooTemplateProxy< RooAbsPdf > _pdf
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *, const char *rangeName=nullptr) const override
Forward determination of analytical integration capabilities to input p.d.f.
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,...
double analyticalIntegralWN(Int_t code, const RooArgSet *, const char *rangeName=nullptr) const override
Forward calculation of analytical integrals to input p.d.f.
TObject * clone(const char *newname) const override
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:164
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
Mother of all ROOT objects.
Definition TObject.h:41
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition JSONIO.h:26