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-2023 CERN for the benefit of the ATLAS collaboration
3
//
4
5
// Local include(s):
6
#include "
TrackingAnalysisAlgorithms/TrackParticleMergerAlg.h
"
7
8
namespace
CP
{
9
10
TrackParticleMergerAlg::TrackParticleMergerAlg
(
const
std::string&
name
,
11
ISvcLocator* svcLoc )
12
:
EL
::
AnaReentrantAlgorithm
(
name
, svcLoc ) {
13
}
14
15
StatusCode
TrackParticleMergerAlg::initialize
() {
16
17
ATH_MSG_DEBUG
(
"Initializing TrackParticleMergerAlg"
);
18
ATH_CHECK
(
m_inputTrackParticleLocations
.initialize() );
19
20
ATH_CHECK
(
m_outputTrackParticleLocationCopy
.initialize(!
m_createViewCollection
.value()) );
21
ATH_CHECK
(
m_outputTrackParticleLocationView
.initialize(
m_createViewCollection
.value()) );
22
23
ATH_CHECK
(
m_requiredDecorations
.initialize(!
m_createViewCollection
.value()) );
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;
35
if
(!
m_createViewCollection
) {
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) {
43
if
(
m_createViewCollection
) {
44
outputViewCol->push_back(tp);
45
}
else
{
46
xAOD::TrackParticle
* newTp =
new
xAOD::TrackParticle
();
47
outputCol->push_back(newTp);
48
*newTp = *tp;
49
}
50
}
51
}
52
53
if
(
m_createViewCollection
) {
54
SG::WriteHandle<ConstDataVector <xAOD::TrackParticleContainer>
> outputTrackParticlesView(
m_outputTrackParticleLocationView
, ctx);
55
ATH_CHECK
( outputTrackParticlesView.
record
(std::move(outputViewCol)) );
56
}
57
else
{
58
SG::WriteHandle<xAOD::TrackParticleContainer>
outputTrackParticlesCopy(
m_outputTrackParticleLocationCopy
, ctx);
59
ATH_CHECK
(outputTrackParticlesCopy.
record
(std::move(outputCol), std::move(outputAuxCol)));
60
}
61
62
return
StatusCode::SUCCESS;
63
}
64
65
}
// 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:29
TrackParticleMergerAlg.h
CP::TrackParticleMergerAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Function executing the algorithm.
Definition
TrackParticleMergerAlg.cxx:28
CP::TrackParticleMergerAlg::TrackParticleMergerAlg
TrackParticleMergerAlg(const std::string &name, ISvcLocator *svcLoc)
Algorithm constructor.
Definition
TrackParticleMergerAlg.cxx:10
CP::TrackParticleMergerAlg::m_requiredDecorations
SG::ReadDecorHandleKeyArray< xAOD::TrackParticleContainer > m_requiredDecorations
Extra guard for deep-copy mode.
Definition
TrackParticleMergerAlg.h:75
CP::TrackParticleMergerAlg::m_outputTrackParticleLocationView
SG::WriteHandleKey< ConstDataVector< xAOD::TrackParticleContainer > > m_outputTrackParticleLocationView
Definition
TrackParticleMergerAlg.h:67
CP::TrackParticleMergerAlg::m_outputTrackParticleLocationCopy
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_outputTrackParticleLocationCopy
Output collection name.
Definition
TrackParticleMergerAlg.h:64
CP::TrackParticleMergerAlg::initialize
virtual StatusCode initialize() override final
Function initialising the algorithm.
Definition
TrackParticleMergerAlg.cxx:15
CP::TrackParticleMergerAlg::m_inputTrackParticleLocations
SG::ReadHandleKeyArray< xAOD::TrackParticleContainer > m_inputTrackParticleLocations
Input track collections to be merged.
Definition
TrackParticleMergerAlg.h:58
CP::TrackParticleMergerAlg::m_createViewCollection
Gaudi::Property< bool > m_createViewCollection
Option to create a view collection and not deep-copy tracks.
Definition
TrackParticleMergerAlg.h:72
EL::AnaReentrantAlgorithm::AnaReentrantAlgorithm
AnaReentrantAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
Definition
AnaReentrantAlgorithm.cxx:29
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
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
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition
AsgComponentFactories.h:16
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition
OwnershipPolicy.h:18
xAOD::name
name
Definition
TriggerMenuJson_v1.cxx:29
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