8#ifndef PAT_INTERFACES__SYSTEMATICS_CACHE_H
9#define PAT_INTERFACES__SYSTEMATICS_CACHE_H
17#include <tbb/concurrent_unordered_map.h>
82 template<
typename CalibData>
148 template<typename
CalibData> template<typename T2>
160 m_calc = std::move (val_calc);
167 template<
typename CalibData>
176 template<
typename CalibData>
186 template<
typename CalibData>
191 auto iter = m_cache.find (sys);
192 if (iter != m_cache.end()) [[
likely]]
194 result = iter->second.get();
195 return StatusCode::SUCCESS;
209 iter = m_cache.find (sys);
210 if (iter != m_cache.end())
212 result = iter->second.get();
213 return StatusCode::SUCCESS;
222 std::shared_ptr<const CalibData> mycalib;
225 auto iter = m_cache.find (mysys);
226 if (iter != m_cache.end())
227 mycalib = iter->second;
233 auto value = std::make_shared<CalibData> ();
237 auto emplace_result = m_cache.emplace (mysys, value);
238 mycalib = emplace_result.first->second;
245 m_cache.emplace (sys, mycalib);
246 result = mycalib.get();
247 return StatusCode::SUCCESS;
252 template<
typename CalibData>
256 auto emplace_result = m_cache.emplace (sys, std::make_shared<CalibData> (std::move (value)));
257 if (emplace_result.second ==
false)
259 ANA_MSG_ERROR (
"failed to add systematic, already present: " << sys.name());
260 return StatusCode::FAILURE;
263 for (
const auto& var : sys)
266 return StatusCode::SUCCESS;
271 template<
typename CalibData>
276 sys.insert (variation);
277 return add (sys, std::move (value));
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
Define macros for attributes used to control the static checker.
Class to wrap a set of SystematicVariations.
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...
bool isAffectedBySystematic(const SystematicVariation &systematic) const
StatusCode get(const CP::SystematicSet &sys, const BTaggingEfficiencyJsonTool::sysData *&result) const
CP::SystematicSet m_affectingSystematics
the list of affecting systematics
StatusCode add(const CP::SystematicSet &sys, BTaggingEfficiencyJsonTool::sysData value)
void initialize(CP::SystematicSet val_affectingSystematics, std::function< StatusCode(const CP::SystematicSet &sys, CalibData &result)> val_calc) noexcept
initialize with the list of affecting systematics and a function to calculate the calibration data fo...
std::function< StatusCode(const CP::SystematicSet &sys, CalibData &result)> m_calc
the function to calculate the calibration data for a given systematics
const CP::SystematicSet & affectingSystematics() const noexcept
the list of affecting systematics
tbb::concurrent_unordered_map< CP::SystematicSet, std::shared_ptr< const CalibData >, SystematicSetHash > m_cache ATLAS_THREAD_SAFE
the cache of previously calculated calibration data
SystematicsCache(T2 *val_parent)
std::mutex m_calcMutex
a mutex to protext against concurrent execution of m_calc
base class to forward messages to another class
MsgStream & msg() const
The standard message stream.
AsgMessagingForward(T *owner)
forwarding constructor
Select isolated Photons, Electrons and Muons.
SystematicSet hash function for general use.