RooRealIntegral.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitCore                                                       *
00004  *    File: $Id: RooRealIntegral.h,v 1.44 2007/05/11 09:11:30 verkerke Exp $
00005  * Authors:                                                                  *
00006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
00007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
00008  *                                                                           *
00009  * Copyright (c) 2000-2005, Regents of the University of California          *
00010  *                          and Stanford University. All rights reserved.    *
00011  *                                                                           *
00012  * Redistribution and use in source and binary forms,                        *
00013  * with or without modification, are permitted according to the terms        *
00014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
00015  *****************************************************************************/
00016 #ifndef ROO_REAL_INTEGRAL
00017 #define ROO_REAL_INTEGRAL
00018 
00019 #include "RooAbsReal.h"
00020 #include "RooArgSet.h"
00021 #include "RooAbsPdf.h"
00022 #include "RooRealProxy.h"
00023 #include "RooSetProxy.h"
00024 #include "RooListProxy.h"
00025 
00026 class RooArgSet ;
00027 class TH1F ;
00028 class RooAbsCategory ;
00029 class RooRealVar ;
00030 class RooAbsIntegrator ;
00031 class RooNumIntConfig ;
00032 
00033 class RooRealIntegral : public RooAbsReal {
00034 public:
00035 
00036   // Constructors, assignment etc
00037   RooRealIntegral() ;
00038   RooRealIntegral(const char *name, const char *title, const RooAbsReal& function, const RooArgSet& depList,
00039                   const RooArgSet* funcNormSet=0, const RooNumIntConfig* config=0, const char* rangeName=0) ;
00040   RooRealIntegral(const RooRealIntegral& other, const char* name=0);
00041   virtual TObject* clone(const char* newname) const { return new RooRealIntegral(*this,newname); }
00042   virtual ~RooRealIntegral();
00043 
00044   Bool_t isValid() const { return _valid; }
00045 
00046   void printMultiline(ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const ;
00047   void printMetaArgs(ostream& os) const ;
00048 
00049   const RooArgSet& numIntCatVars() const { return _sumList ; }
00050   const RooArgSet& numIntRealVars() const { return _intList ; }
00051   const RooArgSet& anaIntVars() const { return _anaList ; }
00052 
00053   RooArgSet intVars() const { RooArgSet tmp(_sumList) ; tmp.add(_intList) ; tmp.add(_anaList) ; tmp.add(_facList) ; return tmp ; }
00054   const char* intRange() { return _rangeName ? _rangeName->GetName() : 0 ; }
00055   const RooAbsReal& integrand() const { return _function.arg() ; }
00056 
00057   void setCacheNumeric(Bool_t flag) { 
00058     // If true, value of this interal is cached if it is (partially numeric)
00059     _cacheNum = flag ;
00060   }
00061 
00062   Bool_t getCacheNumeric() { 
00063     // If true, value of this interal is cached if it is (partially numeric)
00064     return _cacheNum ;
00065   }
00066 
00067   static void setCacheAllNumeric(Int_t ndim) {
00068     // Global switch to cache all integral values that integrate at least ndim dimensions numerically 
00069     _cacheAllNDim = ndim ;
00070   }
00071 
00072   static Int_t getCacheAllNumeric() {
00073     // Return minimum dimensions of numeric integration for which values are cached. 
00074     return _cacheAllNDim ;
00075   }
00076 
00077   virtual std::list<Double_t>* plotSamplingHint(RooAbsRealLValue& obs, Double_t xlo, Double_t xhi) const {
00078     // Forward plot sampling hint of integrand
00079     return _function.arg().plotSamplingHint(obs,xlo,xhi) ;
00080   }
00081 
00082   virtual RooAbsReal* createIntegral(const RooArgSet& iset, const RooArgSet* nset=0, const RooNumIntConfig* cfg=0, const char* rangeName=0) const ;  
00083 
00084 protected:
00085 
00086   mutable Bool_t _valid;
00087 
00088   const RooArgSet& parameters() const ;
00089 
00090   enum IntOperMode { Hybrid, Analytic, PassThrough } ;
00091   //friend class RooAbsPdf ;
00092 
00093   Bool_t initNumIntegrator() const;
00094   void autoSelectDirtyMode() ;
00095 
00096   virtual Double_t sum() const ;
00097   virtual Double_t integrate() const ;
00098   virtual Double_t jacobianProduct() const ;
00099 
00100   // Evaluation and validation implementation
00101   Double_t evaluate() const ;
00102   virtual Bool_t isValidReal(Double_t value, Bool_t printError=kFALSE) const ;
00103   Bool_t servesExclusively(const RooAbsArg* server,const RooArgSet& exclLVBranches, const RooArgSet& allBranches) const ;
00104 
00105 
00106   virtual Bool_t redirectServersHook(const RooAbsCollection& newServerList, 
00107                                      Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive) ;
00108 
00109   // Function pointer and integrands list
00110   mutable RooSetProxy _sumList ; // Set of discrete observable over which is summed numerically
00111   mutable RooSetProxy _intList ; // Set of continuous observables over which is integrated numerically
00112   mutable RooSetProxy _anaList ; // Set of observables over which is integrated/summed analytically
00113   mutable RooSetProxy _jacList ; // Set of lvalue observables over which is analytically integration that have a non-unit Jacobian
00114   mutable RooSetProxy _facList ; // Set of observables on which function does not depends, which are integrated nevertheless
00115 
00116   mutable RooArgSet   _facListOwned ;  // Owned components in _facList
00117   TIterator*          _facListIter ; //! Iterator over factorizing observables
00118   TIterator*          _jacListIter ; //! Iterator over lvalue observables with Jacobian
00119   RooRealProxy       _function ;     // Function being integration
00120   RooArgSet*      _funcNormSet ;     // Optional normalization set passed to function
00121 
00122   mutable RooArgSet       _saveInt ; //! do not persist
00123   mutable RooArgSet       _saveSum ; //! do not persist 
00124 
00125   RooNumIntConfig* _iconfig ;
00126 
00127   mutable RooListProxy _sumCat ; //! do not persist  
00128   TIterator* _sumCatIter ; //!
00129   
00130   Int_t _mode ;
00131   IntOperMode _intOperMode ;   // integration operation mode
00132 
00133   mutable Bool_t _restartNumIntEngine ; //! do not persist
00134   mutable RooAbsIntegrator* _numIntEngine ;  //! do not persist
00135   mutable RooAbsFunc *_numIntegrand;         //! do not persist
00136 
00137   TNamed* _rangeName ; 
00138   
00139   mutable RooArgSet* _params ; //! cache for set of parameters
00140 
00141   Bool_t _cacheNum ;           // Cache integral if numeric
00142   static Int_t _cacheAllNDim ; //! Cache all integrals with given numeric dimension
00143 
00144 
00145   virtual void operModeHook() ; // cache operation mode
00146 
00147   ClassDef(RooRealIntegral,2) // Real-valued function representing an integral over a RooAbsReal object
00148 };
00149 
00150 #endif

Generated on Tue Jul 5 14:26:19 2011 for ROOT_528-00b_version by  doxygen 1.5.1