18 return a.name() < b.name();
24 return a.name() == b.name();
45 std::string::size_type split = 0, split2 = 0;
46 while ((split = systematics.find (
"-", split2)) != std::string::npos) {
47 m_sysVariations.insert (systematics.substr (split2, split - split2));
66 (
const std::vector<SystematicVariation>&
systematics)
77 (
const std::initializer_list<SystematicVariation>&
systematics)
151 filteredSysts.
insert(sys);
153 return filteredSysts;
160 std::set<std::string> baseNames;
162 baseNames.insert(sys.basename());
175 if(!sysMatched) sysMatched = &sys;
177 std::string
error =
"SystematicSet::getSystematicByBaseName ERROR: ";
178 error +=
"Multiple matches for requested basename ";
182 throw std::runtime_error(
error);
186 if(sysMatched)
return *sysMatched;
191 float SystematicSet ::
192 getParameterByBaseName(
const std::string&
basename)
const
199 std::pair<unsigned,float> SystematicSet ::
200 getToyVariationByBaseName (
const std::string&
basename)
const
204 return std::make_pair (0, 0);
205 return var.getToyVariation();
215 using namespace msgSystematics;
221 std::map<std::string,SystematicVariation> requestedMap;
224 std::set<SystematicVariation> inconsistentList;
227 for (
auto& sys : systConfig)
229 std::string
basename = sys.basename();
230 auto iter = requestedMap.find (
basename);
231 if (iter != requestedMap.end())
233 ANA_MSG_ERROR (
"inconsistent systematic variations requested: " << sys <<
" and " << iter->second);
234 return StatusCode::FAILURE;
236 requestedMap.insert (std::make_pair (
basename, sys));
240 for (
auto& sys : affectingSysts)
242 std::string
basename = sys.basename();
243 auto iter = requestedMap.find (
basename);
244 if (iter != requestedMap.end())
246 if (iter->second == sys ||
247 sys.ensembleContains (iter->second))
249 result.insert (iter->second);
253 inconsistentList.insert (iter->second);
261 for (
auto& sys : inconsistentList)
265 ANA_MSG_ERROR (
"unsupported systematic variation " << sys <<
" requested for systematic " << sys.basename());
266 return StatusCode::FAILURE;
271 result.swap (filteredSysts);
272 return StatusCode::SUCCESS;
300 std::string joinedName;
302 if (!joinedName.empty()) {
305 joinedName += sys.name();
314 static const std::hash<std::string> hashFunction;
315 return hashFunction(
name());
321 return sysSet.
hash();
static const std::vector< std::string > systematics
bool operator<(const CP::SystematicSet &a, const CP::SystematicSet &b)
bool operator==(const CP::SystematicSet &a, const CP::SystematicSet &b)
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
std::size_t hash() const
returns: hash value for the joined string.
void clear()
description: clear the set
MATCHTYPE
description: match systematic or continuous version
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
SystematicSet()
construct an empty 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
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::string basename() const
description: the base name, i.e.
void reset()
Reset the value to invalid.
SystematicSet()
construct an empty set
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Select isolated Photons, Electrons and Muons.
std::size_t hash_value(const SystematicSet &)
Hash function specifically for boost::hash.
std::string basename(std::string name)