ATLAS Offline Software
Loading...
Searching...
No Matches
EventDecoratorAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8//
9// includes
10//
17
18//
19// method implementations
20//
21
22namespace CP
23{
24
25 StatusCode EventDecoratorAlg ::
26 initialize ()
27 {
28 ANA_CHECK(m_eventInfoKey.initialize());
29
30 for (const auto& [name, value] : m_uint32Decorations)
31 {
32 ANA_MSG_INFO ("Adding uint32_t decoration " << name << " with value " << value << " to EventInfo");
34 ANA_CHECK(decorKey.initialize());
35#ifndef XAOD_STANDALONE
36 // This adds an output dependency for MT scheduling. I have to
37 // manually add the dependency, since the dependency is only
38 // auto-declared if the key is also a property, which doesn't seem
39 // ideal here.
40 addDependency(decorKey.fullKey(), decorKey.mode());
41#endif
42 //probably safer to use decorKey by value here, despite coverity warning
43 //coverity[PASS_BY_VALUE]
44 m_decFunctions.push_back([decorKey, value](const xAOD::EventInfo& ei) {
46 dec(ei) = value;
47 });
48 }
49
50 return StatusCode::SUCCESS;
51 }
52
53
54
55 StatusCode EventDecoratorAlg ::
56 execute (const EventContext& ctx) const
57 {
59 if (!eventInfo.isValid())
60 {
61 ANA_MSG_ERROR("Failed to retrieve EventInfo");
62 return StatusCode::FAILURE;
63 }
64
65 for (const auto& decFunc : m_decFunctions)
66 {
67 decFunc(*eventInfo);
68 }
69
70 return StatusCode::SUCCESS;
71 }
72}
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
Manage lookup of vectors of auxiliary data.
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
Define macros for attributes used to control the static checker.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
the name of the event info object
std::vector< std::function< void(const xAOD::EventInfo &)> > m_decFunctions
the functions to add decorations
Gaudi::Property< std::map< std::string, uint32_t > > m_uint32Decorations
the uint32_t decorations to add
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Handle class for adding a decoration to an object.
Select isolated Photons, Electrons and Muons.
EventInfo_v1 EventInfo
Definition of the latest event info version.