271{
272 using namespace Acts::UnitLiterals;
273
274 const InDet::BeamSpotData* beamSpotHandle{};
276 return {};
277 }
278 const Acts::Vector3& beamSpotPos = beamSpotHandle->
beamVtx().
position();
279 Acts::Vertex beamSpotConstraintVtx(beamSpotPos);
280 beamSpotConstraintVtx.setCovariance(beamSpotHandle->
beamVtx().covariancePosition());
281
282
283 const Acts::MagneticFieldContext magFieldContext =
m_ctxProvider.getMagneticFieldContext(ctx);
284 const Acts::GeometryContext geoContext =
m_ctxProvider.getGeometryContext(ctx);
285
286
289 theVertexContainer->setStore(theVertexAuxContainer);
290
291 if(trackVector.empty()){
293 theVertexContainer->
push_back(dummyxAODVertex);
297
298 return std::make_pair(theVertexContainer, theVertexAuxContainer);
299 }
300
301 std::shared_ptr<Acts::PerigeeSurface> perigeeSurface =
302 Acts::Surface::makeShared<Acts::PerigeeSurface>(
304
305
306 std::vector<TrackWrapper> allTracks;
307
308 for (const auto& trk : trackVector) {
309 const auto& trkParams = trk->parameters();
310 const auto&
params = trkParams->parameters();
311
312 Acts::BoundVector actsParams;
314
315 if(trkParams->covariance() == nullptr){
316 continue;
317 }
318
319 auto cov = *(trkParams->covariance());
320
321
322
323
324 Acts::BoundMatrix covMat;
325 covMat <<
cov(0,0) ,
cov(0,1) ,
cov(0,2) ,
cov(0,3) ,
cov(0,4) *1./(1_MeV), 0
326 ,
cov(1,0) ,
cov(1,1) ,
cov(1,2) ,
cov(1,3) ,
cov(1,4) *1./(1_MeV) , 0
327 ,
cov(2,0) ,
cov(2,1) ,
cov(2,2) ,
cov(2,3) ,
cov(2,4) *1./(1_MeV) , 0
328 ,
cov(3,0) ,
cov(3,1) ,
cov(3,2) ,
cov(3,3) ,
cov(3,4) *1./(1_MeV) , 0
329 ,
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
330 , 0. , 0. , 0. , 0., 0., 1.;
331
332 allTracks.emplace_back(trk.get(),Acts::BoundTrackParameters(perigeeSurface, actsParams, covMat, Acts::ParticleHypothesis::pion()));
333 }
334
335 std::vector<Acts::InputTrack> allTrackPtrs;
336 allTrackPtrs.reserve(allTracks.size());
337
338 for(const auto& trk : allTracks){
339 allTrackPtrs.emplace_back(&trk);
340 }
341
342 Acts::VertexingOptions vertexingOptions( geoContext, magFieldContext );
343
345 beamSpotConstraintVtx.setPosition(Acts::Vector3::Zero());
347 looseConstraintCovariance.setIdentity();
348 looseConstraintCovariance = looseConstraintCovariance * 1
e+8;
349 beamSpotConstraintVtx.setCovariance(looseConstraintCovariance);
350 }
351
353 vertexingOptions.constraint = std::move(beamSpotConstraintVtx);
354
356
357 auto findResult =
m_vertexFinder->find(allTrackPtrs, vertexingOptions, finderState);
358
359 if(!findResult.ok()){
361 theVertexContainer->
push_back(dummyxAODVertex);
365 return std::make_pair(theVertexContainer, theVertexAuxContainer);
366 }
367
368 std::vector<Acts::Vertex> allVertices = *findResult;
369
370 std::vector<VertexAndSignalComp> vtxList;
371
372
373 vtxList.reserve(allVertices.size());
374
375 for(const auto& vtx : allVertices){
376
377 if(vtx.covariance()(0,0)<0||vtx.covariance()(1,1)<0||vtx.covariance()(2,2)<0)
378 continue;
380 xAODVtx->makePrivateStore();
383 xAODVtx->
setFitQuality(vtx.fitQuality().first, vtx.fitQuality().second);
384
385 const auto& tracks = vtx.tracks();
386 std::vector<Trk::VxTrackAtVertex>* trkAtVtxVec = &(xAODVtx->
vxTrackAtVertex());
387 for(const auto& trk : tracks){
388
389
394 continue;
395 }
396
397 const TrackWrapper* originalParams = trk.originalParams.template as<TrackWrapper>();
398
400 Trk::VxTrackAtVertex trkAtVtx(originalParams->trackLink()->clone());
401 trkAtVtx.setPerigeeAtVertex(fittedPerigee);
402 trkAtVtx.setTrackQuality(Trk::FitQuality(trk.chi2Track, trk.ndf));
403 trkAtVtx.setVtxCompatibility(trk.vertexCompatibility);
404 trkAtVtx.setWeight(trk.trackWeight);
405 trkAtVtxVec->push_back(std::move(trkAtVtx));
406
407 const Trk::LinkToXAODTrackParticle* linkToXAODTP =
408 dynamic_cast<const Trk::LinkToXAODTrackParticle*>(originalParams->trackLink());
409 if (linkToXAODTP) {
411 }
412 }
413
415
416 VertexAndSignalComp vertexAndSig(xAODVtx, sigComp);
417 auto it = std::lower_bound( vtxList.begin(), vtxList.end(), vertexAndSig );
418 vtxList.insert( it, vertexAndSig );
419 }
420
421 for(
unsigned int i = 0;
i < vtxList.size();
i++){
422 auto vtx = vtxList[
i].first;
424 if(i == 0){
426 }
427 else{
429 }
430 }
431
432
434 theVertexContainer->
push_back(dummyxAODVertex);
435
436 if(!vtxList.empty()){
437
442 }
443 else{
447 }
448
449 return std::make_pair(theVertexContainer, theVertexAuxContainer);
450}
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::Isometry3D toIsometry3D(const Isometry3D &iso)
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.