ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
TrackingAnalysisAlgorithms
Root
TrackParticleMergerAlg.cxx
Go to the documentation of this file.
1
//
2
// Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
//
4
5
// Local include(s):
6
#include "
TrackingAnalysisAlgorithms/TrackParticleMergerAlg.h
"
7
8
#include <
AsgDataHandles/ReadHandle.h
>
9
#include <
AsgDataHandles/WriteHandle.h
>
10
11
namespace
CP
{
12
13
StatusCode
TrackParticleMergerAlg::initialize
() {
14
15
ATH_MSG_DEBUG
(
"Initializing TrackParticleMergerAlg"
);
16
ATH_CHECK
(
m_inputTrackParticleLocations
.initialize() );
17
18
ATH_CHECK
(
m_outputTrackParticleLocationCopy
.initialize(!
m_createViewCollection
.value()) );
19
ATH_CHECK
(
m_outputTrackParticleLocationView
.initialize(
m_createViewCollection
.value()) );
20
21
ATH_CHECK
(
m_requiredDecorations
.initialize(!
m_createViewCollection
.value()) );
22
23
return
StatusCode::SUCCESS;
24
}
25
26
StatusCode
TrackParticleMergerAlg::execute
(
const
EventContext& ctx)
const
{
27
28
auto
readHandles =
m_inputTrackParticleLocations
.makeHandles(ctx);
29
std::size_t nTracks = 0;
30
for
(
auto
& readHandle : readHandles) {
31
nTracks += readHandle->size();
32
}
33
34
if
(
m_createViewCollection
) {
35
// View collection pointing to the input tracks
36
auto
outputViewCol = std::make_unique<ConstDataVector<xAOD::TrackParticleContainer>>(
SG::VIEW_ELEMENTS
);
37
outputViewCol->reserve(nTracks);
38
for
(
auto
& readHandle : readHandles) {
39
for
(
const
xAOD::TrackParticle
* tp : *readHandle) {
40
outputViewCol->push_back(tp);
41
}
42
}
43
44
SG::WriteHandle<ConstDataVector <xAOD::TrackParticleContainer>
> outputTrackParticlesView(
m_outputTrackParticleLocationView
, ctx);
45
ATH_CHECK
( outputTrackParticlesView.
record
(std::move(outputViewCol)) );
46
}
else
{
47
// Deep copy of the input tracks
48
auto
outputCol = std::make_unique<xAOD::TrackParticleContainer>();
49
auto
outputAuxCol = std::make_unique<xAOD::TrackParticleAuxContainer>();
50
outputCol->setStore(outputAuxCol.get());
51
outputCol->reserve(nTracks);
52
for
(
auto
& readHandle : readHandles) {
53
for
(
const
xAOD::TrackParticle
* tp : *readHandle) {
54
xAOD::TrackParticle
* newTp = outputCol->push_back(std::make_unique<xAOD::TrackParticle>());
55
*newTp = *tp;
56
}
57
}
58
59
SG::WriteHandle<xAOD::TrackParticleContainer>
outputTrackParticlesCopy(
m_outputTrackParticleLocationCopy
, ctx);
60
ATH_CHECK
( outputTrackParticlesCopy.
record
(std::move(outputCol), std::move(outputAuxCol)) );
61
}
62
63
return
StatusCode::SUCCESS;
64
}
65
66
}
// namespace CP
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x,...)
Definition
AthMsgStreamMacros.h:43
ReadHandle.h
Handle class for reading from StoreGate.
WriteHandle.h
Handle class for recording to StoreGate.
TrackParticleMergerAlg.h
CP::TrackParticleMergerAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Function executing the algorithm.
Definition
TrackParticleMergerAlg.cxx:26
CP::TrackParticleMergerAlg::m_requiredDecorations
SG::ReadDecorHandleKeyArray< xAOD::TrackParticleContainer > m_requiredDecorations
Extra guard for deep-copy mode.
Definition
TrackParticleMergerAlg.h:70
CP::TrackParticleMergerAlg::m_outputTrackParticleLocationView
SG::WriteHandleKey< ConstDataVector< xAOD::TrackParticleContainer > > m_outputTrackParticleLocationView
Definition
TrackParticleMergerAlg.h:62
CP::TrackParticleMergerAlg::m_outputTrackParticleLocationCopy
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_outputTrackParticleLocationCopy
Output collection name.
Definition
TrackParticleMergerAlg.h:59
CP::TrackParticleMergerAlg::initialize
virtual StatusCode initialize() override final
Function initialising the algorithm.
Definition
TrackParticleMergerAlg.cxx:13
CP::TrackParticleMergerAlg::m_inputTrackParticleLocations
SG::ReadHandleKeyArray< xAOD::TrackParticleContainer > m_inputTrackParticleLocations
Input track collections to be merged.
Definition
TrackParticleMergerAlg.h:53
CP::TrackParticleMergerAlg::m_createViewCollection
Gaudi::Property< bool > m_createViewCollection
Option to create a view collection and not deep-copy tracks.
Definition
TrackParticleMergerAlg.h:67
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:71
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition
OwnershipPolicy.h:18
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition
Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
Generated on
for ATLAS Offline Software by
1.17.0