ATLAS Offline Software
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 
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 
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 
xAOD::Vertex_v1::x
float x() const
Returns the x position.
InDet::JetFitterTwoTrackVtxFinderTool::m_maxZ
Gaudi::Property< double > m_maxZ
Definition: JetFitterTwoTrackVtxFinderTool.h:50
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
InDet
DUMMY Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
InDet::JetFitterTwoTrackVtxFinderTool::m_maxR
Gaudi::Property< double > m_maxR
Definition: JetFitterTwoTrackVtxFinderTool.h:49
InDet::JetFitterTwoTrackVtxFinderTool::~JetFitterTwoTrackVtxFinderTool
~JetFitterTwoTrackVtxFinderTool()
xAOD::Vertex_v1::position
const Amg::Vector3D & position() const
Returns the 3-pos.
InDet::JetFitterTwoTrackVtxFinderTool::m_tracksDecorator
SG::AuxElement::Decorator< std::vector< const Trk::ITrackLink * > > m_tracksDecorator
Definition: JetFitterTwoTrackVtxFinderTool.h:47
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
InDet::JetFitterTwoTrackVtxFinderTool::initialize
StatusCode initialize()
Definition: JetFitterTwoTrackVtxFinderTool.cxx:27
InDet::JetFitterTwoTrackVtxFinderTool::m_revertFromPositiveToNegativeTags
Gaudi::Property< bool > m_revertFromPositiveToNegativeTags
Definition: JetFitterTwoTrackVtxFinderTool.h:52
InDet::JetFitterTwoTrackVtxFinderTool::m_twoVertexProbabilityCut
Gaudi::Property< double > m_twoVertexProbabilityCut
Definition: JetFitterTwoTrackVtxFinderTool.h:51
InDet::JetFitterTwoTrackVtxFinderTool::JetFitterTwoTrackVtxFinderTool
JetFitterTwoTrackVtxFinderTool(const std::string &t, const std::string &n, const IInterface *p)
Definition: JetFitterTwoTrackVtxFinderTool.cxx:17
Trk::TwoTrackVerticesInJet
Definition: TwoTrackVerticesInJet.h:45
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LinkToXAODTrackParticle.h
TrackParticleAuxContainer.h
python.TrigInDetConfig.inputTracks
inputTracks
Definition: TrigInDetConfig.py:168
beamspotman.n
n
Definition: beamspotman.py:731
InDet::JetFitterTwoTrackVtxFinderTool::m_SequentialVertexFitter
ToolHandle< Trk::IVertexFitter > m_SequentialVertexFitter
Definition: JetFitterTwoTrackVtxFinderTool.h:45
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
sign
int sign(int a)
Definition: TRT_StrawNeighbourSvc.h:127
Trk::ParametersBase
Definition: ParametersBase.h:55
xAOD::Vertex_v1::z
float z() const
Returns the z position.
InDet::JetFitterTwoTrackVtxFinderTool::finalize
StatusCode finalize()
Definition: JetFitterTwoTrackVtxFinderTool.cxx:42
dot.dot
def dot(G, fn, nodesToHighlight=[])
Definition: dot.py:5
LinkToTrackParticleBase.h
InDet::JetFitterTwoTrackVtxFinderTool::m_CrossDistancesSeedFinder
ToolHandle< Trk::IVertexSeedFinder > m_CrossDistancesSeedFinder
Definition: JetFitterTwoTrackVtxFinderTool.h:44
SequentialVertexFitter.h
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
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
Class describing a Vertex.
Definition: Vertex_v1.h:42
xAOD::Vertex_v1::y
float y() const
Returns the y position.
CrossDistancesSeedFinder.h
InDet::JetFitterTwoTrackVtxFinderTool::computeVtxcandidate
xAOD::Vertex * computeVtxcandidate(const xAOD::Vertex &, const TLorentzVector &, const Trk::ITrackLink *trackA, const Trk::ITrackLink *trackB) const
Definition: JetFitterTwoTrackVtxFinderTool.cxx:84
InDet::JetFitterTwoTrackVtxFinderTool::doVertexFinding
const Trk::TwoTrackVerticesInJet * doVertexFinding(const xAOD::Vertex &, const TLorentzVector &, std::vector< const Trk::ITrackLink * > &) const
Definition: JetFitterTwoTrackVtxFinderTool.cxx:47
JetFitterTwoTrackVtxFinderTool.h
AthAlgTool
Definition: AthAlgTool.h:26
TrackParticleContainer.h