5#include "GaudiKernel/MsgStream.h"
17 declareInterface<IVertexUpdator>(
this);
25 StatusCode
sc = AlgTool::initialize();
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();
145 AmgSymMatrix(3) S = B.transpose()*(trackParametersWeight*B);
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);
#define ATH_MSG_VERBOSE(x)
#define AmgSymMatrix(dim)
#define AmgMatrix(rows, cols)
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
KalmanVertexUpdator(const std::string &t, const std::string &n, const IInterface *p)
Constructor.
xAOD::Vertex * update(xAOD::Vertex &vtx, const VxTrackAtVertex &trk, IVertexUpdator::updateMode mode) const
Method where the fit is actually done.
virtual float vertexPositionChi2(const xAOD::Vertex &old_vtx, const xAOD::Vertex &new_vtx) const override
Method calculating the vertex displacement-related part of the chi2.
virtual xAOD::Vertex * add(xAOD::Vertex &vtx, VxTrackAtVertex &trk) const override
Method adding a single track to the vertex estimate.
virtual IVertexUpdator::positionUpdateOutcome positionUpdate(const xAOD::Vertex &vtx, const LinearizedTrack *trk, double trackWeight, IVertexUpdator::updateMode mode) const override
Position update method.
~KalmanVertexUpdator()
Destructor.
virtual StatusCode initialize() override
virtual xAOD::Vertex * remove(xAOD::Vertex &vtx, VxTrackAtVertex &trk) const override
Method removing already added track from the vertex estimate.
virtual float trackParametersChi2(const xAOD::Vertex &new_vtx, const LinearizedTrack *trk) const override
Method calculating the interstep Chi2 increment.
The VxTrackAtVertex is a common class for all present TrkVertexFitters The VxTrackAtVertex is designe...
LinearizedTrack * linState(void)
Access method for the perigee linearized track.
double weight(void) const
Information about the weight of track in fit (given back by annealing): weight=ndf/2.
void setCovariancePosition(const AmgSymMatrix(3)&covariancePosition)
Sets the vertex covariance matrix.
float numberDoF() const
Returns the number of degrees of freedom of the vertex fit as float.
void setPosition(const Amg::Vector3D &position)
Sets the 3-position.
float chiSquared() const
Returns the of the vertex fit as float.
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.
double chi2(TH1 *h0, TH1 *h1)
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the ATLAS eigen extensions are properly loaded.
Vertex_v1 Vertex
Define the latest version of the vertex class.
hold the test vectors and ease the comparison