RooAbsCachedReal.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  *                                                                           *
00004  * Copyright (c) 2000-2005, Regents of the University of California          *
00005  *                          and Stanford University. All rights reserved.    *
00006  *                                                                           *
00007  * Redistribution and use in source and binary forms,                        *
00008  * with or without modification, are permitted according to the terms        *
00009  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
00010  *****************************************************************************/
00011 
00012 #ifndef ROOABSCACHEDREAL
00013 #define ROOABSCACHEDREAL
00014 
00015 #include "RooAbsPdf.h"
00016 #include "RooRealProxy.h"
00017 #include "RooAbsReal.h"
00018 #include "RooHistFunc.h"
00019 #include "RooObjCacheManager.h"
00020 #include <map>
00021 class RooChangeTracker ;
00022 class RooArgSet ;
00023  
00024 class RooAbsCachedReal : public RooAbsReal {
00025 public:
00026 
00027   RooAbsCachedReal() {} ;
00028   RooAbsCachedReal(const char *name, const char *title, Int_t ipOrder=0);
00029   RooAbsCachedReal(const RooAbsCachedReal& other, const char* name=0) ;
00030   virtual ~RooAbsCachedReal() ;
00031 
00032   virtual Double_t getVal(const RooArgSet* set=0) const ;
00033   virtual Bool_t selfNormalized() const { 
00034     // Declares function self normalized
00035     return kTRUE ; 
00036   }
00037 
00038   void setInterpolationOrder(Int_t order) ;
00039   Int_t getInterpolationOrder() const { 
00040     // Set interpolation order in RooHistFuncs that represent cache histograms
00041     return _ipOrder ; 
00042   }
00043 
00044   virtual Bool_t forceAnalyticalInt(const RooAbsArg& /*dep*/) const { 
00045     // Force all observables to be offered for internal integration
00046     return kTRUE ; 
00047   }
00048   
00049   virtual Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& analVars, const RooArgSet* normSet, const char* rangeName=0) const ; 
00050   virtual Double_t analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=0) const ;
00051    
00052 protected:
00053 
00054   class FuncCacheElem : public RooAbsCacheElement {
00055   public:
00056     FuncCacheElem(const RooAbsCachedReal& self, const RooArgSet* nset) ;
00057     virtual ~FuncCacheElem() {} ;
00058 
00059     // Cache management functions
00060     virtual RooArgList containedArgs(Action) ;
00061     virtual void printCompactTreeHook(std::ostream&, const char *, Int_t, Int_t) ;
00062 
00063     RooHistFunc* func() { return _func ; }
00064     RooDataHist* hist() { return _hist ; }
00065     RooChangeTracker* paramTracker() { return _paramTracker ; }
00066 
00067   private:
00068     // Payload
00069     RooHistFunc*  _func ;
00070     RooChangeTracker* _paramTracker ;
00071     RooDataHist* _hist ;
00072   } ;
00073 
00074   FuncCacheElem* getCache(const RooArgSet* nset) const ;
00075   void clearCacheObject(FuncCacheElem& cache) const ;
00076 
00077   virtual const char* payloadUniqueSuffix() const { return 0 ; }
00078 
00079   friend class FuncCacheElem ;
00080   virtual const char* binningName() const { 
00081     // Returns name of binning to be used for cache histogram creation
00082     return "cache" ; 
00083   }
00084   virtual FuncCacheElem* createCache(const RooArgSet* nset) const ;
00085   virtual const char* inputBaseName() const = 0 ;
00086   virtual RooArgSet* actualObservables(const RooArgSet& nset) const = 0 ;
00087   virtual RooArgSet* actualParameters(const RooArgSet& nset) const = 0 ;
00088   virtual void fillCacheObject(FuncCacheElem& cache) const = 0 ;
00089 
00090   mutable RooObjCacheManager _cacheMgr ; // The cache manager
00091 
00092   
00093   Int_t _ipOrder ; // Interpolation order for cache histograms 
00094  
00095   TString cacheNameSuffix(const RooArgSet& nset) const ;
00096   void disableCache(Bool_t flag) { 
00097     // Switch to disable caching mechanism
00098     _disableCache = flag ; 
00099   }
00100 
00101   mutable std::map<Int_t,std::pair<const RooArgSet*,const RooArgSet*> > _anaIntMap ; //! Map for analytical integration codes
00102   
00103 
00104 private:
00105 
00106   Bool_t _disableCache ; // Flag to run object in passthrough (= non-caching mode)
00107 
00108   ClassDef(RooAbsCachedReal,1) // Abstract base class for cached p.d.f.s
00109 };
00110  
00111 #endif

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