ATLAS Offline Software
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 
8 namespace 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
CP::TrackParticleMergerAlg::m_requiredDecorations
SG::ReadDecorHandleKeyArray< xAOD::TrackParticleContainer > m_requiredDecorations
Extra guard for deep-copy mode.
Definition: TrackParticleMergerAlg.h:76
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
CP::TrackParticleMergerAlg::m_outputTrackParticleLocationView
SG::WriteHandleKey< ConstDataVector< xAOD::TrackParticleContainer > > m_outputTrackParticleLocationView
Definition: TrackParticleMergerAlg.h:68
CP::TrackParticleMergerAlg::m_createViewCollection
Gaudi::Property< bool > m_createViewCollection
Option to create a view collection and not deep-copy tracks.
Definition: TrackParticleMergerAlg.h:73
ParticleTest.tp
tp
Definition: ParticleTest.py:25
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition: Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
CP::TrackParticleMergerAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Function executing the algorithm.
Definition: TrackParticleMergerAlg.cxx:28
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CP::TrackParticleMergerAlg::initialize
virtual StatusCode initialize() override final
Function initialising the algorithm.
Definition: TrackParticleMergerAlg.cxx:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AlgorithmWorkerData.h:24
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
CP::TrackParticleMergerAlg::TrackParticleMergerAlg
TrackParticleMergerAlg(const std::string &name, ISvcLocator *svcLoc)
Algorithm constructor.
Definition: TrackParticleMergerAlg.cxx:10
TrackParticleMergerAlg.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
CP::TrackParticleMergerAlg::m_outputTrackParticleLocationCopy
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_outputTrackParticleLocationCopy
Output collection name.
Definition: TrackParticleMergerAlg.h:65
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
CP::TrackParticleMergerAlg::m_inputTrackParticleLocations
SG::ReadHandleKeyArray< xAOD::TrackParticleContainer > m_inputTrackParticleLocations
Input track collections to be merged.
Definition: TrackParticleMergerAlg.h:59