70 _respectCompSelect(true),
75 _restartNumIntEngine(
kFALSE),
99 const char* rangeName) :
102 _respectCompSelect(true),
103 _sumList(
"!sumList",
"Categories to be summed numerically",this,
kFALSE,
kFALSE),
104 _intList(
"!intList",
"Variables to be integrated numerically",this,
kFALSE,
kFALSE),
105 _anaList(
"!anaList",
"Variables to be integrated analytically",this,
kFALSE,
kFALSE),
106 _jacList(
"!jacList",
"Jacobian product term",this,
kFALSE,
kFALSE),
107 _facList(
"!facList",
"Variables independent of function",this,
kFALSE,
kTRUE),
108 _function(
"!func",
"Function to be integrated",this,
111 _sumCat(
"!sumCat",
"SuperCategory for summation",this,
kFALSE,
kFALSE),
113 _intOperMode(Hybrid),
114 _restartNumIntEngine(
kFALSE),
142 oocxcoutI(&function,Integration) <<
"RooRealIntegral::ctor(" <<
GetName() <<
") Constructing integral of function "
143 << function.GetName() <<
" over observables" << depList <<
" with normalization "
144 << (funcNormSet?*funcNormSet:
RooArgSet()) <<
" with range identifier "
145 << (rangeName?rangeName:
"<none>") << endl ;
158 for (
const auto nArg : *funcNormSet) {
159 if (function.dependsOn(*nArg)) {
177 for (
auto arg : intDepList) {
178 if(!arg->isLValue()) {
183 if (!function.dependsOn(*arg)) {
192 oocxcoutI(&function,Integration) << function.GetName() <<
": Factorizing obserables are " <<
_facList << endl ;
203 RooArgSet exclLVBranches(
"exclLVBranches") ;
205 function.branchNodeServerList(&branchList) ;
207 for (
auto branch: branchList) {
210 if ((realArgLV && (realArgLV->
isJacobianOK(intDepList)!=0)) || catArgLV) {
211 exclLVBranches.
add(*branch) ;
216 branchListVD.
add(*branch) ;
224 RooArgSet exclLVServers(
"exclLVServers") ;
225 exclLVServers.
add(intDepList) ;
233 std::vector<RooAbsArg*> toBeRemoved;
234 for (
auto server : exclLVServers) {
236 toBeRemoved.push_back(server);
240 exclLVServers.
remove(toBeRemoved.begin(), toBeRemoved.end());
244 for (std::size_t i=0; i < exclLVBranches.
size(); ++i) {
245 const RooAbsArg* branch = exclLVBranches[i];
260 for (std::size_t i=0; i < exclLVBranches.
size(); ++i) {
261 const RooAbsArg* branch = exclLVBranches[i];
270 if (exclLVServers.
getSize()>0 && !function.isBinnedDistribution(exclLVBranches)) {
272 intDepList.
remove(exclLVServers) ;
273 intDepList.
add(exclLVBranches) ;
287 for (
auto arg : intDepList) {
288 if (function.forceAnalyticalInt(*arg)) {
289 anIntOKDepList.
add(*arg) ;
293 if (anIntOKDepList.
getSize()>0) {
294 oocxcoutI(&function,Integration) << function.GetName() <<
": Observables that function forcibly requires to be integrated internally " << anIntOKDepList << endl ;
303 for (
const auto arg : function.servers()) {
308 if (!arg->dependsOnValue(intDepList)) {
312 if (function.dependsOnValue(*arg)) {
322 arg->leafNodeServerList(&argLeafServers,0,
kFALSE) ;
328 if (!arg->isValueServer(function) && !arg->isShapeServer(function)) {
333 for (
const auto leaf : argLeafServers) {
337 if (depList.
find(leaf->GetName()) && function.dependsOnValue(*leaf)) {
341 oocxcoutD(&function,Integration) << function.GetName() <<
" : Observable " << leaf->GetName() <<
" has parameterized binning, add value dependence of boundary objects rather than shape of leaf" << endl ;
349 oocxcoutD(&function,Integration) << function.GetName() <<
": Adding observable " << leaf->GetName() <<
" of server "
350 << arg->GetName() <<
" as shape dependent" << endl ;
353 }
else if (!depList.
find(leaf->GetName())) {
355 if (function.dependsOnValue(*leaf)) {
356 oocxcoutD(&function,Integration) << function.GetName() <<
": Adding parameter " << leaf->GetName() <<
" of server " << arg->GetName() <<
" as value dependent" << endl ;
359 oocxcoutD(&function,Integration) << function.GetName() <<
": Adding parameter " << leaf->GetName() <<
" of server " << arg->GetName() <<
" as shape dependent" << endl ;
374 if (arg->isDerived()) {
378 if ((realArgLV && intDepList.
find(realArgLV->
GetName()) && (realArgLV->
isJacobianOK(intDepList)!=0)) || catArgLV) {
387 for (
const auto otherArg : function.servers()) {
389 if (arg==otherArg) continue ;
390 if (otherArg->IsA()==RooConstVar::Class())
continue ;
391 if (arg->overlaps(*otherArg,
kTRUE)) {
397 if (!overlapOK) depOK=
kFALSE ;
410 oocxcoutI(&function,Integration) << function.GetName() <<
": Observable " << arg->GetName() <<
" is suitable for analytical integration (if supported by p.d.f)" << endl ;
431 oocxcoutI(&function,Integration) << function.GetName() <<
": Function integrated observables " <<
_anaList <<
" internally with code " <<
_mode << endl ;
437 std::unique_ptr<RooHelpers::LocalChangeMsgLevel> msgChanger;
448 msgChanger.reset(
nullptr);
464 if (arg->IsA()->InheritsFrom(RooAbsRealLValue::Class()) && arg->isDerived() && !arg->isFundamental()) {
470 auto argDepList = std::unique_ptr<RooArgSet>(arg->getObservables(&intDepList));
471 for (
const auto argDep : *argDepList) {
472 if (argDep->IsA()->InheritsFrom(RooAbsCategoryLValue::Class()) && intDepList.
contains(*argDep)) {
482 if (exclLVServers.
getSize()>0) {
484 intDepList.
remove(exclLVBranches) ;
485 intDepList.
add(exclLVServers) ;
491 for (
const auto arg : function.servers()) {
505 auto argDeps = std::unique_ptr<RooArgSet>(arg->getObservables(&intDepList));
507 if (argDeps->getSize()>0) {
511 for (
const auto dep : *argDeps) {
526 for (
const auto arg : numIntDepList) {
527 if (arg->IsA()->InheritsFrom(RooAbsRealLValue::Class())) {
529 }
else if (arg->IsA()->InheritsFrom(RooAbsCategoryLValue::Class())) {
535 oocxcoutI(&function,Integration) << function.GetName() <<
": Observables " <<
_anaList <<
" are analytically integrated with code " <<
_mode << endl ;
538 oocxcoutI(&function,Integration) << function.GetName() <<
": Observables " <<
_intList <<
" are numerically integrated" << endl ;
541 oocxcoutI(&function,Integration) << function.GetName() <<
": Observables " <<
_sumList <<
" are numerically summed" << endl ;
546 if (numIntDepList.
getSize()>0) {
583 if (server->isValueServer(*
this)) {
585 server->leafNodeServerList(&leafSet) ;
586 for (
const auto leaf : leafSet) {
587 if (leaf->operMode()==
ADirty && leaf->isValueServer(*
this)) {
591 if (leaf->getAttribute(
"projectedDependent")) {
624 if (!(exclLVBranches.
find(client->GetName())==client)) {
625 if (allBranches.
find(client->GetName())==client) {
637 return (numLVServ==1) ;
673 coutE(Integration) <<
ClassName() <<
"::" <<
GetName() <<
": failed to create valid integrand." << endl;
682 coutE(Integration) <<
ClassName() <<
"::" <<
GetName() <<
": failed to create valid integrator." << endl;
686 cxcoutI(NumIntegration) <<
"RooRealIntegral::init(" <<
GetName() <<
") using numeric integrator "
690 cxcoutI(NumIntegration) <<
"RooRealIntegral::init(" <<
GetName() <<
") evaluation requires " <<
_intList.
getSize() <<
"-D numeric integration step. Evaluation may be slow, sufficient numeric precision for fitting & minimization is not guaranteed" << endl ;
704 _valid(other._valid),
705 _respectCompSelect(other._respectCompSelect),
706 _sumList(
"!sumList",this,other._sumList),
707 _intList(
"!intList",this,other._intList),
708 _anaList(
"!anaList",this,other._anaList),
709 _jacList(
"!jacList",this,other._jacList),
710 _facList(
"!facList",
"Variables independent of function",this,
kFALSE,
kTRUE),
711 _function(
"!func",this,other._function),
712 _iconfig(other._iconfig),
713 _sumCat(
"!sumCat",this,other._sumCat),
715 _intOperMode(other._intOperMode),
716 _restartNumIntEngine(
kFALSE),
719 _rangeName(other._rangeName),
725 for (
const auto arg : other.
_facList) {
856 <<
":evaluate: cannot initialize numerical integrator" << endl;
888 cxcoutD(Tracing) <<
"RooRealIntegral::evaluate_analytic(" <<
GetName()
910 if (arg->IsA()->InheritsFrom(RooAbsRealLValue::Class())) {
915 if (arg->IsA()->InheritsFrom(RooAbsCategoryLValue::Class())) {
931 ccxcoutD(Tracing) <<
"raw*fact = " << retVal << endl ;
951 jacProd *= arg->jacobian() ;
956 return fabs(jacProd) ;
971 for (
const auto& nameIdx : *sumCat) {
1039 if (server->isValueServer(*
this))
_params->
add(*server) ;
1129 os <<
indent <<
"--- RooRealIntegral ---" << endl;
1130 os <<
indent <<
" Integrates ";
1134 os <<
indent <<
" operating mode is "
1136 os <<
indent <<
" Summed discrete args are " <<
_sumList << endl ;
1137 os <<
indent <<
" Numerically integrated args are " <<
_intList << endl;
1138 os <<
indent <<
" Analytically integrated args using mode " <<
_mode <<
" are " <<
_anaList << endl ;
1139 os <<
indent <<
" Arguments included in Jacobian are " <<
_jacList << endl ;
1140 os <<
indent <<
" Factorized arguments are " <<
_facList << endl ;
1141 os <<
indent <<
" Function normalization set " ;
static void indent(ostringstream &buf, int indent_level)
static unsigned int total
char * Form(const char *fmt,...)
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
RooExpensiveObjectCache & expensiveObjectCache() const
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
Given a set of possible observables, return the observables that this PDF depends on.
Bool_t dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0, Bool_t valueOnly=kFALSE) const
Test whether we depend on (ie, are served by) any object in the specified collection.
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
static void setDirtyInhibit(Bool_t flag)
Control global dirty inhibit mode.
Bool_t inhibitDirty() const
Delete watch flag.
const RefCountList_t & valueClients() const
List of all value clients of this object. Value clients receive value updates.
virtual void setExpensiveObjectCache(RooExpensiveObjectCache &cache)
void addServer(RooAbsArg &server, Bool_t valueProp=kTRUE, Bool_t shapeProp=kFALSE, std::size_t refCount=1)
Register another RooAbsArg as a server to us, ie, declare that we depend on it.
Bool_t isValueOrShapeDirtyAndClear() const
void setOperMode(OperMode mode, Bool_t recurseADirty=kTRUE)
Set the operation mode of this node.
OperMode _operMode
Mark batches as dirty (only meaningful for RooAbsReal).
Bool_t dependsOnValue(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0) const
Check whether this object depends on values from an element in the serverList.
RefCountList_t _clientList
RefCountList_t _serverList
virtual Bool_t isParameterized() const
Interface function.
virtual RooAbsReal * highBoundFunc() const
Return pointer to RooAbsReal parameterized upper bound, if any.
virtual RooAbsReal * lowBoundFunc() const
Return pointer to RooAbsReal parameterized lower bound, if any.
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
Int_t numTypes(const char *=0) const
Return number of types defined (in range named rangeName if rangeName!=0)
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
Bool_t contains(const RooAbsArg &var) const
Check if collection contains an argument with the same name as var.
Storage_t::size_type size() const
RooAbsArg * first() const
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
const char * GetName() const
Returns name of object.
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
RooAbsArg * find(const char *name) const
Find object with given name in list.
Double_t calculate(const Double_t *yvec=0)
Calculate integral value with given array of parameter values.
virtual Bool_t checkLimits() const
Abstract base class for objects that are lvalues, i.e.
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
virtual Double_t getMax(const char *name=0) const
Get maximum of currently defined range.
virtual const RooAbsBinning & getBinning(const char *name=0, Bool_t verbose=kTRUE, Bool_t createOnTheFly=kFALSE) const =0
Retrive binning configuration with given name or default binning.
virtual Bool_t isJacobianOK(const RooArgSet &depList) const
virtual Double_t getMin(const char *name=0) const
Get miniminum of currently defined range.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
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 ...
friend class RooRealBinding
Double_t traceEval(const RooArgSet *set) const
Calculate current value of object, with error tracing wrapper.
virtual Double_t analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Structure printing.
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
static Bool_t _globalSelectComp
Component selection flag for RooAbsPdf::plotCompOn.
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 listed in ...
virtual Bool_t isBinnedDistribution(const RooArgSet &) const
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Add element to non-owning set.
RooAbsArg * addClone(const RooAbsArg &var, Bool_t silent=kFALSE) override
Add clone of specified element to an owning set.
Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE) override
Add element to an owning set.
RooDouble is a minimal implementation of a TObject holding a Double_t value.
Bool_t registerObject(const char *ownerName, const char *objectName, TObject &cacheObject, TIterator *paramIter)
Register object associated with given name and given associated parameters with given values in cache...
const TObject * retrieveObject(const char *name, TClass *tclass, const RooArgSet ¶ms)
Retrieve object from cache that was registered under given name with given parameters,...
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE) override
Reimplementation of standard RooArgList::addOwned()
RooNameReg is a registry for const char* names.
static const char * str(const TNamed *ptr)
Return C++ string corresponding to given TNamed pointer.
RooNumIntConfig holds the configuration parameters of the various numeric integrators used by RooReal...
RooAbsIntegrator * createIntegrator(RooAbsFunc &func, const RooNumIntConfig &config, Int_t ndim=0, Bool_t isBinned=kFALSE) const
Construct a numeric integrator instance that operates on function 'func' and is configured with 'conf...
static RooNumIntFactory & instance()
Static method returning reference to singleton instance of factory.
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer,...
Lightweight RooAbsFunc interface adaptor that binds an analytic integral of a RooAbsReal object (spec...
RooRealIntegral performs hybrid numerical/analytical integrals of RooAbsReal objects.
RooNumIntConfig * _iconfig
do not persist
virtual void operModeHook()
Cache all integrals with given numeric dimension.
Bool_t getAllowComponentSelection() const
Check if component selection is allowed.
Bool_t 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...
Int_t _mode
do not persist
RooArgSet intVars() const
void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Print the state of this object to the specified output stream.
RooAbsFunc * _numIntegrand
do not persist
static void setCacheAllNumeric(Int_t ndim)
Global switch to cache all integral values that integrate at least ndim dimensions numerically.
RooAbsIntegrator * _numIntEngine
do not persist
virtual ~RooRealIntegral()
void printMetaArgs(std::ostream &os) const
Customized printing of arguments of a RooRealIntegral to more intuitively reflect the contents of the...
const RooArgSet & parameters() const
virtual Bool_t isValidReal(Double_t value, Bool_t printError=kFALSE) const
Check if current value is valid.
TNamed * _rangeName
do not persist
virtual RooAbsReal * createIntegral(const RooArgSet &iset, const RooArgSet *nset=0, const RooNumIntConfig *cfg=0, const char *rangeName=0) const
Create an object that represents the integral of the function over one or more observables listed in ...
virtual Double_t sum() const
Perform summation of list of category dependents to be integrated.
Bool_t _restartNumIntEngine
Bool_t initNumIntegrator() const
(Re)Initialize numerical integration engine if necessary.
virtual Bool_t redirectServersHook(const RooAbsCollection &newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive)
Intercept server redirects and reconfigure internal object accordingly.
virtual Double_t getValV(const RooArgSet *set=0) const
Return value of object.
virtual Double_t jacobianProduct() const
Return product of jacobian terms originating from analytical integration.
Bool_t _cacheNum
cache for set of parameters
static Int_t getCacheAllNumeric()
Return minimum dimensions of numeric integration for which values are cached.
RooArgSet _saveSum
do not persist
static Int_t _cacheAllNDim
void setAllowComponentSelection(Bool_t allow)
Set component selection to be allowed/forbidden.
Double_t evaluate() const
Perform the integration and return the result.
virtual Double_t integrate() const
Perform hybrid numerical/analytical integration over all real-valued dependents.
void autoSelectDirtyMode()
Set appropriate cache operation mode for integral depending on cache operation mode of server objects...
Bool_t _respectCompSelect
bool empty() const
Check if empty.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Overloaded RooArgSet::add() method inserts 'var' into set and registers 'var' as server to owner with...
virtual void removeAll() override
Remove all argument inset using remove(const RooAbsArg&).
The RooSuperCategory can join several RooAbsCategoryLValue objects into a single category.
virtual bool setIndex(value_type index, bool printError=true) override
Set the value of the super category to the specified index.
virtual Bool_t inRange(const char *rangeName) const override
Check that all input category states are in the given range.
const T & arg() const
Return reference to object held in proxy.
The TNamed class is the base class for all named ROOT classes.
virtual const char * GetName() const
Returns name of object.
virtual const char * GetName() const
Returns name of object.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
TString & Append(const char *cs)