Logo ROOT  
Reference Guide
RooWrapperPdf.h
Go to the documentation of this file.
1// Author: Stephan Hageboeck, CERN
2/*****************************************************************************
3 * Project: RooFit *
4 * Package: RooFitCore *
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2018, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16#ifndef ROO_WRAPPER_PDF
17#define ROO_WRAPPER_PDF
18
19#include "RooAbsReal.h"
20#include "RooRealProxy.h"
21#include "RooAbsPdf.h"
22
23class RooWrapperPdf final : public RooAbsPdf {
24public:
25
27 /// Construct a new RooWrapperPdf.
28 /// \param[in] name A name to identify this object.
29 /// \param[in] title Title (for e.g. plotting)
30 /// \param[in] inputFunction Any RooAbsReal that should be converted into a PDF. Although it's possible
31 /// to pass a PDF, it only makes sense for non-PDF functions.
32 RooWrapperPdf(const char *name, const char *title, RooAbsReal& inputFunction) :
33 RooAbsPdf(name, title),
34 _func("inputFunction", "Function to be converted into a PDF", this, inputFunction) { }
35 virtual ~RooWrapperPdf() {};
36
37 RooWrapperPdf(const RooWrapperPdf& other, const char* name = 0) :
38 RooAbsPdf(other, name),
39 _func("inputFunction", this, other._func) { }
40
41 virtual TObject* clone(const char* newname) const override {
42 return new RooWrapperPdf(*this, newname);
43 }
44
45 // Analytical Integration handling
46 Bool_t forceAnalyticalInt(const RooAbsArg& dep) const override {
47 return _func.arg().forceAnalyticalInt(dep);
48 }
49 Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& analVars, const RooArgSet* normSet,
50 const char* rangeName=0) const override {
51 return _func.arg().getAnalyticalIntegralWN(allVars, analVars, normSet, rangeName);
52 }
54 const char* rangeName=0) const override {
55 return _func.arg().getAnalyticalIntegral(allVars, numVars, rangeName);
56 }
57 double analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName) const override {
58 return _func.arg().analyticalIntegralWN(code, normSet, rangeName);
59 }
60 double analyticalIntegral(Int_t code, const char* rangeName=0) const override {
61 return _func.arg().analyticalIntegral(code, rangeName);
62 }
63
64
65 // Internal toy generation. Since our _func is not a PDF (if it is, it doesn't make sense to use this wrapper),
66 // we cannot do anything.
67 /// Get specialised generator. Since the underlying function is not a PDF, this will always return zero.
68// Int_t getGenerator(const RooArgSet& /*directVars*/, RooArgSet& /*generateVars*/,
69// bool /*staticInitOK = true*/) const override { return 0; }
70// void initGenerator(Int_t /*code*/) override { }
71// void generateEvent(Int_t /*code*/) override { }
72// Bool_t isDirectGenSafe(const RooAbsArg& /*arg*/) const override { return false; }
73
74
75 // Hints for optimized brute-force sampling
76 Int_t getMaxVal(const RooArgSet& vars) const override {
77 return _func.arg().getMaxVal(vars);
78 }
79 Double_t maxVal(Int_t code) const override {
80 return _func.arg().maxVal(code);
81 }
82 Int_t minTrialSamples(const RooArgSet& arGenObs) const override {
83 return _func.arg().minTrialSamples(arGenObs);
84 }
85
86 // Plotting and binning hints
87 Bool_t isBinnedDistribution(const RooArgSet& obs) const override {
88 return _func.arg().isBinnedDistribution(obs);
89 }
90 std::list<Double_t>* binBoundaries(RooAbsRealLValue& obs, Double_t xlo, Double_t xhi) const override {
91 return _func.arg().binBoundaries(obs, xlo, xhi);
92 }
93 std::list<Double_t>* plotSamplingHint(RooAbsRealLValue& obs, Double_t xlo, Double_t xhi) const override {
94 return _func.arg().plotSamplingHint(obs, xlo, xhi);
95 }
96
97
98
99private:
101
102 double evaluate() const override {
103 return _func;
104 }
105
107};
108
109#endif
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
#define ClassDefOverride(name, id)
Definition: Rtypes.h:330
char name[80]
Definition: TGX11.cxx:109
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:71
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:59
virtual Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=0) const
Variant of getAnalyticalIntegral that is also passed the normalization set that should be applied to ...
Definition: RooAbsReal.cxx:373
virtual std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &, Double_t, Double_t) const
Definition: RooAbsReal.h:311
virtual Double_t analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
Definition: RooAbsReal.cxx:402
virtual std::list< Double_t > * binBoundaries(RooAbsRealLValue &, Double_t, Double_t) const
Definition: RooAbsReal.h:310
virtual Bool_t forceAnalyticalInt(const RooAbsArg &) const
Definition: RooAbsReal.h:136
virtual Int_t minTrialSamples(const RooArgSet &) const
Definition: RooAbsReal.h:214
virtual Double_t maxVal(Int_t code) const
Return maximum value for set of observables identified by code assigned in getMaxVal.
virtual Double_t analyticalIntegral(Int_t code, const char *rangeName=0) const
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
Definition: RooAbsReal.cxx:416
virtual Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=0) const
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported.
Definition: RooAbsReal.cxx:390
virtual Bool_t isBinnedDistribution(const RooArgSet &) const
Definition: RooAbsReal.h:309
virtual Int_t getMaxVal(const RooArgSet &vars) const
Advertise capability to determine maximum value of function for given set of observables.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
const T & arg() const
Return reference to object held in proxy.
The RooWrapperPdf is a class that can be used to convert a function into a PDF.
Definition: RooWrapperPdf.h:23
Int_t getMaxVal(const RooArgSet &vars) const override
Get specialised generator. Since the underlying function is not a PDF, this will always return zero.
Definition: RooWrapperPdf.h:76
Bool_t forceAnalyticalInt(const RooAbsArg &dep) const override
Definition: RooWrapperPdf.h:46
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=0) const override
Variant of getAnalyticalIntegral that is also passed the normalization set that should be applied to ...
Definition: RooWrapperPdf.h:49
RooRealProxy _func
double analyticalIntegral(Int_t code, const char *rangeName=0) const override
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
Definition: RooWrapperPdf.h:60
std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const override
Definition: RooWrapperPdf.h:93
std::list< Double_t > * binBoundaries(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const override
Definition: RooWrapperPdf.h:90
RooWrapperPdf(const char *name, const char *title, RooAbsReal &inputFunction)
Construct a new RooWrapperPdf.
Definition: RooWrapperPdf.h:32
double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName) const override
Analytical integral with normalization (see RooAbsReal::analyticalIntegralWN() for further informatio...
Definition: RooWrapperPdf.h:57
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
virtual ~RooWrapperPdf()
Definition: RooWrapperPdf.h:35
Bool_t isBinnedDistribution(const RooArgSet &obs) const override
Definition: RooWrapperPdf.h:87
RooWrapperPdf(const RooWrapperPdf &other, const char *name=0)
Definition: RooWrapperPdf.h:37
Double_t maxVal(Int_t code) const override
Return maximum value for set of observables identified by code assigned in getMaxVal.
Definition: RooWrapperPdf.h:79
Int_t minTrialSamples(const RooArgSet &arGenObs) const override
Definition: RooWrapperPdf.h:82
virtual TObject * clone(const char *newname) const override
Definition: RooWrapperPdf.h:41
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &numVars, const char *rangeName=0) const override
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported.
Definition: RooWrapperPdf.h:53
Mother of all ROOT objects.
Definition: TObject.h:37