ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
7#include <set>
8
12#include "EventInfo/EventID.h"
16
17using namespace AthPoolEx;
18
19//___________________________________________________________________________
21 ISvcLocator* pSvcLocator)
22 : AthReentrantAlgorithm(name, pSvcLocator) {}
23//___________________________________________________________________________
25 ATH_MSG_INFO(name() << ": in initialize()");
26
28 ATH_CHECK(m_decor1Key.initialize());
29
30 return StatusCode::SUCCESS;
31}
32//___________________________________________________________________________
33StatusCode 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
40
41 // Handle for the decoration
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//___________________________________________________________________________
72 ATH_MSG_INFO(name() << "in finalize()");
73 return StatusCode::SUCCESS;
74}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
This file contains the class definition for the EventStreamInfo class.
Handle class for reading a decoration on an object.
Handle class for reading from StoreGate.
virtual StatusCode finalize() override final
SG::ReadHandleKey< xAOD::ExampleElectronContainer > m_exampleElectronContainerKey
virtual StatusCode initialize() override final
Gaudi Service Interface method implementations:
virtual StatusCode execute(const EventContext &ctx) const override final
SG::ReadDecorHandleKey< xAOD::ExampleElectronContainer > m_decor1Key
ReadExampleElectron(const std::string &name, ISvcLocator *pSvcLocator)
An algorithm that can be simultaneously executed in multiple threads.
Handle class for reading a decoration on an object.
bool isPresent() const
Is the referenced container present in SG?
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
ExampleElectron_v1 ExampleElectron