18 const IInterface*
p ) :
25 if (m_trackContainerKey.empty() || m_vertexContainerKey.empty()) {
26 ATH_MSG_ERROR(
"No selection variables for the TrackParametersKVU tool!");
27 return StatusCode::FAILURE;
30 ATH_CHECK(m_trackContainerKey.initialize());
31 ATH_CHECK(m_vertexContainerKey.initialize());
33 m_KVUphiKey = m_trackContainerKey.key() + m_KVUphiKey.key();
34 m_KVUthetaKey = m_trackContainerKey.key() + m_KVUthetaKey.key();
35 m_KVUd0Key = m_trackContainerKey.key() + m_KVUd0Key.key();
36 m_KVUz0Key = m_trackContainerKey.key() + m_KVUz0Key.key();
37 m_KVUqOverPKey = m_trackContainerKey.key() + m_KVUqOverPKey.key();
38 m_KVUChi2Key = m_trackContainerKey.key() + m_KVUChi2Key.key();
39 m_KVUusedPVKey = m_trackContainerKey.key() + m_KVUusedPVKey.key();
40 m_KVUCovMatKey = m_trackContainerKey.key() + m_KVUCovMatKey.key();
51 ATH_CHECK(m_vertexTrackUpdator.retrieve());
53 ATH_CHECK(m_LinearizedTrackFactory.retrieve());
57 ATH_MSG_DEBUG(
"Successfully retrived the TrackParametersKVU tool" );
58 return StatusCode::SUCCESS;
64 const EventContext& ctx = Gaudi::Hive::currentContext();
71 if(tracks->
size() !=0) {
81 for (
const auto track : *tracks) {
85 std::unique_ptr<
AmgSymMatrix(5)> updateTrackCov =
nullptr;
86 float updatephi = -999;
87 float updatetheta = -999;
88 float updated0 = -999;
89 float updatez0 = -999;
90 float updateqOverP = -999;
91 float updateChi2 = -999;
92 bool usedPrimaryVertex =
false;
93 std::vector<float>
vec;
95 std::unique_ptr<const Trk::TrackParameters> trackParams =
nullptr;
106 auto vtxSurface = std::make_unique<Trk::PerigeeSurface>(vtxPos);
107 trackParams = m_extrapolator->extrapolate(ctx,*tPerigee,*vtxSurface);
108 std::unique_ptr<const Trk::ImpactParametersAndSigma> iPandSigma =
nullptr;
109 iPandSigma = m_IPEstimator->estimate(trackParams.get(), vtx);
110 if(sqrt(iPandSigma->
IPd0*iPandSigma->
IPd0+iPandSigma->
IPz0*iPandSigma->
IPz0) < minIP){
111 minIP = sqrt(iPandSigma->
IPd0*iPandSigma->
IPd0+iPandSigma->
IPz0*iPandSigma->
IPz0);
114 ATH_MSG_VERBOSE(
"n vtx pos(x, y, z) IPd0 IPz0 : " << nVtx <<
" " << vtx->position().x() <<
" "<< vtx->position().y() <<
" "<< vtx->position().z() <<
" " << iPandSigma->
IPd0 <<
" " << iPandSigma->
IPz0);
120 ATH_MSG_ERROR (
"Couldn't retrieve vxContainer with key: " << m_vertexContainerKey.key() );
121 return StatusCode::FAILURE;
132 auto recVtx = std::make_unique<xAOD::Vertex>();
133 recVtx->makePrivateStore(*closestVertex);
134 auto surface = std::make_unique<const Trk::PerigeeSurface>(globPos);
135 trackParams = m_extrapolator->extrapolate(ctx,*tPerigee,*surface);
136 auto linearTrack = std::make_unique<Trk::VxTrackAtVertex>(0.,
nullptr,
nullptr, trackParams.get(),
nullptr);
139 m_LinearizedTrackFactory->linearize(*linearTrack,globPos);
140 ATH_MSG_VERBOSE(
"Updating linearized track parameters after vertex fit. Track weight = " << linearTrack->weight());
141 m_vertexTrackUpdator->update((*linearTrack), (*recVtx));
142 ATH_MSG_VERBOSE (
"track info after vertex track updator !"<<*linearTrack );
143 if(linearTrack->perigeeAtVertex()) {
145 updateqOverP = linearTrack->perigeeAtVertex()->parameters()[
Trk::qOverP];
146 updated0 = linearTrack->perigeeAtVertex()->parameters()[
Trk::d0];
147 updatez0 = linearTrack->perigeeAtVertex()->parameters()[
Trk::z0];
148 updatephi = linearTrack->perigeeAtVertex()->parameters()[
Trk::phi0];
149 updatetheta = linearTrack->perigeeAtVertex()->parameters()[
Trk::theta];
151 updateTrackCov = std::make_unique<AmgSymMatrix(5)>(*linearTrack->perigeeAtVertex()->covariance());
152 updateChi2 = linearTrack->trackQuality().chiSquared();
160 decoratorKVUqOverP(*
track) = updateqOverP;
161 decoratorKVUd0(*
track) = updated0;
162 decoratorKVUz0(*
track) = updatez0;
163 decoratorKVUphi(*
track) = updatephi;
164 decoratorKVUtheta(*
track) = updatetheta;
165 decoratorKVUChi2(*
track) = updateChi2;
166 decoratorKVUusedPV(*
track) = usedPrimaryVertex;
179 return StatusCode::SUCCESS;