20 template <
typename input_track_t>
25 : originalTrack(params), linTrack(std::move(lTrack)) {}
27 BilloirTrack(
const BilloirTrack& arg) =
default;
29 const input_track_t* originalTrack;
45 struct BilloirVertex {
46 BilloirVertex() =
default;
49 Acts::SpacePointSymMatrix::Zero()};
51 Acts::SpacePointVector::Zero()};
53 Acts::SpacePointSymMatrix::Zero()};
58 Acts::SpacePointVector::Zero()};
63 template <
typename input_track_t,
typename linearizer_t>
66 const std::vector<const input_track_t*>& paramVector,
71 unsigned int nTracks = paramVector.size();
79 int ndf = 2 * nTracks - 3;
86 bool isConstraintFit =
false;
88 isConstraintFit =
true;
92 std::vector<BilloirTrack<input_track_t>> billoirTracks;
94 std::vector<Vector3D> trackMomenta;
100 for (
int nIter = 0; nIter < m_cfg.maxIterations; ++nIter) {
101 billoirTracks.clear();
105 BilloirVertex billoirVertex;
108 for (
const input_track_t* trackContainer : paramVector) {
109 const auto& trackParams = extractParameters(*trackContainer);
114 trackMomenta.push_back(
Vector3D(phi, theta, qop));
117 auto result = linearizer.linearizeTrack(trackParams, linPoint,
121 const auto& linTrack = *result;
122 const auto& parametersAtPCA = linTrack.parametersAtPCA;
130 double fPhi = trackMomenta[iTrack][0];
131 double fTheta = trackMomenta[iTrack][1];
132 double fQOvP = trackMomenta[iTrack][2];
133 BilloirTrack<input_track_t> currentBilloirTrack(trackContainer,
136 currentBilloirTrack.deltaQ << d0,
z0, phi - fPhi, theta - fTheta,
141 Dmat = linTrack.positionJacobian;
145 Emat = linTrack.momentumJacobian;
151 DtWmat = Dmat.transpose() * Wi;
152 EtWmat = Emat.transpose() * Wi;
155 currentBilloirTrack.DiMat = Dmat;
156 currentBilloirTrack.EiMat = Emat;
157 currentBilloirTrack.CiMat = EtWmat * Emat;
158 currentBilloirTrack.BiMat = DtWmat * Emat;
159 currentBilloirTrack.UiVec =
160 EtWmat * currentBilloirTrack.deltaQ;
161 currentBilloirTrack.CiInv =
162 (EtWmat * Emat).inverse();
165 billoirVertex.Tvec +=
166 DtWmat * currentBilloirTrack.deltaQ;
167 billoirVertex.Amat += DtWmat * Dmat;
170 currentBilloirTrack.BCiMat =
171 currentBilloirTrack.BiMat *
172 currentBilloirTrack.CiInv;
175 billoirVertex.BCUvec +=
176 currentBilloirTrack.BCiMat *
177 currentBilloirTrack.UiVec;
178 billoirVertex.BCBmat +=
179 currentBilloirTrack.BCiMat *
180 currentBilloirTrack.BiMat
183 billoirTracks.push_back(currentBilloirTrack);
186 return result.error();
194 billoirVertex.BCUvec;
197 billoirVertex.BCBmat;
198 if (isConstraintFit) {
215 std::vector<std::optional<BoundSymMatrix>> covDeltaPmat(nTracks);
218 for (
auto& bTrack : billoirTracks) {
220 (bTrack.CiInv) * (bTrack.UiVec - bTrack.BiMat.transpose() * deltaV);
223 trackMomenta[iTrack] += deltaP;
227 trackMomenta[iTrack][0], trackMomenta[iTrack][1]);
229 trackMomenta[iTrack][0] = correctedPhiTheta.first;
230 trackMomenta[iTrack][1] = correctedPhiTheta.second;
237 transMat(0, 0) = bTrack.DiMat(0, 0);
238 transMat(0, 1) = bTrack.DiMat(0, 1);
239 transMat(1, 0) = bTrack.DiMat(1, 0);
240 transMat(1, 1) = bTrack.DiMat(1, 1);
256 PPmat = bTrack.CiInv +
257 bTrack.BCiMat.transpose() * covDeltaVmat * bTrack.BCiMat;
261 covMat.block<4, 4>(0, 0) = VVmat;
262 covMat.block<4, 3>(0, 4) = VPmat;
263 covMat.block<3, 4>(4, 0) = VPmat.transpose();
265 covMat.block<3, 3>(4, 4) = PPmat;
268 covDeltaPmat[iTrack] = transMat * covMat * transMat.transpose();
271 ((bTrack.deltaQ - bTrack.DiMat * deltaV - bTrack.EiMat * deltaP)
273 .dot(bTrack.linTrack.weightAtPCA *
274 (bTrack.deltaQ - bTrack.DiMat * deltaV -
275 bTrack.EiMat * deltaP));
276 newChi2 += bTrack.chi2;
281 if (isConstraintFit) {
291 (deltaTrk.transpose())
297 if (!std::isnormal(newChi2)) {
298 return VertexingError::NumericFailure;
303 if (newChi2 < chi2) {
308 fittedVertex.setFullPosition(vertexPos);
309 fittedVertex.setFullCovariance(covDeltaVmat);
310 fittedVertex.setFitQuality(chi2, ndf);
312 std::vector<TrackAtVertex<input_track_t>> tracksAtVertex;
314 std::shared_ptr<PerigeeSurface> perigee =
315 Surface::makeShared<PerigeeSurface>(
319 for (
auto& bTrack : billoirTracks) {
322 paramVec << 0., 0., trackMomenta[iTrack](0), trackMomenta[iTrack](1),
323 trackMomenta[iTrack](2), 0.;
326 covDeltaPmat[iTrack], paramVec, perigee);
329 bTrack.originalTrack);
330 tracksAtVertex.push_back(std::move(trackVx));
333 fittedVertex.setTracksAtVertex(tracksAtVertex);
336 return std::move(fittedVertex);