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