67 _respectCompSelect(true),
72 _restartNumIntEngine(false),
96 const char* rangeName) :
99 _respectCompSelect(true),
100 _sumList(
"!sumList",
"Categories to be summed numerically",this,false,false),
101 _intList(
"!intList",
"Variables to be integrated numerically",this,false,false),
102 _anaList(
"!anaList",
"Variables to be integrated analytically",this,false,false),
103 _jacList(
"!jacList",
"Jacobian product term",this,false,false),
104 _facList(
"!facList",
"Variables independent of function",this,false,true),
105 _function(
"!func",
"Function to be integrated",this,
108 _sumCat(
"!sumCat",
"SuperCategory for summation",this,false,false),
111 _restartNumIntEngine(false),
140 <<
function.GetName() <<
" over observables" << depList <<
" with normalization "
141 << (funcNormSet?*funcNormSet:
RooArgSet()) <<
" with range identifier "
142 << (rangeName?rangeName:
"<none>") << endl ;
155 for (
const auto nArg : *funcNormSet) {
174 for (
auto arg : intDepList) {
175 if(!arg->isLValue()) {
200 RooArgSet exclLVBranches(
"exclLVBranches") ;
202 function.branchNodeServerList(&branchList) ;
204 for (
auto branch: branchList) {
207 if ((realArgLV && (realArgLV->
isJacobianOK(intDepList)!=0)) || catArgLV) {
208 exclLVBranches.
add(*branch) ;
213 branchListVD.
add(*branch) ;
218 exclLVBranches.
remove(depList,
true,
true) ;
221 RooArgSet exclLVServers(
"exclLVServers") ;
222 exclLVServers.
add(intDepList) ;
225 bool converged(
false) ;
230 std::vector<RooAbsArg*> toBeRemoved;
231 for (
auto server : exclLVServers) {
233 toBeRemoved.push_back(server);
237 exclLVServers.remove(toBeRemoved.begin(), toBeRemoved.end());
241 for (std::size_t i=0; i < exclLVBranches.
size(); ++i) {
242 const RooAbsArg* branch = exclLVBranches[i];
246 bsList.
remove(exclLVServers,
true,
true) ;
248 exclLVBranches.
remove(*branch,
true,
true) ;
257 for (std::size_t i=0; i < exclLVBranches.
size(); ++i) {
258 const RooAbsArg* branch = exclLVBranches[i];
260 exclLVBranches.
remove(*branch,
true,
true) ;
267 if (exclLVServers.
getSize()>0 && !
function.isBinnedDistribution(exclLVBranches)) {
269 intDepList.
remove(exclLVServers) ;
270 intDepList.
add(exclLVBranches) ;
284 for (
auto arg : intDepList) {
285 if (
function.forceAnalyticalInt(*arg)) {
286 anIntOKDepList.
add(*arg) ;
290 if (anIntOKDepList.
getSize()>0) {
300 for (
const auto arg :
function.servers()) {
305 if (!arg->dependsOnValue(intDepList)) {
309 if (
function.dependsOnValue(*arg)) {
319 arg->leafNodeServerList(&argLeafServers,0,
false) ;
330 for (
const auto leaf : argLeafServers) {
334 if (depList.
find(leaf->GetName()) &&
function.dependsOnValue(*leaf)) {
338 oocxcoutD(&
function,
Integration) <<
function.GetName() <<
" : Observable " << leaf->GetName() <<
" has parameterized binning, add value dependence of boundary objects rather than shape of leaf" << endl ;
347 << arg->GetName() <<
" as shape dependent" << endl ;
350 }
else if (!depList.
find(leaf->GetName())) {
352 if (
function.dependsOnValue(*leaf)) {
371 if (arg->isDerived()) {
375 if ((realArgLV && intDepList.
find(realArgLV->
GetName()) && (realArgLV->
isJacobianOK(intDepList)!=0)) || catArgLV) {
383 bool overlapOK = true ;
384 for (
const auto otherArg :
function.servers()) {
386 if (arg==otherArg) continue ;
388 if (arg->overlaps(*otherArg,
true)) {
394 if (!overlapOK) depOK=false ;
406 anIntOKDepList.
add(*arg,
true) ;
434 std::unique_ptr<RooHelpers::LocalChangeMsgLevel> msgChanger;
445 msgChanger.reset(
nullptr);
467 auto argDepList = std::unique_ptr<RooArgSet>(arg->getObservables(&intDepList));
468 for (
const auto argDep : *argDepList) {
470 numIntDepList.
add(*argDep,
true) ;
479 if (exclLVServers.
getSize()>0) {
481 intDepList.
remove(exclLVBranches) ;
482 intDepList.
add(exclLVServers) ;
488 for (
const auto arg :
function.servers()) {
497 numIntDepList.
add(*arg,
true) ;
502 auto argDeps = std::unique_ptr<RooArgSet>(arg->getObservables(&intDepList));
504 if (argDeps->getSize()>0) {
508 for (
const auto dep : *argDeps) {
510 numIntDepList.
add(*dep,
true) ;
523 for (
const auto arg : numIntDepList) {
543 if (numIntDepList.
getSize()>0) {
580 if (server->isValueServer(*
this)) {
582 server->leafNodeServerList(&leafSet) ;
583 for (
const auto leaf : leafSet) {
584 if (leaf->operMode()==
ADirty && leaf->isValueServer(*
this)) {
588 if (leaf->getAttribute(
"projectedDependent")) {
608 if (exclLVBranches.
getSize()==0)
return false ;
621 if (!(exclLVBranches.
find(client->GetName())==client)) {
622 if (allBranches.
find(client->GetName())==client) {
634 return (numLVServ==1) ;
687 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 ;
701 _valid(other._valid),
702 _respectCompSelect(other._respectCompSelect),
703 _sumList(
"!sumList",this,other._sumList),
704 _intList(
"!intList",this,other._intList),
705 _anaList(
"!anaList",this,other._anaList),
706 _jacList(
"!jacList",this,other._jacList),
707 _facList(
"!facList",
"Variables independent of function",this,false,true),
708 _function(
"!func",this,other._function),
709 _iconfig(other._iconfig),
710 _sumCat(
"!sumCat",this,other._sumCat),
712 _intOperMode(other._intOperMode),
713 _restartNumIntEngine(false),
716 _rangeName(other._rangeName),
722 for (
const auto arg : other.
_facList) {
853 <<
":evaluate: cannot initialize numerical integrator" << endl;
948 jacProd *= arg->jacobian() ;
953 return fabs(jacProd) ;
968 for (
const auto& nameIdx : *sumCat) {
1004 bool ,
bool ,
bool )
1036 if (server->isValueServer(*
this))
_params->
add(*server) ;
1110 os <<
indent <<
"--- RooRealIntegral ---" << endl;
1111 os <<
indent <<
" Integrates ";
1115 os <<
indent <<
" operating mode is "
1117 os <<
indent <<
" Summed discrete args are " <<
_sumList << endl ;
1118 os <<
indent <<
" Numerically integrated args are " <<
_intList << endl;
1119 os <<
indent <<
" Analytically integrated args using mode " <<
_mode <<
" are " <<
_anaList << endl ;
1120 os <<
indent <<
" Arguments included in Jacobian are " <<
_jacList << endl ;
1121 os <<
indent <<
" Factorized arguments are " <<
_facList << endl ;
1122 os <<
indent <<
" Function normalization set " ;
static void indent(ostringstream &buf, int indent_level)
static unsigned int total
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
RooExpensiveObjectCache & expensiveObjectCache() const
TObject * Clone(const char *newname=0) const override
Make a clone of an object using the Streamer facility.
void setOperMode(OperMode mode, bool recurseADirty=true)
Set the operation mode of this node.
bool dependsOnValue(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0) const
Check whether this object depends on values from an element in the serverList.
RooArgSet * getObservables(const RooArgSet &set, bool valueOnly=true) const
Given a set of possible observables, return the observables that this PDF depends on.
const RefCountList_t & valueClients() const
List of all value clients of this object. Value clients receive value updates.
virtual void setExpensiveObjectCache(RooExpensiveObjectCache &cache)
static void setDirtyInhibit(bool flag)
Control global dirty inhibit mode.
bool dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0, bool valueOnly=false) const
Test whether we depend on (ie, are served by) any object in the specified collection.
void addServer(RooAbsArg &server, bool valueProp=true, bool shapeProp=false, std::size_t refCount=1)
Register another RooAbsArg as a server to us, ie, declare that we depend on it.
bool isValueOrShapeDirtyAndClear() const
bool inhibitDirty() const
Delete watch flag.
RefCountList_t _clientList
RefCountList_t _serverList
virtual bool 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.
virtual bool addOwned(RooAbsArg &var, bool silent=false)
Add an argument and transfer the ownership to the collection.
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
bool contains(const RooAbsArg &var) const
Check if collection contains an argument with the same name as var.
void Print(Option_t *options=0) const override
This method must be overridden when a class wants to print itself.
Int_t getSize() const
Return the number of elements in the collection.
const char * GetName() const override
Returns name of object.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of 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...
Storage_t::size_type size() const
RooAbsArg * first() const
RooAbsArg * find(const char *name) const
Find object with given name in list.
bool isValid() const
Is integrator in valid state.
double calculate(const double *yvec=0)
Calculate integral value with given array of parameter values.
virtual bool checkLimits() const
If true, finite limits are required on the observable range.
TClass * IsA() const override
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 getMax(const char *name=0) const
Get maximum of currently defined range.
virtual const RooAbsBinning & getBinning(const char *name=0, bool verbose=true, bool createOnTheFly=false) const =0
Retrive binning configuration with given name or default binning.
virtual bool isJacobianOK(const RooArgSet &depList) const
virtual double getMin(const char *name=0) const
Get minimum of currently defined range.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
virtual double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
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
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 ...
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Structure printing.
double _value
Cache for current value of object.
double traceEval(const RooArgSet *set) const
Calculate current value of object, with error tracing wrapper.
virtual bool isBinnedDistribution(const RooArgSet &) const
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
TClass * IsA() const override
static bool _globalSelectComp
Component selection flag for RooAbsPdf::plotCompOn.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
void removeAll() override
Remove all argument inset using remove(const RooAbsArg&).
bool addOwned(RooAbsArg &var, bool silent=false) override
Overloaded RooCollection_t::addOwned() method insert object into owning set and registers object as s...
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
RooDouble is a minimal implementation of a TObject holding a double value.
const TObject * retrieveObject(const char *name, TClass *tclass, const RooArgSet ¶ms)
Retrieve object from cache that was registered under given name with given parameters,...
bool 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...
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 isBinned=false) 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
bool initNumIntegrator() const
(Re)Initialize numerical integration engine if necessary.
RooArgSet * _params
! cache for set of parameters
void setAllowComponentSelection(bool allow)
Set component selection to be allowed/forbidden.
RooRealProxy _function
Function being integration.
RooArgSet intVars() const
RooSetProxy _intList
Set of continuous observables over which is integrated numerically.
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.
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.
IntOperMode _intOperMode
integration operation mode
RooArgSet * _funcNormSet
Optional normalization set passed to function.
RooAbsIntegrator * _numIntEngine
! do not persist
bool _cacheNum
Cache integral if numeric.
double evaluate() const override
Perform the integration and return the result.
const RooArgSet & parameters() const
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=0) const override
Return value of object.
RooArgSet _saveInt
! do not persist
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.
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
RooAbsReal * createIntegral(const RooArgSet &iset, const RooArgSet *nset=0, const RooNumIntConfig *cfg=0, const char *rangeName=0) const override
Create an object that represents the integral of the function over one or more observables listed in ...
void autoSelectDirtyMode()
Set appropriate cache operation mode for integral depending on cache operation mode of server objects...
RooArgSet _facListOwned
Owned components in _facList.
bool getAllowComponentSelection() const
Check if component selection is allowed.
bool empty() const
Check if empty.
The RooSuperCategory can join several RooAbsCategoryLValue objects into a single category.
bool setIndex(value_type index, bool printError=true) override
Set the value of the super category to the specified index.
bool 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.
const char * GetName() const override
Returns name of object.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
TString & Append(const char *cs)
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
void function(const Char_t *name_, T fun, const Char_t *docstring=0)