Logo ROOT   6.16/01
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 <utility>
20#include <vector>
21#include <map>
22
23#include "Rtypes.h"
24#include "RooNameSet.h"
25
26class RooAbsArg;
27class RooArgSet;
28
30
32protected:
33 typedef std::pair<const RooArgSet*, const RooArgSet*> Pair;
34 struct PairCmp {
35 inline bool operator()(const Pair& a, const Pair& b) const
36 {
37 if (a.first < b.first) return true;
38 if (b.first < a.first) return false;
39 return a.second < b.second;
40 }
41 };
42 typedef std::vector<Pair> PairVectType;
43 typedef std::map<Pair, ULong_t> PairIdxMapType;
44
45public:
46 RooNormSetCache(ULong_t max = 32);
47 virtual ~RooNormSetCache();
48
49 void add(const RooArgSet* set1, const RooArgSet* set2 = 0);
50
51 inline Int_t index(const RooArgSet* set1, const RooArgSet* set2 = 0,
52 const TNamed* set2RangeName = 0)
53 {
54 // Match range name first
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))
60 return it->second;
61 return -1;
62 }
63
64 inline Bool_t contains(const RooArgSet* set1, const RooArgSet* set2 = 0,
65 const TNamed* set2RangeName = 0)
66 { return (index(set1,set2,set2RangeName) >= 0); }
67
68 inline Bool_t containsSet1(const RooArgSet* set1)
69 {
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)
73 return kTRUE;
74 return kFALSE;
75 }
76
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; }
81
82 Bool_t autoCache(const RooAbsArg* self, const RooArgSet* set1,
83 const RooArgSet* set2 = 0, const TNamed* set2RangeName = 0,
84 Bool_t autoRefill = kTRUE);
85
86 void clear();
87 Int_t entries() const { return _pairs.size(); }
88
89 void initialize(const RooNormSetCache& other) { clear(); *this = other; }
90
91protected:
92
97
101
102 ClassDef(RooNormSetCache, 0) // Management tool for tracking sets of similar integration/normalization sets
103};
104
105#endif
#define b(i)
Definition: RSha256.hxx:100
RooArgSet * pRooArgSet
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
unsigned long ULong_t
Definition: RtypesCore.h:51
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassDef(name, id)
Definition: Rtypes.h:324
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
RooNameSet is a utility class that stores the names the objects in a RooArget.
Definition: RooNameSet.h:24
Class RooNormSet cache manage the bookkeeping of multiple instances of sets of integration and normal...
const RooArgSet * lastSet1() const
RooNameSet _name1
Int_t index(const RooArgSet *set1, const RooArgSet *set2=0, const TNamed *set2RangeName=0)
void clear()
Clear contents.
virtual ~RooNormSetCache()
Destructor.
std::pair< const RooArgSet *, const RooArgSet * > Pair
TNamed * _set2RangeName
RooNameSet _name2
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...
PairIdxMapType _pairToIdx
RooNormSetCache(ULong_t max=32)
void initialize(const RooNormSetCache &other)
Bool_t containsSet1(const RooArgSet *set1)
Int_t entries() const
void add(const RooArgSet *set1, const RooArgSet *set2=0)
Add given pair of RooArgSet pointers to our store.
Bool_t contains(const RooArgSet *set1, const RooArgSet *set2=0, const TNamed *set2RangeName=0)
const RooNameSet & nameSet1() const
PairVectType _pairs
const RooArgSet * lastSet2() const
std::map< Pair, ULong_t > PairIdxMapType
std::vector< Pair > PairVectType
const RooNameSet & nameSet2() const
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
bool operator()(const Pair &a, const Pair &b) const
auto * a
Definition: textangle.C:12