203{
204
205 using namespace Acts::UnitLiterals;
206
207
208 SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle {
m_beamSpotKey, ctx};
209
210
213 theVertexContainer->setStore(theVertexAuxContainer);
214
215
219 << "), skipping vertexing and returning only dummy...");
222 dummyxAODVertex);
223 dummyxAODVertex->
setPosition(beamSpotHandle->beamVtx().position());
225 beamSpotHandle->beamVtx().covariancePosition());
226 dummyxAODVertex->
vxTrackAtVertex() = std::vector<Trk::VxTrackAtVertex>();
228 return std::make_pair(theVertexContainer, theVertexAuxContainer);
229 }
230
231 const Acts::Vector3& beamSpotPos = beamSpotHandle->beamVtx().position();
232 Acts::Vertex beamSpotConstraintVtx(beamSpotPos);
233 beamSpotConstraintVtx.setCovariance(beamSpotHandle->beamVtx().covariancePosition());
234
235 std::shared_ptr<Acts::PerigeeSurface> perigeeSurface =
236 Acts::Surface::makeShared<Acts::PerigeeSurface>((trackVector[0])->
parameters()->associatedSurface().
transform());
237
238
239 Acts::MagneticFieldContext magFieldContext =
m_extrapolationTool->getMagneticFieldContext(ctx);
240
241 const auto& geoContext
243
244
245 std::vector<TrackWrapper> allTracks;
246
247 for (const auto& trk : trackVector) {
248
249 const auto& trkParams = trk->parameters();
250 const auto&
params = trkParams->parameters();
251
252 Acts::BoundVector actsParams;
254
255 if(trkParams->covariance() == nullptr){
256 continue;
257 }
258 auto cov = *(trkParams->covariance());
259
260
261
262
263 Acts::BoundMatrix covMat;
264 covMat <<
cov(0,0) ,
cov(0,1) ,
cov(0,2) ,
cov(0,3) ,
cov(0,4) *1./(1_MeV), 0
265 ,
cov(1,0) ,
cov(1,1) ,
cov(1,2) ,
cov(1,3) ,
cov(1,4) *1./(1_MeV) , 0
266 ,
cov(2,0) ,
cov(2,1) ,
cov(2,2) ,
cov(2,3) ,
cov(2,4) *1./(1_MeV) , 0
267 ,
cov(3,0) ,
cov(3,1) ,
cov(3,2) ,
cov(3,3) ,
cov(3,4) *1./(1_MeV) , 0
268 ,
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
269 , 0. , 0. , 0. , 0., 0., 1.;
270
271 allTracks.emplace_back(trk.get(),Acts::BoundTrackParameters(perigeeSurface, actsParams, covMat, Acts::ParticleHypothesis::pion()));
272 }
273
274 std::vector<Acts::InputTrack> allTrackPtrs;
275 allTrackPtrs.reserve(allTracks.size());
276
277for(const auto& trk : allTracks){
278 allTrackPtrs.emplace_back(&trk);
279 }
280
281 Acts::VertexingOptions vertexingOptions(geoContext,
282 magFieldContext);
283
285 beamSpotConstraintVtx.setPosition(Acts::Vector3::Zero());
286 beamSpotConstraintVtx.setCovariance(Acts::SquareMatrix<3>::Zero());
287 }
289
290
291 Acts::Vector4 vtxConstraintPos;
292 Acts::SquareMatrix4 vtxConstraintCov;
293
294 auto beamSpotCov = beamSpotHandle->beamVtx().covariancePosition();
295
296 vtxConstraintPos << beamSpotPos(0), beamSpotPos(1), beamSpotPos(2), 0.;
297 vtxConstraintCov << beamSpotCov(0,0), beamSpotCov(0,1), beamSpotCov(0,2), 0.
298 , beamSpotCov(1,0), beamSpotCov(1,1), beamSpotCov(1,2), 0.
299 , beamSpotCov(2,0), beamSpotCov(2,1), beamSpotCov(2,2), 0.
300 , 0., 0., 0., 1.;
301
302 vertexingOptions.constraint.setFullPosition(vtxConstraintPos);
303 vertexingOptions.constraint.setFullCovariance(vtxConstraintCov);
304
306
307 auto findResult =
m_vertexFinder->find(allTrackPtrs, vertexingOptions, finderState);
308
309 if(!findResult.ok()){
311 theVertexContainer->
push_back(dummyxAODVertex);
312 dummyxAODVertex->
setPosition(beamSpotHandle->beamVtx().position());
314 dummyxAODVertex->
vxTrackAtVertex() = std::vector<Trk::VxTrackAtVertex>();
316
317 return std::make_pair(theVertexContainer, theVertexAuxContainer);
318 }
319
320 std::vector<Acts::Vertex> allVertices = *findResult;
321
322 for(const auto& vtx : allVertices){
324 xAODVtx->makePrivateStore();
327 xAODVtx->
setFitQuality(vtx.fitQuality().first, vtx.fitQuality().second);
328
329 const auto& tracks = vtx.tracks();
330 std::vector<Trk::VxTrackAtVertex>* trkAtVtxVec = &(xAODVtx->
vxTrackAtVertex());
331 for(const auto& trk : tracks){
332
334
335 const TrackWrapper* originalParams = trk.originalParams.template as<TrackWrapper>();
336
337
338 Trk::VxTrackAtVertex trkAtVtx(originalParams->trackLink()->clone());
339 trkAtVtx.setPerigeeAtVertex(fittedPerigee);
340 trkAtVtx.setTrackQuality(Trk::FitQuality(trk.chi2Track, trk.ndf));
341 trkAtVtx.setVtxCompatibility(trk.vertexCompatibility);
342 trkAtVtx.setWeight(trk.trackWeight);
343 trkAtVtxVec->push_back(trkAtVtx);
344
345 const Trk::LinkToXAODTrackParticle* linkToXAODTP =
346 dynamic_cast<const Trk::LinkToXAODTrackParticle*>(originalParams->trackLink());
347 if (linkToXAODTP) {
349 }
350 }
351
353 }
354
356 if (!theVertexContainer->
empty()) {
361 theVertexContainer->
push_back(dummyxAODVertex);
364 dummyxAODVertex->
vxTrackAtVertex() = std::vector<Trk::VxTrackAtVertex>();
366 } else {
368 }
369 } else {
371 theVertexContainer->
push_back(dummyxAODVertex);
372 dummyxAODVertex->
setPosition(beamSpotHandle->beamVtx().position());
374 dummyxAODVertex->
vxTrackAtVertex() = std::vector<Trk::VxTrackAtVertex>();
376 }
377
378
379
380 for (
unsigned int i = 0;
i < theVertexContainer->
size() - 1;
i++) {
381
383 " Vtx: " << i <<
" x= " << (*theVertexContainer)[i]->
position().
x()
384 <<
" y= " << (*theVertexContainer)[i]->
position().
y() <<
" z= "
385 << (*theVertexContainer)[i]->
position().
z() <<
" ntracks= "
386 << (*theVertexContainer)[i]->vxTrackAtVertex().
size()
387 <<
" chi2= " << (*theVertexContainer)[i]->
chiSquared()
388 << " ndf = " << (*theVertexContainer)[i]->numberDoF());
389 if (i > 0) {
391 }
392 }
393 }
394
395 return std::make_pair(theVertexContainer, theVertexAuxContainer);
396}
#define ATH_MSG_WARNING(x)
size_t size() const
Number of registered mappings.
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 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
const Amg::Vector3D & position() const
Method to retrieve the position of the Intersection.
@ 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.