ATLAS Offline Software
Loading...
Searching...
No Matches
egammaAmbiguityRelinker.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
9
11 #include "xAODEgamma/Electron.h"
14 #include "xAODEgamma/Photon.h"
17
19
20
22 ISvcLocator* pSvcLocator)
23 : AthReentrantAlgorithm(name, pSvcLocator)
24 {}
25
26 StatusCode
28 {
29 // the data handle keys
30 ATH_CHECK(m_electronOutputKey.initialize());
31 ATH_CHECK(m_electronInputKey.initialize());
32 ATH_CHECK(m_photonOutputKey.initialize());
33 ATH_CHECK(m_photonInputKey.initialize());
34 return StatusCode::SUCCESS;
35 }
36
37 StatusCode
38 egammaAmbiguityRelinker::execute(const EventContext& ctx) const {
43
44 ATH_CHECK(el_outputContainer.record(std::make_unique<xAOD::ElectronContainer>(),
45 std::make_unique<xAOD::ElectronAuxContainer>()));
46
47 ATH_CHECK(ph_outputContainer.record(std::make_unique<xAOD::PhotonContainer>(),
48 std::make_unique<xAOD::PhotonAuxContainer>()));
49
50
51 xAOD::ElectronContainer* electrons = el_outputContainer.ptr();
52 xAOD::PhotonContainer* photons = ph_outputContainer.ptr();
53 electrons->reserve(el_inputContainer->size());
54 photons->reserve(ph_inputContainer->size());
55
56 for (const xAOD::Electron* old_el : *el_inputContainer) {
57 xAOD::Electron* electron = electrons->push_back(std::make_unique<xAOD::Electron>());
58 *electron=*old_el;
59 }
60
61 for (const xAOD::Photon* old_ph : *ph_inputContainer) {
62 xAOD::Photon* photon = photons->push_back(std::make_unique<xAOD::Photon>());
63 *photon=*old_ph;
64 }
65
66 // Recompute ambiguity links
67 egAmbLinkHelper::doAmbiguityLinks(ctx, electrons, photons);
68 egAmbLinkHelper::doAmbiguityLinks(ctx, photons, electrons);
69
70 return StatusCode::SUCCESS;
71 }
72
#define ATH_CHECK
Evaluate an expression and check for errors.
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
An algorithm that can be simultaneously executed in multiple threads.
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
StatusCode initialize() override final
SG::ReadHandleKey< xAOD::ElectronContainer > m_electronInputKey
Name of the electron input collection.
SG::ReadHandleKey< xAOD::PhotonContainer > m_photonInputKey
Name of the photon input collection.
egammaAmbiguityRelinker(const std::string &name, ISvcLocator *pSvcLocator)
SG::WriteHandleKey< xAOD::PhotonContainer > m_photonOutputKey
Name of the photon output collection.
StatusCode execute(const EventContext &ctx) const override final
SG::WriteHandleKey< xAOD::ElectronContainer > m_electronOutputKey
Name of the electron output collection.
void doAmbiguityLinks(const EventContext &ctx, DataVector< SrcT > *srcContainer, DataVector< DestT > *destContainer)
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
Photon_v1 Photon
Definition of the current "egamma version".
Electron_v1 Electron
Definition of the current "egamma version".