File indexing completed on 2025-10-21 08:02:19
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/TrackParametrization.hpp"
0012 #include "Acts/EventData/MultiTrajectory.hpp"
0013 #include "Acts/Geometry/GeometryContext.hpp"
0014 #include "Acts/Utilities/Logger.hpp"
0015 #include "Acts/Utilities/Result.hpp"
0016
0017 #include <cstddef>
0018 #include <optional>
0019
0020 namespace Acts {
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 class MbfSmoother {
0038 public:
0039
0040
0041
0042
0043
0044
0045
0046 template <typename traj_t>
0047 Result<void> operator()(const GeometryContext& gctx, traj_t& trajectory,
0048 std::size_t entryIndex,
0049 const Logger& logger = getDummyLogger()) const {
0050 (void)gctx;
0051 (void)logger;
0052
0053 using TrackStateProxy = typename traj_t::TrackStateProxy;
0054
0055 TrackStateProxy startTs = trajectory.getTrackState(entryIndex);
0056
0057
0058
0059 BoundMatrix bigLambdaHat = BoundMatrix::Zero();
0060 BoundVector smallLambdaHat = BoundVector::Zero();
0061
0062 trajectory.applyBackwards(startTs.index(), [&](TrackStateProxy ts) {
0063
0064 ts.addComponents(TrackStatePropMask::Smoothed);
0065
0066 InternalTrackState internalTrackState(ts);
0067
0068
0069 calculateSmoothed(internalTrackState, bigLambdaHat, smallLambdaHat);
0070
0071
0072 if (!ts.hasPrevious()) {
0073 return;
0074 }
0075
0076
0077 if (ts.typeFlags().test(TrackStateFlag::MeasurementFlag)) {
0078 visitMeasurement(internalTrackState, bigLambdaHat, smallLambdaHat);
0079 } else {
0080 visitNonMeasurement(internalTrackState, bigLambdaHat, smallLambdaHat);
0081 }
0082 });
0083
0084 return Result<void>::success();
0085 }
0086
0087 private:
0088
0089
0090 struct InternalTrackState final {
0091 using Jacobian =
0092 typename TrackStateTraits<MultiTrajectoryTraits::MeasurementSizeMax,
0093 false>::Covariance;
0094 using Parameters =
0095 typename TrackStateTraits<MultiTrajectoryTraits::MeasurementSizeMax,
0096 false>::Parameters;
0097 using Covariance =
0098 typename TrackStateTraits<MultiTrajectoryTraits::MeasurementSizeMax,
0099 false>::Covariance;
0100
0101 struct Measurement final {
0102 unsigned int calibratedSize{0};
0103
0104 const double* calibrated{nullptr};
0105 const double* calibratedCovariance{nullptr};
0106 BoundSubspaceIndices projector;
0107
0108 template <typename TrackStateProxy>
0109 explicit Measurement(TrackStateProxy ts)
0110 : calibratedSize(ts.calibratedSize()),
0111 calibrated(ts.effectiveCalibrated().data()),
0112 calibratedCovariance(ts.effectiveCalibratedCovariance().data()),
0113 projector(ts.projectorSubspaceIndices()) {}
0114 };
0115
0116 Jacobian jacobian;
0117
0118 Parameters predicted;
0119 Covariance predictedCovariance;
0120 Parameters filtered;
0121 Covariance filteredCovariance;
0122 Parameters smoothed;
0123 Covariance smoothedCovariance;
0124
0125 std::optional<Measurement> measurement;
0126
0127 template <typename TrackStateProxy>
0128 explicit InternalTrackState(TrackStateProxy ts)
0129 : jacobian(ts.jacobian()),
0130 predicted(ts.predicted()),
0131 predictedCovariance(ts.predictedCovariance()),
0132 filtered(ts.filtered()),
0133 filteredCovariance(ts.filteredCovariance()),
0134 smoothed(ts.smoothed()),
0135 smoothedCovariance(ts.smoothedCovariance()),
0136 measurement(ts.typeFlags().test(TrackStateFlag::MeasurementFlag)
0137 ? std::optional<Measurement>(ts)
0138 : std::nullopt) {}
0139 };
0140
0141
0142 void calculateSmoothed(InternalTrackState& ts,
0143 const BoundMatrix& bigLambdaHat,
0144 const BoundVector& smallLambdaHat) const;
0145
0146
0147 void visitNonMeasurement(const InternalTrackState& ts,
0148 BoundMatrix& bigLambdaHat,
0149 BoundVector& smallLambdaHat) const;
0150
0151
0152 void visitMeasurement(const InternalTrackState& ts, BoundMatrix& bigLambdaHat,
0153 BoundVector& smallLambdaHat) const;
0154 };
0155
0156 }