00001 #ifndef PATINTERFACES_SYSTEMATIC_SET_H
00002 #define PATINTERFACES_SYSTEMATIC_SET_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <PATInterfaces/Global.h>
00011
00012 #include <set>
00013 #include <vector>
00014 #include <string>
00015 #include <functional>
00016
00017 #include <PATInterfaces/SystematicCode.h>
00018 #include <PATInterfaces/SystematicVariation.h>
00019
00020
00021 namespace CP
00022 {
00023
00024
00025 using ::operator<;
00026 using ::operator==;
00027
00029 class SystematicSet
00030 {
00031
00032 public:
00033
00034
00036 SystematicSet();
00038 SystematicSet(const std::string& systematics);
00040 SystematicSet(const std::vector<std::string>& systematics);
00042 SystematicSet(const std::vector<SystematicVariation>& systematics);
00043
00045 #ifndef __CINT__
00046 #if __cplusplus >= 201100
00047 SystematicSet(const std::initializer_list<SystematicVariation>& systematics);
00048 #endif
00049 #endif
00050
00051 public:
00052
00053
00054 typedef std::set<SystematicVariation>::iterator iterator;
00055 typedef std::set<SystematicVariation>::const_iterator const_iterator;
00056
00058 const_iterator begin() const
00059 { return m_sysVariations.begin(); }
00060
00062 const_iterator end() const
00063 { return m_sysVariations.end(); }
00064
00066 iterator find(const SystematicVariation& sys) const
00067 { return m_sysVariations.find(sys); }
00068
00070 bool empty() const
00071 { return m_sysVariations.empty(); }
00072
00074 size_t size() const
00075 { return m_sysVariations.size(); }
00076
00078 void insert(const SystematicVariation& systematic);
00079
00081 void insert(const SystematicSet& systematics);
00082
00084 void swap(SystematicSet& otherSet);
00085
00087 void clear() { return m_sysVariations.clear(); }
00088
00089 public:
00090
00091
00093 enum MATCHTYPE { FULL, FULLORCONTINUOUS };
00094 bool matchSystematic(const SystematicVariation& systematic,
00095 MATCHTYPE type=FULL) const;
00096
00099 SystematicSet filterByBaseName(const std::string& basename) const;
00100
00102 std::set<std::string> getBaseNames() const;
00103
00105 SystematicVariation
00106 getSystematicByBaseName(const std::string& basename) const;
00107
00109 float
00110 getParameterByBaseName(const std::string& basename) const;
00111
00123 public:
00124 std::pair<unsigned,float>
00125 getToyVariationByBaseName (const std::string& basename) const;
00126
00136 static SystematicCode
00137 filterForAffectingSystematics (const SystematicSet& systConfig,
00138 const SystematicSet& affectingSystematics,
00139 SystematicSet& filteredSystematics);
00140
00141 public:
00142
00143
00146 std::string name() const;
00147
00150 std::size_t hash() const;
00151
00152 private:
00153
00154
00156 std::string joinNames() const;
00157
00159 std::size_t computeHash() const;
00160
00161 private:
00162
00163
00165 std::set<SystematicVariation> m_sysVariations;
00166
00168 mutable std::string m_joinedName;
00169 mutable bool m_nameIsCached;
00170
00173 mutable std::size_t m_hash;
00174 mutable bool m_hashIsCached;
00175
00179
00180
00181 };
00182
00183
00185 struct SystematicSetHash
00186 : public std::unary_function<SystematicSet, std::size_t>
00187 {
00188 std::size_t operator()(const SystematicSet&);
00189 };
00190
00192 std::size_t hash_value(const SystematicSet&);
00193
00195
00197
00198
00199 }
00200
00201 namespace std
00202 {
00204 #if __cplusplus >= 201100
00205 template<> struct hash<CP::SystematicSet>
00206 {
00207 std::size_t operator()(const CP::SystematicSet& sysSet) const
00208 { return sysSet.hash(); }
00209 };
00210 #endif
00211 }
00212
00213 #endif