47 for (std::map<TString,ExpensiveObject*>::iterator iter =
_map.begin() ; iter!=
_map.end() ; ++iter) {
117 for (std::map<TString,ExpensiveObject*>::iterator iter =
_map.begin() ; iter !=
_map.end() ; ++iter) {
118 if (iter->second->uid() == uid) {
119 return iter->second->payload() ;
133 for (std::map<TString,ExpensiveObject*>::iterator iter =
_map.begin() ; iter !=
_map.end() ; ++iter) {
134 if (iter->second->uid() == uid) {
135 _map.erase(iter->first) ;
150 for (std::map<TString,ExpensiveObject*>::iterator iter =
_map.begin() ; iter !=
_map.end() ; ++iter) {
151 if (iter->second->uid() == uid) {
152 iter->second->setPayload(obj) ;
194 oocoutW(&inPayload,Caching) <<
"RooExpensiveObject::registerObject() WARNING: ignoring non-RooAbsReal/non-RooAbsCategory reference parameter " << arg->GetName() << std::endl ;
207 _realRefParams(other._realRefParams),
208 _catRefParams(other._catRefParams),
209 _ownerName(other._ownerName)
232 if (_payload->IsA() != tc) {
240 if (std::abs(real->
getVal()-_realRefParams[real->
GetName()])>1
e-12) {
263 for(
auto const& item :
_map) {
264 std::cout <<
"uid = " << item.second->uid() <<
" key=" << item.first <<
" value=" ;
265 item.second->print() ;
275 std::cout << _payload->
ClassName() <<
"::" << _payload->GetName() ;
276 if (!_realRefParams.empty() || !_catRefParams.empty()) {
277 std::cout <<
" parameters=( " ;
278 auto iter = _realRefParams.begin() ;
279 while(iter!=_realRefParams.end()) {
280 std::cout << iter->first <<
"=" << iter->second <<
" " ;
283 auto iter2 = _catRefParams.begin() ;
284 while(iter2!=_catRefParams.end()) {
285 std::cout << iter2->first <<
"=" << iter2->second <<
" " ;
290 std::cout << std::endl ;
300 for(
auto const& item : other.
_map) {
301 if (std::string(ownerName)==item.second->ownerName()) {
304 oocoutI(item.second->payload(),Caching) <<
"RooExpensiveObjectCache::importCache() importing cache object "
305 << item.first <<
" associated with object " << item.second->ownerName() << std::endl ;
Common abstract base class for objects that represent a value and a "shape" in RooFit.
A space to attach TBranches.
virtual value_type getCurrentIndex() const
Return index number of current state.
Abstract base class for objects that represent a real value and implements functionality common to al...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
TString _ownerName
Name of RooAbsArg object that is associated to cache contents.
virtual ~ExpensiveObject()
std::map< TString, double > _realRefParams
Names and values of real-valued reference parameters.
TObject * _payload
Payload.
bool matches(TClass *tc, const RooArgSet ¶ms)
Check object type ;.
std::map< TString, Int_t > _catRefParams
Names and values of discrete-valued reference parameters.
Int_t _uid
Unique element ID ;.
const TObject * payload() const
RooExpensiveObjectCache is a singleton class that serves as repository for objects that are expensive...
const TObject * getObj(Int_t uniqueID)
Retrieve payload object of cache element with given unique ID.
~RooExpensiveObjectCache() override
Destructor.
bool registerObject(const char *ownerName, const char *objectName, TObject &cacheObject, const RooArgSet ¶ms)
Register object associated with given name and given associated parameters with given values in cache...
bool clearObj(Int_t uniqueID)
Clear cache element with given unique ID Retrieve payload object of cache element with given unique I...
std::map< TString, ExpensiveObject * > _map
const TObject * retrieveObject(const char *name, TClass *tclass, const RooArgSet ¶ms)
Retrieve object from cache that was registered under given name with given parameters,...
void clearAll()
Clear all cache elements.
bool setObj(Int_t uniqueID, TObject *obj)
Place new payload object in cache element with given unique ID.
static RooExpensiveObjectCache & instance()
Return reference to singleton instance.
void importCacheObjects(RooExpensiveObjectCache &other, const char *ownerName, bool verbose=false)
TClass instances represent classes, structs and namespaces in the ROOT type system.
const char * GetName() const override
Returns name of object.
Mother of all ROOT objects.
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
virtual const char * ClassName() const
Returns name of class to which the object belongs.