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 #include <list>
23 
24 class RooWrapperPdf final : public RooAbsPdf {
25 public:
26 
28  /// Construct a new RooWrapperPdf.
29  /// \param[in] name A name to identify this object.
30  /// \param[in] title Title (for e.g. plotting)
31  /// \param[in] inputFunction Any RooAbsReal that should be converted into a PDF. Although it's possible
32  /// to pass a PDF, it only makes sense for non-PDF functions.
33  RooWrapperPdf(const char *name, const char *title, RooAbsReal& inputFunction) :
34  RooAbsPdf(name, title),
35  _func("inputFunction", "Function to be converted into a PDF", this, inputFunction) { }
36  virtual ~RooWrapperPdf() {};
37 
38  RooWrapperPdf(const RooWrapperPdf& other, const char* name = 0) :
39  RooAbsPdf(other, name),
40  _func("inputFunction", this, other._func) { }
41 
42  virtual TObject* clone(const char* newname) const override {
43  return new RooWrapperPdf(*this, newname);
44  }
45 
46  // Analytical Integration handling
47  Bool_t forceAnalyticalInt(const RooAbsArg& dep) const override {
48  return _func.arg().forceAnalyticalInt(dep);
49  }
50  Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& analVars, const RooArgSet* normSet,
51  const char* rangeName=0) const override {
52  return _func.arg().getAnalyticalIntegralWN(allVars, analVars, normSet, rangeName);
53  }
55  const char* rangeName=0) const override {
56  return _func.arg().getAnalyticalIntegral(allVars, numVars, rangeName);
57  }
58  double analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName) const override {
59  return _func.arg().analyticalIntegralWN(code, normSet, rangeName);
60  }
61  double analyticalIntegral(Int_t code, const char* rangeName=0) const override {
62  return _func.arg().analyticalIntegral(code, rangeName);
63  }
64 
65 
66  // Internal toy generation. Since our _func is not a PDF (if it is, it doesn't make sense to use this wrapper),
67  // we cannot do anything.
68  /// Get specialised generator. Since the underlying function is not a PDF, this will always return zero.
69 // Int_t getGenerator(const RooArgSet& /*directVars*/, RooArgSet& /*generateVars*/,
70 // bool /*staticInitOK = true*/) const override { return 0; }
71 // void initGenerator(Int_t /*code*/) override { }
72 // void generateEvent(Int_t /*code*/) override { }
73 // Bool_t isDirectGenSafe(const RooAbsArg& /*arg*/) const override { return false; }
74 
75 
76  // Hints for optimized brute-force sampling
77  Int_t getMaxVal(const RooArgSet& vars) const override {
78  return _func.arg().getMaxVal(vars);
79  }
80  Double_t maxVal(Int_t code) const override {
81  return _func.arg().maxVal(code);
82  }
83  Int_t minTrialSamples(const RooArgSet& arGenObs) const override {
84  return _func.arg().minTrialSamples(arGenObs);
85  }
86 
87  // Plotting and binning hints
88  Bool_t isBinnedDistribution(const RooArgSet& obs) const override {
89  return _func.arg().isBinnedDistribution(obs);
90  }
91  std::list<Double_t>* binBoundaries(RooAbsRealLValue& obs, Double_t xlo, Double_t xhi) const override {
92  return _func.arg().binBoundaries(obs, xlo, xhi);
93  }
94  std::list<Double_t>* plotSamplingHint(RooAbsRealLValue& obs, Double_t xlo, Double_t xhi) const override {
95  return _func.arg().plotSamplingHint(obs, xlo, xhi);
96  }
97 
98 
99 
100 private:
102 
103  double evaluate() const override {
104  return _func;
105  }
106 
108 };
109 
110 #endif
RooAbsReal::analyticalIntegral
virtual Double_t analyticalIntegral(Int_t code, const char *rangeName=0) const
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
Definition: RooAbsReal.cxx:429
RooWrapperPdf::isBinnedDistribution
Bool_t isBinnedDistribution(const RooArgSet &obs) const override
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
Definition: RooWrapperPdf.h:88
RooAbsReal.h
RooAbsReal::plotSamplingHint
virtual std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const
Interface for returning an optional hint for initial sampling points when constructing a curve projec...
Definition: RooAbsReal.cxx:3840
RooWrapperPdf::analyticalIntegral
double analyticalIntegral(Int_t code, const char *rangeName=0) const override
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
Definition: RooWrapperPdf.h:61
RooTemplateProxy::arg
const T & arg() const
Return reference to object held in proxy.
Definition: RooTemplateProxy.h:259
RooWrapperPdf
The RooWrapperPdf is a class that can be used to convert a function into a PDF.
Definition: RooWrapperPdf.h:24
RooAbsReal::isBinnedDistribution
virtual Bool_t isBinnedDistribution(const RooArgSet &) const
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
Definition: RooAbsReal.h:327
RooWrapperPdf::RooWrapperPdf
RooWrapperPdf()
Definition: RooWrapperPdf.h:27
RooWrapperPdf::maxVal
Double_t maxVal(Int_t code) const override
Return maximum value for set of observables identified by code assigned in getMaxVal.
Definition: RooWrapperPdf.h:80
RooAbsReal::binBoundaries
virtual std::list< Double_t > * binBoundaries(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const
Retrieve bin boundaries if this distribution is binned in obs.
Definition: RooAbsReal.cxx:3829
RooAbsReal
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
ClassDefOverride
#define ClassDefOverride(name, id)
Definition: Rtypes.h:329
RooWrapperPdf::clone
virtual TObject * clone(const char *newname) const override
Definition: RooWrapperPdf.h:42
bool
RooWrapperPdf::_func
RooRealProxy _func
Definition: RooWrapperPdf.h:101
RooWrapperPdf::binBoundaries
std::list< Double_t > * binBoundaries(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const override
Retrieve bin boundaries if this distribution is binned in obs.
Definition: RooWrapperPdf.h:91
RooAbsReal::forceAnalyticalInt
virtual Bool_t forceAnalyticalInt(const RooAbsArg &) const
Definition: RooAbsReal.h:153
RooWrapperPdf::RooWrapperPdf
RooWrapperPdf(const RooWrapperPdf &other, const char *name=0)
Definition: RooWrapperPdf.h:38
RooWrapperPdf::RooWrapperPdf
RooWrapperPdf(const char *name, const char *title, RooAbsReal &inputFunction)
Construct a new RooWrapperPdf.
Definition: RooWrapperPdf.h:33
RooAbsReal::minTrialSamples
virtual Int_t minTrialSamples(const RooArgSet &) const
Definition: RooAbsReal.h:231
RooWrapperPdf::evaluate
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
Definition: RooWrapperPdf.h:103
RooWrapperPdf::~RooWrapperPdf
virtual ~RooWrapperPdf()
Definition: RooWrapperPdf.h:36
RooAbsPdf.h
RooWrapperPdf::minTrialSamples
Int_t minTrialSamples(const RooArgSet &arGenObs) const override
Definition: RooWrapperPdf.h:83
RooAbsReal::analyticalIntegralWN
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:415
RooAbsReal::getMaxVal
virtual Int_t getMaxVal(const RooArgSet &vars) const
Advertise capability to determine maximum value of function for given set of observables.
Definition: RooAbsReal.cxx:3657
RooRealProxy.h
RooAbsReal::getAnalyticalIntegral
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:403
RooWrapperPdf::getAnalyticalIntegralWN
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:50
RooWrapperPdf::getAnalyticalIntegral
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:54
RooAbsReal::maxVal
virtual Double_t maxVal(Int_t code) const
Return maximum value for set of observables identified by code assigned in getMaxVal.
Definition: RooAbsReal.cxx:3668
RooWrapperPdf::analyticalIntegralWN
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:58
RooTemplateProxy< RooAbsReal >
RooAbsReal::getAnalyticalIntegralWN
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:386
Double_t
double Double_t
Definition: RtypesCore.h:59
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
RooWrapperPdf::forceAnalyticalInt
Bool_t forceAnalyticalInt(const RooAbsArg &dep) const override
Definition: RooWrapperPdf.h:47
name
char name[80]
Definition: TGX11.cxx:110
RooWrapperPdf::getMaxVal
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:77
RooAbsArg
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:72
RooAbsPdf
Definition: RooAbsPdf.h:43
RooWrapperPdf::plotSamplingHint
std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const override
Interface for returning an optional hint for initial sampling points when constructing a curve projec...
Definition: RooWrapperPdf.h:94
RooAbsRealLValue
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
Definition: RooAbsRealLValue.h:31
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:29
int