Logo ROOT  
Reference Guide
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
20public:
21 RooNormalizedPdf(RooAbsPdf &pdf, RooArgSet const &normSet)
22 : _pdf("numerator", "numerator", this, pdf),
23 _normIntegral("denominator", "denominator", this,
24 *pdf.createIntegral(normSet, *pdf.getIntegratorConfig(), nullptr), true, false, true),
25 _normSet{normSet}
26 {
27 auto name = std::string(pdf.GetName()) + "_over_" + _normIntegral->GetName();
28 SetName(name.c_str());
29 SetTitle(name.c_str());
30 }
31
32 RooNormalizedPdf(const RooNormalizedPdf &other, const char *name)
33 : RooAbsPdf(other, name), _pdf("numerator", this, other._pdf),
34 _normIntegral("denominator", this, other._normIntegral), _normSet{other._normSet}
35 {
36 }
37
38 TObject *clone(const char *newname) const override { return new RooNormalizedPdf(*this, newname); }
39
40 bool selfNormalized() const override { return true; }
41
42 bool forceAnalyticalInt(const RooAbsArg & /*dep*/) const override { return true; }
43 /// Forward determination of analytical integration capabilities to input p.d.f
44 Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet * /*normSet*/,
45 const char *rangeName = nullptr) const override
46 {
47 return _pdf->getAnalyticalIntegralWN(allVars, analVars, &_normSet, rangeName);
48 }
49 /// Forward calculation of analytical integrals to input p.d.f
50 double analyticalIntegralWN(Int_t code, const RooArgSet * /*normSet*/, const char *rangeName = 0) const override
51 {
52 return _pdf->analyticalIntegralWN(code, &_normSet, rangeName);
53 }
54
55 ExtendMode extendMode() const override { return static_cast<RooAbsPdf &>(*_pdf).extendMode(); }
56 double expectedEvents(const RooArgSet *nset) const override
57 {
58 return static_cast<RooAbsPdf &>(*_pdf).expectedEvents(nset);
59 }
60
61protected:
62 void computeBatch(cudaStream_t *, double *output, size_t size, RooFit::Detail::DataMap const&) const override;
63 double evaluate() const override
64 {
65 // Evaluate() should not be called in the BatchMode, but we still need it
66 // to support printing of the object.
67 return getValV(nullptr);
68 }
69 double getValV(const RooArgSet * /*normSet*/) const override
70 {
72 };
73
74private:
78};
79
80#endif
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
char name[80]
Definition: TGX11.cxx:110
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:71
void SetName(const char *name) override
Set the name of the TNamed.
Definition: RooAbsArg.cxx:2314
virtual double expectedEvents(const RooArgSet *nset) const
Return expected number of events to be used in calculation of extended likelihood.
Definition: RooAbsPdf.cxx:3180
double normalizeWithNaNPacking(double rawVal, double normVal) const
Definition: RooAbsPdf.cxx:313
virtual ExtendMode extendMode() const
Returns ability of PDF to provide extended likelihood terms.
Definition: RooAbsPdf.h:262
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:91
virtual Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=nullptr) const
Variant of getAnalyticalIntegral that is also passed the normalization set that should be applied to ...
Definition: RooAbsReal.cxx:360
RooAbsReal * createIntegral(const RooArgSet &iset, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Create an object that represents the integral of the function over one or more observables std::liste...
Definition: RooAbsReal.cxx:522
virtual double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=nullptr) const
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
Definition: RooAbsReal.cxx:389
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:56
A RooNormalizedPdf wraps a pdf divided by its integral for a given normalization set into a new self-...
double analyticalIntegralWN(Int_t code, const RooArgSet *, const char *rangeName=0) const override
Forward calculation of analytical integrals to input p.d.f.
RooRealProxy _normIntegral
RooNormalizedPdf(RooAbsPdf &pdf, RooArgSet const &normSet)
bool selfNormalized() const override
Shows if a PDF is self-normalized, which means that no attempt is made to add a normalization term.
RooRealProxy _pdf
RooArgSet const & _normSet
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.
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
void computeBatch(cudaStream_t *, double *output, size_t size, RooFit::Detail::DataMap const &) const override
Base function for computing multiple values of a RooAbsReal.
double getValV(const RooArgSet *) const override
Return current value, normalized by integrating over the observables in nset.
TObject * clone(const char *newname) const override
ExtendMode extendMode() const override
Returns ability of PDF to provide extended likelihood terms.
double expectedEvents(const RooArgSet *nset) const override
Return expected number of events to be used in calculation of extended likelihood.
bool forceAnalyticalInt(const RooAbsArg &) const override
RooNormalizedPdf(const RooNormalizedPdf &other, const char *name)
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
static void output()