ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
AsgAnalysisAlgorithms
Root
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
//
11
#include "
AsgAnalysisAlgorithms/EventDecoratorAlg.h
"
12
#include "
AsgDataHandles/ReadHandle.h
"
13
#include "
AsgDataHandles/WriteDecorHandle.h
"
14
#include "
AsgDataHandles/WriteDecorHandleKey.h
"
15
#include "
AthContainers/AuxVectorData.h
"
16
17
//
18
// method implementations
19
//
20
21
namespace
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"
);
32
SG::WriteDecorHandleKey<xAOD::EventInfo>
decorKey{
m_eventInfoKey
,
name
};
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) {
44
SG::WriteDecorHandle<xAOD::EventInfo,uint32_t>
dec(std::move(decorKey));
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
{
57
SG::ReadHandle<xAOD::EventInfo>
eventInfo(
m_eventInfoKey
, ctx);
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
}
ReadHandle.h
Handle class for reading from StoreGate.
WriteDecorHandleKey.h
WriteDecorHandle.h
Handle class for adding a decoration to an object.
AuxVectorData.h
Manage lookup of vectors of auxiliary data.
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:290
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
EventDecoratorAlg.h
CP::EventDecoratorAlg::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
the name of the event info object
Definition
EventDecoratorAlg.h:37
CP::EventDecoratorAlg::m_decFunctions
std::vector< std::function< void(const xAOD::EventInfo &)> > m_decFunctions
the functions to add decorations
Definition
EventDecoratorAlg.h:43
CP::EventDecoratorAlg::m_uint32Decorations
Gaudi::Property< std::map< std::string, uint32_t > > m_uint32Decorations
the uint32_t decorations to add
Definition
EventDecoratorAlg.h:40
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteDecorHandleKey
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
Definition
StoreGate/StoreGate/WriteDecorHandleKey.h:90
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
xAOD::name
name
Definition
TriggerMenuJson_v1.cxx:29
xAOD::EventInfo
EventInfo_v1 EventInfo
Definition of the latest event info version.
Definition
IEventInfoCnvTool.h:16
Generated on
for ATLAS Offline Software by
1.17.0