ATLAS Offline Software
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 
10 #include <PATInterfaces/Global.h>
11 
12 #include <set>
13 #include <vector>
14 #include <string>
15 #include <functional>
16 
19 #include "CxxUtils/CachedValue.h"
20 
21 
22 namespace 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 
37  SystematicSet();
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 
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
134  filterForAffectingSystematics (const SystematicSet& systConfig,
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 
190 namespace 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
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
CP::SystematicSet::getToyVariationByBaseName
std::pair< unsigned, float > getToyVariationByBaseName(const std::string &basename) const
the toy variation for the given basename
Definition: SystematicSet.cxx:201
CP::SystematicSet::swap
void swap(SystematicSet &otherSet)
description: swap elements of a set
Definition: SystematicSet.cxx:108
CP::SystematicSet::size
size_t size() const
returns: size of the set
Definition: SystematicSet.h:71
std::hash< CP::SystematicSet >::operator()
std::size_t operator()(const CP::SystematicSet &sysSet) const
Definition: SystematicSet.h:195
CP::SystematicSet::joinNames
std::string joinNames() const
description: join systematic names into single string
Definition: SystematicSet.cxx:299
CP::SystematicSet::computeHash
std::size_t computeHash() const
description: compute and store the hash value
Definition: SystematicSet.cxx:313
CP::SystematicSet::empty
bool empty() const
returns: whether the set is empty
Definition: SystematicSet.h:67
CP::SystematicSet::const_iterator
std::set< SystematicVariation >::const_iterator const_iterator
Definition: SystematicSet.h:52
CP::SystematicSetHash
SystematicSet hash function for general use.
Definition: SystematicSet.h:175
CP::SystematicSet::m_hash
CxxUtils::CachedValue< std::size_t > m_hash
description: cached hash value for quick retrieval in unordered containers
Definition: SystematicSet.h:169
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
CP::SystematicSetHash::operator()
std::size_t operator()(const SystematicSet &sysSet) const
Definition: SystematicSet.h:176
CP::SystematicSet::name
std::string name() const
returns: the systematics joined into a single string.
Definition: SystematicSet.cxx:278
CP::SystematicSet::filterByBaseName
SystematicSet filterByBaseName(const std::string &basename) const
description: get the subset of systematics matching basename Should this return a StatusCode instead?
Definition: SystematicSet.cxx:147
CP::SystematicVariation
Definition: SystematicVariation.h:47
CP::SystematicSet::MATCHTYPE
MATCHTYPE
description: match systematic or continuous version
Definition: SystematicSet.h:90
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
CP::SystematicSet::getParameterByBaseName
float getParameterByBaseName(const std::string &basename) const
returns: the parameter value for the given basename
Definition: SystematicSet.cxx:193
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
CP::SystematicSet::FULL
@ FULL
Definition: SystematicSet.h:90
CP::SystematicSet::m_sysVariations
std::set< SystematicVariation > m_sysVariations
description: the set of systematics encapsulated in this class
Definition: SystematicSet.h:162
CP::SystematicSet::hash
std::size_t hash() const
returns: hash value for the joined string.
Definition: SystematicSet.cxx:289
CP::SystematicSet::getSystematicByBaseName
SystematicVariation getSystematicByBaseName(const std::string &basename) const
description: get the first systematic matching basename
Definition: SystematicSet.cxx:171
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Global.h
CxxUtils::CachedValue< std::string >
CP::SystematicSet::FULLORCONTINUOUS
@ FULLORCONTINUOUS
Definition: SystematicSet.h:90
CP::SystematicSet::iterator
std::set< SystematicVariation >::iterator iterator
Definition: SystematicSet.h:51
CP::SystematicSet::end
const_iterator end() const
description: const iterator to the end of the set
Definition: SystematicSet.h:59
CP::SystematicSet::getBaseNames
std::set< std::string > getBaseNames() const
description: get the set of base systematic names from this set
Definition: SystematicSet.cxx:159
StatusCode.h
CP::SystematicSet::m_joinedName
CxxUtils::CachedValue< std::string > m_joinedName
description: cache the joined string, useful for hash
Definition: SystematicSet.h:165
CheckAppliedSFs.systematics
def systematics
Definition: CheckAppliedSFs.py:231
CachedValue.h
Cached value with atomic update.
CP::SystematicSet::insert
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
Definition: SystematicSet.cxx:88
CP::SystematicSet::clear
void clear()
description: clear the set
Definition: SystematicSet.cxx:119
CP::SystematicSet::find
iterator find(const SystematicVariation &sys) const
description: find an element in the set
Definition: SystematicSet.h:63
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
CP::SystematicSet::SystematicSet
SystematicSet()
construct an empty set
Definition: SystematicSet.cxx:37
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CP::SystematicSet::begin
const_iterator begin() const
description: const iterator to the beginning of the set
Definition: SystematicSet.h:55
CP::SystematicSet::matchSystematic
bool matchSystematic(const SystematicVariation &systematic, MATCHTYPE type=FULL) const
Definition: SystematicSet.cxx:128
SystematicVariation.h
CP::SystematicSet::filterForAffectingSystematics
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...
Definition: SystematicSet.cxx:213
CP::hash_value
std::size_t hash_value(const SystematicSet &)
Hash function specifically for boost::hash.
Definition: SystematicSet.cxx:321
beamspotman.basename
basename
Definition: beamspotman.py:640