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//
16
17//
18// method implementations
19//
20
21namespace CP
22{
23
24 StatusCode EventDecoratorAlg ::
25 initialize ()
26 {
27 ANA_CHECK(m_eventInfoKey.initialize());
28
29 for (const auto& [name, value] : m_uint32Decorations)
30 {
31 ANA_MSG_INFO ("Adding uint32_t decoration " << name << " with value " << value << " to EventInfo");
33 ANA_CHECK(decorKey.initialize());
34#ifndef XAOD_STANDALONE
35 // This adds an output dependency for MT scheduling. I have to
36 // manually add the dependency, since the dependency is only
37 // auto-declared if the key is also a property, which doesn't seem
38 // ideal here.
39 addDependency(decorKey.fullKey(), decorKey.mode());
40#endif
41 //probably safer to use decorKey by value here, despite coverity warning
42 //coverity[PASS_BY_VALUE]
43 m_decFunctions.push_back([decorKey, value](const xAOD::EventInfo& ei) {
45 dec(ei) = value;
46 });
47 }
48
49 return StatusCode::SUCCESS;
50 }
51
52
53
54 StatusCode EventDecoratorAlg ::
55 execute (const EventContext& ctx) const
56 {
58 if (!eventInfo.isValid())
59 {
60 ANA_MSG_ERROR("Failed to retrieve EventInfo");
61 return StatusCode::FAILURE;
62 }
63
64 for (const auto& decFunc : m_decFunctions)
65 {
66 decFunc(*eventInfo);
67 }
68
69 return StatusCode::SUCCESS;
70 }
71}
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
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.