ATLAS Offline Software
Loading...
Searching...
No Matches
TrackParticleMergerAlg.cxx
Go to the documentation of this file.
1//
2// Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3//
4
5// Local include(s):
7
8namespace CP {
9
11 ISvcLocator* svcLoc )
12 : EL::AnaReentrantAlgorithm( name, svcLoc ) {
13 }
14
16
17 ATH_MSG_DEBUG("Initializing TrackParticleMergerAlg");
19
22
24
25 return StatusCode::SUCCESS;
26 }
27
28 StatusCode TrackParticleMergerAlg::execute(const EventContext& ctx) const {
29
30 // Setup containers for output, to avoid const conversions setup two different kind of containers
31 auto outputViewCol = std::make_unique<ConstDataVector<xAOD::TrackParticleContainer>>(SG::VIEW_ELEMENTS);
32 auto outputCol = std::make_unique<xAOD::TrackParticleContainer>();
33
34 std::unique_ptr<xAOD::TrackParticleAuxContainer> outputAuxCol;
36 outputAuxCol = std::make_unique<xAOD::TrackParticleAuxContainer>();
37 outputCol->setStore(outputAuxCol.get());
38 }
39
40 auto readHandles = m_inputTrackParticleLocations.makeHandles(ctx);
41 for (auto& readHandle : readHandles) {
42 for (const xAOD::TrackParticle* tp : *readHandle) {
44 outputViewCol->push_back(tp);
45 } else {
47 outputCol->push_back(newTp);
48 *newTp = *tp;
49 }
50 }
51 }
52
55 ATH_CHECK( outputTrackParticlesView.record(std::move(outputViewCol)) );
56 }
57 else {
59 ATH_CHECK(outputTrackParticlesCopy.record(std::move(outputCol), std::move(outputAuxCol)));
60 }
61
62 return StatusCode::SUCCESS;
63 }
64
65} // namespace CP
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
virtual StatusCode execute(const EventContext &ctx) const override final
Function executing the algorithm.
TrackParticleMergerAlg(const std::string &name, ISvcLocator *svcLoc)
Algorithm constructor.
SG::ReadDecorHandleKeyArray< xAOD::TrackParticleContainer > m_requiredDecorations
Extra guard for deep-copy mode.
SG::WriteHandleKey< ConstDataVector< xAOD::TrackParticleContainer > > m_outputTrackParticleLocationView
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_outputTrackParticleLocationCopy
Output collection name.
virtual StatusCode initialize() override final
Function initialising the algorithm.
SG::ReadHandleKeyArray< xAOD::TrackParticleContainer > m_inputTrackParticleLocations
Input track collections to be merged.
Gaudi::Property< bool > m_createViewCollection
Option to create a view collection and not deep-copy tracks.
AnaReentrantAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Select isolated Photons, Electrons and Muons.
This module defines the arguments passed from the BATCH driver to the BATCH worker.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
TrackParticle_v1 TrackParticle
Reference the current persistent version: