File indexing completed on 2025-01-18 09:11:07
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 template <typename traj_t>
0046 Result<void> operator()(const GeometryContext& gctx, traj_t& trajectory,
0047 std::size_t entryIndex,
0048 const Logger& logger = getDummyLogger()) const {
0049 (void)gctx;
0050 (void)logger;
0051
0052 using TrackStateProxy = typename traj_t::TrackStateProxy;
0053
0054 TrackStateProxy startTs = trajectory.getTrackState(entryIndex);
0055
0056
0057
0058 BoundMatrix bigLambdaHat = BoundMatrix::Zero();
0059 BoundVector smallLambdaHat = BoundVector::Zero();
0060
0061 trajectory.applyBackwards(startTs.index(), [&](TrackStateProxy ts) {
0062
0063 ts.addComponents(TrackStatePropMask::Smoothed);
0064
0065 InternalTrackState internalTrackState(ts);
0066
0067
0068 calculateSmoothed(internalTrackState, bigLambdaHat, smallLambdaHat);
0069
0070
0071 if (!ts.hasPrevious()) {
0072 return;
0073 }
0074
0075
0076 if (ts.typeFlags().test(TrackStateFlag::MeasurementFlag)) {
0077 visitMeasurement(internalTrackState, bigLambdaHat, smallLambdaHat);
0078 } else {
0079 visitNonMeasurement(internalTrackState, bigLambdaHat, smallLambdaHat);
0080 }
0081 });
0082
0083 return Result<void>::success();
0084 }
0085
0086 private:
0087
0088
0089 struct InternalTrackState final {
0090 using Jacobian =
0091 typename TrackStateTraits<MultiTrajectoryTraits::MeasurementSizeMax,
0092 false>::Covariance;
0093 using Parameters =
0094 typename TrackStateTraits<MultiTrajectoryTraits::MeasurementSizeMax,
0095 false>::Parameters;
0096 using Covariance =
0097 typename TrackStateTraits<MultiTrajectoryTraits::MeasurementSizeMax,
0098 false>::Covariance;
0099
0100 struct Measurement final {
0101 unsigned int calibratedSize{0};
0102
0103 const double* calibrated{nullptr};
0104 const double* calibratedCovariance{nullptr};
0105 BoundSubspaceIndices projector;
0106
0107 template <typename TrackStateProxy>
0108 explicit Measurement(TrackStateProxy ts)
0109 : calibratedSize(ts.calibratedSize()),
0110 calibrated(ts.effectiveCalibrated().data()),
0111 calibratedCovariance(ts.effectiveCalibratedCovariance().data()),
0112 projector(ts.projectorSubspaceIndices()) {}
0113 };
0114
0115 Jacobian jacobian;
0116
0117 Parameters predicted;
0118 Covariance predictedCovariance;
0119 Parameters filtered;
0120 Covariance filteredCovariance;
0121 Parameters smoothed;
0122 Covariance smoothedCovariance;
0123
0124 std::optional<Measurement> measurement;
0125
0126 template <typename TrackStateProxy>
0127 explicit InternalTrackState(TrackStateProxy ts)
0128 : jacobian(ts.jacobian()),
0129 predicted(ts.predicted()),
0130 predictedCovariance(ts.predictedCovariance()),
0131 filtered(ts.filtered()),
0132 filteredCovariance(ts.filteredCovariance()),
0133 smoothed(ts.smoothed()),
0134 smoothedCovariance(ts.smoothedCovariance()),
0135 measurement(ts.typeFlags().test(TrackStateFlag::MeasurementFlag)
0136 ? std::optional<Measurement>(ts)
0137 : std::nullopt) {}
0138 };
0139
0140
0141 void calculateSmoothed(InternalTrackState& ts,
0142 const BoundMatrix& bigLambdaHat,
0143 const BoundVector& smallLambdaHat) const;
0144
0145
0146 void visitNonMeasurement(const InternalTrackState& ts,
0147 BoundMatrix& bigLambdaHat,
0148 BoundVector& smallLambdaHat) const;
0149
0150
0151 void visitMeasurement(const InternalTrackState& ts, BoundMatrix& bigLambdaHat,
0152 BoundVector& smallLambdaHat) const;
0153 };
0154
0155 }