ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetRecTools
TrackVertexAssociationTool
src
PV0TrackSelectionAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
PV0TrackSelectionAlg.h
"
6
7
PV0TrackSelectionAlg::PV0TrackSelectionAlg
(
const
std::string& name, ISvcLocator* pSvcLocator ) :
8
AthReentrantAlgorithm
( name, pSvcLocator ){}
9
10
StatusCode
PV0TrackSelectionAlg::initialize
(){
11
ATH_CHECK
(
m_inTrackKey
.initialize());
12
ATH_CHECK
(
m_vertexKey
.initialize());
13
ATH_CHECK
(
m_outTrackKey
.initialize());
14
15
ATH_CHECK
(
m_decorDeps
.initialize(
m_inTrackKey
,
m_outTrackKey
));
16
17
ATH_CHECK
(
m_TVATool
.retrieve());
18
19
return
StatusCode::SUCCESS;
20
}
21
22
StatusCode
PV0TrackSelectionAlg::finalize
(){
23
return
StatusCode::SUCCESS;
24
}
25
26
StatusCode
PV0TrackSelectionAlg::execute
(
const
EventContext& ctx)
const
{
27
28
ATH_MSG_DEBUG
(
"Executing "
<< name() <<
"..."
);
29
30
SG::ReadHandle<xAOD::TrackParticleContainer>
inTracks(
m_inTrackKey
, ctx);
31
SG::ReadHandle<xAOD::VertexContainer>
vertices(
m_vertexKey
, ctx);
32
33
if
(!inTracks.
isValid
() || !vertices.
isValid
()) {
34
if
(!inTracks.
isValid
())
ATH_MSG_ERROR
(
"TrackParticle container not found: "
<<
m_inTrackKey
.key());
35
if
(!vertices.
isValid
())
ATH_MSG_ERROR
(
"Vertex container not found: "
<<
m_vertexKey
.key());
36
return
StatusCode::FAILURE;
37
}
38
39
// Find the primary vertex
40
const
xAOD::Vertex
* pv(
nullptr
);
41
for
(
const
xAOD::Vertex
* vertex : *vertices){
42
if
(vertex->vertexType() ==
xAOD::VxType::PriVtx
){
43
pv = vertex;
44
break
;
45
}
46
}
47
48
auto
pv0tracks = std::make_unique<ConstDataVector<xAOD::TrackParticleContainer> >(
SG::VIEW_ELEMENTS
);
49
50
if
(pv !=
nullptr
){
51
for
(
const
xAOD::TrackParticle
* track : *inTracks) {
52
if
(
m_TVATool
->isCompatible(*track, *pv) ) pv0tracks->push_back(track);
53
}
54
}
55
else
ATH_MSG_DEBUG
(
"No primary vertex found. Selecting no tracks."
);
56
57
std::unique_ptr<const xAOD::TrackParticleContainer> outTracksC(pv0tracks.release()->asDataVector());
58
SG::WriteHandle<xAOD::TrackParticleContainer>
outTrackHandle(
m_outTrackKey
, ctx);
59
60
if
(outTrackHandle.
put
(std::move(outTracksC)) ==
nullptr
){
61
ATH_MSG_ERROR
(
"Failed to record "
<<
m_outTrackKey
.key() <<
" as const xAOD::TrackParticleContainer!"
);
62
return
StatusCode::FAILURE;
63
}
64
ATH_CHECK
(
m_decorDeps
.linkDecors (
m_inTrackKey
, ctx));
65
66
return
StatusCode::SUCCESS;
67
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
PV0TrackSelectionAlg.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
PV0TrackSelectionAlg::m_vertexKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexKey
Definition
PV0TrackSelectionAlg.h:45
PV0TrackSelectionAlg::execute
StatusCode execute(const EventContext &) const override
Definition
PV0TrackSelectionAlg.cxx:26
PV0TrackSelectionAlg::m_outTrackKey
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_outTrackKey
Definition
PV0TrackSelectionAlg.h:47
PV0TrackSelectionAlg::finalize
StatusCode finalize() override
Definition
PV0TrackSelectionAlg.cxx:22
PV0TrackSelectionAlg::m_inTrackKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inTrackKey
Definition
PV0TrackSelectionAlg.h:44
PV0TrackSelectionAlg::m_decorDeps
SG::ShallowCopyDecorDeps< xAOD::TrackParticleContainer > m_decorDeps
Definition
PV0TrackSelectionAlg.h:49
PV0TrackSelectionAlg::m_TVATool
ToolHandle< CP::ITrackVertexAssociationTool > m_TVATool
Definition
PV0TrackSelectionAlg.h:42
PV0TrackSelectionAlg::PV0TrackSelectionAlg
PV0TrackSelectionAlg()
PV0TrackSelectionAlg::initialize
StatusCode initialize() override
Definition
PV0TrackSelectionAlg.cxx:10
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::put
const_pointer_type put(std::unique_ptr< T > data, bool returnExisting=false) const
Record an object to the store.
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition
OwnershipPolicy.h:18
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition
TrackingPrimitives.h:590
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition
Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
xAOD::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition
Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
Generated on
for ATLAS Offline Software by
1.17.0