Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
25class RooAbsArg;
26class RooArgSet;
27
29
31protected:
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
44public:
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
90protected:
91
96
100
101 ClassDef(RooNormSetCache, 0) // Management tool for tracking sets of similar integration/normalization sets
102};
103
104#endif
#define b(i)
Definition RSha256.hxx:100
#define a(i)
Definition RSha256.hxx:99
RooArgSet * pRooArgSet
const Bool_t kFALSE
Definition RtypesCore.h:92
unsigned long ULong_t
Definition RtypesCore.h:55
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassDef(name, id)
Definition Rtypes.h:325
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition RooAbsArg.h:72
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:29
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
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
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
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