ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Database
AthenaPOOL
AthenaPoolExample
AthenaPoolExampleAlgorithms
src
ReadExampleElectron.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
ReadExampleElectron.h
"
6
7
#include <set>
8
9
#include "
AthenaPoolExampleData/ExampleElectron.h
"
10
#include "
AthenaPoolExampleData/ExampleElectronContainer.h
"
11
#include "
EventBookkeeperMetaData/EventBookkeeperCollection.h
"
12
#include "
EventInfo/EventID.h
"
13
#include "
EventInfo/EventStreamInfo.h
"
14
#include "
StoreGate/ReadDecorHandle.h
"
15
#include "
StoreGate/ReadHandle.h
"
16
17
using namespace
AthPoolEx
;
18
19
//___________________________________________________________________________
20
ReadExampleElectron::ReadExampleElectron
(
const
std::string& name,
21
ISvcLocator* pSvcLocator)
22
:
AthReentrantAlgorithm
(name, pSvcLocator) {}
23
//___________________________________________________________________________
24
StatusCode
ReadExampleElectron::initialize
() {
25
ATH_MSG_INFO
(name() <<
": in initialize()"
);
26
27
ATH_CHECK
(
m_exampleElectronContainerKey
.initialize());
28
ATH_CHECK
(
m_decor1Key
.initialize());
29
30
return
StatusCode::SUCCESS;
31
}
32
//___________________________________________________________________________
33
StatusCode
ReadExampleElectron::execute
(
const
EventContext& ctx)
const
{
34
ATH_MSG_INFO
(name() <<
": is executing ..."
);
35
size_t
idx = 0;
36
37
// Setup the handle for the ElectronContainer
38
SG::ReadHandle<xAOD::ExampleElectronContainer>
objs =
39
SG::makeHandle
(
m_exampleElectronContainerKey
, ctx);
40
41
// Handle for the decoration
42
SG::ReadDecorHandle<xAOD::ExampleElectronContainer, float>
hdl1(
m_decor1Key
,
43
ctx);
44
45
if
(objs.isValid()) {
46
47
// Access the example electrons
48
for
(
const
xAOD::ExampleElectron
* obj : *objs) {
49
ATH_MSG_INFO
(
"ExampleElectron #"
<< idx <<
" {pt = "
<< obj->pt()
50
<<
", charge = "
<< obj->charge()
51
<<
"} "
);
52
53
// check to see if the first decor was written and print it out
54
if
(hdl1.
isPresent
()) {
55
ATH_MSG_INFO
(
"Decoration reader: decor1 = "
<< hdl1(*obj));
56
}
else
{
57
ATH_MSG_INFO
(
"Decoration reader decor1 hasn't been written"
);
58
}
59
60
++idx;
// iterate the index
61
}
62
63
}
else
{
64
ATH_MSG_ERROR
(
" Could not get example electron"
);
65
return
StatusCode::FAILURE;
66
}
67
68
return
StatusCode::SUCCESS;
69
}
70
//___________________________________________________________________________
71
StatusCode
ReadExampleElectron::finalize
() {
72
ATH_MSG_INFO
(name() <<
"in finalize()"
);
73
return
StatusCode::SUCCESS;
74
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
EventBookkeeperCollection.h
EventID.h
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
EventStreamInfo.h
This file contains the class definition for the EventStreamInfo class.
ExampleElectronContainer.h
ExampleElectron.h
ReadExampleElectron.h
ReadDecorHandle.h
Handle class for reading a decoration on an object.
ReadHandle.h
Handle class for reading from StoreGate.
AthPoolEx::ReadExampleElectron::finalize
virtual StatusCode finalize() override final
Definition
ReadExampleElectron.cxx:71
AthPoolEx::ReadExampleElectron::m_exampleElectronContainerKey
SG::ReadHandleKey< xAOD::ExampleElectronContainer > m_exampleElectronContainerKey
Definition
ReadExampleElectron.h:33
AthPoolEx::ReadExampleElectron::initialize
virtual StatusCode initialize() override final
Gaudi Service Interface method implementations:
Definition
ReadExampleElectron.cxx:24
AthPoolEx::ReadExampleElectron::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition
ReadExampleElectron.cxx:33
AthPoolEx::ReadExampleElectron::m_decor1Key
SG::ReadDecorHandleKey< xAOD::ExampleElectronContainer > m_decor1Key
Definition
ReadExampleElectron.h:40
AthPoolEx::ReadExampleElectron::ReadExampleElectron
ReadExampleElectron(const std::string &name, ISvcLocator *pSvcLocator)
Definition
ReadExampleElectron.cxx:20
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition
StoreGate/StoreGate/ReadDecorHandle.h:94
SG::ReadDecorHandle::isPresent
bool isPresent() const
Is the referenced container present in SG?
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
AthPoolEx
Definition
PassNoneFilter.h:16
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:269
xAOD::ExampleElectron
ExampleElectron_v1 ExampleElectron
Definition
ExampleElectron.h:12
Generated on
for ATLAS Offline Software by
1.17.0