ATLAS Offline Software
Loading...
Searching...
No Matches
SystematicSet.h
Go to the documentation of this file.
1#ifndef PATINTERFACES_SYSTEMATIC_SET_H
2#define PATINTERFACES_SYSTEMATIC_SET_H
3
4// Author: Steve Farrell (steven.farrell@cern.ch)
5
6// This module implements a class that represents a set of systematics
7// in a way to facilitate efficient lookups by systematic tools.
8// A hash value is cached using the joined string name and boost::hash<string>.
9
11
12#include <set>
13#include <vector>
14#include <string>
15#include <functional>
16
20
21
22namespace CP
23{
24
25 // Pulling global ops into CP. Not ideal.
26 using ::operator<;
27 using ::operator==;
28
31 {
32
33 public:
34 // Public constructors
35
39 SystematicSet(const std::string& systematics);
41 SystematicSet(const std::vector<std::string>& systematics);
43 SystematicSet(const std::vector<SystematicVariation>& systematics);
44
46 SystematicSet(const std::initializer_list<SystematicVariation>& systematics);
47
48 public:
49 // Public set-interface methods
50
51 typedef std::set<SystematicVariation>::iterator iterator;
52 typedef std::set<SystematicVariation>::const_iterator const_iterator;
53
56 { return m_sysVariations.begin(); }
57
60 { return m_sysVariations.end(); }
61
64 { return m_sysVariations.find(sys); }
65
67 bool empty() const
68 { return m_sysVariations.empty(); }
69
71 size_t size() const
72 { return m_sysVariations.size(); }
73
75 void insert(const SystematicVariation& systematic);
76
78 void insert(const SystematicSet& systematics);
79
81 void swap(SystematicSet& otherSet);
82
84 void clear();
85
86 public:
87 // Specialized search and filtering methods
88
91 bool matchSystematic(const SystematicVariation& systematic,
92 MATCHTYPE type=FULL) const;
93
96 SystematicSet filterByBaseName(const std::string& basename) const;
97
99 std::set<std::string> getBaseNames() const;
100
103 getSystematicByBaseName(const std::string& basename) const;
104
106 float
107 getParameterByBaseName(const std::string& basename) const;
108
120 public:
121 std::pair<unsigned,float>
122 getToyVariationByBaseName (const std::string& basename) const;
123
133 static StatusCode
135 const SystematicSet& affectingSystematics,
136 SystematicSet& filteredSystematics);
137
138 public:
139 // Public name and hash methods
140
143 std::string name() const;
144
147 std::size_t hash() const;
148
149 private:
150 // Private modification methods
151
153 std::string joinNames() const;
154
156 std::size_t computeHash() const;
157
158 private:
159 // Private members
160
162 std::set<SystematicVariation> m_sysVariations;
163
166
170 };
171
172
175 {
176 std::size_t operator()(const SystematicSet& sysSet) const {
177 return sysSet.hash();}
178 };
179
181 std::size_t hash_value(const SystematicSet&);
182
184 //bool operator < (const SystematicSet& a, const SystematicSet& b);
186 //bool operator == (const SystematicSet& a, const SystematicSet& b);
187
188}
189
190namespace std
191{
193 template<> struct hash<CP::SystematicSet>
194 {
195 std::size_t operator()(const CP::SystematicSet& sysSet) const
196 { return sysSet.hash(); }
197 };
198}
199
200#endif
Cached value with atomic update.
static const std::vector< std::string > systematics
Class to wrap a set of SystematicVariations.
std::string name() const
returns: the systematics joined into a single string.
std::set< SystematicVariation > m_sysVariations
description: the set of systematics encapsulated in this class
bool matchSystematic(const SystematicVariation &systematic, MATCHTYPE type=FULL) const
bool empty() const
returns: whether the set is empty
std::size_t hash() const
returns: hash value for the joined string.
const_iterator end() const
description: const iterator to the end of the set
void clear()
description: clear the set
MATCHTYPE
description: match systematic or continuous version
std::pair< unsigned, float > getToyVariationByBaseName(const std::string &basename) const
the toy variation for the given basename
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
float getParameterByBaseName(const std::string &basename) const
returns: the parameter value for the given basename
SystematicSet()
construct an empty set
std::set< SystematicVariation >::const_iterator const_iterator
const_iterator begin() const
description: const iterator to the beginning of the set
iterator find(const SystematicVariation &sys) const
description: find an element in the set
CxxUtils::CachedValue< std::string > m_joinedName
description: cache the joined string, useful for hash
void swap(SystematicSet &otherSet)
description: swap elements of a set
size_t size() const
returns: size of the set
SystematicSet filterByBaseName(const std::string &basename) const
description: get the subset of systematics matching basename Should this return a StatusCode instead?
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...
std::string joinNames() const
description: join systematic names into single string
std::size_t computeHash() const
description: compute and store the hash value
std::set< std::string > getBaseNames() const
description: get the set of base systematic names from this set
SystematicVariation getSystematicByBaseName(const std::string &basename) const
description: get the first systematic matching basename
CxxUtils::CachedValue< std::size_t > m_hash
description: cached hash value for quick retrieval in unordered containers
std::set< SystematicVariation >::iterator iterator
Cached value with atomic update.
Definition CachedValue.h:55
Class to wrap a set of SystematicVariations.
Select isolated Photons, Electrons and Muons.
std::size_t hash_value(const SystematicSet &)
Hash function specifically for boost::hash.
STL namespace.
SystematicSet hash function for general use.
std::size_t operator()(const SystematicSet &sysSet) const
std::size_t operator()(const CP::SystematicSet &sysSet) const
std::string basename(std::string name)
Definition utils.cxx:207