File indexing completed on 2026-06-05 07:47:40
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/TrackParametrization.hpp"
0013 #include "Acts/EventData/BoundTrackParameters.hpp"
0014 #include "Acts/EventData/Types.hpp"
0015
0016 #include <unordered_map>
0017
0018 namespace Acts::detail {
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 template <typename traj_t, typename parameters_t = BoundTrackParameters>
0034 std::pair<DynamicMatrix, std::unordered_map<std::size_t, std::size_t>>
0035 globalTrackParametersCovariance(const traj_t& multiTraj,
0036 const std::size_t& entryIndex) {
0037 using CovMatrix = BoundMatrix;
0038 using GainMatrix = BoundMatrix;
0039
0040
0041 std::size_t lastSmoothedIndex = kTrackIndexInvalid;
0042
0043 std::size_t nSmoothedStates = 0;
0044
0045 multiTraj.visitBackwards(entryIndex, [&](const auto& ts) {
0046 if (ts.hasSmoothed()) {
0047 if (lastSmoothedIndex == kTrackIndexInvalid) {
0048 lastSmoothedIndex = ts.index();
0049 }
0050 nSmoothedStates++;
0051 }
0052 });
0053
0054
0055 DynamicMatrix fullGlobalTrackParamsCov(nSmoothedStates * eBoundSize,
0056 nSmoothedStates * eBoundSize);
0057 fullGlobalTrackParamsCov.setZero();
0058
0059
0060 std::unordered_map<std::size_t, std::size_t> stateRowIndices;
0061
0062
0063 std::size_t nProcessed = 0;
0064 auto prev_ts = multiTraj.getTrackState(lastSmoothedIndex);
0065 multiTraj.visitBackwards(lastSmoothedIndex, [&](const auto& ts) {
0066 const std::size_t iRow =
0067 fullGlobalTrackParamsCov.rows() - eBoundSize * (nProcessed + 1);
0068
0069 fullGlobalTrackParamsCov.block<eBoundSize, eBoundSize>(iRow, iRow) =
0070 ts.smoothedCovariance();
0071
0072
0073
0074 if (nProcessed > 0) {
0075
0076 GainMatrix G = ts.filteredCovariance() * prev_ts.jacobian().transpose() *
0077 prev_ts.predictedCovariance().inverse();
0078
0079 for (std::size_t iProcessed = 1; iProcessed <= nProcessed; iProcessed++) {
0080 const std::size_t iCol = iRow + eBoundSize * iProcessed;
0081 CovMatrix prev_correlation =
0082 fullGlobalTrackParamsCov.block<eBoundSize, eBoundSize>(
0083 iRow + eBoundSize, iCol);
0084 CovMatrix correlation = G * prev_correlation;
0085 fullGlobalTrackParamsCov.block<eBoundSize, eBoundSize>(iRow, iCol) =
0086 correlation;
0087 fullGlobalTrackParamsCov.block<eBoundSize, eBoundSize>(iCol, iRow) =
0088 correlation.transpose();
0089 }
0090 }
0091 stateRowIndices.emplace(ts.index(), iRow);
0092 nProcessed++;
0093 prev_ts = ts;
0094 });
0095
0096 return {fullGlobalTrackParamsCov, stateRowIndices};
0097 }
0098
0099 }