5 #include "GaudiKernel/MsgStream.h"
17 declareInterface<IVertexUpdator>(
this);
28 msg(MSG::ERROR)<<
" Unable to initialize the AlgTool"<<
endmsg;
29 return StatusCode::FAILURE;
32 return StatusCode::SUCCESS;
52 std::vector<Trk::VxTrackAtVertex> & tracksAtVertex = vtx.
vxTrackAtVertex();
56 auto righttrack =
std::find(tracksAtVertex.begin(), tracksAtVertex.end(), trk);
59 if (righttrack == tracksAtVertex.end())
61 ATH_MSG_VERBOSE (
"The track requested for removal or adding is not found in the vector of tracks");
64 ATH_MSG_ERROR (
"During remove track has to be already attached to the vertex");
65 msg(MSG::ERROR) <<
"The copy of initial xAOD::Vertex returned" <<
endmsg;
70 righttrack = tracksAtVertex.insert(tracksAtVertex.end(),trk);
71 ATH_MSG_VERBOSE (
"Updating vertex with new track which is still not attached to vertex. Adding it before updating...");
79 double trkWeight = trk.
weight();
83 vtx.covariancePosition().computeInverseWithCheck(vrt_inverse,invertible);
103 ndf +=
sign * trkWeight * (2.0);
114 righttrack->setWeight( trkWeight );
115 righttrack->setTrackQuality(
Trk::FitQuality(trk_chi, 2 * trkWeight) );
119 tracksAtVertex.erase( righttrack );
129 const AmgMatrix(5,3)&
A = trk->positionJacobian();
130 const AmgMatrix(5,3)& B = trk->momentumJacobian();
131 const AmgVector(5) & trackParameters = trk->expectedParametersAtPCA();
132 const AmgVector(5) & constantTerm = trk->constantTerm();
133 const AmgSymMatrix(5) & trackParametersWeight = trk->expectedWeightAtPCA();
139 const AmgSymMatrix(3)& old_vrt_weight = vtx.covariancePosition().inverse();
146 S =
S.inverse().eval();
149 AmgSymMatrix(5) gB = trackParametersWeight - trackParametersWeight*(B*(
S*B.transpose()))*trackParametersWeight.transpose();
152 AmgSymMatrix(3) new_vrt_weight_later_cov = old_vrt_weight + trackWeight *
sign *
A.transpose()*(gB*
A);
154 new_vrt_weight_later_cov = new_vrt_weight_later_cov.inverse().eval();
157 Amg::Vector3D new_vrt_position = new_vrt_weight_later_cov*(old_vrt_weight * old_pos + trackWeight *
sign *
A.transpose() * gB *(trackParameters - constantTerm) );
178 const AmgMatrix(5,3)&
A = trk->positionJacobian();
179 const AmgMatrix(5,3) & B = trk->momentumJacobian();
180 const AmgVector(5) & trkParameters = trk->expectedParametersAtPCA();
183 AmgSymMatrix(3) Sm = B.transpose()*(trkParametersWeight*B);
186 Sm.computeInverseWithCheck(Sm_inverse,invertible);
190 Sm= Sm_inverse.eval();
192 const AmgVector(5)& theResidual = trk->constantTerm();
195 Amg::Vector3D newTrackMomentum = Sm*B.transpose()*trkParametersWeight*(trkParameters - theResidual -
A*new_position);
198 AmgVector(5) refTrackParameters = theResidual +
A * new_position + B * newTrackMomentum;
201 AmgVector(5) paramDifference = trkParameters - refTrackParameters;
203 return paramDifference.transpose() * ( trkParametersWeight * paramDifference );;
207 AmgSymMatrix(3) old_wrt_weight = old_vtx.covariancePosition().inverse();
209 return posDifference.transpose()*(old_wrt_weight*posDifference);