ATLAS Offline Software
ReadExampleElectron.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "ReadExampleElectron.h"
6 
7 #include <set>
8 
12 #include "EventInfo/EventID.h"
15 #include "StoreGate/ReadHandle.h"
16 
17 using 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 //___________________________________________________________________________
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
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 }
xAOD::ExampleElectron_v1
Definition: ExampleElectron_v1.h:14
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
EventBookkeeperCollection.h
AthPoolEx::ReadExampleElectron::initialize
virtual StatusCode initialize() override final
Gaudi Service Interface method implementations:
Definition: ReadExampleElectron.cxx:24
AthPoolEx::ReadExampleElectron::m_exampleElectronContainerKey
SG::ReadHandleKey< xAOD::ExampleElectronContainer > m_exampleElectronContainerKey
Definition: ReadExampleElectron.h:40
ExampleElectronContainer.h
SG::ReadDecorHandle::isPresent
bool isPresent() const
Is the referenced container present in SG?
AthPoolEx::ReadExampleElectron::m_decor1Key
SG::ReadDecorHandleKey< xAOD::ExampleElectronContainer > m_decor1Key
Definition: ReadExampleElectron.h:47
EventStreamInfo.h
This file contains the class definition for the EventStreamInfo class.
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
EventID.h
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition: StoreGate/StoreGate/ReadDecorHandle.h:94
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
checkFileSG.objs
list objs
Definition: checkFileSG.py:93
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthPoolEx::ReadExampleElectron::ReadExampleElectron
ReadExampleElectron(const std::string &name, ISvcLocator *pSvcLocator)
Standard Service Constructor.
Definition: ReadExampleElectron.cxx:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
AthPoolEx::ReadExampleElectron::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: ReadExampleElectron.cxx:33
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
ReadDecorHandle.h
Handle class for reading a decoration on an object.
AthPoolEx
Definition: PassNoneFilter.h:16
ReadHandle.h
Handle class for reading from StoreGate.
ExampleElectron.h
python.PyAthena.obj
obj
Definition: PyAthena.py:132
AthPoolEx::ReadExampleElectron::finalize
virtual StatusCode finalize() override final
Definition: ReadExampleElectron.cxx:71
ReadExampleElectron.h