Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/RooExpensiveObjectCache.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*****************************************************************************
0002  * Project: RooFit                                                           *
0003  * Package: RooFitCore                                                       *
0004  *    File: $Id$
0005  * Authors:                                                                  *
0006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
0007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
0008  *                                                                           *
0009  * Copyright (c) 2000-2005, Regents of the University of California          *
0010  *                          and Stanford University. All rights reserved.    *
0011  *                                                                           *
0012  * Redistribution and use in source and binary forms,                        *
0013  * with or without modification, are permitted according to the terms        *
0014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
0015  *****************************************************************************/
0016 #ifndef ROO_EXPENSIVE_OBJECT_CACHE
0017 #define ROO_EXPENSIVE_OBJECT_CACHE
0018 
0019 #include "TObject.h"
0020 #include "RooArgSet.h"
0021 #include "TString.h"
0022 #include <map>
0023 
0024 class RooExpensiveObjectCache : public TObject {
0025 public:
0026 
0027   RooExpensiveObjectCache() {}
0028   RooExpensiveObjectCache(const RooExpensiveObjectCache& other) : TObject(other) {}
0029   ~RooExpensiveObjectCache() override ;
0030 
0031   bool registerObject(const char* ownerName, const char* objectName, TObject& cacheObject, const RooArgSet& params) ;
0032   const TObject* retrieveObject(const char* name, TClass* tclass, const RooArgSet& params) ;
0033 
0034   const TObject* getObj(Int_t uniqueID) ;
0035   bool clearObj(Int_t uniqueID) ;
0036   bool setObj(Int_t uniqueID, TObject* obj) ;
0037   void clearAll() ;
0038 
0039   void importCacheObjects(RooExpensiveObjectCache& other, const char* ownerName, bool verbose=false) ;
0040 
0041   static RooExpensiveObjectCache& instance() ;
0042 
0043   Int_t size() const { return _map.size() ; }
0044   bool empty() const { return _map.empty() ; }
0045 
0046   void print() const ;
0047 
0048    class ExpensiveObject {
0049    public:
0050       ExpensiveObject() = default;
0051       ExpensiveObject(Int_t uid, const char *ownerName, TObject &payload, RooArgSet const &params);
0052       ExpensiveObject(Int_t uid, const ExpensiveObject &other);
0053       virtual ~ExpensiveObject();
0054       bool matches(TClass *tc, const RooArgSet &params);
0055 
0056       Int_t uid() const { return _uid; }
0057       const TObject *payload() const { return _payload; }
0058       TObject *payload() { return _payload; }
0059       void setPayload(TObject *obj) { _payload = obj; }
0060       const char *ownerName() const { return _ownerName.Data(); }
0061 
0062       void print() const;
0063 
0064    protected:
0065       Int_t _uid = 0;                           ///< Unique element ID ;
0066       TObject *_payload = nullptr;              ///< Payload
0067       std::map<TString, double> _realRefParams; ///< Names and values of real-valued reference parameters
0068       std::map<TString, Int_t> _catRefParams;   ///< Names and values of discrete-valued reference parameters
0069       TString _ownerName;                       ///< Name of RooAbsArg object that is associated to cache contents
0070 
0071       ClassDef(ExpensiveObject, 2); // Cache element containing expensive object and parameter values for which object is valid
0072    };
0073 
0074 protected:
0075 
0076   Int_t _nextUID = 0;
0077 
0078   std::map<TString,ExpensiveObject*> _map ;
0079 
0080 
0081   ClassDefOverride(RooExpensiveObjectCache,2) // Singleton class that serves as session repository for expensive objects
0082 };
0083 
0084 #endif