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 {
58 template <
typename input_track_t,
typename linearizer_t>
61 const std::vector<const input_track_t*>& paramVector,
67 unsigned int nTracks = paramVector.size();
75 int ndf = 2 * nTracks - 3;
82 bool isConstraintFit =
false;
84 isConstraintFit =
true;
88 std::vector<BilloirTrack<input_track_t>> billoirTracks;
90 std::vector<Vector3D> trackMomenta;
96 for (
int nIter = 0; nIter < m_cfg.maxIterations; ++nIter) {
97 billoirTracks.clear();
101 BilloirVertex billoirVertex;
104 for (
const input_track_t* trackContainer : paramVector) {
105 const auto& trackParams = extractParameters(*trackContainer);
110 trackMomenta.push_back(
Vector3D(phi, theta, qop));
113 auto result = linearizer.linearizeTrack(
114 trackParams, linPoint, vertexingOptions.
geoContext,
117 const auto& linTrack = *result;
118 const auto& parametersAtPCA = linTrack.parametersAtPCA;
126 double fPhi = trackMomenta[iTrack][0];
127 double fTheta = trackMomenta[iTrack][1];
128 double fQOvP = trackMomenta[iTrack][2];
129 BilloirTrack<input_track_t> currentBilloirTrack(trackContainer,
132 currentBilloirTrack.deltaQ << d0, z0, phi - fPhi, theta - fTheta,
137 Dmat = linTrack.positionJacobian;
141 Emat = linTrack.momentumJacobian;
147 DtWmat = Dmat.transpose() * Wi;
148 EtWmat = Emat.transpose() * Wi;
151 currentBilloirTrack.DiMat = Dmat;
152 currentBilloirTrack.EiMat = Emat;
153 currentBilloirTrack.CiMat = EtWmat * Emat;
154 currentBilloirTrack.BiMat = DtWmat * Emat;
155 currentBilloirTrack.UiVec =
156 EtWmat * currentBilloirTrack.deltaQ;
157 currentBilloirTrack.CiInv =
158 (EtWmat * Emat).inverse();
161 billoirVertex.Tvec +=
162 DtWmat * currentBilloirTrack.deltaQ;
163 billoirVertex.Amat += DtWmat * Dmat;
166 currentBilloirTrack.BCiMat =
167 currentBilloirTrack.BiMat *
168 currentBilloirTrack.CiInv;
171 billoirVertex.BCUvec +=
172 currentBilloirTrack.BCiMat *
173 currentBilloirTrack.UiVec;
174 billoirVertex.BCBmat +=
175 currentBilloirTrack.BCiMat *
176 currentBilloirTrack.BiMat
179 billoirTracks.push_back(currentBilloirTrack);
182 return result.error();
189 Vector4D Vdel = billoirVertex.Tvec - billoirVertex.BCUvec;
192 billoirVertex.BCBmat;
193 if (isConstraintFit) {
206 Vector4D deltaV = covDeltaVmat * Vdel;
210 std::vector<std::optional<BoundSymMatrix>> covDeltaPmat(nTracks);
213 for (
auto& bTrack : billoirTracks) {
215 (bTrack.CiInv) * (bTrack.UiVec - bTrack.BiMat.transpose() * deltaV);
218 trackMomenta[iTrack] += deltaP;
222 trackMomenta[iTrack][0], trackMomenta[iTrack][1]);
224 trackMomenta[iTrack][0] = correctedPhiTheta.first;
225 trackMomenta[iTrack][1] = correctedPhiTheta.second;
232 transMat(0, 0) = bTrack.DiMat(0, 0);
233 transMat(0, 1) = bTrack.DiMat(0, 1);
234 transMat(1, 0) = bTrack.DiMat(1, 0);
235 transMat(1, 1) = bTrack.DiMat(1, 1);
251 PPmat = bTrack.CiInv +
252 bTrack.BCiMat.transpose() * covDeltaVmat * bTrack.BCiMat;
256 covMat.block<4, 4>(0, 0) = VVmat;
257 covMat.block<4, 3>(0, 4) = VPmat;
258 covMat.block<3, 4>(4, 0) = VPmat.transpose();
260 covMat.block<3, 3>(4, 4) = PPmat;
263 covDeltaPmat[iTrack] = transMat * covMat * transMat.transpose();
266 ((bTrack.deltaQ - bTrack.DiMat * deltaV - bTrack.EiMat * deltaP)
268 .dot(bTrack.linTrack.weightAtPCA *
269 (bTrack.deltaQ - bTrack.DiMat * deltaV -
270 bTrack.EiMat * deltaP));
271 newChi2 += bTrack.chi2;
276 if (isConstraintFit) {
286 (deltaTrk.transpose())
292 if (!std::isnormal(newChi2)) {
293 return VertexingError::NumericFailure;
298 if (newChi2 < chi2) {
303 fittedVertex.setFullPosition(vertexPos);
304 fittedVertex.setFullCovariance(covDeltaVmat);
305 fittedVertex.setFitQuality(chi2, ndf);
307 std::vector<TrackAtVertex<input_track_t>> tracksAtVertex;
309 std::shared_ptr<PerigeeSurface> perigee =
310 Surface::makeShared<PerigeeSurface>(
314 for (
auto& bTrack : billoirTracks) {
317 paramVec[
eBoundPhi] = trackMomenta[iTrack](0);
321 covDeltaPmat[iTrack]);
323 bTrack.originalTrack);
324 tracksAtVertex.push_back(std::move(trackVx));
327 fittedVertex.setTracksAtVertex(tracksAtVertex);