00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef ROO_NORMSET_CACHE
00017 #define ROO_NORMSET_CACHE
00018
00019 #include "Riosfwd.h"
00020 #include <assert.h>
00021 #include "Rtypes.h"
00022 #include "RooNameSet.h"
00023 #include "RooSetPair.h"
00024 #include "RooHashTable.h"
00025
00026 class RooArgSet ;
00027 class RooSetPair ;
00028
00029 typedef RooArgSet* pRooArgSet ;
00030
00031 class RooNormSetCache {
00032
00033 public:
00034 RooNormSetCache(Int_t regSize=10) ;
00035 RooNormSetCache(const RooNormSetCache& other) ;
00036 virtual ~RooNormSetCache() ;
00037
00038 void add(const RooArgSet* set1, const RooArgSet* set2=0) ;
00039
00040 inline Int_t index(const RooArgSet* set1, const RooArgSet* set2=0, const TNamed* set2RangeName=0) {
00041
00042
00043 if (set2RangeName != _set2RangeName) return -1 ;
00044
00045
00046 Int_t i ;
00047 for (i=0 ; i<_nreg ; i++) {
00048 if (_asArr[i]._set1 == set1 &&
00049 _asArr[i]._set2 == set2
00050 ) return i ;
00051 }
00052
00053 return -1 ;
00054 }
00055
00056 inline Bool_t contains(const RooArgSet* set1, const RooArgSet* set2=0, const TNamed* set2RangeName=0) {
00057 if (set2RangeName!=_set2RangeName) return kFALSE ;
00058 if (_htable) return (_htable->findSetPair(set1,set2)) ;
00059 return (index(set1,set2,set2RangeName)>=0) ;
00060 }
00061
00062 inline Bool_t containsSet1(const RooArgSet* set1) {
00063 Int_t i ;
00064 for (i=0 ; i<_nreg ; i++) {
00065 if (_asArr[i]._set1 == set1) return kTRUE ;
00066 }
00067 return kFALSE ;
00068 }
00069
00070 const RooArgSet* lastSet1() const { return _nreg>0?_asArr[_nreg-1]._set1:0 ; }
00071 const RooArgSet* lastSet2() const { return _nreg>0?_asArr[_nreg-1]._set2:0 ; }
00072 const RooNameSet& nameSet1() const { return _name1 ; }
00073 const RooNameSet& nameSet2() const { return _name2 ; }
00074
00075 Bool_t autoCache(const RooAbsArg* self, const RooArgSet* set1, const RooArgSet* set2=0, const TNamed* set2RangeName=0, Bool_t autoRefill=kTRUE) ;
00076
00077 void clear() ;
00078 Int_t entries() const { return _nreg ; }
00079
00080 void initialize(const RooNormSetCache& other) ;
00081
00082 protected:
00083
00084 void expand() ;
00085
00086 RooHashTable* _htable ;
00087 Int_t _regSize ;
00088 Int_t _nreg ;
00089 RooSetPair* _asArr ;
00090
00091 RooNameSet _name1 ;
00092 RooNameSet _name2 ;
00093 TNamed* _set2RangeName ;
00094
00095 ClassDef(RooNormSetCache,1)
00096 } ;
00097
00098 #endif