Logo ROOT  
Reference Guide
RooExpensiveObjectCache.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * File: $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 #ifndef ROO_EXPENSIVE_OBJECT_CACHE
17 #define ROO_EXPENSIVE_OBJECT_CACHE
18 
19 #include "TObject.h"
20 #include "RooArgSet.h"
21 #include "TString.h"
22 #include <map>
23 
25 public:
26 
29  virtual ~RooExpensiveObjectCache() ;
30 
31  Bool_t registerObject(const char* ownerName, const char* objectName, TObject& cacheObject, TIterator* paramIter) ;
32  Bool_t registerObject(const char* ownerName, const char* objectName, TObject& cacheObject, const RooArgSet& params) ;
33  const TObject* retrieveObject(const char* name, TClass* tclass, const RooArgSet& params) ;
34 
35  const TObject* getObj(Int_t uniqueID) ;
36  Bool_t clearObj(Int_t uniqueID) ;
37  Bool_t setObj(Int_t uniqueID, TObject* obj) ;
38  void clearAll() ;
39 
40  void importCacheObjects(RooExpensiveObjectCache& other, const char* ownerName, Bool_t verbose=kFALSE) ;
41 
43 
44  Int_t size() const { return _map.size() ; }
45 
46  void print() const ;
47 
49  public:
50  ExpensiveObject() { _uid = 0 ; _payload = 0 ; } ;
51  ExpensiveObject(Int_t uid, const char* ownerName, TObject& payload, TIterator* paramIter) ;
52  ExpensiveObject(Int_t uid, const ExpensiveObject& other) ;
53  virtual ~ExpensiveObject() ;
54  Bool_t matches(TClass* tc, const RooArgSet& params) ;
55 
56  Int_t uid() const { return _uid ; }
57  const TObject* payload() const { return _payload ; }
58  TObject* payload() { return _payload ; }
59  void setPayload(TObject* obj) { _payload = obj ; }
60  const char* ownerName() const { return _ownerName.Data() ; }
61 
62  void print() const;
63 
64  protected:
65 
66  Int_t _uid ; // Unique element ID ;
67  TObject* _payload ; // Payload
68  std::map<TString,Double_t> _realRefParams ; // Names and values of real-valued reference parameters
69  std::map<TString,Int_t> _catRefParams ; // Names and values of discrete-valued reference parameters
70  TString _ownerName ; // Name of RooAbsArg object that is associated to cache contents
71 
72  ClassDef(ExpensiveObject,2) ; // Cache element containing expensive object and parameter values for which object is valid
73 } ;
74 
75 
76 protected:
77 
79 
80  std::map<TString,ExpensiveObject*> _map ;
81 
82 
83  ClassDef(RooExpensiveObjectCache,2) // Singleton class that serves as session repository for expensive objects
84 };
85 
86 #endif
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
RooExpensiveObjectCache::ExpensiveObject::payload
const TObject * payload() const
Definition: RooExpensiveObjectCache.h:57
RooExpensiveObjectCache::_map
std::map< TString, ExpensiveObject * > _map
Definition: RooExpensiveObjectCache.h:80
RooExpensiveObjectCache::~RooExpensiveObjectCache
virtual ~RooExpensiveObjectCache()
Destructor.
Definition: RooExpensiveObjectCache.cxx:67
RooArgSet.h
TString::Data
const char * Data() const
Definition: TString.h:369
RooExpensiveObjectCache::ExpensiveObject::_uid
Int_t _uid
Definition: RooExpensiveObjectCache.h:66
RooExpensiveObjectCache::clearObj
Bool_t clearObj(Int_t uniqueID)
Clear cache element with given unique ID Retrieve payload object of cache element with given unique I...
Definition: RooExpensiveObjectCache.cxx:170
RooExpensiveObjectCache::size
Int_t size() const
Definition: RooExpensiveObjectCache.h:44
RooExpensiveObjectCache::_nextUID
Int_t _nextUID
Definition: RooExpensiveObjectCache.h:78
RooExpensiveObjectCache::ExpensiveObject::_realRefParams
std::map< TString, Double_t > _realRefParams
Definition: RooExpensiveObjectCache.h:68
TString
Basic string class.
Definition: TString.h:136
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
TString.h
RooExpensiveObjectCache::ExpensiveObject::_payload
TObject * _payload
Definition: RooExpensiveObjectCache.h:67
RooExpensiveObjectCache
RooExpensiveObjectCache is a singleton class that serves as repository for objects that are expensive...
Definition: RooExpensiveObjectCache.h:24
bool
TIterator
Iterator abstract base class.
Definition: TIterator.h:30
RooExpensiveObjectCache::ExpensiveObject::~ExpensiveObject
virtual ~ExpensiveObject()
Definition: RooExpensiveObjectCache.cxx:259
RooExpensiveObjectCache::ExpensiveObject::setPayload
void setPayload(TObject *obj)
Definition: RooExpensiveObjectCache.h:59
RooExpensiveObjectCache::ExpensiveObject::print
void print() const
Definition: RooExpensiveObjectCache.cxx:322
RooExpensiveObjectCache::ExpensiveObject::uid
Int_t uid() const
Definition: RooExpensiveObjectCache.h:56
RooExpensiveObjectCache::ExpensiveObject::_catRefParams
std::map< TString, Int_t > _catRefParams
Definition: RooExpensiveObjectCache.h:69
RooExpensiveObjectCache::setObj
Bool_t setObj(Int_t uniqueID, TObject *obj)
Place new payload object in cache element with given unique ID.
Definition: RooExpensiveObjectCache.cxx:187
RooExpensiveObjectCache::ExpensiveObject::ownerName
const char * ownerName() const
Definition: RooExpensiveObjectCache.h:60
RooExpensiveObjectCache::ExpensiveObject::matches
Bool_t matches(TClass *tc, const RooArgSet &params)
Check object type ;.
Definition: RooExpensiveObjectCache.cxx:271
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
RooExpensiveObjectCache::instance
static RooExpensiveObjectCache & instance()
Return reference to singleton instance.
Definition: RooExpensiveObjectCache.cxx:80
RooExpensiveObjectCache::importCacheObjects
void importCacheObjects(RooExpensiveObjectCache &other, const char *ownerName, Bool_t verbose=kFALSE)
Definition: RooExpensiveObjectCache.cxx:347
RooExpensiveObjectCache::print
void print() const
Definition: RooExpensiveObjectCache.cxx:307
TObject.h
RooExpensiveObjectCache::ExpensiveObject::_ownerName
TString _ownerName
Definition: RooExpensiveObjectCache.h:70
TClass
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
RooExpensiveObjectCache::RooExpensiveObjectCache
RooExpensiveObjectCache()
Constructor.
Definition: RooExpensiveObjectCache.cxx:48
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
name
char name[80]
Definition: TGX11.cxx:110
RooExpensiveObjectCache::ExpensiveObject
Definition: RooExpensiveObjectCache.h:48
RooExpensiveObjectCache::ExpensiveObject::ExpensiveObject
ExpensiveObject()
Definition: RooExpensiveObjectCache.h:50
RooExpensiveObjectCache::ExpensiveObject::payload
TObject * payload()
Definition: RooExpensiveObjectCache.h:58
genreflex::verbose
bool verbose
Definition: rootcling_impl.cxx:133
RooExpensiveObjectCache::clearAll
void clearAll()
Clear all cache elements.
Definition: RooExpensiveObjectCache.cxx:203
RooExpensiveObjectCache::getObj
const TObject * getObj(Int_t uniqueID)
Retrieve payload object of cache element with given unique ID
Definition: RooExpensiveObjectCache.cxx:154
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:29
int