Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooRealIntegral.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooRealIntegral.h,v 1.44 2007/05/11 09:11:30 verkerke Exp $
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-2005, 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_REAL_INTEGRAL
17#define ROO_REAL_INTEGRAL
18
19#include <RooAbsPdf.h>
20#include <RooAbsReal.h>
21#include <RooArgSet.h>
22#include <RooListProxy.h>
23#include <RooRealProxy.h>
24#include <RooSetProxy.h>
25
27class RooNumIntConfig;
28
30public:
31
32 // Constructors, assignment etc
34 RooRealIntegral(const char *name, const char *title, const RooAbsReal& function, const RooArgSet& depList,
35 const RooArgSet* funcNormSet=nullptr, const RooNumIntConfig* config=nullptr, const char* rangeName=nullptr) ;
36 RooRealIntegral(const RooRealIntegral& other, const char* name=nullptr);
37 TObject* clone(const char* newname) const override { return new RooRealIntegral(*this,newname); }
38 ~RooRealIntegral() override;
39
40 double getValV(const RooArgSet* set=nullptr) const override ;
41
42 bool isValid() const override { return _valid; }
43
44 void printMultiline(std::ostream& os, Int_t contents, bool verbose=false, TString indent="") const override ;
45 void printMetaArgs(std::ostream& os) const override ;
46
47 const RooArgSet& numIntCatVars() const { return _sumList ; }
48 const RooArgSet& numIntRealVars() const { return _intList ; }
49 const RooArgSet& anaIntVars() const { return _anaList ; }
50
51 RooArgSet intVars() const { RooArgSet tmp(_sumList) ; tmp.add(_intList) ; tmp.add(_anaList) ; tmp.add(_facList) ; return tmp ; }
52 const char* intRange() const { return _rangeName ? _rangeName->GetName() : nullptr ; }
53 const RooAbsReal& integrand() const { return *_function; }
54
55 void setCacheNumeric(bool flag) {
56 // If true, value of this integral is cached if it is (partially numeric)
57 _cacheNum = flag ;
58 }
59
61 // If true, value of this integral is cached if it is (partially numeric)
62 return _cacheNum ;
63 }
64
65 static void setCacheAllNumeric(Int_t ndim) ;
66
67 static Int_t getCacheAllNumeric() ;
68
69 std::list<double>* plotSamplingHint(RooAbsRealLValue& obs, double xlo, double xhi) const override {
70 // Forward plot sampling hint of integrand
71 return _function->plotSamplingHint(obs,xlo,xhi) ;
72 }
73
74 RooFit::OwningPtr<RooAbsReal> createIntegral(const RooArgSet& iset, const RooArgSet* nset=nullptr, const RooNumIntConfig* cfg=nullptr, const char* rangeName=nullptr) const override ;
75
76 void setAllowComponentSelection(bool allow);
77 bool getAllowComponentSelection() const;
78
79 std::unique_ptr<RooAbsArg> compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext & ctx) const override;
80
81 void translate(RooFit::Detail::CodeSquashContext &ctx) const override;
82protected:
83
84 mutable bool _valid = false;
85 bool _respectCompSelect = true;
86
87 const RooArgSet& parameters() const ;
88
90 //friend class RooAbsPdf ;
91
92 bool initNumIntegrator() const;
93 void autoSelectDirtyMode() ;
94
95 virtual double sum() const ;
96 virtual double integrate() const ;
97 virtual double jacobianProduct() const ;
98
99 // Evaluation and validation implementation
100 double evaluate() const override ;
101 bool isValidReal(double value, bool printError=false) const override ;
102
103 bool redirectServersHook(const RooAbsCollection& newServerList,
104 bool mustReplaceAll, bool nameChange, bool isRecursive) override ;
105
106 // Internal function to get the normalization set for the integrated
107 // function. By default, we will take the normalization set from the function
108 // proxy, but _funcNormSet will be used if it is set.
109 inline RooArgSet const* funcNormSet() const {
111 }
112
113 // Function pointer and integrands list
114 RooSetProxy _sumList; ///< Set of discrete observable over which is summed numerically
115 RooSetProxy _intList; ///< Set of continuous observables over which is integrated numerically
116 RooSetProxy _anaList; ///< Set of observables over which is integrated/summed analytically
117 RooSetProxy _jacList; ///< Set of lvalue observables over which is analytically integration that have a non-unit Jacobian
118 RooSetProxy _facList; ///< Set of observables on which function does not depends, which are integrated nevertheless
119
120 RooRealProxy _function ; ///< Function being integrated
121 std::unique_ptr<RooArgSet> _funcNormSet; ///< Optional normalization set passed to function
122
125
127
129
131 IntOperMode _intOperMode = Hybrid; ///< integration operation mode
132
133 mutable bool _restartNumIntEngine = false; ///<!
134 mutable std::unique_ptr<RooAbsIntegrator> _numIntEngine; ///<!
135 mutable std::unique_ptr<RooAbsFunc> _numIntegrand; ///<!
136
137 TNamed* _rangeName = nullptr;
138
139 mutable std::unique_ptr<RooArgSet> _params; ///<! cache for set of parameters
140
141 bool _cacheNum = false; ///< Cache integral if numeric
142 static Int_t _cacheAllNDim ; ///<! Cache all integrals with given numeric dimension
143
144private:
145 void addNumIntDep(RooAbsArg const &arg);
146
147 ClassDefOverride(RooRealIntegral,5) // Real-valued function representing an integral over a RooAbsReal object
148};
149
150#endif
RooAbsReal & function()
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
static void indent(ostringstream &buf, int indent_level)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
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:77
Abstract container object that can hold multiple RooAbsArg objects.
Storage_t const & get() const
Const access to the underlying stl container.
Abstract interface for integrators of real-valued functions that implement the RooAbsFunc interface.
const RooArgSet * nset() const
Definition RooAbsProxy.h:52
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
virtual std::list< double > * plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const
Interface for returning an optional hint for initial sampling points when constructing a curve projec...
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
A class to maintain the context for squashing of RooFit models into code.
Holds the configuration parameters of the various numeric integrators used by RooRealIntegral.
Performs hybrid numerical/analytical integrals of RooAbsReal objects.
RooNumIntConfig * _iconfig
bool initNumIntegrator() const
(Re)Initialize numerical integration engine if necessary.
const RooArgSet & numIntRealVars() const
RooArgSet const * funcNormSet() const
RooFit::OwningPtr< RooAbsReal > createIntegral(const RooArgSet &iset, const RooArgSet *nset=nullptr, const RooNumIntConfig *cfg=nullptr, const char *rangeName=nullptr) const override
Create an object that represents the integral of the function over one or more observables listed in ...
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 ...
void setAllowComponentSelection(bool allow)
Set component selection to be allowed/forbidden.
RooRealProxy _function
Function being integrated.
const RooArgSet & anaIntVars() const
std::list< double > * plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const override
Interface for returning an optional hint for initial sampling points when constructing a curve projec...
RooArgSet intVars() const
RooSetProxy _intList
Set of continuous observables over which is integrated numerically.
const RooAbsReal & integrand() const
const RooArgSet & numIntCatVars() const
virtual double sum() const
Perform summation of list of category dependents to be integrated.
RooSetProxy _facList
Set of observables on which function does not depends, which are integrated nevertheless.
std::unique_ptr< RooArgSet > _params
! cache for set of parameters
static void setCacheAllNumeric(Int_t ndim)
Global switch to cache all integral values that integrate at least ndim dimensions numerically.
IntOperMode _intOperMode
integration operation mode
TObject * clone(const char *newname) const override
bool _cacheNum
Cache integral if numeric.
double evaluate() const override
Perform the integration and return the result.
const RooArgSet & parameters() const
std::unique_ptr< RooAbsFunc > _numIntegrand
!
void addNumIntDep(RooAbsArg const &arg)
Sort numeric integration variables in summation and integration lists.
RooSetProxy _jacList
Set of lvalue observables over which is analytically integration that have a non-unit Jacobian.
bool isValidReal(double value, bool printError=false) const override
Check if current value is valid.
double getValV(const RooArgSet *set=nullptr) const override
Return value of object.
RooSetProxy _anaList
Set of observables over which is integrated/summed analytically.
bool redirectServersHook(const RooAbsCollection &newServerList, bool mustReplaceAll, bool nameChange, bool isRecursive) override
Intercept server redirects and reconfigure internal object accordingly.
RooSetProxy _sumList
Set of discrete observable over which is summed numerically.
~RooRealIntegral() override
void printMetaArgs(std::ostream &os) const override
Customized printing of arguments of a RooRealIntegral to more intuitively reflect the contents of the...
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Print the state of this object to the specified output stream.
std::unique_ptr< RooAbsIntegrator > _numIntEngine
!
virtual double integrate() const
Perform hybrid numerical/analytical integration over all real-valued dependents.
RooListProxy _sumCat
!
virtual double jacobianProduct() const
Return product of jacobian terms originating from analytical integration.
static Int_t getCacheAllNumeric()
Return minimum dimensions of numeric integration for which values are cached.
static Int_t _cacheAllNDim
! Cache all integrals with given numeric dimension
std::unique_ptr< RooArgSet > _funcNormSet
Optional normalization set passed to function.
std::unique_ptr< RooAbsArg > compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext &ctx) const override
void autoSelectDirtyMode()
Set appropriate cache operation mode for integral depending on cache operation mode of server objects...
bool isValid() const override
Check if current value is valid.
const char * intRange() const
bool getAllowComponentSelection() const
Check if component selection is allowed.
void setCacheNumeric(bool flag)
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:139
T * OwningPtr
An alias for raw pointers for indicating that the return type of a RooFit function is an owning point...
Definition Config.h:35