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 "RooAbsReal.h"
20#include "RooArgSet.h"
21#include "RooAbsPdf.h"
22#include "RooRealProxy.h"
23#include "RooSetProxy.h"
24#include "RooListProxy.h"
25#include <list>
26
27class RooArgSet ;
28class TH1F ;
29class RooAbsCategory ;
30class RooRealVar ;
31class RooAbsIntegrator ;
32class RooNumIntConfig ;
33
35public:
36
37 // Constructors, assignment etc
39 RooRealIntegral(const char *name, const char *title, const RooAbsReal& function, const RooArgSet& depList,
40 const RooArgSet* funcNormSet=nullptr, const RooNumIntConfig* config=nullptr, const char* rangeName=nullptr) ;
41 RooRealIntegral(const RooRealIntegral& other, const char* name=nullptr);
42 TObject* clone(const char* newname) const override { return new RooRealIntegral(*this,newname); }
43 ~RooRealIntegral() override;
44
45 double getValV(const RooArgSet* set=nullptr) const override ;
46
47 bool isValid() const override { return _valid; }
48
49 void printMultiline(std::ostream& os, Int_t contents, bool verbose=false, TString indent="") const override ;
50 void printMetaArgs(std::ostream& os) const override ;
51
52 const RooArgSet& numIntCatVars() const { return _sumList ; }
53 const RooArgSet& numIntRealVars() const { return _intList ; }
54 const RooArgSet& anaIntVars() const { return _anaList ; }
55
56 RooArgSet intVars() const { RooArgSet tmp(_sumList) ; tmp.add(_intList) ; tmp.add(_anaList) ; tmp.add(_facList) ; return tmp ; }
57 const char* intRange() const { return _rangeName ? _rangeName->GetName() : nullptr ; }
58 const RooAbsReal& integrand() const { return *_function; }
59
60 void setCacheNumeric(bool flag) {
61 // If true, value of this integral is cached if it is (partially numeric)
62 _cacheNum = flag ;
63 }
64
66 // If true, value of this integral is cached if it is (partially numeric)
67 return _cacheNum ;
68 }
69
70 static void setCacheAllNumeric(Int_t ndim) ;
71
72 static Int_t getCacheAllNumeric() ;
73
74 std::list<double>* plotSamplingHint(RooAbsRealLValue& obs, double xlo, double xhi) const override {
75 // Forward plot sampling hint of integrand
76 return _function->plotSamplingHint(obs,xlo,xhi) ;
77 }
78
79 RooFit::OwningPtr<RooAbsReal> createIntegral(const RooArgSet& iset, const RooArgSet* nset=nullptr, const RooNumIntConfig* cfg=nullptr, const char* rangeName=nullptr) const override ;
80
81 void setAllowComponentSelection(bool allow);
82 bool getAllowComponentSelection() const;
83
84 std::unique_ptr<RooAbsArg> compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext & ctx) const override;
85
86protected:
87
88 mutable bool _valid = false;
89 bool _respectCompSelect = true;
90
91 const RooArgSet& parameters() const ;
92
94 //friend class RooAbsPdf ;
95
96 bool initNumIntegrator() const;
97 void autoSelectDirtyMode() ;
98
99 virtual double sum() const ;
100 virtual double integrate() const ;
101 virtual double jacobianProduct() const ;
102
103 // Evaluation and validation implementation
104 double evaluate() const override ;
105 bool isValidReal(double value, bool printError=false) const override ;
106 bool servesExclusively(const RooAbsArg* server,const RooArgSet& exclLVBranches, const RooArgSet& allBranches) const ;
107
108
109 bool redirectServersHook(const RooAbsCollection& newServerList,
110 bool mustReplaceAll, bool nameChange, bool isRecursive) override ;
111
112 // Internal function to get the normalization set for the integrated
113 // function. By default, we will take the normalization set from the function
114 // proxy, but _funcNormSet will be used if it is set.
115 inline RooArgSet const* funcNormSet() const {
117 }
118
119 // Function pointer and integrands list
120 mutable RooSetProxy _sumList ; ///< Set of discrete observable over which is summed numerically
121 mutable RooSetProxy _intList ; ///< Set of continuous observables over which is integrated numerically
122 mutable RooSetProxy _anaList ; ///< Set of observables over which is integrated/summed analytically
123 mutable RooSetProxy _jacList ; ///< Set of lvalue observables over which is analytically integration that have a non-unit Jacobian
124 mutable RooSetProxy _facList ; ///< Set of observables on which function does not depends, which are integrated nevertheless
125
126 mutable RooArgSet _facListOwned ; ///< Owned components in _facList
127 RooRealProxy _function ; ///<Function being integration
128 std::unique_ptr<RooArgSet> _funcNormSet; ///< Optional normalization set passed to function
129
130 mutable RooArgSet _saveInt ; ///<! do not persist
131 mutable RooArgSet _saveSum ; ///<! do not persist
132
134
135 mutable RooListProxy _sumCat ; ///<! do not persist
136
138 IntOperMode _intOperMode = Hybrid; ///< integration operation mode
139
140 mutable bool _restartNumIntEngine = false; ///<! do not persist
141 mutable std::unique_ptr<RooAbsIntegrator> _numIntEngine; ///<! do not persist
142 mutable std::unique_ptr<RooAbsFunc> _numIntegrand; ///<! do not persist
143
144 TNamed* _rangeName = nullptr;
145
146 mutable std::unique_ptr<RooArgSet> _params; ///<! cache for set of parameters
147
148 bool _cacheNum = false; ///< Cache integral if numeric
149 static Int_t _cacheAllNDim ; ///<! Cache all integrals with given numeric dimension
150
151 ClassDefOverride(RooRealIntegral,4) // Real-valued function representing an integral over a RooAbsReal object
152};
153
154#endif
#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
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition RooAbsArg.h:74
A space to attach TBranches.
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
Storage_t const & get() const
Const access to the underlying stl container.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
RooAbsIntegrator is the abstract interface for integrators of real-valued functions that implement th...
const RooArgSet * nset() const
Definition RooAbsProxy.h:52
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:62
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
RooNumIntConfig holds the configuration parameters of the various numeric integrators used by RooReal...
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 std::liste...
void setAllowComponentSelection(bool allow)
Set component selection to be allowed/forbidden.
RooRealProxy _function
Function being integration.
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
! do not persist
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.
RooArgSet _saveInt
! do not persist
double getValV(const RooArgSet *set=nullptr) const override
Return value of object.
RooSetProxy _anaList
Set of observables over which is integrated/summed analytically.
bool _restartNumIntEngine
! do not persist
bool servesExclusively(const RooAbsArg *server, const RooArgSet &exclLVBranches, const RooArgSet &allBranches) const
Utility function that returns true if 'object server' is a server to exactly one of the RooAbsArgs in...
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
! do not persist
virtual double integrate() const
Perform hybrid numerical/analytical integration over all real-valued dependents.
RooListProxy _sumCat
! do not persist
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.
RooArgSet _saveSum
! do not persist
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...
RooArgSet _facListOwned
Owned components in _facList.
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)
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:40
1-D histogram with a float per channel (see TH1 documentation)}
Definition TH1.h:577
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:43