266{
267 using namespace Acts::UnitLiterals;
268
269 SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle {
m_beamSpotKey, ctx};
270 const Acts::Vector3& beamSpotPos = beamSpotHandle->beamVtx().position();
271 Acts::Vertex beamSpotConstraintVtx(beamSpotPos);
272 beamSpotConstraintVtx.setCovariance(beamSpotHandle->beamVtx().covariancePosition());
273
274
275 Acts::MagneticFieldContext magFieldContext =
m_extrapolationTool->getMagneticFieldContext(ctx);
276
278
279
282 theVertexContainer->setStore(theVertexAuxContainer);
283
284 if(trackVector.empty()){
286 theVertexContainer->
push_back(dummyxAODVertex);
287 dummyxAODVertex->
setPosition(beamSpotHandle->beamVtx().position());
290
291 return std::make_pair(theVertexContainer, theVertexAuxContainer);
292 }
293
294 std::shared_ptr<Acts::PerigeeSurface> perigeeSurface =
295 Acts::Surface::makeShared<Acts::PerigeeSurface>((trackVector[0])->
parameters()->associatedSurface().
transform());
296
297
298 std::vector<TrackWrapper> allTracks;
299
300 for (const auto& trk : trackVector) {
301 const auto& trkParams = trk->parameters();
302 const auto&
params = trkParams->parameters();
303
304 Acts::BoundVector actsParams;
306
307 if(trkParams->covariance() == nullptr){
308 continue;
309 }
310
311 auto cov = *(trkParams->covariance());
312
313
314
315
316 Acts::BoundMatrix covMat;
317 covMat <<
cov(0,0) ,
cov(0,1) ,
cov(0,2) ,
cov(0,3) ,
cov(0,4) *1./(1_MeV), 0
318 ,
cov(1,0) ,
cov(1,1) ,
cov(1,2) ,
cov(1,3) ,
cov(1,4) *1./(1_MeV) , 0
319 ,
cov(2,0) ,
cov(2,1) ,
cov(2,2) ,
cov(2,3) ,
cov(2,4) *1./(1_MeV) , 0
320 ,
cov(3,0) ,
cov(3,1) ,
cov(3,2) ,
cov(3,3) ,
cov(3,4) *1./(1_MeV) , 0
321 ,
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
322 , 0. , 0. , 0. , 0., 0., 1.;
323
324 allTracks.emplace_back(trk.get(),Acts::BoundTrackParameters(perigeeSurface, actsParams, covMat, Acts::ParticleHypothesis::pion()));
325 }
326
327 std::vector<Acts::InputTrack> allTrackPtrs;
328 allTrackPtrs.reserve(allTracks.size());
329
330 for(const auto& trk : allTracks){
331 allTrackPtrs.emplace_back(&trk);
332 }
333
334 Acts::VertexingOptions vertexingOptions( geoContext, magFieldContext );
335
337 beamSpotConstraintVtx.setPosition(Acts::Vector3::Zero());
339 looseConstraintCovariance.setIdentity();
340 looseConstraintCovariance = looseConstraintCovariance * 1
e+8;
341 beamSpotConstraintVtx.setCovariance(looseConstraintCovariance);
342 }
343
345 vertexingOptions.constraint = beamSpotConstraintVtx;
346
348
349 auto findResult =
m_vertexFinder->find(allTrackPtrs, vertexingOptions, finderState);
350
351 if(!findResult.ok()){
353 theVertexContainer->
push_back(dummyxAODVertex);
354 dummyxAODVertex->
setPosition(beamSpotHandle->beamVtx().position());
357 return std::make_pair(theVertexContainer, theVertexAuxContainer);
358 }
359
360 std::vector<Acts::Vertex> allVertices = *findResult;
361
362 std::vector<VertexAndSignalComp> vtxList;
363
364
365 vtxList.reserve(allVertices.size());
366
367 for(const auto& vtx : allVertices){
368
369 if(vtx.covariance()(0,0)<0||vtx.covariance()(1,1)<0||vtx.covariance()(2,2)<0)
370 continue;
372 xAODVtx->makePrivateStore();
375 xAODVtx->
setFitQuality(vtx.fitQuality().first, vtx.fitQuality().second);
376
377 const auto& tracks = vtx.tracks();
378 std::vector<Trk::VxTrackAtVertex>* trkAtVtxVec = &(xAODVtx->
vxTrackAtVertex());
379 for(const auto& trk : tracks){
380
381
386 continue;
387 }
388
389 const TrackWrapper* originalParams = trk.originalParams.template as<TrackWrapper>();
390
392 Trk::VxTrackAtVertex trkAtVtx(originalParams->trackLink()->clone());
393 trkAtVtx.setPerigeeAtVertex(fittedPerigee);
394 trkAtVtx.setTrackQuality(Trk::FitQuality(trk.chi2Track, trk.ndf));
395 trkAtVtx.setVtxCompatibility(trk.vertexCompatibility);
396 trkAtVtx.setWeight(trk.trackWeight);
397 trkAtVtxVec->push_back(trkAtVtx);
398
399 const Trk::LinkToXAODTrackParticle* linkToXAODTP =
400 dynamic_cast<const Trk::LinkToXAODTrackParticle*>(originalParams->trackLink());
401 if (linkToXAODTP) {
403 }
404 }
405
407
408 VertexAndSignalComp vertexAndSig(xAODVtx, sigComp);
409 auto it = std::lower_bound( vtxList.begin(), vtxList.end(), vertexAndSig );
410 vtxList.insert( it, vertexAndSig );
411 }
412
413 for(
unsigned int i = 0;
i < vtxList.size();
i++){
414 auto vtx = vtxList[
i].first;
416 if(i == 0){
418 }
419 else{
421 }
422 }
423
424
426 theVertexContainer->
push_back(dummyxAODVertex);
427
428 if(!vtxList.empty()){
429
434 }
435 else{
436 dummyxAODVertex->
setPosition(beamSpotHandle->beamVtx().position());
439 }
440
441 return std::make_pair(theVertexContainer, theVertexAuxContainer);
442}
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.
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.
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.