Logo ROOT  
Reference Guide
RooRealIntegral.cxx
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * @(#)root/roofitcore:$Id$
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 
17 /**
18 \file RooRealIntegral.cxx
19 \class RooRealIntegral
20 \ingroup Roofitcore
21 
22 RooRealIntegral performs hybrid numerical/analytical integrals of RooAbsReal objects.
23 The class performs none of the actual integration, but only manages the logic
24 of what variables can be integrated analytically, accounts for eventual jacobian
25 terms and defines what numerical integrations needs to be done to complement the
26 analytical integral.
27 The actual analytical integrations (if any) are done in the PDF themselves, the numerical
28 integration is performed in the various implementations of the RooAbsIntegrator base class.
29 **/
30 
31 #include "RooRealIntegral.h"
32 
33 #include "RooFit.h"
34 
35 #include "RooMsgService.h"
36 #include "RooArgSet.h"
37 #include "RooAbsRealLValue.h"
38 #include "RooAbsCategoryLValue.h"
39 #include "RooRealBinding.h"
40 #include "RooRealAnalytic.h"
41 #include "RooInvTransform.h"
42 #include "RooSuperCategory.h"
43 #include "RooNumIntFactory.h"
44 #include "RooNumIntConfig.h"
45 #include "RooNameReg.h"
47 #include "RooConstVar.h"
48 #include "RooDouble.h"
49 #include "RooTrace.h"
50 #include "RooHelpers.h"
51 
52 #include "ROOT/RMakeUnique.hxx"
53 
54 #include "TClass.h"
55 
56 #include <iostream>
57 
58 using namespace std;
59 
61 
62 
64 
65 
66 ////////////////////////////////////////////////////////////////////////////////
67 
69  _valid(kFALSE),
70  _respectCompSelect(true),
71  _funcNormSet(0),
72  _iconfig(0),
73  _mode(0),
74  _intOperMode(Hybrid),
75  _restartNumIntEngine(kFALSE),
76  _numIntEngine(0),
77  _numIntegrand(0),
78  _rangeName(0),
79  _params(0),
80  _cacheNum(kFALSE)
81 {
83 }
84 
85 
86 
87 ////////////////////////////////////////////////////////////////////////////////
88 /// Construct integral of 'function' over observables in 'depList'
89 /// in range 'rangeName' with normalization observables 'funcNormSet'
90 /// (for p.d.f.s). In the integral is performed to the maximum extent
91 /// possible the internal (analytical) integrals advertised by function.
92 /// The other integrations are performed numerically. The optional
93 /// config object prescribes how these numeric integrations are configured.
94 ///
95 
96 RooRealIntegral::RooRealIntegral(const char *name, const char *title,
97  const RooAbsReal& function, const RooArgSet& depList,
98  const RooArgSet* funcNormSet, const RooNumIntConfig* config,
99  const char* rangeName) :
100  RooAbsReal(name,title),
101  _valid(kTRUE),
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,
109  const_cast<RooAbsReal&>(function),kFALSE,kFALSE),
110  _iconfig((RooNumIntConfig*)config),
111  _sumCat("!sumCat","SuperCategory for summation",this,kFALSE,kFALSE),
112  _mode(0),
113  _intOperMode(Hybrid),
114  _restartNumIntEngine(kFALSE),
115  _numIntEngine(0),
116  _numIntegrand(0),
117  _rangeName((TNamed*)RooNameReg::ptr(rangeName)),
118  _params(0),
119  _cacheNum(kFALSE)
120 {
121  // A) Check that all dependents are lvalues
122  //
123  // B) Check if list of dependents can be re-expressed in
124  // lvalues that are higher in the expression tree
125  //
126  // C) Check for dependents that the PDF insists on integrating
127  // analytically iself
128  //
129  // D) Make list of servers that can be integrated analytically
130  // Add all parameters/dependents as value/shape servers
131  //
132  // E) Interact with function to make list of objects actually integrated analytically
133  //
134  // F) Make list of numerical integration variables consisting of:
135  // - Category dependents of RealLValues in analytical integration
136  // - Leaf nodes server lists of function server that are not analytically integrated
137  // - Make Jacobian list for analytically integrated RealLValues
138  //
139  // G) Split numeric list in integration list and summation list
140  //
141 
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 ;
146 
147 
148  // Choose same expensive object cache as integrand
150 // cout << "RRI::ctor(" << GetName() << ") setting expensive object cache to " << &expensiveObjectCache() << " as taken from " << function.GetName() << endl ;
151 
152  // Use objects integrator configuration if none is specified
153  if (!_iconfig) _iconfig = (RooNumIntConfig*) function.getIntegratorConfig() ;
154 
155  // Save private copy of funcNormSet, if supplied, excluding factorizing terms
156  if (funcNormSet) {
157  _funcNormSet = new RooArgSet ;
158  for (const auto nArg : *funcNormSet) {
159  if (function.dependsOn(*nArg)) {
160  _funcNormSet->addClone(*nArg) ;
161  }
162  }
163  } else {
164  _funcNormSet = 0 ;
165  }
166 
167  //_funcNormSet = funcNormSet ? (RooArgSet*)funcNormSet->snapshot(kFALSE) : 0 ;
168 
169  // Make internal copy of dependent list
170  RooArgSet intDepList(depList) ;
171 
172  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
173  // * A) Check that all dependents are lvalues and filter out any
174  // dependents that the PDF doesn't explicitly depend on
175  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
176 
177  for (auto arg : intDepList) {
178  if(!arg->isLValue()) {
179  coutE(InputArguments) << ClassName() << "::" << GetName() << ": cannot integrate non-lvalue ";
180  arg->Print("1");
181  _valid= kFALSE;
182  }
183  if (!function.dependsOn(*arg)) {
184  RooAbsArg* argClone = (RooAbsArg*) arg->Clone() ;
185  _facListOwned.addOwned(*argClone) ;
186  _facList.add(*argClone) ;
187  addServer(*argClone,kFALSE,kTRUE) ;
188  }
189  }
190 
191  if (_facList.getSize()>0) {
192  oocxcoutI(&function,Integration) << function.GetName() << ": Factorizing obserables are " << _facList << endl ;
193  }
194 
195 
196  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
197  // * B) Check if list of dependents can be re-expressed in *
198  // * lvalues that are higher in the expression tree *
199  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
200 
201 
202  // Initial fill of list of LValue branches
203  RooArgSet exclLVBranches("exclLVBranches") ;
204  RooArgSet branchList,branchListVD ;
205  function.branchNodeServerList(&branchList) ;
206 
207  for (auto branch: branchList) {
208  RooAbsRealLValue *realArgLV = dynamic_cast<RooAbsRealLValue*>(branch) ;
209  RooAbsCategoryLValue *catArgLV = dynamic_cast<RooAbsCategoryLValue*>(branch) ;
210  if ((realArgLV && (realArgLV->isJacobianOK(intDepList)!=0)) || catArgLV) {
211  exclLVBranches.add(*branch) ;
212 // cout << "exclv branch = " << endl ;
213 // branch->printCompactTree() ;
214  }
215  if (dependsOnValue(*branch)) {
216  branchListVD.add(*branch) ;
217  } else {
218 // cout << "value of self does not depend on branch " << branch->GetName() << endl ;
219  }
220  }
221  exclLVBranches.remove(depList,kTRUE,kTRUE) ;
222 
223  // Initial fill of list of LValue leaf servers (put in intDepList)
224  RooArgSet exclLVServers("exclLVServers") ;
225  exclLVServers.add(intDepList) ;
226 
227  // Obtain mutual exclusive dependence by iterative reduction
228  Bool_t converged(kFALSE) ;
229  while(!converged) {
230  converged=kTRUE ;
231 
232  // Reduce exclLVServers to only those serving exclusively exclLVBranches
233  std::vector<RooAbsArg*> toBeRemoved;
234  for (auto server : exclLVServers) {
235  if (!servesExclusively(server,exclLVBranches,branchListVD)) {
236  toBeRemoved.push_back(server);
237  converged=kFALSE ;
238  }
239  }
240  exclLVServers.remove(toBeRemoved.begin(), toBeRemoved.end());
241 
242  // Reduce exclLVBranches to only those depending exclusively on exclLVservers
243  // Attention: counting loop, since erasing from container
244  for (std::size_t i=0; i < exclLVBranches.size(); ++i) {
245  const RooAbsArg* branch = exclLVBranches[i];
246  RooArgSet* brDepList = branch->getObservables(&intDepList) ;
247  RooArgSet bsList(*brDepList,"bsList") ;
248  delete brDepList ;
249  bsList.remove(exclLVServers,kTRUE,kTRUE) ;
250  if (bsList.getSize()>0) {
251  exclLVBranches.remove(*branch,kTRUE,kTRUE) ;
252  --i;
253  converged=kFALSE ;
254  }
255  }
256  }
257 
258  // Eliminate exclLVBranches that do not depend on any LVServer
259  // Attention: Counting loop, since modifying container
260  for (std::size_t i=0; i < exclLVBranches.size(); ++i) {
261  const RooAbsArg* branch = exclLVBranches[i];
262  if (!branch->dependsOnValue(exclLVServers)) {
263  exclLVBranches.remove(*branch,kTRUE,kTRUE) ;
264  --i;
265  }
266  }
267 
268  // Replace exclusive lvalue branch servers with lvalue branches
269  // WVE Don't do this for binned distributions - deal with this using numeric integration with transformed bin boundaroes
270  if (exclLVServers.getSize()>0 && !function.isBinnedDistribution(exclLVBranches)) {
271 // cout << "activating LVservers " << exclLVServers << " for use in integration " << endl ;
272  intDepList.remove(exclLVServers) ;
273  intDepList.add(exclLVBranches) ;
274 
275  //cout << "intDepList removing exclLVServers " << exclLVServers << endl ;
276  //cout << "intDepList adding exclLVBranches " << exclLVBranches << endl ;
277 
278  }
279 
280 
281  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
282  // * C) Check for dependents that the PDF insists on integrating *
283  // analytically iself *
284  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
285 
286  RooArgSet anIntOKDepList ;
287  for (auto arg : intDepList) {
288  if (function.forceAnalyticalInt(*arg)) {
289  anIntOKDepList.add(*arg) ;
290  }
291  }
292 
293  if (anIntOKDepList.getSize()>0) {
294  oocxcoutI(&function,Integration) << function.GetName() << ": Observables that function forcibly requires to be integrated internally " << anIntOKDepList << endl ;
295  }
296 
297 
298  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
299  // * D) Make list of servers that can be integrated analytically *
300  // Add all parameters/dependents as value/shape servers *
301  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
302 
303  for (const auto arg : function.servers()) {
304 
305  //cout << "considering server" << arg->GetName() << endl ;
306 
307  // Dependent or parameter?
308  if (!arg->dependsOnValue(intDepList)) {
309 
310  //cout << " server does not depend on observables, adding server as value server to integral" << endl ;
311 
312  if (function.dependsOnValue(*arg)) {
313  addServer(*arg,kTRUE,kFALSE) ;
314  }
315 
316  continue ;
317 
318  } else {
319 
320  // Add final dependents of arg as shape servers
321  RooArgSet argLeafServers ;
322  arg->leafNodeServerList(&argLeafServers,0,kFALSE) ;
323 
324  //arg->printCompactTree() ;
325  //cout << "leaf nodes of server are " << argLeafServers << " depList = " << depList << endl ;
326 
327  // Skip arg if it is neither value or shape server
328  if (!arg->isValueServer(function) && !arg->isShapeServer(function)) {
329  //cout << " server is neither value not shape server of function, ignoring" << endl ;
330  continue ;
331  }
332 
333  for (const auto leaf : argLeafServers) {
334 
335  //cout << " considering leafnode " << leaf->GetName() << " of server " << arg->GetName() << endl ;
336 
337  if (depList.find(leaf->GetName()) && function.dependsOnValue(*leaf)) {
338 
339  RooAbsRealLValue* leaflv = dynamic_cast<RooAbsRealLValue*>(leaf) ;
340  if (leaflv && leaflv->getBinning(rangeName).isParameterized()) {
341  oocxcoutD(&function,Integration) << function.GetName() << " : Observable " << leaf->GetName() << " has parameterized binning, add value dependence of boundary objects rather than shape of leaf" << endl ;
342  if (leaflv->getBinning(rangeName).lowBoundFunc()) {
343  addServer(*leaflv->getBinning(rangeName).lowBoundFunc(),kTRUE,kFALSE) ;
344  }
345  if(leaflv->getBinning(rangeName).highBoundFunc()) {
346  addServer(*leaflv->getBinning(rangeName).highBoundFunc(),kTRUE,kFALSE) ;
347  }
348  } else {
349  oocxcoutD(&function,Integration) << function.GetName() << ": Adding observable " << leaf->GetName() << " of server "
350  << arg->GetName() << " as shape dependent" << endl ;
351  addServer(*leaf,kFALSE,kTRUE) ;
352  }
353  } else if (!depList.find(leaf->GetName())) {
354 
355  if (function.dependsOnValue(*leaf)) {
356  oocxcoutD(&function,Integration) << function.GetName() << ": Adding parameter " << leaf->GetName() << " of server " << arg->GetName() << " as value dependent" << endl ;
357  addServer(*leaf,kTRUE,kFALSE) ;
358  } else {
359  oocxcoutD(&function,Integration) << function.GetName() << ": Adding parameter " << leaf->GetName() << " of server " << arg->GetName() << " as shape dependent" << endl ;
360  addServer(*leaf,kFALSE,kTRUE) ;
361  }
362  }
363  }
364  }
365 
366  // If this dependent arg is self-normalized, stop here
367  //if (function.selfNormalized()) continue ;
368 
369  Bool_t depOK(kFALSE) ;
370  // Check for integratable AbsRealLValue
371 
372  //cout << "checking server " << arg->IsA()->GetName() << "::" << arg->GetName() << endl ;
373 
374  if (arg->isDerived()) {
375  RooAbsRealLValue *realArgLV = dynamic_cast<RooAbsRealLValue*>(arg) ;
376  RooAbsCategoryLValue *catArgLV = dynamic_cast<RooAbsCategoryLValue*>(arg) ;
377  //cout << "realArgLV = " << realArgLV << " intDepList = " << intDepList << endl ;
378  if ((realArgLV && intDepList.find(realArgLV->GetName()) && (realArgLV->isJacobianOK(intDepList)!=0)) || catArgLV) {
379 
380  //cout << " arg " << arg->GetName() << " is derived LValue with valid jacobian" << endl ;
381 
382  // Derived LValue with valid jacobian
383  depOK = kTRUE ;
384 
385  // Now, check for overlaps
386  Bool_t overlapOK = kTRUE ;
387  for (const auto otherArg : function.servers()) {
388  // skip comparison with self
389  if (arg==otherArg) continue ;
390  if (otherArg->IsA()==RooConstVar::Class()) continue ;
391  if (arg->overlaps(*otherArg,kTRUE)) {
392  //cout << "arg " << arg->GetName() << " overlaps with " << otherArg->GetName() << endl ;
393  //overlapOK=kFALSE ;
394  }
395  }
396  // coverity[DEADCODE]
397  if (!overlapOK) depOK=kFALSE ;
398 
399  //cout << "overlap check returns OK=" << (depOK?"T":"F") << endl ;
400 
401  }
402  } else {
403  // Fundamental types are always OK
404  depOK = kTRUE ;
405  }
406 
407  // Add server to list of dependents that are OK for analytical integration
408  if (depOK) {
409  anIntOKDepList.add(*arg,kTRUE) ;
410  oocxcoutI(&function,Integration) << function.GetName() << ": Observable " << arg->GetName() << " is suitable for analytical integration (if supported by p.d.f)" << endl ;
411  }
412  }
413  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
414  // * E) interact with function to make list of objects actually integrated analytically *
415  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
416 
417  RooArgSet anIntDepList ;
418 
419  RooArgSet *anaSet = new RooArgSet( _anaList, Form("UniqueCloneOf_%s",_anaList.GetName()));
421  _anaList.removeAll() ;
422  _anaList.add(*anaSet);
423  delete anaSet;
424 
425  // Avoid confusion -- if mode is zero no analytical integral is defined regardless of contents of _anaListx
426  if (_mode==0) {
427  _anaList.removeAll() ;
428  }
429 
430  if (_mode!=0) {
431  oocxcoutI(&function,Integration) << function.GetName() << ": Function integrated observables " << _anaList << " internally with code " << _mode << endl ;
432  }
433 
434  // when _funcNormSet is a nullptr a warning message appears for RooAddPdf functions
435  // This is not a problem since we do noty use the returned value from getVal()
436  // we then disable the produced warning message in the RooFit::Eval topic
437  std::unique_ptr<RooHelpers::LocalChangeMsgLevel> msgChanger;
438  if (_funcNormSet == nullptr) {
439  // remove only the RooFit::Eval message topic from current active streams
440  // passed level can be whatever if we provide a false as last argument
441  msgChanger = std::make_unique<RooHelpers::LocalChangeMsgLevel>(RooFit::WARNING, 0u, RooFit::Eval, false);
442  }
443 
444  // WVE kludge: synchronize dset for use in analyticalIntegral
445  // LM : is this really needed ??
446  function.getVal(_funcNormSet) ;
447  // delete LocalChangeMsgLevel which will restore previous message level
448  msgChanger.reset(nullptr);
449 
450  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
451  // * F) Make list of numerical integration variables consisting of: *
452  // * - Category dependents of RealLValues in analytical integration *
453  // * - Expanded server lists of server that are not analytically integrated *
454  // * Make Jacobian list with analytically integrated RealLValues *
455  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
456 
457  RooArgSet numIntDepList ;
458 
459 
460  // Loop over actually analytically integrated dependents
461  for (const auto arg : _anaList) {
462 
463  // Process only derived RealLValues
464  if (arg->IsA()->InheritsFrom(RooAbsRealLValue::Class()) && arg->isDerived() && !arg->isFundamental()) {
465 
466  // Add to list of Jacobians to calculate
467  _jacList.add(*arg) ;
468 
469  // Add category dependent of LValueReal used in integration
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)) {
473  numIntDepList.add(*argDep,kTRUE) ;
474  }
475  }
476  }
477  }
478 
479 
480  // If nothing was integrated analytically, swap back LVbranches for LVservers for subsequent numeric integration
481  if (_anaList.getSize()==0) {
482  if (exclLVServers.getSize()>0) {
483  //cout << "NUMINT phase analList is empty. exclLVServers = " << exclLVServers << endl ;
484  intDepList.remove(exclLVBranches) ;
485  intDepList.add(exclLVServers) ;
486  }
487  }
488  //cout << "NUMINT intDepList = " << intDepList << endl ;
489 
490  // Loop again over function servers to add remaining numeric integrations
491  for (const auto arg : function.servers()) {
492 
493  //cout << "processing server for numeric integration " << arg->IsA()->GetName() << "::" << arg->GetName() << endl ;
494 
495  // Process only servers that are not treated analytically
496  if (!_anaList.find(arg->GetName()) && arg->dependsOn(intDepList)) {
497 
498  // Process only derived RealLValues
499  if (dynamic_cast<RooAbsLValue*>(arg) && arg->isDerived() && intDepList.contains(*arg)) {
500  numIntDepList.add(*arg,kTRUE) ;
501  } else {
502 
503  // WVE this will only get the observables, but not l-value transformations
504  // Expand server in final dependents
505  auto argDeps = std::unique_ptr<RooArgSet>(arg->getObservables(&intDepList));
506 
507  if (argDeps->getSize()>0) {
508 
509  // Add final dependents, that are not forcibly integrated analytically,
510  // to numerical integration list
511  for (const auto dep : *argDeps) {
512  if (!_anaList.find(dep->GetName())) {
513  numIntDepList.add(*dep,kTRUE) ;
514  }
515  }
516  }
517  }
518  }
519  }
520 
521  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
522  // * G) Split numeric list in integration list and summation list *
523  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
524 
525  // Split numeric integration list in summation and integration lists
526  for (const auto arg : numIntDepList) {
527  if (arg->IsA()->InheritsFrom(RooAbsRealLValue::Class())) {
528  _intList.add(*arg) ;
529  } else if (arg->IsA()->InheritsFrom(RooAbsCategoryLValue::Class())) {
530  _sumList.add(*arg) ;
531  }
532  }
533 
534  if (_anaList.getSize()>0) {
535  oocxcoutI(&function,Integration) << function.GetName() << ": Observables " << _anaList << " are analytically integrated with code " << _mode << endl ;
536  }
537  if (_intList.getSize()>0) {
538  oocxcoutI(&function,Integration) << function.GetName() << ": Observables " << _intList << " are numerically integrated" << endl ;
539  }
540  if (_sumList.getSize()>0) {
541  oocxcoutI(&function,Integration) << function.GetName() << ": Observables " << _sumList << " are numerically summed" << endl ;
542  }
543 
544 
545  // Determine operating mode
546  if (numIntDepList.getSize()>0) {
547  // Numerical and optional Analytical integration
548  _intOperMode = Hybrid ;
549  } else if (_anaList.getSize()>0) {
550  // Purely analytical integration
552  } else {
553  // No integration performed
555  }
556 
557  // Determine auto-dirty status
559 
560  // Create value caches for _intList and _sumList
563 
564 
565  if (_sumList.getSize()>0) {
566  RooSuperCategory *sumCat = new RooSuperCategory(Form("%s_sumCat",GetName()),"sumCat",_sumList) ;
567  _sumCat.addOwned(*sumCat) ;
568  }
569 
571 }
572 
573 
574 
575 ////////////////////////////////////////////////////////////////////////////////
576 /// Set appropriate cache operation mode for integral depending on cache operation
577 /// mode of server objects
578 
580 {
581  // If any of our servers are is forcedDirty or a projectedDependent, then we need to be ADirty
582  for (const auto server : _serverList) {
583  if (server->isValueServer(*this)) {
584  RooArgSet leafSet ;
585  server->leafNodeServerList(&leafSet) ;
586  for (const auto leaf : leafSet) {
587  if (leaf->operMode()==ADirty && leaf->isValueServer(*this)) {
589  break ;
590  }
591  if (leaf->getAttribute("projectedDependent")) {
593  break ;
594  }
595  }
596  }
597  }
598 }
599 
600 
601 
602 ////////////////////////////////////////////////////////////////////////////////
603 /// Utility function that returns true if 'object server' is a server
604 /// to exactly one of the RooAbsArgs in 'exclLVBranches'
605 
606 Bool_t RooRealIntegral::servesExclusively(const RooAbsArg* server,const RooArgSet& exclLVBranches, const RooArgSet& allBranches) const
607 {
608  // Determine if given server serves exclusively exactly one of the given nodes in exclLVBranches
609 
610  // Special case, no LV servers available
611  if (exclLVBranches.getSize()==0) return kFALSE ;
612 
613  // If server has no clients and is not an LValue itself, return false
614  if (server->_clientList.empty() && exclLVBranches.find(server->GetName())) {
615  return kFALSE ;
616  }
617 
618  // WVE must check for value relations only here!!!!
619 
620  // Loop over all clients
621  Int_t numLVServ(0) ;
622  for (const auto client : server->valueClients()) {
623  // If client is not an LValue, recurse
624  if (!(exclLVBranches.find(client->GetName())==client)) {
625  if (allBranches.find(client->GetName())==client) {
626  if (!servesExclusively(client,exclLVBranches,allBranches)) {
627  // Client is a non-LValue that doesn't have an exclusive LValue server
628  return kFALSE ;
629  }
630  }
631  } else {
632  // Client is an LValue
633  numLVServ++ ;
634  }
635  }
636 
637  return (numLVServ==1) ;
638 }
639 
640 
641 
642 
643 ////////////////////////////////////////////////////////////////////////////////
644 /// (Re)Initialize numerical integration engine if necessary. Return kTRUE if
645 /// successful, or otherwise kFALSE.
646 
648 {
649  // if we already have an engine, check if it still works for the present limits.
650  if(0 != _numIntEngine) {
652  // otherwise, cleanup the old engine
653  delete _numIntEngine ;
654  _numIntEngine= 0;
655  if(0 != _numIntegrand) {
656  delete _numIntegrand;
657  _numIntegrand= 0;
658  }
659  }
660 
661  // All done if there are no arguments to integrate numerically
662  if(0 == _intList.getSize()) return kTRUE;
663 
664  // Bind the appropriate analytic integral (specified by _mode) of our RooRealVar object to
665  // those of its arguments that will be integrated out numerically.
666  if(_mode != 0) {
668  }
669  else {
671  }
672  if(0 == _numIntegrand || !_numIntegrand->isValid()) {
673  coutE(Integration) << ClassName() << "::" << GetName() << ": failed to create valid integrand." << endl;
674  return kFALSE;
675  }
676 
677  // Create appropriate numeric integrator using factory
680 
681  if(0 == _numIntEngine || !_numIntEngine->isValid()) {
682  coutE(Integration) << ClassName() << "::" << GetName() << ": failed to create valid integrator." << endl;
683  return kFALSE;
684  }
685 
686  cxcoutI(NumIntegration) << "RooRealIntegral::init(" << GetName() << ") using numeric integrator "
687  << _numIntEngine->IsA()->GetName() << " to calculate Int" << _intList << endl ;
688 
689  if (_intList.getSize()>3) {
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 ;
691  }
692 
694  return kTRUE;
695 }
696 
697 
698 
699 ////////////////////////////////////////////////////////////////////////////////
700 /// Copy constructor
701 
703  RooAbsReal(other,name),
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),
714  _mode(other._mode),
715  _intOperMode(other._intOperMode),
716  _restartNumIntEngine(kFALSE),
717  _numIntEngine(0),
718  _numIntegrand(0),
719  _rangeName(other._rangeName),
720  _params(0),
721  _cacheNum(kFALSE)
722 {
724 
725  for (const auto arg : other._facList) {
726  RooAbsArg* argClone = (RooAbsArg*) arg->Clone() ;
727  _facListOwned.addOwned(*argClone) ;
728  _facList.add(*argClone) ;
729  addServer(*argClone,kFALSE,kTRUE) ;
730  }
731 
732  other._intList.snapshot(_saveInt) ;
733  other._sumList.snapshot(_saveSum) ;
734 
736 }
737 
738 
739 
740 ////////////////////////////////////////////////////////////////////////////////
741 
743  // Destructor
744 {
745  if (_numIntEngine) delete _numIntEngine ;
746  if (_numIntegrand) delete _numIntegrand ;
747  if (_funcNormSet) delete _funcNormSet ;
748  if (_params) delete _params ;
749 
751 }
752 
753 
754 
755 
756 
757 ////////////////////////////////////////////////////////////////////////////////
758 
759 RooAbsReal* RooRealIntegral::createIntegral(const RooArgSet& iset, const RooArgSet* nset, const RooNumIntConfig* cfg, const char* rangeName) const
760 {
761  // Handle special case of no integration with default algorithm
762  if (iset.getSize()==0) {
763  return RooAbsReal::createIntegral(iset,nset,cfg,rangeName) ;
764  }
765 
766  // Special handling of integral of integral, return RooRealIntegral that represents integral over all dimensions in one pass
767  RooArgSet isetAll(iset) ;
768  isetAll.add(_sumList) ;
769  isetAll.add(_intList) ;
770  isetAll.add(_anaList) ;
771  isetAll.add(_facList) ;
772 
773  const RooArgSet* newNormSet(0) ;
774  RooArgSet* tmp(0) ;
775  if (nset && !_funcNormSet) {
776  newNormSet = nset ;
777  } else if (!nset && _funcNormSet) {
778  newNormSet = _funcNormSet ;
779  } else if (nset && _funcNormSet) {
780  tmp = new RooArgSet ;
781  tmp->add(*nset) ;
782  tmp->add(*_funcNormSet,kTRUE) ;
783  newNormSet = tmp ;
784  }
785  RooAbsReal* ret = _function.arg().createIntegral(isetAll,newNormSet,cfg,rangeName) ;
786 
787  if (tmp) {
788  delete tmp ;
789  }
790 
791  return ret ;
792 }
793 
794 
795 
796 ////////////////////////////////////////////////////////////////////////////////
797 /// Return value of object. If the cache is clean, return the
798 /// cached value, otherwise recalculate on the fly and refill
799 /// the cache
800 
802 {
803 // // fast-track clean-cache processing
804 // if (_operMode==AClean) {
805 // return _value ;
806 // }
807 
808  if (nset && nset!=_lastNSet) {
809  ((RooAbsReal*) this)->setProxyNormSet(nset) ;
810  _lastNSet = (RooArgSet*) nset ;
811  }
812 
814  _value = traceEval(nset) ;
815  }
816 
817  return _value ;
818 }
819 
820 
821 
822 
823 
824 ////////////////////////////////////////////////////////////////////////////////
825 /// Perform the integration and return the result
826 
828 {
830 
831  Double_t retVal(0) ;
832  switch (_intOperMode) {
833 
834  case Hybrid:
835  {
836  // Cache numeric integrals in >1d expensive object cache
837  RooDouble* cacheVal(0) ;
840  }
841 
842  if (cacheVal) {
843  retVal = *cacheVal ;
844  // cout << "using cached value of integral" << GetName() << endl ;
845  } else {
846 
847 
848  // Find any function dependents that are AClean
849  // and switch them temporarily to ADirty
850  Bool_t origState = inhibitDirty() ;
852 
853  // try to initialize our numerical integration engine
854  if(!(_valid= initNumIntegrator())) {
855  coutE(Integration) << ClassName() << "::" << GetName()
856  << ":evaluate: cannot initialize numerical integrator" << endl;
857  return 0;
858  }
859 
860  // Save current integral dependent values
861  _saveInt = _intList ;
862  _saveSum = _sumList ;
863 
864  // Evaluate sum/integral
865  retVal = sum() ;
866 
867 
868  // This must happen BEFORE restoring dependents, otherwise no dirty state propagation in restore step
869  setDirtyInhibit(origState) ;
870 
871  // Restore integral dependent values
874 
875  // Cache numeric integrals in >1d expensive object cache
877  RooDouble* val = new RooDouble(retVal) ;
879  // cout << "### caching value of integral" << GetName() << " in " << &expensiveObjectCache() << endl ;
880  }
881 
882  }
883  break ;
884  }
885  case Analytic:
886  {
888  cxcoutD(Tracing) << "RooRealIntegral::evaluate_analytic(" << GetName()
889  << ")func = " << _function.arg().IsA()->GetName() << "::" << _function.arg().GetName()
890  << " raw = " << retVal << " _funcNormSet = " << (_funcNormSet?*_funcNormSet:RooArgSet()) << endl ;
891 
892 
893  break ;
894  }
895 
896  case PassThrough:
897  {
898  //setDirtyInhibit(kTRUE) ;
899  retVal= _function.arg().getVal(_funcNormSet) ;
900  //setDirtyInhibit(kFALSE) ;
901  break ;
902  }
903  }
904 
905 
906  // Multiply answer with integration ranges of factorized variables
907  if (_facList.getSize()>0) {
908  for (const auto arg : _facList) {
909  // Multiply by fit range for 'real' dependents
910  if (arg->IsA()->InheritsFrom(RooAbsRealLValue::Class())) {
911  RooAbsRealLValue* argLV = (RooAbsRealLValue*)arg ;
912  retVal *= (argLV->getMax() - argLV->getMin()) ;
913  }
914  // Multiply by number of states for category dependents
915  if (arg->IsA()->InheritsFrom(RooAbsCategoryLValue::Class())) {
917  retVal *= argLV->numTypes() ;
918  }
919  }
920  }
921 
922 
923  if (dologD(Tracing)) {
924  cxcoutD(Tracing) << "RooRealIntegral::evaluate(" << GetName() << ") anaInt = " << _anaList << " numInt = " << _intList << _sumList << " mode = " ;
925  switch(_mode) {
926  case Hybrid: ccoutD(Tracing) << "Hybrid" ; break ;
927  case Analytic: ccoutD(Tracing) << "Analytic" ; break ;
928  case PassThrough: ccoutD(Tracing) << "PassThrough" ; break ;
929  }
930 
931  ccxcoutD(Tracing) << "raw*fact = " << retVal << endl ;
932  }
933 
934  return retVal ;
935 }
936 
937 
938 
939 ////////////////////////////////////////////////////////////////////////////////
940 /// Return product of jacobian terms originating from analytical integration
941 
943 {
944  if (_jacList.getSize()==0) {
945  return 1 ;
946  }
947 
948  Double_t jacProd(1) ;
949  for (const auto elm : _jacList) {
950  auto arg = static_cast<const RooAbsRealLValue*>(elm);
951  jacProd *= arg->jacobian() ;
952  }
953 
954  // Take fabs() here: if jacobian is negative, min and max are swapped and analytical integral
955  // will be positive, so must multiply with positive jacobian.
956  return fabs(jacProd) ;
957 }
958 
959 
960 
961 ////////////////////////////////////////////////////////////////////////////////
962 /// Perform summation of list of category dependents to be integrated
963 
965 {
966  if (_sumList.getSize()!=0) {
967  // Add integrals for all permutations of categories summed over
968  Double_t total(0) ;
969 
971  for (const auto& nameIdx : *sumCat) {
972  sumCat->setIndex(nameIdx);
973  if (!_rangeName || sumCat->inRange(RooNameReg::str(_rangeName))) {
974  total += integrate() / jacobianProduct() ;
975  }
976  }
977 
978  return total ;
979 
980  } else {
981  // Simply return integral
982  Double_t ret = integrate() / jacobianProduct() ;
983  return ret ;
984  }
985 }
986 
987 
988 ////////////////////////////////////////////////////////////////////////////////
989 /// Perform hybrid numerical/analytical integration over all real-valued dependents
990 
992 {
993  if (!_numIntEngine) {
994  // Trivial case, fully analytical integration
995  return ((RooAbsReal&)_function.arg()).analyticalIntegralWN(_mode,_funcNormSet,RooNameReg::str(_rangeName)) ;
996  } else {
997  return _numIntEngine->calculate() ;
998  }
999 }
1000 
1001 
1002 
1003 ////////////////////////////////////////////////////////////////////////////////
1004 /// Intercept server redirects and reconfigure internal object accordingly
1005 
1007  Bool_t /*mustReplaceAll*/, Bool_t /*nameChange*/, Bool_t /*isRecursive*/)
1008 {
1010 
1012 
1013  // Update contents value caches for _intList and _sumList
1014  _saveInt.removeAll() ;
1015  _saveSum.removeAll() ;
1018 
1019  // Delete parameters cache if we have one
1020  if (_params) {
1021  delete _params ;
1022  _params = 0 ;
1023  }
1024 
1025  return kFALSE ;
1026 }
1027 
1028 
1029 
1030 ////////////////////////////////////////////////////////////////////////////////
1031 
1033 {
1034  if (!_params) {
1035  _params = new RooArgSet("params") ;
1036 
1037  RooArgSet params ;
1038  for (const auto server : _serverList) {
1039  if (server->isValueServer(*this)) _params->add(*server) ;
1040  }
1041  }
1042 
1043  return *_params ;
1044 }
1045 
1046 
1047 ////////////////////////////////////////////////////////////////////////////////
1048 /// Check if current value is valid
1049 
1050 Bool_t RooRealIntegral::isValidReal(Double_t /*value*/, Bool_t /*printError*/) const
1051 {
1052  return kTRUE ;
1053 }
1054 
1055 ////////////////////////////////////////////////////////////////////////////////
1056 /// Check if component selection is allowed
1057 
1059  return _respectCompSelect;
1060 }
1061 
1062 ////////////////////////////////////////////////////////////////////////////////
1063 /// Set component selection to be allowed/forbidden
1064 
1066  _respectCompSelect = allow;
1067 }
1068 
1069 ////////////////////////////////////////////////////////////////////////////////
1070 /// Customized printing of arguments of a RooRealIntegral to more intuitively reflect the contents of the
1071 /// integration operation
1072 
1073 void RooRealIntegral::printMetaArgs(ostream& os) const
1074 {
1075 
1076  if (intVars().getSize()!=0) {
1077  os << "Int " ;
1078  }
1079  os << _function.arg().GetName() ;
1080  if (_funcNormSet) {
1081  os << "_Norm" ;
1082  os << *_funcNormSet ;
1083  os << " " ;
1084  }
1085 
1086  // List internally integrated observables and factorizing observables as analytically integrated
1087  RooArgSet tmp(_anaList) ;
1088  tmp.add(_facList) ;
1089  if (tmp.getSize()>0) {
1090  os << "d[Ana]" ;
1091  os << tmp ;
1092  os << " " ;
1093  }
1094 
1095  // List numerically integrated and summed observables as numerically integrated
1096  RooArgSet tmp2(_intList) ;
1097  tmp2.add(_sumList) ;
1098  if (tmp2.getSize()>0) {
1099  os << " d[Num]" ;
1100  os << tmp2 ;
1101  os << " " ;
1102  }
1103 }
1104 
1105 
1106 
1107 ////////////////////////////////////////////////////////////////////////////////
1108 /// Print the state of this object to the specified output stream.
1109 
1111 {
1113  os << indent << "--- RooRealIntegral ---" << endl;
1114  os << indent << " Integrates ";
1116  TString deeper(indent);
1117  deeper.Append(" ");
1118  os << indent << " operating mode is "
1119  << (_intOperMode==Hybrid?"Hybrid":(_intOperMode==Analytic?"Analytic":"PassThrough")) << endl ;
1120  os << indent << " Summed discrete args are " << _sumList << endl ;
1121  os << indent << " Numerically integrated args are " << _intList << endl;
1122  os << indent << " Analytically integrated args using mode " << _mode << " are " << _anaList << endl ;
1123  os << indent << " Arguments included in Jacobian are " << _jacList << endl ;
1124  os << indent << " Factorized arguments are " << _facList << endl ;
1125  os << indent << " Function normalization set " ;
1126  if (_funcNormSet)
1127  _funcNormSet->Print("1") ;
1128  else
1129  os << "<none>" ;
1130 
1131  os << endl ;
1132 }
1133 
1134 
1135 
1136 ////////////////////////////////////////////////////////////////////////////////
1137 /// Global switch to cache all integral values that integrate at least ndim dimensions numerically
1138 
1140  _cacheAllNDim = ndim ;
1141 }
1142 
1143 
1144 ////////////////////////////////////////////////////////////////////////////////
1145 /// Return minimum dimensions of numeric integration for which values are cached.
1146 
1148 {
1149  return _cacheAllNDim ;
1150 }
RooAbsArg::Clone
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
Definition: RooAbsArg.h:84
RooExpensiveObjectCache::registerObject
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...
Definition: RooExpensiveObjectCache.cxx:110
RooSuperCategory.h
RooAbsArg::ADirty
@ ADirty
Definition: RooAbsArg.h:390
RooRealIntegral::_numIntEngine
RooAbsIntegrator * _numIntEngine
do not persist
Definition: RooRealIntegral.h:132
RooRealIntegral::printMetaArgs
void printMetaArgs(std::ostream &os) const
Customized printing of arguments of a RooRealIntegral to more intuitively reflect the contents of the...
Definition: RooRealIntegral.cxx:1073
RooHelpers.h
RooNameReg
RooNameReg is a registry for const char* names.
Definition: RooNameReg.h:25
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
RooMsgService.h
ccoutD
#define ccoutD(a)
Definition: RooMsgService.h:37
RooAbsCollection::first
RooAbsArg * first() const
Definition: RooAbsCollection.h:236
RooRealIntegral::_cacheNum
Bool_t _cacheNum
cache for set of parameters
Definition: RooRealIntegral.h:139
RooAbsBinning::highBoundFunc
virtual RooAbsReal * highBoundFunc() const
Return pointer to RooAbsReal parameterized upper bound, if any.
Definition: RooAbsBinning.h:88
RooNumIntConfig.h
RooAbsRealLValue::getMax
virtual Double_t getMax(const char *name=0) const
Get maximum of currently defined range.
Definition: RooAbsRealLValue.h:89
RooRealIntegral::evaluate
Double_t evaluate() const
Perform the integration and return the result.
Definition: RooRealIntegral.cxx:827
RooFit.h
RooRealIntegral::parameters
const RooArgSet & parameters() const
Definition: RooRealIntegral.cxx:1032
RooTemplateProxy::arg
const T & arg() const
Return reference to object held in proxy.
Definition: RooTemplateProxy.h:290
RooFit::InputArguments
@ InputArguments
Definition: RooGlobalFunc.h:61
RooAbsBinning::lowBoundFunc
virtual RooAbsReal * lowBoundFunc() const
Return pointer to RooAbsReal parameterized lower bound, if any.
Definition: RooAbsBinning.h:84
RooRealIntegral::_anaList
RooSetProxy _anaList
Definition: RooRealIntegral.h:113
RooArgSet.h
RooAbsReal::isBinnedDistribution
virtual Bool_t isBinnedDistribution(const RooArgSet &) const
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
Definition: RooAbsReal.h:341
RooAbsReal::createIntegral
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 ...
Definition: RooAbsReal.cxx:548
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
Form
char * Form(const char *fmt,...)
RooAbsArg::dependsOnValue
Bool_t dependsOnValue(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0) const
Check whether this object depends on values from an element in the serverList.
Definition: RooAbsArg.h:102
RooRealIntegral::_intList
RooSetProxy _intList
Definition: RooRealIntegral.h:112
RooRealIntegral::PassThrough
@ PassThrough
Definition: RooRealIntegral.h:91
RooAbsArg::_serverList
RefCountList_t _serverList
Definition: RooAbsArg.h:607
coutE
#define coutE(a)
Definition: RooMsgService.h:33
RooRealIntegral::_saveSum
RooArgSet _saveSum
do not persist
Definition: RooRealIntegral.h:122
RooRealIntegral::RooRealIntegral
RooRealIntegral()
Definition: RooRealIntegral.cxx:68
RooAbsReal::getVal
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:91
RooRealIntegral::setAllowComponentSelection
void setAllowComponentSelection(Bool_t allow)
Set component selection to be allowed/forbidden.
Definition: RooRealIntegral.cxx:1065
RooRealIntegral::_rangeName
TNamed * _rangeName
do not persist
Definition: RooRealIntegral.h:135
Int_t
int Int_t
Definition: RtypesCore.h:45
RooRealAnalytic.h
RooRealIntegral::getAllowComponentSelection
Bool_t getAllowComponentSelection() const
Check if component selection is allowed.
Definition: RooRealIntegral.cxx:1058
RooRealIntegral::_iconfig
RooNumIntConfig * _iconfig
do not persist
Definition: RooRealIntegral.h:124
RooAbsCollection::remove
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
Definition: RooAbsCollection.cxx:585
RooRealIntegral::_facList
RooSetProxy _facList
Definition: RooRealIntegral.h:115
ccxcoutD
#define ccxcoutD(a)
Definition: RooMsgService.h:82
RooAbsCollection::find
RooAbsArg * find(const char *name) const
Find object with given name in list.
Definition: RooAbsCollection.cxx:810
RooRealIntegral::_facListOwned
RooArgSet _facListOwned
Definition: RooRealIntegral.h:117
RooAbsArg::setOperMode
void setOperMode(OperMode mode, Bool_t recurseADirty=kTRUE)
Set the operation mode of this node.
Definition: RooAbsArg.cxx:1817
TClass.h
indent
static void indent(ostringstream &buf, int indent_level)
Definition: TClingCallFunc.cxx:87
RooNumIntFactory::createIntegrator
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...
Definition: RooNumIntFactory.cxx:172
RooAbsReal
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
RooAbsReal::getIntegratorConfig
const RooNumIntConfig * getIntegratorConfig() const
Return the numeric integration configuration used for this object.
Definition: RooAbsReal.cxx:3558
RooRealIntegral::_restartNumIntEngine
Bool_t _restartNumIntEngine
Definition: RooRealIntegral.h:131
RooAbsArg::inhibitDirty
Bool_t inhibitDirty() const
Delete watch flag.
Definition: RooAbsArg.cxx:116
RooRealIntegral::_respectCompSelect
Bool_t _respectCompSelect
Definition: RooRealIntegral.h:87
RooAbsArg::setExpensiveObjectCache
virtual void setExpensiveObjectCache(RooExpensiveObjectCache &cache)
Definition: RooAbsArg.h:503
TString
Basic string class.
Definition: TString.h:136
RooAbsCollection::GetName
const char * GetName() const
Returns name of object.
Definition: RooAbsCollection.h:286
RooAbsArg::expensiveObjectCache
RooExpensiveObjectCache & expensiveObjectCache() const
Definition: RooAbsArg.cxx:2277
RooExpensiveObjectCache::retrieveObject
const TObject * retrieveObject(const char *name, TClass *tclass, const RooArgSet &params)
Retrieve object from cache that was registered under given name with given parameters,...
Definition: RooExpensiveObjectCache.cxx:132
RooRealIntegral::printMultiline
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.
Definition: RooRealIntegral.cxx:1110
RooAbsReal::_globalSelectComp
static Bool_t _globalSelectComp
Component selection flag for RooAbsPdf::plotCompOn.
Definition: RooAbsReal.h:559
RooRealIntegral::_sumList
RooSetProxy _sumList
Definition: RooRealIntegral.h:111
RooSTLRefCountList::empty
bool empty() const
Check if empty.
Definition: RooSTLRefCountList.h:114
RooAbsArg::valueClients
const RefCountList_t & valueClients() const
List of all value clients of this object. Value clients receive value updates.
Definition: RooAbsArg.h:189
RooFit::NumIntegration
@ NumIntegration
Definition: RooGlobalFunc.h:62
RooRealIntegral::_params
RooArgSet * _params
Definition: RooRealIntegral.h:137
RooAbsCategory::numTypes
Int_t numTypes(const char *=0) const
Return number of types defined (in range named rangeName if rangeName!=0)
Definition: RooAbsCategory.h:128
RooRealIntegral::_sumCat
RooListProxy _sumCat
Definition: RooRealIntegral.h:126
bool
RooAbsRealLValue::getMin
virtual Double_t getMin(const char *name=0) const
Get miniminum of currently defined range.
Definition: RooAbsRealLValue.h:86
RooAbsReal::GlobalSelectComponentRAII
Definition: RooAbsReal.h:562
RooRealIntegral
RooRealIntegral performs hybrid numerical/analytical integrals of RooAbsReal objects.
Definition: RooRealIntegral.h:34
RooAbsReal::forceAnalyticalInt
virtual Bool_t forceAnalyticalInt(const RooAbsArg &) const
Definition: RooAbsReal.h:167
RooArgSet::snapshot
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Definition: RooArgSet.h:115
TObject::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:359
total
static unsigned int total
Definition: TGWin32ProxyDefs.h:40
RooTrace.h
RooDouble
RooDouble is a minimal implementation of a TObject holding a Double_t value.
Definition: RooDouble.h:22
RooAbsRealLValue::isJacobianOK
virtual Bool_t isJacobianOK(const RooArgSet &depList) const
Definition: RooAbsRealLValue.cxx:1036
ROOT::Math::fabs
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
Definition: UnaryOperators.h:131
RooFit::WARNING
@ WARNING
Definition: RooGlobalFunc.h:58
RooPrintable::kName
@ kName
Definition: RooPrintable.h:33
oocxcoutD
#define oocxcoutD(o, a)
Definition: RooMsgService.h:83
RooAbsIntegrator::calculate
Double_t calculate(const Double_t *yvec=0)
Calculate integral value with given array of parameter values.
Definition: RooAbsIntegrator.cxx:63
RooRealIntegral::Analytic
@ Analytic
Definition: RooRealIntegral.h:91
TRACE_DESTROY
#define TRACE_DESTROY
Definition: RooTrace.h:24
RooAbsReal::RooRealBinding
friend class RooRealBinding
Definition: RooAbsReal.h:473
RooRealIntegral::redirectServersHook
virtual Bool_t redirectServersHook(const RooAbsCollection &newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive)
Intercept server redirects and reconfigure internal object accordingly.
Definition: RooRealIntegral.cxx:1006
Double_t
RooRealIntegral::_jacList
RooSetProxy _jacList
Definition: RooRealIntegral.h:114
RooAbsIntegrator::checkLimits
virtual Bool_t checkLimits() const
Definition: RooAbsIntegrator.h:45
RooAbsReal::analyticalIntegralWN
virtual Double_t analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
Definition: RooAbsReal.cxx:415
RooAbsIntegrator::isValid
Bool_t isValid() const
Definition: RooAbsIntegrator.h:31
RooAbsCollection::addClone
virtual RooAbsArg * addClone(const RooAbsArg &var, Bool_t silent=kFALSE)
Add a clone of the specified argument to list.
Definition: RooAbsCollection.cxx:428
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:101
TString::Append
TString & Append(const char *cs)
Definition: TString.h:564
ROOT::R::function
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
Definition: RExports.h:151
RooRealIntegral::_mode
Int_t _mode
do not persist
Definition: RooRealIntegral.h:128
RooRealIntegral::sum
virtual Double_t sum() const
Perform summation of list of category dependents to be integrated.
Definition: RooRealIntegral.cxx:964
RooPrintable::kArgs
@ kArgs
Definition: RooPrintable.h:33
RooAbsArg::_clientList
RefCountList_t _clientList
Definition: RooAbsArg.h:608
RooAbsCollection
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
Definition: RooAbsCollection.h:33
RooAbsArg::RooArgSet
friend class RooArgSet
Definition: RooAbsArg.h:599
RooRealIntegral::servesExclusively
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...
Definition: RooRealIntegral.cxx:606
TRACE_CREATE
#define TRACE_CREATE
Definition: RooTrace.h:23
RooAbsCollection::add
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Definition: RooAbsCollection.cxx:455
RooAbsCollection::size
Storage_t::size_type size() const
Definition: RooAbsCollection.h:214
RooAbsReal::_value
Double_t _value
Definition: RooAbsReal.h:477
RooRealAnalytic
Lightweight RooAbsFunc interface adaptor that binds an analytic integral of a RooAbsReal object (spec...
Definition: RooRealAnalytic.h:21
RooRealIntegral::Hybrid
@ Hybrid
Definition: RooRealIntegral.h:91
RooAbsCollection::addOwned
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Definition: RooAbsCollection.cxx:403
RooAbsArg::servers
const RefCountList_t & servers() const
List of all servers of this object.
Definition: RooAbsArg.h:199
RooRealIntegral::_saveInt
RooArgSet _saveInt
Definition: RooRealIntegral.h:121
RooExpensiveObjectCache.h
RooConstVar.h
RooSetProxy::removeAll
virtual void removeAll() override
Remove all argument inset using remove(const RooAbsArg&).
Definition: RooSetProxy.cxx:229
RooAbsArg::addServer
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.
Definition: RooAbsArg.cxx:388
RooFit::Tracing
@ Tracing
Definition: RooGlobalFunc.h:61
RooAbsReal::traceEval
Double_t traceEval(const RooArgSet *set) const
Calculate current value of object, with error tracing wrapper.
Definition: RooAbsReal.cxx:354
RooAbsFunc::isValid
Bool_t isValid() const
Definition: RooAbsFunc.h:37
RooAbsReal::getAnalyticalIntegralWN
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 ...
Definition: RooAbsReal.cxx:386
RooRealIntegral::_funcNormSet
RooArgSet * _funcNormSet
Definition: RooRealIntegral.h:119
RooAbsArg::getObservables
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
Given a set of possible observables, return the observables that this PDF depends on.
Definition: RooAbsArg.h:295
RooRealIntegral::~RooRealIntegral
virtual ~RooRealIntegral()
Definition: RooRealIntegral.cxx:742
RooRealIntegral::_intOperMode
IntOperMode _intOperMode
Definition: RooRealIntegral.h:129
RooAbsCategoryLValue.h
RooRealIntegral::getCacheAllNumeric
static Int_t getCacheAllNumeric()
Return minimum dimensions of numeric integration for which values are cached.
Definition: RooRealIntegral.cxx:1147
RooRealIntegral::isValidReal
virtual Bool_t isValidReal(Double_t value, Bool_t printError=kFALSE) const
Check if current value is valid.
Definition: RooRealIntegral.cxx:1050
RooFit::Hybrid
@ Hybrid
Definition: RooGlobalFunc.h:63
RooSuperCategory
The RooSuperCategory can join several RooAbsCategoryLValue objects into a single category.
Definition: RooSuperCategory.h:27
oocxcoutI
#define oocxcoutI(o, a)
Definition: RooMsgService.h:87
RooRealIntegral::_cacheAllNDim
static Int_t _cacheAllNDim
Definition: RooRealIntegral.h:140
RooNameReg::str
static const char * str(const TNamed *ptr)
Return C++ string corresponding to given TNamed pointer.
Definition: RooNameReg.cxx:103
RooRealIntegral::autoSelectDirtyMode
void autoSelectDirtyMode()
Set appropriate cache operation mode for integral depending on cache operation mode of server objects...
Definition: RooRealIntegral.cxx:579
RooListProxy::addOwned
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE) override
Reimplementation of standard RooArgList::addOwned()
Definition: RooListProxy.cxx:114
name
char name[80]
Definition: TGX11.cxx:110
RooAbsBinning::isParameterized
virtual Bool_t isParameterized() const
Interface function.
Definition: RooAbsBinning.h:80
RooAbsArg::dependsOn
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.
Definition: RooAbsArg.cxx:799
RooRealIntegral::getValV
virtual Double_t getValV(const RooArgSet *set=0) const
Return value of object.
Definition: RooRealIntegral.cxx:801
RooAbsReal::printMultiline
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Structure printing.
Definition: RooAbsReal.cxx:490
RooPrintable::printStream
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,...
Definition: RooPrintable.cxx:75
genreflex::verbose
bool verbose
Definition: rootcling_impl.cxx:133
RooPrintable::kSingleLine
@ kSingleLine
Definition: RooPrintable.h:34
RooDouble.h
RooRealIntegral::integrate
virtual Double_t integrate() const
Perform hybrid numerical/analytical integration over all real-valued dependents.
Definition: RooRealIntegral.cxx:991
dologD
#define dologD(a)
Definition: RooMsgService.h:65
RooRealBinding.h
RooAbsArg
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:72
RooAbsArg::isValueOrShapeDirtyAndClear
Bool_t isValueOrShapeDirtyAndClear() const
Definition: RooAbsArg.h:455
RooNumIntConfig
RooNumIntConfig holds the configuration parameters of the various numeric integrators used by RooReal...
Definition: RooNumIntConfig.h:25
RMakeUnique.hxx
RooRealIntegral.h
RooAbsCollection::Print
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
Definition: RooAbsCollection.h:259
RooAbsLValue
Abstract base class for objects that are lvalues, i.e.
Definition: RooAbsLValue.h:26
RooAbsArg::setDirtyInhibit
static void setDirtyInhibit(Bool_t flag)
Control global dirty inhibit mode.
Definition: RooAbsArg.cxx:264
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
RooRealIntegral::_valid
Bool_t _valid
Definition: RooRealIntegral.h:86
RooNumIntFactory::instance
static RooNumIntFactory & instance()
Static method returning reference to singleton instance of factory.
Definition: RooNumIntFactory.cxx:96
RooRealIntegral::jacobianProduct
virtual Double_t jacobianProduct() const
Return product of jacobian terms originating from analytical integration.
Definition: RooRealIntegral.cxx:942
RooAbsCategoryLValue
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
Definition: RooAbsCategoryLValue.h:25
Class
void Class()
Definition: Class.C:29
RooFit::Integration
@ Integration
Definition: RooGlobalFunc.h:60
RooAbsCollection::removeAll
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
Definition: RooAbsCollection.cxx:644
RooFit::Eval
@ Eval
Definition: RooGlobalFunc.h:61
RooRealIntegral::initNumIntegrator
Bool_t initNumIntegrator() const
(Re)Initialize numerical integration engine if necessary.
Definition: RooRealIntegral.cxx:647
RooRealIntegral::setCacheAllNumeric
static void setCacheAllNumeric(Int_t ndim)
Global switch to cache all integral values that integrate at least ndim dimensions numerically.
Definition: RooRealIntegral.cxx:1139
RooAbsRealLValue
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
Definition: RooAbsRealLValue.h:31
RooRealIntegral::intVars
RooArgSet intVars() const
Definition: RooRealIntegral.h:56
RooInvTransform.h
TObject::ClassName
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:130
cxcoutI
#define cxcoutI(a)
Definition: RooMsgService.h:85
RooAbsRealLValue.h
RooNameReg.h
RooRealIntegral::_function
RooRealProxy _function
Definition: RooRealIntegral.h:118
RooRealIntegral::createIntegral
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 ...
Definition: RooRealIntegral.cxx:759
RooAbsRealLValue::getBinning
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.
RooNumIntFactory.h
RooAbsCollection::getSize
Int_t getSize() const
Definition: RooAbsCollection.h:231
RooSetProxy::add
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...
Definition: RooSetProxy.cxx:165
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:33
cxcoutD
#define cxcoutD(a)
Definition: RooMsgService.h:81
RooAbsReal::_lastNSet
RooArgSet * _lastNSet
Definition: RooAbsReal.h:578
RooRealIntegral::_numIntegrand
RooAbsFunc * _numIntegrand
do not persist
Definition: RooRealIntegral.h:133
int