16 #ifndef ROO_NORMSET_CACHE
17 #define ROO_NORMSET_CACHE
29 typedef RooArgSet* pRooArgSet ;
31 class RooNormSetCache {
33 typedef std::pair<const RooArgSet*, const RooArgSet*> Pair;
35 inline bool operator()(
const Pair& a,
const Pair& b)
const
37 if (a.first < b.first)
return true;
38 if (b.first < a.first)
return false;
39 return a.second < b.second;
42 typedef std::vector<Pair> PairVectType;
43 typedef std::map<Pair, ULong_t> PairIdxMapType;
46 RooNormSetCache(ULong_t max = 32);
47 virtual ~RooNormSetCache();
49 void add(
const RooArgSet* set1,
const RooArgSet* set2 = 0);
51 inline Int_t index(
const RooArgSet* set1,
const RooArgSet* set2 = 0,
52 const TNamed* set2RangeName = 0)
55 if (set2RangeName != _set2RangeName)
return -1;
56 const Pair pair(set1, set2);
57 PairIdxMapType::const_iterator it = _pairToIdx.lower_bound(pair);
58 if (_pairToIdx.end() != it &&
59 !PairCmp()(it->first, pair) && !PairCmp()(pair, it->first))
64 inline Bool_t contains(
const RooArgSet* set1,
const RooArgSet* set2 = 0,
65 const TNamed* set2RangeName = 0)
66 {
return (index(set1,set2,set2RangeName) >= 0); }
68 inline Bool_t containsSet1(
const RooArgSet* set1)
70 const Pair pair(set1, (
const RooArgSet*)0);
71 PairIdxMapType::const_iterator it = _pairToIdx.lower_bound(pair);
72 if (_pairToIdx.end() != it && it->first.first == set1)
77 const RooArgSet* lastSet1()
const {
return _pairs.empty()?0:_pairs.back().first; }
78 const RooArgSet* lastSet2()
const {
return _pairs.empty()?0:_pairs.back().second; }
79 const RooNameSet& nameSet1()
const {
return _name1; }
80 const RooNameSet& nameSet2()
const {
return _name2; }
82 Bool_t autoCache(
const RooAbsArg*
self,
const RooArgSet* set1,
83 const RooArgSet* set2 = 0,
const TNamed* set2RangeName = 0,
84 Bool_t autoRefill = kTRUE);
87 Int_t entries()
const {
return _pairs.size(); }
89 void initialize(
const RooNormSetCache& other) { clear(); *
this = other; }
94 PairIdxMapType _pairToIdx;
100 TNamed* _set2RangeName;
102 ClassDef(RooNormSetCache, 0)