Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RooRealIntegral.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * File: $Id: RooRealIntegral.h,v 1.44 2007/05/11 09:11:30 verkerke Exp $
5  * Authors: *
6  * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7  * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8  * *
9  * Copyright (c) 2000-2005, Regents of the University of California *
10  * and Stanford University. All rights reserved. *
11  * *
12  * Redistribution and use in source and binary forms, *
13  * with or without modification, are permitted according to the terms *
14  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15  *****************************************************************************/
16 #ifndef ROO_REAL_INTEGRAL
17 #define ROO_REAL_INTEGRAL
18 
19 #include "RooAbsReal.h"
20 #include "RooArgSet.h"
21 #include "RooAbsPdf.h"
22 #include "RooRealProxy.h"
23 #include "RooSetProxy.h"
24 #include "RooListProxy.h"
25 
26 class RooArgSet ;
27 class TH1F ;
28 class RooAbsCategory ;
29 class RooRealVar ;
30 class RooAbsIntegrator ;
31 class RooNumIntConfig ;
32 
33 class RooRealIntegral : public RooAbsReal {
34 public:
35 
36  // Constructors, assignment etc
37  RooRealIntegral() ;
38  RooRealIntegral(const char *name, const char *title, const RooAbsReal& function, const RooArgSet& depList,
39  const RooArgSet* funcNormSet=0, const RooNumIntConfig* config=0, const char* rangeName=0) ;
40  RooRealIntegral(const RooRealIntegral& other, const char* name=0);
41  virtual TObject* clone(const char* newname) const { return new RooRealIntegral(*this,newname); }
42  virtual ~RooRealIntegral();
43 
44  virtual Double_t getValV(const RooArgSet* set=0) const ;
45 
46  Bool_t isValid() const { return _valid; }
47 
48  void printMultiline(std::ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const ;
49  void printMetaArgs(std::ostream& os) const ;
50 
51  const RooArgSet& numIntCatVars() const { return _sumList ; }
52  const RooArgSet& numIntRealVars() const { return _intList ; }
53  const RooArgSet& anaIntVars() const { return _anaList ; }
54 
55  RooArgSet intVars() const { RooArgSet tmp(_sumList) ; tmp.add(_intList) ; tmp.add(_anaList) ; tmp.add(_facList) ; return tmp ; }
56  const char* intRange() { return _rangeName ? _rangeName->GetName() : 0 ; }
57  const RooAbsReal& integrand() const { return _function.arg() ; }
58 
59  void setCacheNumeric(Bool_t flag) {
60  // If true, value of this interal is cached if it is (partially numeric)
61  _cacheNum = flag ;
62  }
63 
64  Bool_t getCacheNumeric() {
65  // If true, value of this interal is cached if it is (partially numeric)
66  return _cacheNum ;
67  }
68 
69  static void setCacheAllNumeric(Int_t ndim) ;
70 
71  static Int_t getCacheAllNumeric() ;
72 
73  virtual std::list<Double_t>* plotSamplingHint(RooAbsRealLValue& obs, Double_t xlo, Double_t xhi) const {
74  // Forward plot sampling hint of integrand
75  return _function.arg().plotSamplingHint(obs,xlo,xhi) ;
76  }
77 
78  virtual RooAbsReal* createIntegral(const RooArgSet& iset, const RooArgSet* nset=0, const RooNumIntConfig* cfg=0, const char* rangeName=0) const ;
79 
80  void setAllowComponentSelection(Bool_t allow);
81  Bool_t getAllowComponentSelection() const;
82 
83 protected:
84 
85  mutable Bool_t _valid;
86  Bool_t _respectCompSelect;
87 
88  const RooArgSet& parameters() const ;
89 
90  enum IntOperMode { Hybrid, Analytic, PassThrough } ;
91  //friend class RooAbsPdf ;
92 
93  Bool_t initNumIntegrator() const;
94  void autoSelectDirtyMode() ;
95 
96  virtual Double_t sum() const ;
97  virtual Double_t integrate() const ;
98  virtual Double_t jacobianProduct() const ;
99 
100  // Evaluation and validation implementation
101  Double_t evaluate() const ;
102  virtual Bool_t isValidReal(Double_t value, Bool_t printError=kFALSE) const ;
103  Bool_t servesExclusively(const RooAbsArg* server,const RooArgSet& exclLVBranches, const RooArgSet& allBranches) const ;
104 
105 
106  virtual Bool_t redirectServersHook(const RooAbsCollection& newServerList,
107  Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive) ;
108 
109  // Function pointer and integrands list
110  mutable RooSetProxy _sumList ; // Set of discrete observable over which is summed numerically
111  mutable RooSetProxy _intList ; // Set of continuous observables over which is integrated numerically
112  mutable RooSetProxy _anaList ; // Set of observables over which is integrated/summed analytically
113  mutable RooSetProxy _jacList ; // Set of lvalue observables over which is analytically integration that have a non-unit Jacobian
114  mutable RooSetProxy _facList ; // Set of observables on which function does not depends, which are integrated nevertheless
115 
116  mutable RooArgSet _facListOwned ; // Owned components in _facList
117  RooRealProxy _function ; // Function being integration
118  RooArgSet* _funcNormSet ; // Optional normalization set passed to function
119 
120  mutable RooArgSet _saveInt ; //! do not persist
121  mutable RooArgSet _saveSum ; //! do not persist
122 
123  RooNumIntConfig* _iconfig ;
124 
125  mutable RooListProxy _sumCat ; //! do not persist
126  TIterator* _sumCatIter ; //!
127 
128  Int_t _mode ;
129  IntOperMode _intOperMode ; // integration operation mode
130 
131  mutable Bool_t _restartNumIntEngine ; //! do not persist
132  mutable RooAbsIntegrator* _numIntEngine ; //! do not persist
133  mutable RooAbsFunc *_numIntegrand; //! do not persist
134 
135  TNamed* _rangeName ;
136 
137  mutable RooArgSet* _params ; //! cache for set of parameters
138 
139  Bool_t _cacheNum ; // Cache integral if numeric
140  static Int_t _cacheAllNDim ; //! Cache all integrals with given numeric dimension
141 
142 
143  virtual void operModeHook() ; // cache operation mode
144 
145  ClassDef(RooRealIntegral,3) // Real-valued function representing an integral over a RooAbsReal object
146 };
147 
148 #endif