ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetRecTools
InDetSecVxFinderTool
src
JetFitterTwoTrackVtxFinderTool.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
#include "
InDetSecVxFinderTool/JetFitterTwoTrackVtxFinderTool.h
"
6
7
#include "
TrkVertexSeedFinderTools/CrossDistancesSeedFinder.h
"
8
#include "
TrkVertexFitters/SequentialVertexFitter.h
"
9
10
#include "
xAODTracking/TrackParticleContainer.h
"
11
#include "
xAODTracking/TrackParticleAuxContainer.h
"
12
#include "
TrkParticleBase/LinkToTrackParticleBase.h
"
13
#include "
TrkLinks/LinkToXAODTrackParticle.h
"
14
15
using namespace
InDet
;
16
17
JetFitterTwoTrackVtxFinderTool::JetFitterTwoTrackVtxFinderTool
(
const
std::string &t,
const
std::string &n,
const
IInterface *p)
18
:
AthAlgTool
(t, n, p),
19
m_tracksDecorator
(
"VxTrackAtVertex"
)
20
{
21
declareInterface< JetFitterTwoTrackVtxFinderTool >(
this
);
22
}
23
24
JetFitterTwoTrackVtxFinderTool::~JetFitterTwoTrackVtxFinderTool
() =
default
;
25
26
27
StatusCode
JetFitterTwoTrackVtxFinderTool::initialize
() {
28
29
if
(
m_CrossDistancesSeedFinder
.retrieve().isFailure() ) {
30
ATH_MSG_ERROR
(
"Cannot retrieve Trk::CrossDistancesSeedFinder/CrossDistancesSeedFinder"
);
31
return
StatusCode::FAILURE;
32
}
33
34
if
(
m_SequentialVertexFitter
.retrieve().isFailure() ) {
35
ATH_MSG_ERROR
(
"Cannot retrieve Trk::SequentialVertexFitter/SequentialVertexFitter"
);
36
return
StatusCode::FAILURE;
37
}
38
39
return
StatusCode::SUCCESS;
40
}
41
42
StatusCode
JetFitterTwoTrackVtxFinderTool::finalize
() {
43
return
StatusCode::SUCCESS;
44
}
45
46
47
const
Trk::TwoTrackVerticesInJet
*
JetFitterTwoTrackVtxFinderTool::doVertexFinding
(
const
EventContext& ctx,
48
const
xAOD::Vertex
& primaryVertex,
49
const
TLorentzVector& jetMomentum,
50
std::vector< const Trk::ITrackLink* >& inputTracks)
const
{
51
52
std::vector< const xAOD::Vertex* > VtxCandidates;
53
54
ATH_MSG_DEBUG
(
"Looping over "
<< inputTracks.size() <<
" input tracks... "
);
55
56
// Loop over all the combinations
57
for
(
unsigned
int
indexA(0); indexA<inputTracks.size(); indexA++ ) {
58
const
Trk::ITrackLink
* trackA = inputTracks.at( indexA );
59
60
for
(
unsigned
int
indexB(0); indexB<indexA; indexB++ ) {
61
const
Trk::ITrackLink
* trackB = inputTracks.at( indexB );
62
63
// Computing the Vertex candidate
64
xAOD::Vertex
*myCandidate =
computeVtxcandidate
( ctx,primaryVertex,jetMomentum,trackA,trackB );
65
if
( myCandidate ==
nullptr
)
continue
;
66
67
// Attaching tracks to vertex candidate
68
std::vector< const Trk::ITrackLink* > associatedTracksAtVertex;
69
associatedTracksAtVertex.push_back( trackA );
70
associatedTracksAtVertex.push_back( trackB );
71
m_tracksDecorator
( *myCandidate ) = std::move(associatedTracksAtVertex);
72
73
VtxCandidates.push_back( myCandidate );
74
}
75
}
76
77
78
ATH_MSG_DEBUG
(
"Found "
<< VtxCandidates.size() <<
" 2-trk vertex candidates!"
);
79
80
const
Trk::TwoTrackVerticesInJet
*twoTrackVerticesInJet =
new
Trk::TwoTrackVerticesInJet
( std::move(VtxCandidates),
81
std::vector< const Trk::TrackParticleBase* >() );
82
return
twoTrackVerticesInJet;
83
}
84
85
xAOD::Vertex
*
JetFitterTwoTrackVtxFinderTool::computeVtxcandidate
(
const
EventContext& ctx,
86
const
xAOD::Vertex
& primaryVertex,
87
const
TLorentzVector& jetMomentum,
88
const
Trk::ITrackLink
* trackA,
89
const
Trk::ITrackLink
* trackB )
const
{
90
91
const
Trk::TrackParameters
* perigeeTrackA = trackA->
parameters
();
92
const
Trk::TrackParameters
* perigeeTrackB = trackB->
parameters
();
93
94
std::vector< const Trk::TrackParameters* > perigeeToFit;
95
perigeeToFit.push_back( perigeeTrackA );
96
perigeeToFit.push_back( perigeeTrackB );
97
98
Amg::Vector3D
seedVertex;
99
try
{
100
seedVertex =
m_CrossDistancesSeedFinder
->findSeed( perigeeToFit );
101
102
if
( seedVertex.perp() >
m_maxR
||
103
fabs( seedVertex.z() ) >
m_maxZ
) {
104
ATH_MSG_DEBUG
(
"Vertex seed outside ID. R="
<< seedVertex.perp() <<
" Z="
<< seedVertex.z() );
105
seedVertex = primaryVertex.
position
();
106
}
107
108
}
catch
(...) {
109
ATH_MSG_DEBUG
(
"Seed finding failed. Using primary vertex as seed... (clearly not optimal)"
);
110
seedVertex =
Amg::Vector3D
( primaryVertex.
position
() );
111
}
112
113
ATH_MSG_DEBUG
(
"Seed: x="
<< seedVertex.x() <<
114
" y="
<< seedVertex.y() <<
115
" z="
<< seedVertex.z() );
116
117
118
// Compute V0 candidate
119
std::unique_ptr< xAOD::Vertex > myCandidate(
m_SequentialVertexFitter
->fit(ctx,perigeeToFit,seedVertex) );
120
121
// Check fit completed with success
122
if
( myCandidate ==
nullptr
) {
123
ATH_MSG_DEBUG
(
" Sequential fit failed. shouldn't happen... Skipping V0 candidate... "
);
124
return
nullptr
;
125
}
126
127
// Check ChiSquared and nDof
128
if
( myCandidate->
chiSquared
() < 0 ||
129
myCandidate->
numberDoF
() < 0 ) {
130
ATH_MSG_DEBUG
(
" Fit for V0 candidate failed: chi2 or ndf negative. Deleting candidate..."
);
131
return
nullptr
;
132
}
133
134
// Check two-vertex probability
135
if
( TMath::Prob( myCandidate->
chiSquared
(),myCandidate->
numberDoF
() ) <=
m_twoVertexProbabilityCut
) {
136
ATH_MSG_DEBUG
(
" Candidate not satisfying two-vertex probability "
);
137
return
nullptr
;
138
}
139
140
// Check sign and revertFromPositiveToNegativeTags
141
Amg::Vector3D
jetMomSpatial( jetMomentum.X(),jetMomentum.Y(),jetMomentum.Z() );
142
Amg::Vector3D
twoTrkVtxPos( myCandidate->
position
() );
143
double
sign
= ( twoTrkVtxPos-primaryVertex.
position
() ).dot( jetMomSpatial );
144
145
if
(
sign
>= 0 &&
m_revertFromPositiveToNegativeTags
) {
146
ATH_MSG_DEBUG
(
"Not satisfying sign and revertFromPositiveToNegativeTags requirements"
);
147
return
nullptr
;
148
}
149
150
ATH_MSG_DEBUG
(
" Candidate: x="
<< myCandidate->
x
() <<
151
" y="
<< myCandidate->
y
() <<
152
" z="
<< myCandidate->
z
() );
153
154
return
myCandidate.release();
155
}
156
157
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:28
CrossDistancesSeedFinder.h
TrackParticleContainer.h
JetFitterTwoTrackVtxFinderTool.h
LinkToTrackParticleBase.h
LinkToXAODTrackParticle.h
SequentialVertexFitter.h
sign
int sign(int a)
Definition
TRT_StrawNeighbourSvc.h:108
TrackParticleAuxContainer.h
AthAlgTool::AthAlgTool
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Definition
AthAlgTool.cxx:16
InDet::JetFitterTwoTrackVtxFinderTool::m_maxZ
Gaudi::Property< double > m_maxZ
Definition
JetFitterTwoTrackVtxFinderTool.h:52
InDet::JetFitterTwoTrackVtxFinderTool::m_CrossDistancesSeedFinder
ToolHandle< Trk::IVertexSeedFinder > m_CrossDistancesSeedFinder
Definition
JetFitterTwoTrackVtxFinderTool.h:46
InDet::JetFitterTwoTrackVtxFinderTool::m_revertFromPositiveToNegativeTags
Gaudi::Property< bool > m_revertFromPositiveToNegativeTags
Definition
JetFitterTwoTrackVtxFinderTool.h:54
InDet::JetFitterTwoTrackVtxFinderTool::JetFitterTwoTrackVtxFinderTool
JetFitterTwoTrackVtxFinderTool(const std::string &t, const std::string &n, const IInterface *p)
Definition
JetFitterTwoTrackVtxFinderTool.cxx:17
InDet::JetFitterTwoTrackVtxFinderTool::m_SequentialVertexFitter
ToolHandle< Trk::IVertexFitter > m_SequentialVertexFitter
Definition
JetFitterTwoTrackVtxFinderTool.h:47
InDet::JetFitterTwoTrackVtxFinderTool::m_maxR
Gaudi::Property< double > m_maxR
Definition
JetFitterTwoTrackVtxFinderTool.h:51
InDet::JetFitterTwoTrackVtxFinderTool::doVertexFinding
const Trk::TwoTrackVerticesInJet * doVertexFinding(const EventContext &ctx, const xAOD::Vertex &, const TLorentzVector &, std::vector< const Trk::ITrackLink * > &) const
Definition
JetFitterTwoTrackVtxFinderTool.cxx:47
InDet::JetFitterTwoTrackVtxFinderTool::finalize
StatusCode finalize()
Definition
JetFitterTwoTrackVtxFinderTool.cxx:42
InDet::JetFitterTwoTrackVtxFinderTool::m_twoVertexProbabilityCut
Gaudi::Property< double > m_twoVertexProbabilityCut
Definition
JetFitterTwoTrackVtxFinderTool.h:53
InDet::JetFitterTwoTrackVtxFinderTool::initialize
StatusCode initialize()
Definition
JetFitterTwoTrackVtxFinderTool.cxx:27
InDet::JetFitterTwoTrackVtxFinderTool::m_tracksDecorator
SG::AuxElement::Decorator< std::vector< const Trk::ITrackLink * > > m_tracksDecorator
Definition
JetFitterTwoTrackVtxFinderTool.h:49
InDet::JetFitterTwoTrackVtxFinderTool::computeVtxcandidate
xAOD::Vertex * computeVtxcandidate(const EventContext &ctx, const xAOD::Vertex &, const TLorentzVector &, const Trk::ITrackLink *trackA, const Trk::ITrackLink *trackB) const
Definition
JetFitterTwoTrackVtxFinderTool.cxx:85
InDet::JetFitterTwoTrackVtxFinderTool::~JetFitterTwoTrackVtxFinderTool
~JetFitterTwoTrackVtxFinderTool()
Trk::ITrackLink
An abstract class which is meant to represent an element link to the Trk::Track or Trk::TrackParticle...
Definition
ITrackLink.h:26
Trk::ITrackLink::parameters
virtual const TrackParameters * parameters() const =0
return the track parameters of the track or TrackParticleBase)
Trk::TwoTrackVerticesInJet
Definition
TwoTrackVerticesInJet.h:45
xAOD::Vertex_v1::z
float z() const
Returns the z position.
xAOD::Vertex_v1::y
float y() const
Returns the y position.
xAOD::Vertex_v1::numberDoF
float numberDoF() const
Returns the number of degrees of freedom of the vertex fit as float.
xAOD::Vertex_v1::chiSquared
float chiSquared() const
Returns the of the vertex fit as float.
xAOD::Vertex_v1::position
const Amg::Vector3D & position() const
Returns the 3-pos.
Definition
Vertex_v1.cxx:106
xAOD::Vertex_v1::x
float x() const
Returns the x position.
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition
GeoPrimitives.h:47
InDet
Primary Vertex Finder.
Definition
VP1ErrorUtils.h:36
Trk::TrackParameters
ParametersBase< TrackParametersDim, Charged > TrackParameters
Definition
Tracking/TrkEvent/TrkParameters/TrkParameters/TrackParameters.h:27
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