13 template <
typename input_track_t,
typename linearizer_t>
23 auto fitRes = fitImpl(state, linearizer, vertexingOptions);
26 return fitRes.error();
32 template <
typename input_track_t,
typename linearizer_t>
46 bool isSmallShift =
true;
49 unsigned int nIter = 0;
52 while (nIter < m_cfg.maxIterations &&
62 currentVtxInfo.
oldPosition = currentVtx->fullPosition();
65 double perpDist = std::sqrt(dist[0] * dist[0] + dist[1] * dist[1]);
67 if (perpDist > m_cfg.maxDistToLinPoint) {
71 prepareVertexForFit(state, currentVtx, vertexingOptions);
74 if (state.
vtxInfoMap[currentVtx].constraintVertex.fullCovariance() !=
75 SymMatrix4D::Zero()) {
76 currentVtx->setFullPosition(
77 state.
vtxInfoMap[currentVtx].constraintVertex.fullPosition());
78 currentVtx->setFitQuality(
79 state.
vtxInfoMap[currentVtx].constraintVertex.fitQuality());
80 currentVtx->setFullCovariance(
81 state.
vtxInfoMap[currentVtx].constraintVertex.fullCovariance());
84 else if (currentVtx->fullCovariance() == SymMatrix4D::Zero()) {
85 return VertexingError::NoCovariance;
90 currentVtx->setFullCovariance(currentVtx->fullCovariance() * weight);
94 setAllVertexCompatibilities(state, currentVtx, vertexingOptions);
100 setWeightsAndUpdate(state, linearizer, vertexingOptions);
104 isSmallShift = checkSmallShift(state);
111 if (m_cfg.doSmoothing) {
112 doVertexSmoothing(state);
118 template <
typename input_track_t,
typename linearizer_t>
124 if (state.
vtxInfoMap[&newVertex].trackLinks.empty()) {
125 return VertexingError::EmptyInput;
128 std::vector<Vertex<input_track_t>*> verticesToFit;
132 auto res = prepareVertexForFit(state, &newVertex, vertexingOptions);
137 std::vector<Vertex<input_track_t>*> lastIterAddedVertices = {&newVertex};
139 std::vector<Vertex<input_track_t>*> currentIterAddedVertices;
143 while (!lastIterAddedVertices.empty()) {
144 for (
auto& lastVtxIter : lastIterAddedVertices) {
146 const std::vector<const input_track_t*>& trks =
148 for (
const auto& trk : trks) {
155 for (
auto vtxIter = range.first; vtxIter != range.second; ++vtxIter) {
156 auto newVtxIter = vtxIter->second;
157 if (!isAlreadyInList(newVtxIter, verticesToFit)) {
159 verticesToFit.push_back(newVtxIter);
163 if (newVtxIter != lastVtxIter) {
164 currentIterAddedVertices.push_back(newVtxIter);
171 lastIterAddedVertices = currentIterAddedVertices;
172 currentIterAddedVertices.clear();
178 auto fitRes = fitImpl(state, linearizer, vertexingOptions);
180 return fitRes.error();
186 template <
typename input_track_t,
typename linearizer_t>
191 return std::find(verticesVec.begin(), verticesVec.end(),
vtx) !=
195 template <
typename input_track_t,
typename linearizer_t>
203 const Vector3D& seedPos = currentVtxInfo.seedPosition.template head<3>();
206 for (
const auto& trk : currentVtxInfo.trackLinks) {
207 auto res = m_cfg.ipEst.estimate3DImpactParameters(
209 m_extractParameters(*trk), seedPos, state.
ipState);
214 currentVtxInfo.ip3dParams.emplace(trk, *(res.value()));
219 template <
typename input_track_t,
typename linearizer_t>
229 for (
const auto& trk : currentVtxInfo.
trackLinks) {
236 auto res = m_cfg.ipEst.estimate3DImpactParameters(
238 m_extractParameters(*trk),
244 currentVtxInfo.
ip3dParams.emplace(trk, *(res.value()));
247 auto compRes = m_cfg.ipEst.get3dVertexCompatibility(
251 return compRes.error();
253 trkAtVtx.vertexCompatibility = *compRes;
258 template <
typename input_track_t,
typename linearizer_t>
266 for (
const auto& trk : currentVtxInfo.
trackLinks) {
270 double currentTrkWeight = m_cfg.annealingTool.getWeight(
272 collectTrackToVertexCompatibilities(state, trk));
273 trkAtVtx.trackWeight = currentTrkWeight;
275 if (trkAtVtx.trackWeight > m_cfg.minWeight) {
277 if (trkAtVtx.linearizedState.covarianceAtPCA ==
278 BoundSymMatrix::Zero() ||
280 auto result = linearizer.linearizeTrack(
281 m_extractParameters(*trk), state.
vtxInfoMap[
vtx].oldPosition,
285 return result.error();
287 trkAtVtx.linearizedState = *result;
291 KalmanVertexUpdater::updateVertexWithTrack<input_track_t>(*
vtx,
304 template <
typename input_track_t,
typename linearizer_t>
308 const input_track_t* trk)
const {
309 std::vector<double> trkToVtxCompatibilities;
313 for (
auto vtxIter = range.first; vtxIter != range.second; ++vtxIter) {
314 trkToVtxCompatibilities.push_back(
316 .vertexCompatibility);
319 return trkToVtxCompatibilities;
322 template <
typename input_track_t,
typename linearizer_t>
327 vtx->fullPosition().template head<3>();
329 (
vtx->fullCovariance().template block<3, 3>(0, 0)).inverse();
330 double relativeShift = diff.dot(vtxWgt * diff);
331 if (relativeShift > m_cfg.maxRelativeShift) {
338 template <
typename input_track_t,
typename linearizer_t>
343 KalmanVertexTrackUpdater::update<input_track_t>(