ATLAS Offline Software
Loading...
Searching...
No Matches
JetFitterTwoTrackVtxFinderTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6
9
14
15using namespace InDet;
16
17JetFitterTwoTrackVtxFinderTool::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
25
26
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
43 return StatusCode::SUCCESS;
44}
45
46
48 const TLorentzVector& jetMomentum,
49 std::vector< const Trk::ITrackLink* >& inputTracks) const {
50
51 std::vector< const xAOD::Vertex* > VtxCandidates;
52
53 ATH_MSG_DEBUG( "Looping over " << inputTracks.size() << " input tracks... " );
54
55 // Loop over all the combinations
56 for ( unsigned int indexA(0); indexA<inputTracks.size(); indexA++ ) {
57 const Trk::ITrackLink* trackA = inputTracks.at( indexA );
58
59 for ( unsigned int indexB(0); indexB<indexA; indexB++ ) {
60 const Trk::ITrackLink* trackB = inputTracks.at( indexB );
61
62 // Computing the Vertex candidate
63 xAOD::Vertex *myCandidate = computeVtxcandidate( primaryVertex,jetMomentum,trackA,trackB );
64 if ( myCandidate == nullptr ) continue;
65
66 // Attaching tracks to vertex candidate
67 std::vector< const Trk::ITrackLink* > associatedTracksAtVertex;
68 associatedTracksAtVertex.push_back( trackA );
69 associatedTracksAtVertex.push_back( trackB );
70 m_tracksDecorator ( *myCandidate ) = associatedTracksAtVertex;
71
72 VtxCandidates.push_back( myCandidate );
73 }
74 }
75
76
77 ATH_MSG_DEBUG( "Found " << VtxCandidates.size() <<" 2-trk vertex candidates!" );
78
79 const Trk::TwoTrackVerticesInJet *twoTrackVerticesInJet = new Trk::TwoTrackVerticesInJet ( VtxCandidates,
80 std::vector< const Trk::TrackParticleBase* >() );
81 return twoTrackVerticesInJet;
82}
83
85 const TLorentzVector& jetMomentum,
86 const Trk::ITrackLink* trackA,
87 const Trk::ITrackLink* trackB ) const {
88
89 const Trk::TrackParameters* perigeeTrackA = trackA->parameters();
90 const Trk::TrackParameters* perigeeTrackB = trackB->parameters();
91
92 std::vector< const Trk::TrackParameters* > perigeeToFit;
93 perigeeToFit.push_back( perigeeTrackA );
94 perigeeToFit.push_back( perigeeTrackB );
95
96 Amg::Vector3D seedVertex;
97 try {
98 seedVertex = m_CrossDistancesSeedFinder->findSeed( perigeeToFit );
99
100 if ( seedVertex.perp() > m_maxR ||
101 fabs( seedVertex.z() ) > m_maxZ ) {
102 ATH_MSG_DEBUG( "Vertex seed outside ID. R=" << seedVertex.perp() << " Z=" << seedVertex.z() );
103 seedVertex = primaryVertex.position();
104 }
105
106 } catch (...) {
107 ATH_MSG_DEBUG( "Seed finding failed. Using primary vertex as seed... (clearly not optimal)" );
108 seedVertex = Amg::Vector3D( primaryVertex.position() );
109 }
110
111 ATH_MSG_DEBUG( "Seed: x=" << seedVertex.x() <<
112 " y=" << seedVertex.y() <<
113 " z=" << seedVertex.z() );
114
115
116 // Compute V0 candidate
117 std::unique_ptr< xAOD::Vertex > myCandidate( m_SequentialVertexFitter->fit(perigeeToFit,seedVertex) );
118
119 // Check fit completed with success
120 if ( myCandidate == nullptr ) {
121 ATH_MSG_DEBUG( " Sequential fit failed. shouldn't happen... Skipping V0 candidate... " );
122 return nullptr;
123 }
124
125 // Check ChiSquared and nDof
126 if ( myCandidate->chiSquared() < 0 ||
127 myCandidate->numberDoF() < 0 ) {
128 ATH_MSG_DEBUG( " Fit for V0 candidate failed: chi2 or ndf negative. Deleting candidate..." );
129 return nullptr;
130 }
131
132 // Check two-vertex probability
133 if ( TMath::Prob( myCandidate->chiSquared(),myCandidate->numberDoF() ) <= m_twoVertexProbabilityCut ) {
134 ATH_MSG_DEBUG( " Candidate not satisfying two-vertex probability " );
135 return nullptr;
136 }
137
138 // Check sign and revertFromPositiveToNegativeTags
139 Amg::Vector3D jetMomSpatial( jetMomentum.X(),jetMomentum.Y(),jetMomentum.Z() );
140 Amg::Vector3D twoTrkVtxPos( myCandidate->position() );
141 double sign = ( twoTrkVtxPos-primaryVertex.position() ).dot( jetMomSpatial );
142
144 ATH_MSG_DEBUG( "Not satisfying sign and revertFromPositiveToNegativeTags requirements" );
145 return nullptr;
146 }
147
148 ATH_MSG_DEBUG( " Candidate: x=" << myCandidate->x() <<
149 " y=" << myCandidate->y() <<
150 " z=" << myCandidate->z() );
151
152 return myCandidate.release();
153}
154
155
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
int sign(int a)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
ToolHandle< Trk::IVertexSeedFinder > m_CrossDistancesSeedFinder
JetFitterTwoTrackVtxFinderTool(const std::string &t, const std::string &n, const IInterface *p)
const Trk::TwoTrackVerticesInJet * doVertexFinding(const xAOD::Vertex &, const TLorentzVector &, std::vector< const Trk::ITrackLink * > &) const
ToolHandle< Trk::IVertexFitter > m_SequentialVertexFitter
xAOD::Vertex * computeVtxcandidate(const xAOD::Vertex &, const TLorentzVector &, const Trk::ITrackLink *trackA, const Trk::ITrackLink *trackB) const
SG::AuxElement::Decorator< std::vector< const Trk::ITrackLink * > > m_tracksDecorator
float z() const
Returns the z position.
float y() const
Returns the y position.
float numberDoF() const
Returns the number of degrees of freedom of the vertex fit as float.
float chiSquared() const
Returns the of the vertex fit as float.
const Amg::Vector3D & position() const
Returns the 3-pos.
float x() const
Returns the x position.
Eigen::Matrix< double, 3, 1 > Vector3D
Primary Vertex Finder.
ParametersBase< TrackParametersDim, Charged > TrackParameters
Vertex_v1 Vertex
Define the latest version of the vertex class.