ATLAS Offline Software
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 
7  #include "StoreGate/ReadHandle.h"
8  #include "StoreGate/WriteHandle.h"
9 
11  #include "xAODEgamma/Electron.h"
14  #include "xAODEgamma/Photon.h"
17 
19 
20 
22  ISvcLocator* pSvcLocator)
23  : AthReentrantAlgorithm(name, pSvcLocator)
24  {}
25 
28  {
29  // the data handle keys
32  ATH_CHECK(m_photonOutputKey.initialize());
33  ATH_CHECK(m_photonInputKey.initialize());
34  return StatusCode::SUCCESS;
35  }
36 
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
69 
70  return StatusCode::SUCCESS;
71  }
72 
DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
egammaAmbiguityRelinker::egammaAmbiguityRelinker
egammaAmbiguityRelinker(const std::string &name, ISvcLocator *pSvcLocator)
Definition: egammaAmbiguityRelinker.cxx:21
egammaAmbiguityRelinker::execute
StatusCode execute(const EventContext &ctx) const override final
Definition: egammaAmbiguityRelinker.cxx:38
egammaAmbiguityRelinker::m_electronOutputKey
SG::WriteHandleKey< xAOD::ElectronContainer > m_electronOutputKey
Name of the electron output collection.
Definition: egammaAmbiguityRelinker.h:49
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
egammaAmbiguityRelinker::m_electronInputKey
SG::ReadHandleKey< xAOD::ElectronContainer > m_electronInputKey
Name of the electron input collection.
Definition: egammaAmbiguityRelinker.h:54
egammaAmbiguityRelinker::m_photonOutputKey
SG::WriteHandleKey< xAOD::PhotonContainer > m_photonOutputKey
Name of the photon output collection.
Definition: egammaAmbiguityRelinker.h:59
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
EgammaContainer.h
WriteHandle.h
Handle class for recording to StoreGate.
ElectronContainer.h
ElectronAuxContainer.h
Photon.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
egammaAmbiguityRelinker.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
egAmbLinkHelper.h
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
egammaAmbiguityRelinker::m_photonInputKey
SG::ReadHandleKey< xAOD::PhotonContainer > m_photonInputKey
Name of the photon input collection.
Definition: egammaAmbiguityRelinker.h:64
xAOD::Electron_v1
Definition: Electron_v1.h:34
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
PhotonAuxContainer.h
xAOD::photon
@ photon
Definition: TrackingPrimitives.h:200
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
xAOD::Photon_v1
Definition: Photon_v1.h:37
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
egammaAmbiguityRelinker::initialize
StatusCode initialize() override final
Definition: egammaAmbiguityRelinker.cxx:27
Electron.h
ReadHandle.h
Handle class for reading from StoreGate.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
PhotonContainer.h
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
egAmbLinkHelper::doAmbiguityLinks
void doAmbiguityLinks(const EventContext &ctx, DataVector< SrcT > *srcContainer, DataVector< DestT > *destContainer)
Definition: egAmbLinkHelper.h:15