Logo ROOT  
Reference Guide
RooNormSetCache.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * File: $Id: RooNormSetCache.h,v 1.12 2007/08/09 19:55:47 wouter Exp $
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_NORMSET_CACHE
17 #define ROO_NORMSET_CACHE
18 
19 #include <vector>
20 #include <map>
21 
22 #include "Rtypes.h"
23 #include "RooNameSet.h"
24 
25 class RooAbsArg;
26 class RooArgSet;
27 
28 typedef RooArgSet* pRooArgSet ;
29 
31 protected:
32  typedef std::pair<const RooArgSet*, const RooArgSet*> Pair;
33  struct PairCmp {
34  inline bool operator()(const Pair& a, const Pair& b) const
35  {
36  if (a.first < b.first) return true;
37  if (b.first < a.first) return false;
38  return a.second < b.second;
39  }
40  };
41  typedef std::vector<Pair> PairVectType;
42  typedef std::map<Pair, ULong_t> PairIdxMapType;
43 
44 public:
45  RooNormSetCache(ULong_t max = 32);
46  virtual ~RooNormSetCache();
47 
48  void add(const RooArgSet* set1, const RooArgSet* set2 = 0);
49 
50  inline Int_t index(const RooArgSet* set1, const RooArgSet* set2 = 0,
51  const TNamed* set2RangeName = 0)
52  {
53  // Match range name first
54  if (set2RangeName != _set2RangeName) return -1;
55  const Pair pair(set1, set2);
56  PairIdxMapType::const_iterator it = _pairToIdx.lower_bound(pair);
57  if (_pairToIdx.end() != it &&
58  !PairCmp()(it->first, pair) && !PairCmp()(pair, it->first))
59  return it->second;
60  return -1;
61  }
62 
63  inline Bool_t contains(const RooArgSet* set1, const RooArgSet* set2 = 0,
64  const TNamed* set2RangeName = 0)
65  { return (index(set1,set2,set2RangeName) >= 0); }
66 
67  inline Bool_t containsSet1(const RooArgSet* set1)
68  {
69  const Pair pair(set1, (const RooArgSet*)0);
70  PairIdxMapType::const_iterator it = _pairToIdx.lower_bound(pair);
71  if (_pairToIdx.end() != it && it->first.first == set1)
72  return kTRUE;
73  return kFALSE;
74  }
75 
76  const RooArgSet* lastSet1() const { return _pairs.empty()?0:_pairs.back().first; }
77  const RooArgSet* lastSet2() const { return _pairs.empty()?0:_pairs.back().second; }
78  const RooNameSet& nameSet1() const { return _name1; }
79  const RooNameSet& nameSet2() const { return _name2; }
80 
81  Bool_t autoCache(const RooAbsArg* self, const RooArgSet* set1,
82  const RooArgSet* set2 = 0, const TNamed* set2RangeName = 0,
83  Bool_t autoRefill = kTRUE);
84 
85  void clear();
86  Int_t entries() const { return _pairs.size(); }
87 
88  void initialize(const RooNormSetCache& other) { clear(); *this = other; }
89 
90 protected:
91 
96 
100 
101  ClassDef(RooNormSetCache, 0) // Management tool for tracking sets of similar integration/normalization sets
102 };
103 
104 #endif
RooNormSetCache
Definition: RooNormSetCache.h:30
RooNormSetCache::PairIdxMapType
std::map< Pair, ULong_t > PairIdxMapType
Definition: RooNormSetCache.h:42
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooNormSetCache::initialize
void initialize(const RooNormSetCache &other)
Definition: RooNormSetCache.h:88
RooNormSetCache::PairCmp::operator()
bool operator()(const Pair &a, const Pair &b) const
Definition: RooNormSetCache.h:34
RooNormSetCache::_next
ULong_t _next
Definition: RooNormSetCache.h:95
RooNormSetCache::_pairToIdx
PairIdxMapType _pairToIdx
Definition: RooNormSetCache.h:93
RooNormSetCache::_pairs
PairVectType _pairs
Definition: RooNormSetCache.h:92
RooNameSet.h
RooNormSetCache::_name1
RooNameSet _name1
Definition: RooNormSetCache.h:97
RooNormSetCache::index
Int_t index(const RooArgSet *set1, const RooArgSet *set2=0, const TNamed *set2RangeName=0)
Definition: RooNormSetCache.h:50
RooNormSetCache::contains
Bool_t contains(const RooArgSet *set1, const RooArgSet *set2=0, const TNamed *set2RangeName=0)
Definition: RooNormSetCache.h:63
RooNormSetCache::RooNormSetCache
RooNormSetCache(ULong_t max=32)
Definition: RooNormSetCache.cxx:48
b
#define b(i)
Definition: RSha256.hxx:118
bool
RooNormSetCache::_set2RangeName
TNamed * _set2RangeName
Definition: RooNormSetCache.h:99
RooNormSetCache::containsSet1
Bool_t containsSet1(const RooArgSet *set1)
Definition: RooNormSetCache.h:67
RooNormSetCache::_max
ULong_t _max
Definition: RooNormSetCache.h:94
a
auto * a
Definition: textangle.C:12
RooNormSetCache::nameSet2
const RooNameSet & nameSet2() const
Definition: RooNormSetCache.h:79
TNamed
Definition: TNamed.h:29
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
RooNormSetCache::add
void add(const RooArgSet *set1, const RooArgSet *set2=0)
Add given pair of RooArgSet pointers to our store.
Definition: RooNormSetCache.cxx:79
RooNormSetCache::_name2
RooNameSet _name2
Definition: RooNormSetCache.h:98
RooNormSetCache::PairCmp
Definition: RooNormSetCache.h:33
ULong_t
unsigned long ULong_t
Definition: RtypesCore.h:55
RooNormSetCache::lastSet2
const RooArgSet * lastSet2() const
Definition: RooNormSetCache.h:77
RooNormSetCache::clear
void clear()
Clear contents.
Definition: RooNormSetCache.cxx:63
RooNameSet
Definition: RooNameSet.h:24
RooNormSetCache::Pair
std::pair< const RooArgSet *, const RooArgSet * > Pair
Definition: RooNormSetCache.h:32
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
RooNormSetCache::nameSet1
const RooNameSet & nameSet1() const
Definition: RooNormSetCache.h:78
RooAbsArg
Definition: RooAbsArg.h:73
pRooArgSet
RooArgSet * pRooArgSet
Definition: RooNormSetCache.h:26
RooNormSetCache::autoCache
Bool_t autoCache(const RooAbsArg *self, const RooArgSet *set1, const RooArgSet *set2=0, const TNamed *set2RangeName=0, Bool_t autoRefill=kTRUE)
If RooArgSets set1 and set2 or sets with similar contents have been seen by this cache manager before...
Definition: RooNormSetCache.cxx:113
RooNormSetCache::~RooNormSetCache
virtual ~RooNormSetCache()
Destructor.
Definition: RooNormSetCache.cxx:56
Rtypes.h
RooNormSetCache::lastSet1
const RooArgSet * lastSet1() const
Definition: RooNormSetCache.h:76
RooNormSetCache::PairVectType
std::vector< Pair > PairVectType
Definition: RooNormSetCache.h:41
RooArgSet
Definition: RooArgSet.h:28
RooNormSetCache::entries
Int_t entries() const
Definition: RooNormSetCache.h:86
int