ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkInDet
src
TrackToVertexWrapper.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Author: James Catmore (james.catmore@cern.ch)
6
7
#include "
DerivationFrameworkInDet/TrackToVertexWrapper.h
"
8
#include "
TrkVertexFitterInterfaces/ITrackToVertexIPEstimator.h
"
9
#include <vector>
10
#include <string>
11
#include "
StoreGate/WriteDecorHandle.h
"
12
#include "
DerivationFrameworkInDet/DecoratorUtils.h
"
13
14
namespace
DerivationFramework
{
15
16
StatusCode
TrackToVertexWrapper::initialize
()
17
{
18
if
(
m_sgName
.empty()) {
19
ATH_MSG_ERROR
(
"No decoration prefix name provided for the output of TracktoVertexWrapper!"
);
20
return
StatusCode::FAILURE;
21
}
22
if
(
m_containerName
.key().empty()) {
23
ATH_MSG_ERROR
(
"No TrackParticle collection provided for TracktoVertexWrapper!"
);
24
return
StatusCode::FAILURE;
25
}
26
ATH_CHECK
(
m_containerName
.initialize() );
27
ATH_CHECK
(
m_tool
.retrieve());
28
ATH_CHECK
(
m_vertexKey
.initialize());
29
{
30
// FIXME Properly configure WriteDecorHandleKeys in python
31
std::vector<std::string> names;
32
names.resize(
kNFloatDecor
);
33
names[
kdecnD0Decor
] =
"unbiased_d0"
;
34
names[
kdecnZ0Decor
] =
"unbiased_z0"
;
35
names[
kdecnZ0SinThetaDecor
] =
"unbiased_z0SinTheta"
;
36
names[
kdecnD0ErrDecor
] =
"unbiased_d0Sigma"
;
37
names[
kdecnZ0ErrDecor
] =
"unbiased_z0Sigma"
;
38
names[
kdecnZ0SinThetaErrDecor
] =
"unbiased_z0SigmaSinTheta"
;
39
names[
kdecnPVD0ErrDecor
] =
"unbiased_PVd0Sigma"
;
40
names[
kdecnPVZ0ErrDecor
] =
"unbiased_PVz0Sigma"
;
41
names[
kdecnPVZ0SinThetaErrDecor
] =
"unbiased_PVz0SigmaSinTheta"
;
42
names[
kdecn_b_D0Decor
] =
"biased_d0"
;
43
names[
kdecn_b_Z0Decor
] =
"biased_z0"
;
44
names[
kdecn_b_Z0SinThetaDecor
] =
"biased_z0SinTheta"
;
45
names[
kdecn_b_D0ErrDecor
] =
"biased_d0Sigma"
;
46
names[
kdecn_b_Z0ErrDecor
] =
"biased_z0Sigma"
;
47
names[
kdecn_b_Z0SinThetaErrDecor
] =
"biased_z0SigmaSinTheta"
;
48
names[
kdecn_b_PVD0ErrDecor
] =
"biased_PVd0Sigma"
;
49
names[
kdecn_b_PVZ0ErrDecor
] =
"biased_PVz0Sigma"
;
50
names[
kdecn_b_PVZ0SinThetaErrDecor
] =
"biased_PVz0SigmaSinTheta"
;
51
createDecoratorKeys
(*
this
,
m_containerName
,
m_sgName
+
"_"
, names,
m_trackFloatDecorKeys
);
52
}
53
return
StatusCode::SUCCESS;
54
}
55
56
57
StatusCode
TrackToVertexWrapper::addBranches
(
const
EventContext& ctx)
const
58
{
59
60
// retrieve track container
61
SG::ReadHandle<xAOD::TrackParticleContainer>
tracks(
m_containerName
, ctx );
62
if
( ! tracks.
isValid
() ) {
63
ATH_MSG_ERROR
(
"Couldn't retrieve TrackParticles with key: "
<<
m_containerName
.key() );
64
return
StatusCode::FAILURE;
65
}
66
SG::ReadHandle<xAOD::VertexContainer>
vertices {
m_vertexKey
, ctx };
67
if
( !vertices.
isValid
() )
68
{
69
ATH_MSG_ERROR
(
"Couldn't retrieve Vertices with key: "
<<
m_vertexKey
.key());
70
return
StatusCode::FAILURE;
71
}
72
73
std::vector<SG::WriteDecorHandle<xAOD::TrackParticleContainer,float> >
74
track_decorators =
createDecorators<xAOD::TrackParticleContainer,float>
(
m_trackFloatDecorKeys
,ctx);
75
// Run tool for each element and calculate the impact parameters/errors
76
for
(
const
auto
*trItr : *tracks) {
77
std::unique_ptr<Trk::ImpactParametersAndSigma> iPandSigma;
78
std::unique_ptr<Trk::ImpactParametersAndSigma> iPandSigmaBiased;
79
const
xAOD::Vertex
* foundVertex {
nullptr
};
80
for
(
const
auto
*
const
vx : *vertices) {
81
for
(
const
auto
& tpLink : vx->trackParticleLinks()) {
82
if
(*tpLink == trItr) {
83
foundVertex = vx;
84
break
;
85
}
86
}
87
if
(foundVertex)
break
;
88
}
89
if
( foundVertex ) {
90
iPandSigma=
m_tool
->estimate(ctx,trItr,foundVertex,
true
);
91
iPandSigmaBiased =
m_tool
->estimate(ctx,trItr,foundVertex,
false
);
92
if
( !iPandSigma )
ATH_MSG_WARNING
(
"trackToVertexIPEstimator failed !"
);
93
if
( !iPandSigmaBiased )
ATH_MSG_WARNING
(
"trackToVertexIPEstimator biased IP failed !"
);
94
}
95
else
{
96
ATH_MSG_DEBUG
(
"No vertex associated to the track. Skipping it."
);
97
}
98
99
// Do the decoration for each track
100
if
(iPandSigma) {
101
track_decorators[
kdecnD0Decor
]( *trItr ) = iPandSigma->IPd0;
102
track_decorators[
kdecnZ0Decor
]( *trItr ) = iPandSigma->IPz0;
103
track_decorators[
kdecnZ0SinThetaDecor
]( *trItr ) = iPandSigma->IPz0SinTheta;
104
track_decorators[
kdecnD0ErrDecor
]( *trItr ) = iPandSigma->sigmad0;
105
track_decorators[
kdecnZ0ErrDecor
]( *trItr ) = iPandSigma->sigmaz0;
106
track_decorators[
kdecnZ0SinThetaErrDecor
]( *trItr ) = iPandSigma->sigmaz0SinTheta;
107
track_decorators[
kdecnPVD0ErrDecor
] (*trItr ) = iPandSigma->PVsigmad0;
108
track_decorators[
kdecnPVZ0ErrDecor
] (*trItr ) = iPandSigma->PVsigmaz0;
109
track_decorators[
kdecnPVZ0SinThetaErrDecor
] (*trItr ) = iPandSigma->PVsigmaz0SinTheta;
110
}
111
else
{
112
track_decorators[
kdecnD0Decor
]( *trItr ) = 999.;
113
track_decorators[
kdecnZ0Decor
]( *trItr ) = 999.;
114
track_decorators[
kdecnZ0SinThetaDecor
]( *trItr ) = 999.;
115
track_decorators[
kdecnD0ErrDecor
]( *trItr ) = 999.;
116
track_decorators[
kdecnZ0ErrDecor
]( *trItr ) = 999.;
117
track_decorators[
kdecnZ0SinThetaErrDecor
]( *trItr ) = 999.;
118
track_decorators[
kdecnPVD0ErrDecor
] (*trItr ) = 999.;
119
track_decorators[
kdecnPVZ0ErrDecor
] (*trItr ) = 999.;
120
track_decorators[
kdecnPVZ0SinThetaErrDecor
] (*trItr ) = 999.;
121
}
122
123
if
(iPandSigmaBiased) {
124
track_decorators[
kdecn_b_D0Decor
]( *trItr ) = iPandSigmaBiased->IPd0;
125
track_decorators[
kdecn_b_Z0Decor
]( *trItr ) = iPandSigmaBiased->IPz0;
126
track_decorators[
kdecn_b_Z0SinThetaDecor
]( *trItr ) = iPandSigmaBiased->IPz0SinTheta;
127
track_decorators[
kdecn_b_D0ErrDecor
]( *trItr ) = iPandSigmaBiased->sigmad0;
128
track_decorators[
kdecn_b_Z0ErrDecor
]( *trItr ) = iPandSigmaBiased->sigmaz0;
129
track_decorators[
kdecn_b_Z0SinThetaErrDecor
]( *trItr ) = iPandSigmaBiased->sigmaz0SinTheta;
130
track_decorators[
kdecn_b_PVD0ErrDecor
] (*trItr ) = iPandSigmaBiased->PVsigmad0;
131
track_decorators[
kdecn_b_PVZ0ErrDecor
] (*trItr ) = iPandSigmaBiased->PVsigmaz0;
132
track_decorators[
kdecn_b_PVZ0SinThetaErrDecor
] (*trItr ) = iPandSigmaBiased->PVsigmaz0SinTheta;
133
}
134
else
{
135
track_decorators[
kdecn_b_D0Decor
]( *trItr ) = 999.;
136
track_decorators[
kdecn_b_Z0Decor
]( *trItr ) = 999.;
137
track_decorators[
kdecn_b_Z0SinThetaDecor
]( *trItr ) = 999.;
138
track_decorators[
kdecn_b_D0ErrDecor
]( *trItr ) = 999.;
139
track_decorators[
kdecn_b_Z0ErrDecor
]( *trItr ) = 999.;
140
track_decorators[
kdecn_b_Z0SinThetaErrDecor
]( *trItr ) = 999.;
141
track_decorators[
kdecn_b_PVD0ErrDecor
] (*trItr ) = 999.;
142
track_decorators[
kdecn_b_PVZ0ErrDecor
] (*trItr ) = 999.;
143
track_decorators[
kdecn_b_PVZ0SinThetaErrDecor
] (*trItr ) = 999.;
144
}
145
}
// end of loop over tracks
146
147
return
StatusCode::SUCCESS;
148
}
149
150
}
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_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
DecoratorUtils.h
ITrackToVertexIPEstimator.h
WriteDecorHandle.h
Handle class for adding a decoration to an object.
TrackToVertexWrapper.h
DerivationFramework::TrackToVertexWrapper::m_tool
ToolHandle< Trk::ITrackToVertexIPEstimator > m_tool
Definition
TrackToVertexWrapper.h:32
DerivationFramework::TrackToVertexWrapper::m_sgName
Gaudi::Property< std::string > m_sgName
Definition
TrackToVertexWrapper.h:34
DerivationFramework::TrackToVertexWrapper::m_trackFloatDecorKeys
std::vector< SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > > m_trackFloatDecorKeys
Definition
TrackToVertexWrapper.h:59
DerivationFramework::TrackToVertexWrapper::kdecn_b_PVZ0ErrDecor
@ kdecn_b_PVZ0ErrDecor
Definition
TrackToVertexWrapper.h:56
DerivationFramework::TrackToVertexWrapper::kdecn_b_PVZ0SinThetaErrDecor
@ kdecn_b_PVZ0SinThetaErrDecor
Definition
TrackToVertexWrapper.h:57
DerivationFramework::TrackToVertexWrapper::kNFloatDecor
@ kNFloatDecor
Definition
TrackToVertexWrapper.h:58
DerivationFramework::TrackToVertexWrapper::kdecnPVZ0SinThetaErrDecor
@ kdecnPVZ0SinThetaErrDecor
Definition
TrackToVertexWrapper.h:48
DerivationFramework::TrackToVertexWrapper::kdecn_b_PVD0ErrDecor
@ kdecn_b_PVD0ErrDecor
Definition
TrackToVertexWrapper.h:55
DerivationFramework::TrackToVertexWrapper::kdecnPVZ0ErrDecor
@ kdecnPVZ0ErrDecor
Definition
TrackToVertexWrapper.h:47
DerivationFramework::TrackToVertexWrapper::kdecnD0ErrDecor
@ kdecnD0ErrDecor
Definition
TrackToVertexWrapper.h:43
DerivationFramework::TrackToVertexWrapper::kdecnD0Decor
@ kdecnD0Decor
Definition
TrackToVertexWrapper.h:40
DerivationFramework::TrackToVertexWrapper::kdecnZ0ErrDecor
@ kdecnZ0ErrDecor
Definition
TrackToVertexWrapper.h:44
DerivationFramework::TrackToVertexWrapper::kdecnZ0SinThetaDecor
@ kdecnZ0SinThetaDecor
Definition
TrackToVertexWrapper.h:42
DerivationFramework::TrackToVertexWrapper::kdecn_b_Z0SinThetaErrDecor
@ kdecn_b_Z0SinThetaErrDecor
Definition
TrackToVertexWrapper.h:54
DerivationFramework::TrackToVertexWrapper::kdecn_b_Z0Decor
@ kdecn_b_Z0Decor
Definition
TrackToVertexWrapper.h:50
DerivationFramework::TrackToVertexWrapper::kdecnZ0SinThetaErrDecor
@ kdecnZ0SinThetaErrDecor
Definition
TrackToVertexWrapper.h:45
DerivationFramework::TrackToVertexWrapper::kdecn_b_Z0ErrDecor
@ kdecn_b_Z0ErrDecor
Definition
TrackToVertexWrapper.h:53
DerivationFramework::TrackToVertexWrapper::kdecnPVD0ErrDecor
@ kdecnPVD0ErrDecor
Definition
TrackToVertexWrapper.h:46
DerivationFramework::TrackToVertexWrapper::kdecn_b_D0Decor
@ kdecn_b_D0Decor
Definition
TrackToVertexWrapper.h:49
DerivationFramework::TrackToVertexWrapper::kdecn_b_D0ErrDecor
@ kdecn_b_D0ErrDecor
Definition
TrackToVertexWrapper.h:52
DerivationFramework::TrackToVertexWrapper::kdecnZ0Decor
@ kdecnZ0Decor
Definition
TrackToVertexWrapper.h:41
DerivationFramework::TrackToVertexWrapper::kdecn_b_Z0SinThetaDecor
@ kdecn_b_Z0SinThetaDecor
Definition
TrackToVertexWrapper.h:51
DerivationFramework::TrackToVertexWrapper::m_vertexKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexKey
Definition
TrackToVertexWrapper.h:38
DerivationFramework::TrackToVertexWrapper::initialize
virtual StatusCode initialize() override final
Definition
TrackToVertexWrapper.cxx:16
DerivationFramework::TrackToVertexWrapper::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override final
Definition
TrackToVertexWrapper.cxx:57
DerivationFramework::TrackToVertexWrapper::m_containerName
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_containerName
Definition
TrackToVertexWrapper.h:36
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
DerivationFramework
THE reconstruction tool.
Definition
CascadeTools.h:16
DerivationFramework::createDecorators
std::vector< SG::WriteDecorHandle< T_Cont, T > > createDecorators(const std::vector< SG::WriteDecorHandleKey< T_Cont > > &keys, const EventContext &ctx)
Definition
DecoratorUtils.h:51
DerivationFramework::createDecoratorKeys
void createDecoratorKeys(T_Parent &parent, const SG::ReadHandleKey< T_Cont > &container_key, const std::string &prefix, const std::vector< std::string > &decor_names, std::vector< SG::WriteDecorHandleKey< T_Cont > > &decor_out)
Definition
DecoratorUtils.h:20
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