ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Event
xAOD
xAODEventInfoCnv
src
EventInfoCnvAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
// System include(s):
7
#include <memory>
8
9
// Gaudi/Athena include(s):
10
#include "
AthenaKernel/errorcheck.h
"
11
#include "GaudiKernel/ConcurrencyFlags.h"
12
13
// EDM include(s):
14
#include "EventInfo/EventInfo.h"
15
#include "
EventInfo/PileUpEventInfo.h
"
16
#include "
xAODEventInfo/EventInfo.h
"
17
#include "
xAODEventInfo/EventAuxInfo.h
"
18
#include "
xAODEventInfo/EventInfoContainer.h
"
19
#include "
xAODEventInfo/EventInfoAuxContainer.h
"
20
21
// Local include(s):
22
#include "
EventInfoCnvAlg.h
"
23
24
namespace
xAODMaker
{
25
26
EventInfoCnvAlg::EventInfoCnvAlg
(
const
std::string& name,
27
ISvcLocator* svcLoc )
28
:
AthReentrantAlgorithm
( name, svcLoc ),
29
m_cnvTool
(
"xAODMaker::EventInfoCnvTool/EventInfoCnvTool"
, this ) {
30
31
declareProperty
(
"AODKey"
,
m_aodKey
=
""
);
32
declareProperty
(
"xAODKey"
,
m_xaodKey
=
"EventInfo"
);
33
declareProperty
(
"PileupKey"
,
m_pileupKey
=
"PileupEventInfo"
);
34
declareProperty
(
"CnvTool"
,
m_cnvTool
);
35
}
36
37
StatusCode
EventInfoCnvAlg::initialize
() {
38
39
// Greet the user:
40
ATH_MSG_INFO
(
"Initializing "
<< name() );
41
ATH_MSG_DEBUG
(
" AOD Key: "
<<
m_aodKey
);
42
ATH_MSG_DEBUG
(
"xAOD Key: "
<<
m_xaodKey
.key() );
43
44
// Retrieve the converter tool:
45
CHECK
(
m_cnvTool
.retrieve() );
46
47
CHECK
(
m_aodKey
.initialize(
SG::AllowEmpty
) );
48
CHECK
(
m_xaodKey
.initialize() );
49
CHECK
(
m_pileupKey
.initialize(
SG::AllowEmpty
) );
50
51
// Return gracefully:
52
return
StatusCode::SUCCESS;
53
}
54
55
StatusCode
EventInfoCnvAlg::execute
(
const
EventContext& ctx)
const
{
56
57
// Check if anything needs to be done:
58
// FIXME: Job configuration should be fixed so we don't need this test.
59
if
(
evtStore
()->
contains< xAOD::EventInfo >
(
m_xaodKey
.key() ) ) {
60
ATH_MSG_WARNING
(
"xAOD::EventInfo with key \""
<<
m_xaodKey
.key()
61
<<
"\" is already in StoreGate; "
62
<<
"EventInfoCnvAlg should not be scheduled."
);
63
return
StatusCode::SUCCESS;
64
}
65
66
// Retrieve the AOD object:
67
// FIXME: Use a ReadHandle.
68
const
EventInfo
* aod =
nullptr
;
69
if
(
m_aodKey
.empty() ) {
70
// If key has not been set, do a keyless retrieve instead.
71
// This is not standard behavior, but is for compatibility
72
// with existing configurations.
73
CHECK
(
evtStore
()->retrieve( aod ) );
74
}
else
{
75
SG::ReadHandle<EventInfo>
ei (
m_aodKey
, ctx);
76
aod = ei.
cptr
();
77
}
78
79
// Create the xAOD object(s):
80
auto
ei = std::make_unique<xAOD::EventInfo>();
81
auto
ei_aux = std::make_unique<xAOD::EventAuxInfo>();
82
ei->setStore (ei_aux.get());
83
84
// Check if this is a PileUpEventInfo object:
85
const
PileUpEventInfo
* paod =
86
dynamic_cast<
const
PileUpEventInfo
*
>
( aod );
87
if
( paod ) {
88
// Create an EventInfoContainer for the pileup events:
89
auto
puei = std::make_unique<xAOD::EventInfoContainer>();
90
auto
puei_aux = std::make_unique<xAOD::EventInfoAuxContainer>();
91
puei->setStore (puei_aux.get());
92
93
// Sub-events for the main EventInfo object:
94
std::vector< xAOD::EventInfo::SubEvent > subEvents;
95
96
// A convenience type declaration:
97
typedef
ElementLink< xAOD::EventInfoContainer >
EiLink;
98
99
// Create xAOD::EventInfo objects for each pileup EventInfo object:
100
PileUpEventInfo::SubEvent::const_iterator pu_itr = paod->
beginSubEvt
();
101
PileUpEventInfo::SubEvent::const_iterator pu_end = paod->
endSubEvt
();
102
for
( ; pu_itr != pu_end; ++pu_itr ) {
103
// Create a new xAOD object:
104
xAOD::EventInfo
* ei =
new
xAOD::EventInfo
();
105
puei->push_back( ei );
106
// Fill it with information:
107
CHECK
(
m_cnvTool
->convert( ctx, pu_itr->pSubEvt, ei,
true
,
false
) );
108
// And now add a sub-event to the temporary list:
109
xAOD::EventInfo::PileUpType
type
=
xAOD::EventInfo::Unknown
;
110
switch
(pu_itr->type()) {
111
case
PileUpTimeEventIndex::Signal
:
112
type
=
xAOD::EventInfo::Signal
;
113
break
;
114
case
PileUpTimeEventIndex::MinimumBias
:
115
type
=
xAOD::EventInfo::MinimumBias
;
116
break
;
117
case
PileUpTimeEventIndex::Cavern
:
118
type
=
xAOD::EventInfo::Cavern
;
119
break
;
120
case
PileUpTimeEventIndex::HaloGas
:
121
type
=
xAOD::EventInfo::HaloGas
;
122
break
;
123
case
PileUpTimeEventIndex::HighPtMinimumBias
:
124
type
=
xAOD::EventInfo::HighPtMinimumBias
;
125
break
;
126
case
PileUpTimeEventIndex::ZeroBias
:
127
type
=
xAOD::EventInfo::ZeroBias
;
128
break
;
129
default
:
130
break
;
131
}
132
subEvents.emplace_back( pu_itr->time(),
133
pu_itr->index(),
134
type
,
135
EiLink(
m_pileupKey
.key(),
136
puei->size() -
137
1 ) );
138
}
139
140
// And now update the main EventInfo object with the sub-events:
141
ei->setSubEvents( subEvents );
142
143
// Record PU objects.
144
SG::WriteHandle<xAOD::EventInfoContainer>
puei_h (
m_pileupKey
, ctx);
145
CHECK
( puei_h.
record
(std::move(puei), std::move(puei_aux)) );
146
}
147
148
// Do the translation:
149
CHECK
(
m_cnvTool
->convert( ctx, aod, ei.get(),
false
,
true
) );
150
151
// Record EI objects.
152
SG::WriteHandle<xAOD::EventInfo>
ei_h (
m_xaodKey
, ctx);
153
CHECK
( ei_h.
record
(std::move(ei), std::move (ei_aux)) );
154
155
// Return gracefully:
156
return
StatusCode::SUCCESS;
157
}
158
159
}
// namespace xAODMaker
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
errorcheck.h
Helpers for checking error return status codes and reporting errors.
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
EventAuxInfo.h
EventInfoAuxContainer.h
EventInfoCnvAlg.h
EventInfoContainer.h
PileUpEventInfo.h
This class provides information about an overlaid event.
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonAlgorithm< Gaudi::Algorithm >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
ElementLink
ElementLink implementation for ROOT usage.
Definition
A/AthLinks/ElementLink.h:40
PileUpEventInfo
This class provides information about an overlaid event.
Definition
PileUpEventInfo.h:38
PileUpEventInfo::endSubEvt
SubEvent::iterator endSubEvt()
Definition
PileUpEventInfo.h:138
PileUpEventInfo::beginSubEvt
SubEvent::iterator beginSubEvt()
Definition
PileUpEventInfo.h:137
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
xAODMaker::EventInfoCnvAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm.
Definition
EventInfoCnvAlg.cxx:55
xAODMaker::EventInfoCnvAlg::m_xaodKey
SG::WriteHandleKey< xAOD::EventInfo > m_xaodKey
Key for the output object.
Definition
EventInfoCnvAlg.h:48
xAODMaker::EventInfoCnvAlg::initialize
virtual StatusCode initialize() override
Function initialising the algorithm.
Definition
EventInfoCnvAlg.cxx:37
xAODMaker::EventInfoCnvAlg::EventInfoCnvAlg
EventInfoCnvAlg(const std::string &name, ISvcLocator *svcLoc)
Regular Algorithm constructor.
Definition
EventInfoCnvAlg.cxx:26
xAODMaker::EventInfoCnvAlg::m_pileupKey
SG::WriteHandleKey< xAOD::EventInfoContainer > m_pileupKey
For pileup.
Definition
EventInfoCnvAlg.h:51
xAODMaker::EventInfoCnvAlg::m_cnvTool
ToolHandle< IEventInfoCnvTool > m_cnvTool
Handle to the converter tool.
Definition
EventInfoCnvAlg.h:54
xAODMaker::EventInfoCnvAlg::m_aodKey
SG::ReadHandleKey< EventInfo > m_aodKey
Key for the input object If blank, we do a keyless retrieve from SG instead!
Definition
EventInfoCnvAlg.h:46
xAOD::EventInfo_v1::PileUpType
PileUpType
Enumerator describing the types of pileup events.
Definition
EventInfo_v1.h:264
xAOD::EventInfo_v1::HaloGas
@ HaloGas
Halo-gas non-collision background.
Definition
EventInfo_v1.h:269
xAOD::EventInfo_v1::HighPtMinimumBias
@ HighPtMinimumBias
High pT Minimum bias pileup event.
Definition
EventInfo_v1.h:270
xAOD::EventInfo_v1::MinimumBias
@ MinimumBias
(Low pT) Minimum bias pileup event
Definition
EventInfo_v1.h:267
xAOD::EventInfo_v1::ZeroBias
@ ZeroBias
Zero bias pileup event.
Definition
EventInfo_v1.h:271
xAOD::EventInfo_v1::Signal
@ Signal
The signal event.
Definition
EventInfo_v1.h:266
xAOD::EventInfo_v1::Cavern
@ Cavern
Cavern background pileup event.
Definition
EventInfo_v1.h:268
xAOD::EventInfo_v1::Unknown
@ Unknown
Type not known/specified.
Definition
EventInfo_v1.h:265
contains
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
Definition
hcg.cxx:116
EventInfo
Definition
EventInfo.py:1
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:27
xAODMaker
Definition
StoreGateSvc.h:70
xAOD::EventInfo
EventInfo_v1 EventInfo
Definition of the latest event info version.
Definition
IEventInfoCnvTool.h:16
type
PileUpTimeEventIndex::MinimumBias
@ MinimumBias
Definition
PileUpTimeEventIndex.h:17
PileUpTimeEventIndex::HaloGas
@ HaloGas
Definition
PileUpTimeEventIndex.h:19
PileUpTimeEventIndex::HighPtMinimumBias
@ HighPtMinimumBias
Definition
PileUpTimeEventIndex.h:20
PileUpTimeEventIndex::Signal
@ Signal
Definition
PileUpTimeEventIndex.h:16
PileUpTimeEventIndex::ZeroBias
@ ZeroBias
Definition
PileUpTimeEventIndex.h:21
PileUpTimeEventIndex::Cavern
@ Cavern
Definition
PileUpTimeEventIndex.h:18
EventInfo.h
Generated on
for ATLAS Offline Software by
1.17.0