259{
260 using namespace Acts::UnitLiterals;
261
262 const InDet::BeamSpotData* beamSpotHandle{};
264 return {};
265 }
266 const Acts::Vector3& beamSpotPos = beamSpotHandle->
beamVtx().
position();
267 Acts::Vertex beamSpotConstraintVtx(beamSpotPos);
268 beamSpotConstraintVtx.setCovariance(beamSpotHandle->
beamVtx().covariancePosition());
269
270
271 const Acts::MagneticFieldContext magFieldContext =
m_ctxProvider.getMagneticFieldContext(ctx);
272 const Acts::GeometryContext geoContext =
m_ctxProvider.getGeometryContext(ctx);
273
274
277 theVertexContainer->setStore(theVertexAuxContainer);
278
279 if(trackVector.empty()){
281 theVertexContainer->
push_back(dummyxAODVertex);
285
286 return std::make_pair(theVertexContainer, theVertexAuxContainer);
287 }
288
289 std::shared_ptr<Acts::PerigeeSurface> perigeeSurface =
290 Acts::Surface::makeShared<Acts::PerigeeSurface>((trackVector[0])->
parameters()->associatedSurface().
transform());
291
292
293 std::vector<TrackWrapper> allTracks;
294
295 for (const auto& trk : trackVector) {
296 const auto& trkParams = trk->parameters();
297 const auto&
params = trkParams->parameters();
298
299 Acts::BoundVector actsParams;
301
302 if(trkParams->covariance() == nullptr){
303 continue;
304 }
305
306 auto cov = *(trkParams->covariance());
307
308
309
310
311 Acts::BoundMatrix covMat;
312 covMat <<
cov(0,0) ,
cov(0,1) ,
cov(0,2) ,
cov(0,3) ,
cov(0,4) *1./(1_MeV), 0
313 ,
cov(1,0) ,
cov(1,1) ,
cov(1,2) ,
cov(1,3) ,
cov(1,4) *1./(1_MeV) , 0
314 ,
cov(2,0) ,
cov(2,1) ,
cov(2,2) ,
cov(2,3) ,
cov(2,4) *1./(1_MeV) , 0
315 ,
cov(3,0) ,
cov(3,1) ,
cov(3,2) ,
cov(3,3) ,
cov(3,4) *1./(1_MeV) , 0
316 ,
cov(4,0) *1./(1_MeV) ,
cov(4,1) *1./(1_MeV) ,
cov(4,2) *1./(1_MeV) ,
cov(4,3) *1./(1_MeV) ,
cov(4,4) *1./(1_MeV*1_MeV), 0
317 , 0. , 0. , 0. , 0., 0., 1.;
318
319 allTracks.emplace_back(trk.get(),Acts::BoundTrackParameters(perigeeSurface, actsParams, covMat, Acts::ParticleHypothesis::pion()));
320 }
321
322 std::vector<Acts::InputTrack> allTrackPtrs;
323 allTrackPtrs.reserve(allTracks.size());
324
325 for(const auto& trk : allTracks){
326 allTrackPtrs.emplace_back(&trk);
327 }
328
329 Acts::VertexingOptions vertexingOptions( geoContext, magFieldContext );
330
332 beamSpotConstraintVtx.setPosition(Acts::Vector3::Zero());
334 looseConstraintCovariance.setIdentity();
335 looseConstraintCovariance = looseConstraintCovariance * 1
e+8;
336 beamSpotConstraintVtx.setCovariance(looseConstraintCovariance);
337 }
338
340 vertexingOptions.constraint = beamSpotConstraintVtx;
341
343
344 auto findResult =
m_vertexFinder->find(allTrackPtrs, vertexingOptions, finderState);
345
346 if(!findResult.ok()){
348 theVertexContainer->
push_back(dummyxAODVertex);
352 return std::make_pair(theVertexContainer, theVertexAuxContainer);
353 }
354
355 std::vector<Acts::Vertex> allVertices = *findResult;
356
357 std::vector<VertexAndSignalComp> vtxList;
358
359
360 vtxList.reserve(allVertices.size());
361
362 for(const auto& vtx : allVertices){
363
364 if(vtx.covariance()(0,0)<0||vtx.covariance()(1,1)<0||vtx.covariance()(2,2)<0)
365 continue;
367 xAODVtx->makePrivateStore();
370 xAODVtx->
setFitQuality(vtx.fitQuality().first, vtx.fitQuality().second);
371
372 const auto& tracks = vtx.tracks();
373 std::vector<Trk::VxTrackAtVertex>* trkAtVtxVec = &(xAODVtx->
vxTrackAtVertex());
374 for(const auto& trk : tracks){
375
376
381 continue;
382 }
383
384 const TrackWrapper* originalParams = trk.originalParams.template as<TrackWrapper>();
385
387 Trk::VxTrackAtVertex trkAtVtx(originalParams->trackLink()->clone());
388 trkAtVtx.setPerigeeAtVertex(fittedPerigee);
389 trkAtVtx.setTrackQuality(Trk::FitQuality(trk.chi2Track, trk.ndf));
390 trkAtVtx.setVtxCompatibility(trk.vertexCompatibility);
391 trkAtVtx.setWeight(trk.trackWeight);
392 trkAtVtxVec->push_back(trkAtVtx);
393
394 const Trk::LinkToXAODTrackParticle* linkToXAODTP =
395 dynamic_cast<const Trk::LinkToXAODTrackParticle*>(originalParams->trackLink());
396 if (linkToXAODTP) {
398 }
399 }
400
402
403 VertexAndSignalComp vertexAndSig(xAODVtx, sigComp);
404 auto it = std::lower_bound( vtxList.begin(), vtxList.end(), vertexAndSig );
405 vtxList.insert( it, vertexAndSig );
406 }
407
408 for(
unsigned int i = 0;
i < vtxList.size();
i++){
409 auto vtx = vtxList[
i].first;
411 if(i == 0){
413 }
414 else{
416 }
417 }
418
419
421 theVertexContainer->
push_back(dummyxAODVertex);
422
423 if(!vtxList.empty()){
424
429 }
430 else{
434 }
435
436 return std::make_pair(theVertexContainer, theVertexAuxContainer);
437}
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const T * front() const
Access the first element in the collection as an rvalue.
const Trk::RecVertex & beamVtx() const noexcept
const Amg::Vector3D & position() const
return position of vertex
void setCovariancePosition(const AmgSymMatrix(3)&covariancePosition)
Sets the vertex covariance matrix.
void addTrackAtVertex(const ElementLink< TrackParticleContainer > &tr, float weight=1.0)
Add a new track to the vertex.
void setVertexType(VxType::VertexType vType)
Set the type of the vertex.
void setPosition(const Amg::Vector3D &position)
Sets the 3-position.
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.
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
@ 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.