269{
270 using namespace Acts::UnitLiterals;
271
272 SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle {
m_beamSpotKey, ctx};
273 const Acts::Vector3& beamSpotPos = beamSpotHandle->beamVtx().position();
274 Acts::Vertex beamSpotConstraintVtx(beamSpotPos);
275 beamSpotConstraintVtx.setCovariance(beamSpotHandle->beamVtx().covariancePosition());
276
277
278 Acts::MagneticFieldContext magFieldContext =
m_extrapolationTool->getMagneticFieldContext(ctx);
279
281
282
285 theVertexContainer->setStore(theVertexAuxContainer);
286
287 if(trackVector.empty()){
289 theVertexContainer->
push_back(dummyxAODVertex);
290 dummyxAODVertex->
setPosition(beamSpotHandle->beamVtx().position());
293
294 return std::make_pair(theVertexContainer, theVertexAuxContainer);
295 }
296
297 std::shared_ptr<Acts::PerigeeSurface> perigeeSurface =
298 Acts::Surface::makeShared<Acts::PerigeeSurface>((trackVector[0])->
parameters()->associatedSurface().
transform());
299
300
301 std::vector<TrackWrapper> allTracks;
302
303 for (const auto& trk : trackVector) {
304 const auto& trkParams = trk->parameters();
305 const auto&
params = trkParams->parameters();
306
307 Acts::BoundVector actsParams;
309
310 if(trkParams->covariance() == nullptr){
311 continue;
312 }
313
314 auto cov = *(trkParams->covariance());
315
316
317
318
319 Acts::BoundSquareMatrix covMat;
320 covMat <<
cov(0,0) ,
cov(0,1) ,
cov(0,2) ,
cov(0,3) ,
cov(0,4) *1./(1_MeV), 0
321 ,
cov(1,0) ,
cov(1,1) ,
cov(1,2) ,
cov(1,3) ,
cov(1,4) *1./(1_MeV) , 0
322 ,
cov(2,0) ,
cov(2,1) ,
cov(2,2) ,
cov(2,3) ,
cov(2,4) *1./(1_MeV) , 0
323 ,
cov(3,0) ,
cov(3,1) ,
cov(3,2) ,
cov(3,3) ,
cov(3,4) *1./(1_MeV) , 0
324 ,
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
325 , 0. , 0. , 0. , 0., 0., 1.;
326
327 allTracks.emplace_back(trk.get(),Acts::BoundTrackParameters(perigeeSurface, actsParams, covMat, Acts::ParticleHypothesis::pion()));
328 }
329
330 std::vector<Acts::InputTrack> allTrackPtrs;
331 allTrackPtrs.reserve(allTracks.size());
332
333 for(const auto& trk : allTracks){
334 allTrackPtrs.emplace_back(&trk);
335 }
336
337 Acts::VertexingOptions vertexingOptions( geoContext, magFieldContext );
338
340 beamSpotConstraintVtx.setPosition(Acts::Vector3::Zero());
342 looseConstraintCovariance.setIdentity();
343 looseConstraintCovariance = looseConstraintCovariance * 1
e+8;
344 beamSpotConstraintVtx.setCovariance(looseConstraintCovariance);
345 }
346
348 vertexingOptions.constraint = beamSpotConstraintVtx;
349
351
352 auto findResult =
m_vertexFinder->find(allTrackPtrs, vertexingOptions, finderState);
353
354 if(!findResult.ok()){
356 theVertexContainer->
push_back(dummyxAODVertex);
357 dummyxAODVertex->
setPosition(beamSpotHandle->beamVtx().position());
360 return std::make_pair(theVertexContainer, theVertexAuxContainer);
361 }
362
363 std::vector<Acts::Vertex> allVertices = *findResult;
364
365 std::vector<VertexAndSignalComp> vtxList;
366
367
368 vtxList.reserve(allVertices.size());
369
370 for(const auto& vtx : allVertices){
371
372 if(vtx.covariance()(0,0)<0||vtx.covariance()(1,1)<0||vtx.covariance()(2,2)<0)
373 continue;
378 xAODVtx->
setFitQuality(vtx.fitQuality().first, vtx.fitQuality().second);
379
380 const auto& tracks = vtx.tracks();
381 std::vector<Trk::VxTrackAtVertex>* trkAtVtxVec = &(xAODVtx->
vxTrackAtVertex());
382 for(const auto& trk : tracks){
383
384
389 continue;
390 }
391
392 const TrackWrapper* originalParams = trk.originalParams.template as<TrackWrapper>();
393
395 Trk::VxTrackAtVertex trkAtVtx(originalParams->trackLink()->clone());
396 trkAtVtx.setPerigeeAtVertex(fittedPerigee);
397 trkAtVtx.setTrackQuality(Trk::FitQuality(trk.chi2Track, trk.ndf));
398 trkAtVtx.setVtxCompatibility(trk.vertexCompatibility);
399 trkAtVtx.setWeight(trk.trackWeight);
400 trkAtVtxVec->push_back(trkAtVtx);
401
402 const Trk::LinkToXAODTrackParticle* linkToXAODTP =
403 dynamic_cast<const Trk::LinkToXAODTrackParticle*>(originalParams->trackLink());
404 if (linkToXAODTP) {
406 }
407 }
408
410
411 VertexAndSignalComp vertexAndSig(xAODVtx, sigComp);
412 auto it = std::lower_bound( vtxList.begin(), vtxList.end(), vertexAndSig );
413 vtxList.insert( it, vertexAndSig );
414 }
415
416 for(
unsigned int i = 0;
i < vtxList.size();
i++){
417 auto vtx = vtxList[
i].first;
419 if(i == 0){
421 }
422 else{
424 }
425 }
426
427
429 theVertexContainer->
push_back(dummyxAODVertex);
430
431 if(!vtxList.empty()){
432
437 }
438 else{
439 dummyxAODVertex->
setPosition(beamSpotHandle->beamVtx().position());
442 }
443
444 return std::make_pair(theVertexContainer, theVertexAuxContainer);
445}
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 makePrivateStore()
Create a new (empty) private store for this object.
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.