14 using namespace InDet;
25 declareInterface< JetFitterMultiStageFit >(
this);
38 return StatusCode::SUCCESS;
43 const TLorentzVector & jetMomentum,
44 const std::vector<const Trk::ITrackLink*> & firstInputTracks,
45 const std::vector<const Trk::ITrackLink*> & secondInputTracks,
48 Amg::Vector3D myDirection(jetMomentum.X(),jetMomentum.Y(),jetMomentum.Z());
50 std::vector<std::vector<const Trk::ITrackLink*> > bunchesOfTracks;
52 std::vector<const Trk::ITrackLink*> tracksToAdd;
54 std::vector<const Trk::ITrackLink*>::const_iterator tracks2Begin=firstInputTracks.begin();
55 std::vector<const Trk::ITrackLink*>::const_iterator tracks2End=firstInputTracks.end();
56 for (std::vector<const Trk::ITrackLink*>::const_iterator tracks2Iter=tracks2Begin;
57 tracks2Iter!=tracks2End;++tracks2Iter) {
58 tracksToAdd.push_back(*tracks2Iter);
61 bunchesOfTracks.push_back(tracksToAdd);
64 std::vector<const Trk::ITrackLink*>::const_iterator tracks3Begin=secondInputTracks.begin();
65 std::vector<const Trk::ITrackLink*>::const_iterator tracks3End=secondInputTracks.end();
66 for (std::vector<const Trk::ITrackLink*>::const_iterator tracks3Iter=tracks3Begin;
67 tracks3Iter!=tracks3End;++tracks3Iter) {
68 tracksToAdd.push_back(*tracks3Iter);
71 if (!tracksToAdd.empty())
73 bunchesOfTracks.push_back(tracksToAdd);
82 std::vector<std::vector<const Trk::ITrackLink*> >::const_iterator BunchesBegin=bunchesOfTracks.begin();
83 std::vector<std::vector<const Trk::ITrackLink*> >::const_iterator BunchesEnd=bunchesOfTracks.end();
85 std::vector<const Trk::ITrackLink*>::const_iterator tracksToAddBegin;
86 std::vector<const Trk::ITrackLink*>::const_iterator tracksToAddEnd;
87 std::vector<const Trk::ITrackLink*>::const_iterator tracksToAddIter;
92 for (std::vector<std::vector<const Trk::ITrackLink*> >::const_iterator BunchesIter=BunchesBegin;
93 BunchesIter!=BunchesEnd;++BunchesIter) {
95 if (BunchesIter == BunchesBegin) {
96 ATH_MSG_VERBOSE(
" initial fit with " << (*BunchesIter).size() <<
" tracks ");
97 myJetCandidate =
m_initializationHelper->initializeJetCandidate(*BunchesIter, &primaryVertex, &myDirection,
99 m_routines->initializeToMinDistancesToJetAxis(myJetCandidate);
100 if (!(*BunchesIter).empty()) {
109 ATH_MSG_VERBOSE(
" other fit with " << (*BunchesIter).size() <<
" tracks ");
111 std::vector<Trk::VxTrackAtVertex*>* setOfTracks=myJetCandidate->
vxTrackAtVertex();
112 tracksToAddBegin=(*BunchesIter).begin();
113 tracksToAddEnd=(*BunchesIter).end();
115 for (tracksToAddIter=tracksToAddBegin;tracksToAddIter!=tracksToAddEnd;++tracksToAddIter) {
116 std::vector<Trk::VxTrackAtVertex*> temp_vector_tracksAtVertex;
118 temp_vector_tracksAtVertex.push_back(newVxTrack);
119 setOfTracks->push_back(newVxTrack);
125 ATH_MSG_VERBOSE(
" new overall number of tracks (vertices?) to fit : " << setOfVertices.size());
129 m_routines->initializeToMinDistancesToJetAxis(myJetCandidate);
138 return myJetCandidate;
143 bool performClustering)
const {
145 int numClusteringLoops=0;
146 bool noMoreVerticesToCluster(
false);
151 bool noMoreTracksToDelete(
false);
154 m_routines->performTheFit(myJetCandidate, 15,
false, 30, 0.001);
158 std::vector<Trk::VxVertexOnJetAxis *>::const_iterator verticesBegin = vertices.begin();
159 std::vector<Trk::VxVertexOnJetAxis *>::const_iterator verticesEnd = vertices.end();
165 for (std::vector<Trk::VxVertexOnJetAxis *>::const_iterator verticesIter = verticesBegin;
166 verticesIter != verticesEnd; ++verticesIter) {
167 if (*verticesIter ==
nullptr) {
168 ATH_MSG_WARNING(
"One vertex is empy. Problem when trying to delete incompatible vertices. No further vertices deleted.");
174 worseVertex = *verticesIter;
185 m_routines->deleteVertexFromJetCandidate(worseVertex, myJetCandidate);
189 noMoreTracksToDelete =
true;
190 ATH_MSG_VERBOSE(
"No tracks to delete: maximum probability is " << max_prob);
196 if (!performClustering)
break;
200 m_routines->fillTableWithFullProbOfMerging(myJetCandidate,8,
false,10,0.01);
204 m_routines->fillTableWithFastProbOfMerging(myJetCandidate);
209 if (clusteringTablePtr==
nullptr) {
210 ATH_MSG_WARNING(
" No Clustering Table while it should have been calculated... no more clustering performed during vertexing ");
211 noMoreVerticesToCluster=
true;
218 float probVertex(0.);
224 float probVertexExcludingPrimary(0.);
228 bool firstProbIsWithPrimary= ( fabs(probVertex-probVertexExcludingPrimary)>1
e-6 );
233 ATH_MSG_VERBOSE(
" merging vtx number " << (*pairOfVxVertexOnJetAxis.first).getNumVertex() <<
234 " and " << (*pairOfVxVertexOnJetAxis.second).getNumVertex() <<
" (should be PV).");
236 m_helper->mergeVerticesInJetCandidate(*pairOfVxVertexOnJetAxis.first,
237 *pairOfVxVertexOnJetAxis.second,
246 if (probVertexExcludingPrimary>0.) {
252 CLHEP::HepLorentzVector massVector1 =
m_jetFitterUtils->fourMomentumAtVertex(*firstVertex);
253 CLHEP::HepLorentzVector massVector2 =
m_jetFitterUtils->fourMomentumAtVertex(*secondVertex);
255 CLHEP::HepLorentzVector sumMassVector = massVector1 + massVector2;
257 double massTwoVertex = sumMassVector.mag();
262 double vertexClusteringProbabilityCutWithMass =
265 ATH_MSG_DEBUG(
"m="<<massTwoVertex<<
" prob="<<vertexClusteringProbabilityCutWithMass);
267 if (probVertexExcludingPrimary > vertexClusteringProbabilityCutWithMass) {
274 ATH_MSG_VERBOSE(
" merging vtx number " << (*pairOfVxVertexOnJetAxis.first).getNumVertex() <<
275 " and " << (*pairOfVxVertexOnJetAxis.second).getNumVertex() <<
" mass merged vertex: " << massTwoVertex);
277 m_helper->mergeVerticesInJetCandidate(*pairOfVxVertexOnJetAxisExcludingPrimary.first,
278 *pairOfVxVertexOnJetAxisExcludingPrimary.second,
286 noMoreVerticesToCluster=
true;
290 numClusteringLoops+=1;