RooExpensiveObjectCache.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitCore                                                       *
00004  *    File: $Id: RooExpensiveObjectCache.h 36209 2010-10-08 21:37:36Z wouter $
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_EXPENSIVE_OBJECT_CACHE
00017 #define ROO_EXPENSIVE_OBJECT_CACHE
00018 
00019 #include "Rtypes.h"
00020 #include "RooArgSet.h"
00021 #include "TString.h"
00022 #include <list>
00023 #include <map>
00024 
00025 class RooExpensiveObjectCache : public TObject {
00026 public:
00027 
00028   RooExpensiveObjectCache() ;
00029   RooExpensiveObjectCache(const RooExpensiveObjectCache&) ;
00030   virtual ~RooExpensiveObjectCache() ;
00031 
00032   Bool_t registerObject(const char* ownerName, const char* objectName, TObject& cacheObject, TIterator* paramIter) ;
00033   Bool_t registerObject(const char* ownerName, const char* objectName, TObject& cacheObject, const RooArgSet& params) ;
00034   const TObject* retrieveObject(const char* name, TClass* tclass, const RooArgSet& params) ;
00035 
00036   const TObject* getObj(Int_t uniqueID) ;
00037   Bool_t clearObj(Int_t uniqueID) ;
00038   Bool_t setObj(Int_t uniqueID, TObject* obj) ;
00039   void clearAll() ;
00040 
00041   void importCacheObjects(RooExpensiveObjectCache& other, const char* ownerName, Bool_t verbose=kFALSE) ;
00042 
00043   static RooExpensiveObjectCache& instance() ;
00044 
00045   Int_t size() const { return _map.size() ; }
00046 
00047   static void cleanup() ;
00048 
00049   void print() const ;
00050 
00051   class ExpensiveObject {
00052   public:
00053     ExpensiveObject() { _uid = 0 ; _payload = 0 ; } ;
00054     ExpensiveObject(Int_t uid, const char* ownerName, TObject& payload, TIterator* paramIter) ;
00055     ExpensiveObject(Int_t uid, const ExpensiveObject& other) ;
00056     virtual ~ExpensiveObject() ;
00057     Bool_t matches(TClass* tc, const RooArgSet& params) ;
00058 
00059     Int_t uid() const { return _uid ; }
00060     const TObject* payload() const { return _payload ; }
00061     TObject* payload() { return _payload ; }
00062     void setPayload(TObject* obj) { _payload = obj ; }
00063     const char* ownerName() const { return _ownerName.Data() ; }
00064 
00065     void print() ;
00066 
00067   protected:
00068     
00069     Int_t _uid ; // Unique element ID ;
00070     TObject* _payload ; // Payload
00071     std::map<TString,Double_t> _realRefParams ; // Names and values of real-valued reference parameters
00072     std::map<TString,Int_t> _catRefParams ; // Names and values of discrete-valued reference parameters 
00073     TString _ownerName ; // Name of RooAbsArg object that is associated to cache contents
00074   
00075     ClassDef(ExpensiveObject,2) ; // Cache element containing expensive object and parameter values for which object is valid
00076 } ;
00077 
00078  
00079 protected:
00080 
00081   Int_t _nextUID ; 
00082 
00083   static RooExpensiveObjectCache* _instance ;  //!
00084 
00085   std::map<TString,ExpensiveObject*> _map ;
00086  
00087   
00088   ClassDef(RooExpensiveObjectCache,2) // Singleton class that serves as session repository for expensive objects
00089 };
00090 
00091 #endif

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