 |
ATLAS Offline Software
|
Go to the documentation of this file.
8 #ifndef PAT_INTERFACES__SYSTEMATICS_CACHE_H
9 #define PAT_INTERFACES__SYSTEMATICS_CACHE_H
18 #include <tbb/concurrent_unordered_map.h>
83 template<
typename CalibData>
161 m_calc = std::move (val_calc);
168 template<
typename CalibData>
177 template<
typename CalibData>
187 template<
typename CalibData>
192 auto iter = m_cache.find (
sys);
195 result = iter->second.get();
196 return StatusCode::SUCCESS;
210 iter = m_cache.find (
sys);
211 if (iter != m_cache.end())
213 result = iter->second.get();
214 return StatusCode::SUCCESS;
223 std::shared_ptr<const CalibData> mycalib;
226 auto iter = m_cache.find (mysys);
227 if (iter != m_cache.end())
228 mycalib = iter->second;
234 auto value = std::make_shared<CalibData> ();
238 auto emplace_result = m_cache.emplace (mysys,
value);
239 mycalib = emplace_result.first->second;
246 m_cache.emplace (
sys, mycalib);
248 return StatusCode::SUCCESS;
253 template<
typename CalibData>
257 auto emplace_result = m_cache.emplace (
sys, std::make_shared<CalibData> (std::move (
value)));
258 if (emplace_result.second ==
false)
260 ANA_MSG_ERROR (
"failed to add systematic, already present: " <<
sys.name());
261 return StatusCode::FAILURE;
264 for (
const auto&
var :
sys)
267 return StatusCode::SUCCESS;
272 template<
typename CalibData>
277 sys.insert (variation);
base class to forward messages to another class
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...
SystematicSet hash function for general use.
Class to wrap a set of SystematicVariations.
bool const RAWDATA *ch2 const
Select isolated Photons, Electrons and Muons.
MsgStream & msg() const
The standard message stream.
bool isAffectedBySystematic(const SystematicVariation &systematic) const
whether we are affected by the given systematic variation
::StatusCode StatusCode
StatusCode definition for legacy code.
std::function< StatusCode(const CP::SystematicSet &sys, CalibData &result)> m_calc
the function to calculate the calibration data for a given systematics
const_iterator end() const
description: const iterator to the end of the set
AsgMessagingForward(T *owner)
forwarding constructor
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
std::mutex m_calcMutex
a mutex to protext against concurrent execution of m_calc
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)
iterator find(const SystematicVariation &sys) const
description: find an element in the set
helper class to cache systematics varied calibration constants inside a ISystematicsTool or IRentrant...
CP::SystematicSet m_affectingSystematics
the list of affecting systematics
const CP::SystematicSet & affectingSystematics() const noexcept
the list of affecting systematics
StatusCode add(const CP::SystematicSet &sys, CalibData value)
add an individual systematic variation
Define macros for attributes used to control the static checker.
StatusCode get(const CP::SystematicSet &sys, const CalibData *&result) const
get the pointer to the cached calibration data for the given systematic, calculating it if necessary
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...