69 _respectCompSelect(true),
74 _restartNumIntEngine(
kFALSE),
98 const char* rangeName) :
101 _respectCompSelect(true),
102 _sumList(
"!sumList",
"Categories to be summed numerically",this,
kFALSE,
kFALSE),
103 _intList(
"!intList",
"Variables to be integrated numerically",this,
kFALSE,
kFALSE),
104 _anaList(
"!anaList",
"Variables to be integrated analytically",this,
kFALSE,
kFALSE),
105 _jacList(
"!jacList",
"Jacobian product term",this,
kFALSE,
kFALSE),
106 _facList(
"!facList",
"Variables independent of function",this,
kFALSE,
kTRUE),
107 _function(
"!func",
"Function to be integrated",this,false,false),
109 _sumCat(
"!sumCat",
"SuperCategory for summation",this,
kFALSE,
kFALSE),
111 _intOperMode(Hybrid),
112 _restartNumIntEngine(
kFALSE),
140 oocxcoutI(&function,Integration) <<
"RooRealIntegral::ctor(" <<
GetName() <<
") Constructing integral of function "
141 << function.GetName() <<
" over observables" << depList <<
" with normalization "
142 << (funcNormSet?*funcNormSet:
RooArgSet()) <<
" with range identifier "
143 << (rangeName?rangeName:
"<none>") << endl ;
156 for (
const auto nArg : *funcNormSet) {
157 if (function.dependsOn(*nArg)) {
175 for (
auto arg : intDepList) {
176 if(!arg->isLValue()) {
181 if (!function.dependsOn(*arg)) {
190 oocxcoutI(&function,Integration) << function.GetName() <<
": Factorizing obserables are " <<
_facList << endl ;
201 RooArgSet exclLVBranches(
"exclLVBranches") ;
203 function.branchNodeServerList(&branchList) ;
205 for (
auto branch: branchList) {
208 if ((realArgLV && (realArgLV->
isJacobianOK(intDepList)!=0)) || catArgLV) {
209 exclLVBranches.
add(*branch) ;
214 branchListVD.
add(*branch) ;
222 RooArgSet exclLVServers(
"exclLVServers") ;
223 exclLVServers.
add(intDepList) ;
231 std::vector<RooAbsArg*> toBeRemoved;
232 for (
auto server : exclLVServers) {
234 toBeRemoved.push_back(server);
238 exclLVServers.
remove(toBeRemoved.begin(), toBeRemoved.end());
242 for (std::size_t i=0; i < exclLVBranches.
size(); ++i) {
243 const RooAbsArg* branch = exclLVBranches[i];
258 for (std::size_t i=0; i < exclLVBranches.
size(); ++i) {
259 const RooAbsArg* branch = exclLVBranches[i];
268 if (exclLVServers.
getSize()>0 && !function.isBinnedDistribution(exclLVBranches)) {
270 intDepList.
remove(exclLVServers) ;
271 intDepList.
add(exclLVBranches) ;
285 for (
auto arg : intDepList) {
286 if (function.forceAnalyticalInt(*arg)) {
287 anIntOKDepList.
add(*arg) ;
291 if (anIntOKDepList.
getSize()>0) {
292 oocxcoutI(&function,Integration) << function.GetName() <<
": Observables that function forcibly requires to be integrated internally " << anIntOKDepList << endl ;
301 for (
const auto arg : function.servers()) {
306 if (!arg->dependsOnValue(intDepList)) {
310 if (function.dependsOnValue(*arg)) {
320 arg->leafNodeServerList(&argLeafServers,0,
kFALSE) ;
326 if (!arg->isValueServer(function) && !arg->isShapeServer(function)) {
331 for (
const auto leaf : argLeafServers) {
335 if (depList.
find(leaf->GetName()) && function.dependsOnValue(*leaf)) {
339 oocxcoutD(&function,Integration) << function.GetName() <<
" : Observable " << leaf->GetName() <<
" has parameterized binning, add value dependence of boundary objects rather than shape of leaf" << endl ;
347 oocxcoutD(&function,Integration) << function.GetName() <<
": Adding observable " << leaf->GetName() <<
" of server "
348 << arg->GetName() <<
" as shape dependent" << endl ;
351 }
else if (!depList.
find(leaf->GetName())) {
353 if (function.dependsOnValue(*leaf)) {
354 oocxcoutD(&function,Integration) << function.GetName() <<
": Adding parameter " << leaf->GetName() <<
" of server " << arg->GetName() <<
" as value dependent" << endl ;
357 oocxcoutD(&function,Integration) << function.GetName() <<
": Adding parameter " << leaf->GetName() <<
" of server " << arg->GetName() <<
" as shape dependent" << endl ;
372 if (arg->isDerived()) {
376 if ((realArgLV && intDepList.
find(realArgLV->
GetName()) && (realArgLV->
isJacobianOK(intDepList)!=0)) || catArgLV) {
385 for (
const auto otherArg : function.servers()) {
387 if (arg==otherArg) continue ;
388 if (otherArg->IsA()==RooConstVar::Class())
continue ;
389 if (arg->overlaps(*otherArg,
kTRUE)) {
395 if (!overlapOK) depOK=
kFALSE ;
408 oocxcoutI(&function,Integration) << function.GetName() <<
": Observable " << arg->GetName() <<
" is suitable for analytical integration (if supported by p.d.f)" << endl ;
429 oocxcoutI(&function,Integration) << function.GetName() <<
": Function integrated observables " <<
_anaList <<
" internally with code " <<
_mode << endl ;
435 std::unique_ptr<RooHelpers::LocalChangeMsgLevel> msgChanger;
446 msgChanger.reset(
nullptr);
462 if (arg->IsA()->InheritsFrom(RooAbsRealLValue::Class()) && arg->isDerived() && !arg->isFundamental()) {
468 auto argDepList = std::unique_ptr<RooArgSet>(arg->getObservables(&intDepList));
469 for (
const auto argDep : *argDepList) {
470 if (argDep->IsA()->InheritsFrom(RooAbsCategoryLValue::Class()) && intDepList.
contains(*argDep)) {
480 if (exclLVServers.
getSize()>0) {
482 intDepList.
remove(exclLVBranches) ;
483 intDepList.
add(exclLVServers) ;
489 for (
const auto arg : function.servers()) {
503 auto argDeps = std::unique_ptr<RooArgSet>(arg->getObservables(&intDepList));
505 if (argDeps->getSize()>0) {
509 for (
const auto dep : *argDeps) {
524 for (
const auto arg : numIntDepList) {
525 if (arg->IsA()->InheritsFrom(RooAbsRealLValue::Class())) {
527 }
else if (arg->IsA()->InheritsFrom(RooAbsCategoryLValue::Class())) {
533 oocxcoutI(&function,Integration) << function.GetName() <<
": Observables " <<
_anaList <<
" are analytically integrated with code " <<
_mode << endl ;
536 oocxcoutI(&function,Integration) << function.GetName() <<
": Observables " <<
_intList <<
" are numerically integrated" << endl ;
539 oocxcoutI(&function,Integration) << function.GetName() <<
": Observables " <<
_sumList <<
" are numerically summed" << endl ;
544 if (numIntDepList.
getSize()>0) {
585 if (server->isValueServer(*
this)) {
587 server->leafNodeServerList(&leafSet) ;
588 for (
const auto leaf : leafSet) {
589 if (leaf->operMode()==
ADirty && leaf->isValueServer(*
this)) {
593 if (leaf->getAttribute(
"projectedDependent")) {
626 if (!(exclLVBranches.
find(client->GetName())==client)) {
627 if (allBranches.
find(client->GetName())==client) {
639 return (numLVServ==1) ;
675 coutE(Integration) <<
ClassName() <<
"::" <<
GetName() <<
": failed to create valid integrand." << endl;
684 coutE(Integration) <<
ClassName() <<
"::" <<
GetName() <<
": failed to create valid integrator." << endl;
688 cxcoutI(NumIntegration) <<
"RooRealIntegral::init(" <<
GetName() <<
") using numeric integrator "
692 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 ;
706 _valid(other._valid),
707 _respectCompSelect(other._respectCompSelect),
708 _sumList(
"!sumList",this,other._sumList),
709 _intList(
"!intList",this,other._intList),
710 _anaList(
"!anaList",this,other._anaList),
711 _jacList(
"!jacList",this,other._jacList),
712 _facList(
"!facList",
"Variables independent of function",this,
kFALSE,
kTRUE),
713 _function(
"!func",this,other._function),
714 _iconfig(other._iconfig),
715 _sumCat(
"!sumCat",this,other._sumCat),
717 _intOperMode(other._intOperMode),
718 _restartNumIntEngine(
kFALSE),
721 _rangeName(other._rangeName),
727 for (
const auto arg : other.
_facList) {
858 <<
":evaluate: cannot initialize numerical integrator" << endl;
890 cxcoutD(Tracing) <<
"RooRealIntegral::evaluate_analytic(" <<
GetName()
916 if (arg->IsA()->InheritsFrom(RooAbsRealLValue::Class())) {
921 if (arg->IsA()->InheritsFrom(RooAbsCategoryLValue::Class())) {
937 ccxcoutD(Tracing) <<
"raw*fact = " << retVal << endl ;
957 jacProd *= arg->jacobian() ;
962 return fabs(jacProd) ;
977 for (
const auto& nameIdx : *sumCat) {
1045 if (server->isValueServer(*
this))
_params->
add(*server) ;
1119 os <<
indent <<
"--- RooRealIntegral ---" << endl;
1120 os <<
indent <<
" Integrates ";
1124 os <<
indent <<
" operating mode is "
1126 os <<
indent <<
" Summed discrete args are " <<
_sumList << endl ;
1127 os <<
indent <<
" Numerically integrated args are " <<
_intList << endl;
1128 os <<
indent <<
" Analytically integrated args using mode " <<
_mode <<
" are " <<
_anaList << endl ;
1129 os <<
indent <<
" Arguments included in Jacobian are " <<
_jacList << endl ;
1130 os <<
indent <<
" Factorized arguments are " <<
_facList << endl ;
1131 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.
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.
virtual RooAbsArg * addClone(const RooAbsArg &var, Bool_t silent=kFALSE)
Add a clone of the specified argument to list.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
void assign(const RooAbsCollection &other) const
Sets the value, cache and constant attribute of any argument in our set that also appears in the othe...
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add an argument and transfer the ownership to the collection.
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...
friend class RooRealBinding
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 ...
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.
virtual Bool_t isBinnedDistribution(const RooArgSet &) const
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
Bool_t isValueServer() const
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
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
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.
bool setArg(T &newRef)
Change object held in proxy into newRef.
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)