206{
207
208 using namespace Acts::UnitLiterals;
209
210
211 SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle {
m_beamSpotKey, ctx};
212
213
216 theVertexContainer->setStore(theVertexAuxContainer);
217
218
222 << "), skipping vertexing and returning only dummy...");
225 dummyxAODVertex);
226 dummyxAODVertex->
setPosition(beamSpotHandle->beamVtx().position());
228 beamSpotHandle->beamVtx().covariancePosition());
229 dummyxAODVertex->
vxTrackAtVertex() = std::vector<Trk::VxTrackAtVertex>();
231 return std::make_pair(theVertexContainer, theVertexAuxContainer);
232 }
233
234 const Acts::Vector3& beamSpotPos = beamSpotHandle->beamVtx().position();
235 Acts::Vertex beamSpotConstraintVtx(beamSpotPos);
236 beamSpotConstraintVtx.setCovariance(beamSpotHandle->beamVtx().covariancePosition());
237
238 std::shared_ptr<Acts::PerigeeSurface> perigeeSurface =
239 Acts::Surface::makeShared<Acts::PerigeeSurface>((trackVector[0])->
parameters()->associatedSurface().
transform());
240
241
242 Acts::MagneticFieldContext magFieldContext =
m_extrapolationTool->getMagneticFieldContext(ctx);
243
244 const auto& geoContext
246
247
248 std::vector<TrackWrapper> allTracks;
249
250 for (const auto& trk : trackVector) {
251
252 const auto& trkParams = trk->parameters();
253 const auto&
params = trkParams->parameters();
254
255 Acts::BoundVector actsParams;
257
258 if(trkParams->covariance() == nullptr){
259 continue;
260 }
261 auto cov = *(trkParams->covariance());
262
263
264
265
266 Acts::BoundSquareMatrix covMat;
267 covMat <<
cov(0,0) ,
cov(0,1) ,
cov(0,2) ,
cov(0,3) ,
cov(0,4) *1./(1_MeV), 0
268 ,
cov(1,0) ,
cov(1,1) ,
cov(1,2) ,
cov(1,3) ,
cov(1,4) *1./(1_MeV) , 0
269 ,
cov(2,0) ,
cov(2,1) ,
cov(2,2) ,
cov(2,3) ,
cov(2,4) *1./(1_MeV) , 0
270 ,
cov(3,0) ,
cov(3,1) ,
cov(3,2) ,
cov(3,3) ,
cov(3,4) *1./(1_MeV) , 0
271 ,
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
272 , 0. , 0. , 0. , 0., 0., 1.;
273
274 allTracks.emplace_back(trk.get(),Acts::BoundTrackParameters(perigeeSurface, actsParams, covMat, Acts::ParticleHypothesis::pion()));
275 }
276
277 std::vector<Acts::InputTrack> allTrackPtrs;
278 allTrackPtrs.reserve(allTracks.size());
279
280for(const auto& trk : allTracks){
281 allTrackPtrs.emplace_back(&trk);
282 }
283
284 Acts::VertexingOptions vertexingOptions(geoContext,
285 magFieldContext);
286
288 beamSpotConstraintVtx.setPosition(Acts::Vector3::Zero());
289 beamSpotConstraintVtx.setCovariance(Acts::ActsSquareMatrix<3>::Zero());
290 }
292
293
294 Acts::Vector4 vtxConstraintPos;
295 Acts::SquareMatrix4 vtxConstraintCov;
296
297 auto beamSpotCov = beamSpotHandle->beamVtx().covariancePosition();
298
299 vtxConstraintPos << beamSpotPos(0), beamSpotPos(1), beamSpotPos(2), 0.;
300 vtxConstraintCov << beamSpotCov(0,0), beamSpotCov(0,1), beamSpotCov(0,2), 0.
301 , beamSpotCov(1,0), beamSpotCov(1,1), beamSpotCov(1,2), 0.
302 , beamSpotCov(2,0), beamSpotCov(2,1), beamSpotCov(2,2), 0.
303 , 0., 0., 0., 1.;
304
305 vertexingOptions.constraint.setFullPosition(vtxConstraintPos);
306 vertexingOptions.constraint.setFullCovariance(vtxConstraintCov);
307
309
310 auto findResult =
m_vertexFinder->find(allTrackPtrs, vertexingOptions, finderState);
311
312 if(!findResult.ok()){
314 theVertexContainer->
push_back(dummyxAODVertex);
315 dummyxAODVertex->
setPosition(beamSpotHandle->beamVtx().position());
317 dummyxAODVertex->
vxTrackAtVertex() = std::vector<Trk::VxTrackAtVertex>();
319
320 return std::make_pair(theVertexContainer, theVertexAuxContainer);
321 }
322
323 std::vector<Acts::Vertex> allVertices = *findResult;
324
325 for(const auto& vtx : allVertices){
330 xAODVtx->
setFitQuality(vtx.fitQuality().first, vtx.fitQuality().second);
331
332 const auto& tracks = vtx.tracks();
333 std::vector<Trk::VxTrackAtVertex>* trkAtVtxVec = &(xAODVtx->
vxTrackAtVertex());
334 for(const auto& trk : tracks){
335
337
338 const TrackWrapper* originalParams = trk.originalParams.template as<TrackWrapper>();
339
340
341 Trk::VxTrackAtVertex trkAtVtx(originalParams->trackLink()->clone());
342 trkAtVtx.setPerigeeAtVertex(fittedPerigee);
343 trkAtVtx.setTrackQuality(Trk::FitQuality(trk.chi2Track, trk.ndf));
344 trkAtVtx.setVtxCompatibility(trk.vertexCompatibility);
345 trkAtVtx.setWeight(trk.trackWeight);
346 trkAtVtxVec->push_back(trkAtVtx);
347
348 const Trk::LinkToXAODTrackParticle* linkToXAODTP =
349 dynamic_cast<const Trk::LinkToXAODTrackParticle*>(originalParams->trackLink());
350 if (linkToXAODTP) {
352 }
353 }
354
356 }
357
359 if (!theVertexContainer->
empty()) {
364 theVertexContainer->
push_back(dummyxAODVertex);
367 dummyxAODVertex->
vxTrackAtVertex() = std::vector<Trk::VxTrackAtVertex>();
369 } else {
371 }
372 } else {
374 theVertexContainer->
push_back(dummyxAODVertex);
375 dummyxAODVertex->
setPosition(beamSpotHandle->beamVtx().position());
377 dummyxAODVertex->
vxTrackAtVertex() = std::vector<Trk::VxTrackAtVertex>();
379 }
380
381
382
383 for (
unsigned int i = 0;
i < theVertexContainer->
size() - 1;
i++) {
384
386 " Vtx: " << i <<
" x= " << (*theVertexContainer)[i]->position().
x()
387 <<
" y= " << (*theVertexContainer)[i]->position().
y() <<
" z= "
388 << (*theVertexContainer)[i]->position().
z() <<
" ntracks= "
389 << (*theVertexContainer)[i]->vxTrackAtVertex().
size()
390 <<
" chi2= " << (*theVertexContainer)[i]->
chiSquared()
391 << " ndf = " << (*theVertexContainer)[i]->numberDoF());
392 if (i > 0) {
394 }
395 }
396 }
397
398 return std::make_pair(theVertexContainer, theVertexAuxContainer);
399}
#define ATH_MSG_WARNING(x)
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.
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
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.
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.
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
float chiSquared(const U &p)
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.