43 struct TrackParticle_pair
66 declareInterface< ISecVertexInJetFinder >(
this) ;
81 return StatusCode::SUCCESS;
86 const TLorentzVector & jetMomentum,
87 const std::vector<const Trk::TrackParticleBase*> & myTracks)
const {
88 Amg::Vector3D myDirection(jetMomentum.Vect().X(),jetMomentum.Vect().Y(),jetMomentum.Vect().Z());
90 std::vector<TrackParticle_pair> tracks;
92 std::vector<const Trk::TrackParticleBase*>::const_iterator tracksBegin=myTracks.begin();
93 std::vector<const Trk::TrackParticleBase*>::const_iterator tracksEnd=myTracks.end();
94 for (std::vector<const Trk::TrackParticleBase*>::const_iterator tracksIter=tracksBegin;
95 tracksIter!=tracksEnd;++tracksIter) {
96 if (
m_trkFilter->decision(**tracksIter,&primaryVertex)) {
97 tracks.emplace_back((*tracksIter)->perigee()->momentum().perp(),*tracksIter);
101 std::vector<std::vector<const Trk::TrackParticleBase*> > bunchesOfTracks;
103 std::sort(tracks.begin(),tracks.end());
105 std::vector<const Trk::TrackParticleBase*> tracksToAdd;
107 std::vector<TrackParticle_pair>::const_iterator tracks2Begin=tracks.begin();
108 std::vector<TrackParticle_pair>::const_iterator tracks2End=tracks.end();
109 for (std::vector<TrackParticle_pair>::const_iterator tracks2Iter=tracks2Begin;
110 tracks2Iter!=tracks2End;++tracks2Iter) {
113 tracksToAdd.push_back((*tracks2Iter).second);
116 bunchesOfTracks.push_back(tracksToAdd);
121 bunchesOfTracks.push_back(tracksToAdd);
123 std::vector<std::vector<const Trk::TrackParticleBase*> >::const_iterator BunchesBegin=bunchesOfTracks.begin();
124 std::vector<std::vector<const Trk::TrackParticleBase*> >::const_iterator BunchesEnd=bunchesOfTracks.end();
126 std::vector<const Trk::TrackParticleBase*>::const_iterator tracksToAddBegin;
127 std::vector<const Trk::TrackParticleBase*>::const_iterator tracksToAddEnd;
128 std::vector<const Trk::TrackParticleBase*>::const_iterator tracksToAddIter;
133 for (std::vector<std::vector<const Trk::TrackParticleBase*> >::const_iterator BunchesIter=BunchesBegin;
134 BunchesIter!=BunchesEnd;++BunchesIter) {
136 if (BunchesIter==BunchesBegin) {
139 m_routines->initializeToMinDistancesToJetAxis(myJetCandidate);
144 std::vector<Trk::VxTrackAtVertex*>* setOfTracks=myJetCandidate->
vxTrackAtVertex();
145 tracksToAddBegin=(*BunchesIter).begin();
146 tracksToAddEnd=(*BunchesIter).end();
147 for (tracksToAddIter=tracksToAddBegin;tracksToAddIter!=tracksToAddEnd;++tracksToAddIter) {
148 std::vector<Trk::VxTrackAtVertex*> temp_vector_tracksAtVertex;
153 temp_vector_tracksAtVertex.push_back(newVxTrack);
154 setOfTracks->push_back(newVxTrack);
164 std::vector<Trk::VxCandidate*> myCandidates;
165 myCandidates.push_back(myJetCandidate);
173 const TLorentzVector & jetMomentum,
174 const std::vector<const Trk::TrackParticleBase*> & firstInputTracks,
175 const std::vector<const Trk::TrackParticleBase*> & secondInputTracks,
179 Amg::Vector3D myDirection(jetMomentum.Vect().X(),jetMomentum.Vect().Y(),jetMomentum.Vect().Z());
181 std::vector<std::vector<const Trk::TrackParticleBase*> > bunchesOfTracks;
183 std::vector<const Trk::TrackParticleBase*> tracksToAdd;
185 std::vector<const Trk::TrackParticleBase*>::const_iterator tracks2Begin=firstInputTracks.begin();
186 std::vector<const Trk::TrackParticleBase*>::const_iterator tracks2End=firstInputTracks.end();
187 for (std::vector<const Trk::TrackParticleBase*>::const_iterator tracks2Iter=tracks2Begin;
188 tracks2Iter!=tracks2End;++tracks2Iter) {
190 tracksToAdd.push_back(*tracks2Iter);
193 bunchesOfTracks.push_back(tracksToAdd);
196 std::vector<const Trk::TrackParticleBase*>::const_iterator tracks3Begin=secondInputTracks.begin();
197 std::vector<const Trk::TrackParticleBase*>::const_iterator tracks3End=secondInputTracks.end();
198 for (std::vector<const Trk::TrackParticleBase*>::const_iterator tracks3Iter=tracks3Begin;
199 tracks3Iter!=tracks3End;++tracks3Iter) {
201 tracksToAdd.push_back(*tracks3Iter);
204 if (!tracksToAdd.empty())
206 bunchesOfTracks.push_back(tracksToAdd);
216 std::vector<std::vector<const Trk::TrackParticleBase*> >::const_iterator BunchesBegin=bunchesOfTracks.begin();
217 std::vector<std::vector<const Trk::TrackParticleBase*> >::const_iterator BunchesEnd=bunchesOfTracks.end();
219 std::vector<const Trk::TrackParticleBase*>::const_iterator tracksToAddBegin;
220 std::vector<const Trk::TrackParticleBase*>::const_iterator tracksToAddEnd;
221 std::vector<const Trk::TrackParticleBase*>::const_iterator tracksToAddIter;
226 for (std::vector<std::vector<const Trk::TrackParticleBase*> >::const_iterator BunchesIter=BunchesBegin;
227 BunchesIter!=BunchesEnd;++BunchesIter) {
229 if (BunchesIter==BunchesBegin) {
231 myJetCandidate=
m_initializationHelper->initializeJetCandidate(*BunchesIter,&primaryVertex,&myDirection,&vtxSeedDirection);
232 m_routines->initializeToMinDistancesToJetAxis(myJetCandidate);
233 if (!(*BunchesIter).empty())
240 std::vector<Trk::VxTrackAtVertex*>* setOfTracks=myJetCandidate->
vxTrackAtVertex();
241 tracksToAddBegin=(*BunchesIter).begin();
242 tracksToAddEnd=(*BunchesIter).end();
243 for (tracksToAddIter=tracksToAddBegin;tracksToAddIter!=tracksToAddEnd;++tracksToAddIter) {
244 std::vector<Trk::VxTrackAtVertex*> temp_vector_tracksAtVertex;
249 temp_vector_tracksAtVertex.push_back(newVxTrack);
250 setOfTracks->push_back(newVxTrack);
256 m_routines->initializeToMinDistancesToJetAxis(myJetCandidate);
261 std::vector<Trk::VxCandidate*> myCandidates;
262 myCandidates.push_back(myJetCandidate);
270 bool performClustering)
const {
273 int numClusteringLoops=0;
274 bool noMoreVerticesToCluster(
false);
281 bool noMoreTracksToDelete(
false);
288 std::vector<Trk::VxVertexOnJetAxis*>::const_iterator verticesBegin=vertices.begin();
289 std::vector<Trk::VxVertexOnJetAxis*>::const_iterator verticesEnd=vertices.end();
295 for (std::vector<Trk::VxVertexOnJetAxis*>::const_iterator verticesIter=verticesBegin;
296 verticesIter!=verticesEnd;++verticesIter) {
297 if (*verticesIter==
nullptr) {
298 if (
msgLvl(MSG::WARNING))
msg() <<
"One vertex is empy. Problem when trying to delete incompatible vertices. No further vertices deleted." <<
endmsg;
303 worseVertex=*verticesIter;
308 if (
msgLvl(
MSG::DEBUG))
msg() <<
"Deleted vertex " << worseVertex->getNumVertex() <<
" with probability " << max_prob <<
endmsg;
311 if (
msgLvl(MSG::INFO))
msg() <<
" The most incompatible vertex is the primary vertex. Please check..." <<
endmsg;
314 m_routines->deleteVertexFromJetCandidate(worseVertex,myJetCandidate);
317 noMoreTracksToDelete=
true;
324 if (!performClustering)
break;
327 m_routines->fillTableWithFullProbOfMerging(myJetCandidate,5,
false,10,0.01);
329 m_routines->fillTableWithFastProbOfMerging(myJetCandidate);
336 if (clusteringTablePtr==
nullptr) {
337 if (
msgLvl(MSG::WARNING))
msg() <<
" No Clustering Table while it should have been calculated... no more clustering performed during vertexing " <<
endmsg;
338 noMoreVerticesToCluster=
true;
344 float probVertex(0.);
349 if (
msgLvl(
MSG::VERBOSE))
msg() <<
" merging vtx number " << (*pairOfVxVertexOnJetAxis.first).getNumVertex() <<
350 " and " << (*pairOfVxVertexOnJetAxis.second).getNumVertex() <<
endmsg;
352 m_helper->mergeVerticesInJetCandidate(*pairOfVxVertexOnJetAxis.first,
353 *pairOfVxVertexOnJetAxis.second,
359 noMoreVerticesToCluster=
true;
362 numClusteringLoops+=1;