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