ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 <utility>
20 #include <vector>
21 #include <map>
22 
23 #include "Rtypes.h"
24 #include "Riosfwd.h"
25 #include "RooNameSet.h"
26 
27 class RooAbsArg;
28 class RooArgSet;
29 
30 typedef RooArgSet* pRooArgSet ;
31 
33 protected:
34  typedef std::pair<const RooArgSet*, const RooArgSet*> Pair;
35  struct PairCmp {
36  inline bool operator()(const Pair& a, const Pair& b) const
37  {
38  if (a.first < b.first) return true;
39  if (b.first < a.first) return false;
40  return a.second < b.second;
41  }
42  };
43  typedef std::vector<Pair> PairVectType;
44  typedef std::map<Pair, ULong_t> PairIdxMapType;
45 
46 public:
48  virtual ~RooNormSetCache();
49 
50  void add(const RooArgSet* set1, const RooArgSet* set2 = 0);
51 
52  inline Int_t index(const RooArgSet* set1, const RooArgSet* set2 = 0,
53  const TNamed* set2RangeName = 0)
54  {
55  // Match range name first
56  if (set2RangeName != _set2RangeName) return -1;
57  const Pair pair(set1, set2);
58  PairIdxMapType::const_iterator it = _pairToIdx.lower_bound(pair);
59  if (_pairToIdx.end() != it &&
60  !PairCmp()(it->first, pair) && !PairCmp()(pair, it->first))
61  return it->second;
62  return -1;
63  }
64 
65  inline Bool_t contains(const RooArgSet* set1, const RooArgSet* set2 = 0,
66  const TNamed* set2RangeName = 0)
67  { return (index(set1,set2,set2RangeName) >= 0); }
68 
69  inline Bool_t containsSet1(const RooArgSet* set1)
70  {
71  const Pair pair(set1, (const RooArgSet*)0);
72  PairIdxMapType::const_iterator it = _pairToIdx.lower_bound(pair);
73  if (_pairToIdx.end() != it && it->first.first == set1)
74  return kTRUE;
75  return kFALSE;
76  }
77 
78  const RooArgSet* lastSet1() const { return _pairs.empty()?0:_pairs.back().first; }
79  const RooArgSet* lastSet2() const { return _pairs.empty()?0:_pairs.back().second; }
80  const RooNameSet& nameSet1() const { return _name1; }
81  const RooNameSet& nameSet2() const { return _name2; }
82 
83  Bool_t autoCache(const RooAbsArg* self, const RooArgSet* set1,
84  const RooArgSet* set2 = 0, const TNamed* set2RangeName = 0,
85  Bool_t autoRefill = kTRUE);
86 
87  void clear();
88  Int_t entries() const { return _pairs.size(); }
89 
90  void initialize(const RooNormSetCache& other) { clear(); *this = other; }
91 
92 protected:
93 
98 
102 
103  ClassDef(RooNormSetCache, 0) // Management tool for tracking sets of similar integration/normalization sets
104 };
105 
106 #endif
const RooArgSet * lastSet2() const
Int_t index(const RooArgSet *set1, const RooArgSet *set2=0, const TNamed *set2RangeName=0)
void initialize(const RooNormSetCache &other)
Bool_t contains(const RooArgSet *set1, const RooArgSet *set2=0, const TNamed *set2RangeName=0)
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TArc * a
Definition: textangle.C:12
const Bool_t kFALSE
Definition: Rtypes.h:92
Class RooNormSet cache manage the bookkeeping of multiple instances of sets of integration and normal...
const RooNameSet & nameSet2() const
PairIdxMapType _pairToIdx
const RooNameSet & nameSet1() const
#define ClassDef(name, id)
Definition: Rtypes.h:254
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
void add(const RooArgSet *set1, const RooArgSet *set2=0)
Add given pair of RooArgSet pointers to our store.
const RooArgSet * lastSet1() const
RooNameSet is a utility class that stores the names the objects in a RooArget.
Definition: RooNameSet.h:24
TNamed * _set2RangeName
Bool_t containsSet1(const RooArgSet *set1)
Int_t entries() const
RooNameSet _name1
RooNormSetCache(ULong_t max=32)
std::pair< const RooArgSet *, const RooArgSet * > Pair
unsigned long ULong_t
Definition: RtypesCore.h:51
bool operator()(const Pair &a, const Pair &b) const
PairVectType _pairs
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
Definition: vector.h:440
RooArgSet * pRooArgSet
void clear()
Clear contents.
std::vector< Pair > PairVectType
std::map< Pair, ULong_t > PairIdxMapType
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
const Bool_t kTRUE
Definition: Rtypes.h:91
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...
virtual ~RooNormSetCache()
Destructor.