ATLAS Offline Software
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
}
PV0TrackSelectionAlg::execute
StatusCode execute(const EventContext &) const override
Definition:
PV0TrackSelectionAlg.cxx:26
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition:
OwnershipPolicy.h:18
SG::ReadHandle
Definition:
StoreGate/StoreGate/ReadHandle.h:70
PV0TrackSelectionAlg::initialize
StatusCode initialize() override
Definition:
PV0TrackSelectionAlg.cxx:10
PV0TrackSelectionAlg::m_TVATool
ToolHandle< CP::ITrackVertexAssociationTool > m_TVATool
Definition:
PV0TrackSelectionAlg.h:42
PV0TrackSelectionAlg.h
PV0TrackSelectionAlg::m_decorDeps
SG::ShallowCopyDecorDeps< xAOD::TrackParticleContainer > m_decorDeps
Definition:
PV0TrackSelectionAlg.h:49
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition:
AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition:
AthReentrantAlgorithm.h:83
PV0TrackSelectionAlg::m_vertexKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexKey
Definition:
PV0TrackSelectionAlg.h:45
PV0TrackSelectionAlg::finalize
StatusCode finalize() override
Definition:
PV0TrackSelectionAlg.cxx:22
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition:
AthMsgStreamMacros.h:33
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
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition:
TrackingPrimitives.h:571
ATH_CHECK
#define ATH_CHECK
Definition:
AthCheckMacros.h:40
PV0TrackSelectionAlg::PV0TrackSelectionAlg
PV0TrackSelectionAlg()
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
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition:
Control/AthContainers/Root/debug.cxx:228
SG::WriteHandle
Definition:
StoreGate/StoreGate/WriteHandle.h:76
Trk::vertex
@ vertex
Definition:
MeasurementType.h:21
xAOD::Vertex_v1
Class describing a Vertex.
Definition:
Vertex_v1.h:42
python.changerun.pv
pv
Definition:
changerun.py:81
PV0TrackSelectionAlg::m_inTrackKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inTrackKey
Definition:
PV0TrackSelectionAlg.h:44
PV0TrackSelectionAlg::m_outTrackKey
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_outTrackKey
Definition:
PV0TrackSelectionAlg.h:47
xAOD::track
@ track
Definition:
TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition:
TrackParticle_v1.h:43
SG::WriteHandle::put
const_pointer_type put(std::unique_ptr< T > data, bool returnExisting=false) const
Record an object to the store.
Generated on Sun Dec 22 2024 21:16:46 for ATLAS Offline Software by
1.8.18