2 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
5 /// @author Nils Krumnack
12 #include <AsgMessaging/MessageCheck.h>
13 #include <AsgMessaging/StatusCode.h>
14 #include <SystematicsHandles/Helpers.h>
17 // method implementations
22 template<typename T> template<typename T2> SysReadHandleArray<T> ::
23 SysReadHandleArray (T2 *owner, const std::string& propertyName,
24 const std::string& propertyDescription)
25 : AsgMessagingForward (owner)
26 , m_propertyName (propertyName)
27 , m_evtStoreGetter ([owner] () {return &*owner->evtStore();})
29 owner->declareProperty (propertyName, m_inputName, propertyDescription);
30 owner->declareProperty (propertyName + "Regex", m_affectingRegex, "affecting systematics for " + propertyDescription);
35 template<typename T> StatusCode SysReadHandleArray<T> ::
38 assert (m_isInitialized == false);
39 if (m_inputName.size() != m_affectingRegex.size())
41 ANA_MSG_ERROR ("array sizes for property " << m_propertyName << " and " << m_propertyName << "Regex do not match");
42 return StatusCode::FAILURE;
44 m_isInitialized = true;
45 return StatusCode::SUCCESS;
50 template<typename T> std::size_t SysReadHandleArray<T> ::
51 size () const noexcept
53 assert (m_isInitialized);
54 return m_inputName.size();
59 template<typename T> const std::string& SysReadHandleArray<T> ::
60 getName (const CP::SystematicSet& sys,
61 std::size_t index) const
63 assert (m_isInitialized);
64 assert (index < size());
65 auto cache = m_inputNameCache.find (std::make_pair (sys, index));
66 if (cache == m_inputNameCache.end())
68 std::string newName = makeSystematicsName
69 (m_inputName[index], m_affectingRegex[index], sys);
70 ANA_MSG_DEBUG ("SysReadHandleArray: " << newName << " (" << sys.name() << ")");
71 m_inputNameCache.insert (std::make_pair (std::make_pair (sys, index), newName));
72 cache = m_inputNameCache.find (std::make_pair (sys, index));
73 assert (cache != m_inputNameCache.end());
75 // retrieving this here, just so it exists
77 m_evtStore = m_evtStoreGetter();
84 template<typename T> ::StatusCode SysReadHandleArray<T> ::
85 retrieve (const T*& object, const CP::SystematicSet& sys,
86 std::size_t index) const
88 assert (m_isInitialized);
89 assert (index < size());
90 const std::string& name = getName (sys, index);
92 return m_evtStore->retrieve (object, name);
97 template<typename T> std::string SysReadHandleArray<T> ::
98 getInputAffecting () const
100 assert (m_isInitialized);
102 for (const std::string& regex : m_affectingRegex)