place all tracks in the origTrack vector and initially all in the seedTrack vector
122 {
125 theVertexContainer->setStore(theVertexAuxContainer);
126
129 static const xAOD::Vertex::Decorator<bool> isInitialized("isInitialized");
131
132 std::vector<xAODVertex_pair> myxAODVertices;
133
134 std::vector<Trk::TrackToVtxLink*> myTrackToVtxLinks;
135
137 std::vector<Trk::ITrackLink*> origTracks = trackVector;
138 std::vector<Trk::ITrackLink*> seedTracks = trackVector;
139
140
141 std::map<Trk::ITrackLink*, Trk::TrackToVtxLink*> TrackLinkOf;
142
143
144
145
146 for (Trk::ITrackLink* trkIter : origTracks) {
147 Trk::TrackToVtxLink* newTrkToVtxLink(new Trk::TrackToVtxLink(new std::vector<xAOD::Vertex*>));
148
149 TrackLinkOf[trkIter] = newTrkToVtxLink;
150 myTrackToVtxLinks.push_back(newTrkToVtxLink);
151 }
152
153 int iteration = 0;
154 unsigned int seedtracknumber = seedTracks.size();
155
156 do {
157 if (seedtracknumber == 0) {
ATH_MSG_DEBUG(
"New iteration. No tracks available after track selection for seeding."); }
158
159 iteration += 1;
160 ATH_MSG_DEBUG(
"Iteration number " << iteration <<
" and tracks left for seeding " << seedtracknumber);
161
162 std::vector<const Trk::TrackParameters*> perigeeList;
163
164 perigeeList.reserve(seedTracks.size());
165for (
const Trk::ITrackLink* seedtrkAtVtxIter : seedTracks) { perigeeList.push_back((seedtrkAtVtxIter)->
parameters()); }
166
168
169 std::unique_ptr<Trk::IMode3dInfo>
info;
172
173 ATH_MSG_DEBUG(
"Found seed at x: " << seedVertex.x() <<
" at y: " << seedVertex.y() <<
" at z: " << seedVertex.z());
174
176 theVertexContainer->
push_back(seededxAODVertex);
179 looseConstraintCovariance.setIdentity();
180 looseConstraintCovariance = looseConstraintCovariance * 1
e+8;
182 seededxAODVertex->
vxTrackAtVertex() = std::vector<Trk::VxTrackAtVertex>();
184
185 if (seedVertex.z() == 0) {
186 ATH_MSG_DEBUG(
"No good seed found: no further vertices in event");
187 ATH_MSG_DEBUG(
"Number of input tracks: " << perigeeList.size() <<
", but no good seed returned");
188 break;
189 }
190
192 looseConstraintCovariance.setIdentity();
193 looseConstraintCovariance = looseConstraintCovariance * 1
e+8;
200
204
205 MvfFitInfo(*actualCandidate) =
207 isInitialized(*actualCandidate) = false;
208 std::vector<Trk::VxTrackAtVertex*> vectorOfTracks(0);
209 VTAV(*actualCandidate) = vectorOfTracks;
210
211 for (Trk::ITrackLink* trkIter : origTracks) {
212
215 Trk::TrackToVtxLink* actualLink = TrackLinkOf[trkIter];
216 std::vector<xAOD::Vertex*>* actualvtxlink = actualLink->
vertices();
217
218 actualvtxlink->push_back(actualCandidate);
219 VTAV(*actualCandidate).push_back(new Trk::MVFVxTrackAtVertex((trkIter)->clone(), actualLink));
220 }
221 }
222
223 ATH_MSG_DEBUG(
" Considering n. " << VTAV(*actualCandidate).size() <<
" tracks for the fit. ");
224
225 if (VTAV(*actualCandidate).size() < 2) {
226 ATH_MSG_DEBUG(
"No tracks found near seed, while at least two tracks were expected.");
227
228 if (VTAV.isAvailable(*actualCandidate)) {
229 for (auto *tav : VTAV(*actualCandidate)) {
230 if (tav == nullptr) continue;
231
232 (static_cast<Trk::MVFVxTrackAtVertex*>(tav))->setLinkToVertices(nullptr);
233 delete tav;
234 tav = nullptr;
235 }
236 VTAV(*actualCandidate).clear();
237 }
238 if (MvfFitInfo.isAvailable(*actualCandidate) && MvfFitInfo(*actualCandidate) != nullptr) {
239 delete MvfFitInfo(*actualCandidate);
240 MvfFitInfo(*actualCandidate) = nullptr;
241 }
242 delete actualCandidate;
243 actualCandidate = nullptr;
244
245 break;
246 }
247
249
251
252 ATH_MSG_DEBUG(
"Deleting tracks with really good fit to vertex from seeding tracks.");
254
255 ATH_MSG_DEBUG(
"Found and deleted " << nFound <<
" tracks from seeding tracks.");
256 if (nFound == 0) {
257 ATH_MSG_DEBUG(
"All tracks used for fitting came from fiting tracks, removing closest from seeding.");
258
259
260
262 }
263
264 if (nFound == 0) {
265 ATH_MSG_DEBUG(
"You still have not removed any tracks from seeds! Aborting.");
266 break;
267 }
268
270 bool goodVertex =
checkFit(actualCandidate);
271
272 if (!goodVertex) {
273 ATH_MSG_DEBUG(
"Bad vertex, deleting the vertex and clearing all pointers");
274
276
277 if (actualCandidate) {
278 if (VTAV.isAvailable(*actualCandidate)) {
279 for (auto *tav : VTAV(*actualCandidate)) {
280 if (tav == nullptr) continue;
281
282 (static_cast<Trk::MVFVxTrackAtVertex*>(tav))->setLinkToVertices(nullptr);
283 delete tav;
284 tav = nullptr;
285 }
286 VTAV(*actualCandidate).clear();
287 }
288 if (MvfFitInfo.isAvailable(*actualCandidate) && MvfFitInfo(*actualCandidate) != nullptr) {
289 delete MvfFitInfo(*actualCandidate);
290 MvfFitInfo(*actualCandidate) = nullptr;
291 }
292
293 delete actualCandidate;
294 actualCandidate = nullptr;
295 }
296
297 } else {
299
302 myxAODVertices.emplace_back(0, actualCandidate);
303 }
304 seedtracknumber = seedTracks.size();
306
309 <<
m_maxIterations <<
") reached; to reconstruct more vertices, set maxIterations to a higher value.");
310 }
311
312 ATH_MSG_DEBUG(
"Secondary vertex finding complete with " << iteration <<
" iterations and " << myxAODVertices.size()
313 << " vertices found.");
314
315 for (const xAODVertex_pair& vtxIter : myxAODVertices) {
317
324
325 std::vector<Trk::VxTrackAtVertex>* tracksOfVertex = &(cand->
vxTrackAtVertex());
326 tracksOfVertex->clear();
327
328 for (Trk::VxTrackAtVertex* MVFtrkIter : VTAV(*fittedVert)) {
329 if ((*MVFtrkIter).initialPerigee()) { (*MVFtrkIter).setPerigeeAtVertex(((*MVFtrkIter).initialPerigee())->clone()); }
330 tracksOfVertex->push_back(*MVFtrkIter);
331 }
332 }
333
334 for (const xAODVertex_pair& vtxIter : myxAODVertices) {
336
337 for (Trk::VxTrackAtVertex* MVFtrkIter : VTAV(*cand)) {
338 (static_cast<Trk::MVFVxTrackAtVertex*>(MVFtrkIter))->setLinkToVertices(nullptr);
339 delete MVFtrkIter;
340 MVFtrkIter = nullptr;
341 }
342
343 delete MvfFitInfo(*cand);
344 }
345
347
349 std::vector<Trk::VxTrackAtVertex>* myVxTracksAtVtx = &((vxIter)->vxTrackAtVertex());
350 if (!myVxTracksAtVtx) continue;
351
352 for (Trk::VxTrackAtVertex& tracksIter : *myVxTracksAtVtx) {
353 Trk::LinkToXAODTrackParticle* linkToXAODTP = nullptr;
354 Trk::ITrackLink* tmpLink = (tracksIter).trackOrParticleLink();
356 linkToXAODTP = static_cast<Trk::LinkToXAODTrackParticle*>(tmpLink);
357 }
358
359 if (linkToXAODTP) { (vxIter)->addTrackAtVertex(*linkToXAODTP, (tracksIter).
weight()); }
360 }
361
362 int ntrk = myVxTracksAtVtx->size();
363 if (ntrk == 2) {
365
367 if (isV0) {
370 }
371 }
372 }
373
374
375 for (Trk::TrackToVtxLink* iterator : myTrackToVtxLinks) {
delete iterator; }
376
377 if (!theVertexContainer->empty()) {
382 theVertexContainer->push_back(dummyxAODVertex);
385 dummyxAODVertex->
vxTrackAtVertex() = std::vector<Trk::VxTrackAtVertex>();
387 } else {
389 }
390 }
391
392 else if (theVertexContainer->empty()) {
394 theVertexContainer->push_back(dummyxAODVertex);
397 looseConstraintCovariance.setIdentity();
398 looseConstraintCovariance = looseConstraintCovariance * 1
e+8;
400 dummyxAODVertex->
vxTrackAtVertex() = std::vector<Trk::VxTrackAtVertex>();
402 }
403
404 int noVtx = 0;
405 int kinkVtx = 0;
406 int notSpec = 0;
407 int secVtx = 0;
408 int V0vtx = 0;
409 for (
unsigned int i = 0;
i < theVertexContainer->size();
i++) {
412 switch (vtxType) {
419 }
420
421 ATH_MSG_DEBUG(
" Vtx: " << i <<
" x= " << (*theVertexContainer)[i]->position().
x() <<
" y= "
422 << (*theVertexContainer)[i]->position().
y() <<
" z= " << (*theVertexContainer)[i]->position().
z()
423 <<
" ntracks= " << (*theVertexContainer)[i]->vxTrackAtVertex().
size() <<
" chi2= "
424 << (*theVertexContainer)[i]->
chiSquared() <<
" #dof = " << (*theVertexContainer)[i]->numberDoF());
425 }
426
427 ATH_MSG_DEBUG(
"Done finding " << theVertexContainer->size() <<
" vertices and cleaning the container.");
428 ATH_MSG_DEBUG(
"Seeds good/bad/all : " << noVtx <<
"/" << kinkVtx <<
"/" << notSpec);
429 ATH_MSG_DEBUG(
"'Good' secondaries : " << secVtx <<
" and V0: " << V0vtx);
430
431 return std::make_pair(theVertexContainer, theVertexAuxContainer);
432 }
value_type push_back(value_type pElem)
Add an element to the end of the collection.
void makePrivateStore()
Create a new (empty) private store for this object.
virtual ITrackLinkType type() const =0
return the type
const std::vector< xAOD::Vertex * > * vertices(void) const
Const access to the vertex list.
void setCovariancePosition(const AmgSymMatrix(3)&covariancePosition)
Sets the vertex covariance matrix.
void setVertexType(VxType::VertexType vType)
Set the type of the vertex.
void setPosition(const Amg::Vector3D &position)
Sets the 3-position.
float chiSquared() const
Returns the of the vertex fit as float.
std::vector< Trk::VxTrackAtVertex > & vxTrackAtVertex()
Non-const access to the VxTrackAtVertex vector.
void setFitQuality(float chiSquared, float numberDoF)
Set the 'Fit Quality' information.
const Amg::Vector3D & position() const
Returns the 3-pos.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 3, 1 > Vector3D
float chiSquared(const U &p)
@ V0Vtx
Vertex from V0 decay.
@ NotSpecified
Default value, no explicit type set.
@ SecVtx
Secondary vertex.
@ NoVtx
Dummy vertex. TrackParticle was not used in vertex fit.
VertexAuxContainer_v1 VertexAuxContainer
Definition of the current jet auxiliary container.
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
JetConstituentVector::iterator iterator