File indexing completed on 2025-07-14 08:25:17
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011
0012 #include "Acts/Utilities/detail/ReferenceWrapperAnyCompat.hpp"
0013
0014 #include "Acts/Definitions/Algebra.hpp"
0015 #include "Acts/Definitions/Direction.hpp"
0016 #include "Acts/Definitions/Tolerance.hpp"
0017 #include "Acts/Definitions/TrackParametrization.hpp"
0018 #include "Acts/EventData/TrackParameters.hpp"
0019 #include "Acts/EventData/detail/CorrectedTransformationFreeToBound.hpp"
0020 #include "Acts/Geometry/GeometryContext.hpp"
0021 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0022 #include "Acts/MagneticField/NullBField.hpp"
0023 #include "Acts/Propagator/ConstrainedStep.hpp"
0024 #include "Acts/Propagator/PropagatorTraits.hpp"
0025 #include "Acts/Propagator/StepperOptions.hpp"
0026 #include "Acts/Propagator/detail/SteppingHelper.hpp"
0027 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0028 #include "Acts/Surfaces/Surface.hpp"
0029 #include "Acts/Utilities/Intersection.hpp"
0030 #include "Acts/Utilities/Logger.hpp"
0031 #include "Acts/Utilities/Result.hpp"
0032
0033 #include <algorithm>
0034 #include <cmath>
0035 #include <functional>
0036 #include <limits>
0037 #include <string>
0038 #include <tuple>
0039
0040 namespace Acts {
0041
0042
0043
0044
0045
0046
0047 class StraightLineStepper {
0048 public:
0049 using Jacobian = BoundMatrix;
0050 using Covariance = BoundSquareMatrix;
0051 using BoundState = std::tuple<BoundTrackParameters, Jacobian, double>;
0052 using CurvilinearState =
0053 std::tuple<CurvilinearTrackParameters, Jacobian, double>;
0054 using BField = NullBField;
0055
0056 struct Config {};
0057
0058 struct Options : public StepperPlainOptions {
0059 void setPlainOptions(const StepperPlainOptions& options) {
0060 static_cast<StepperPlainOptions&>(*this) = options;
0061 }
0062 };
0063
0064
0065
0066 struct State {
0067 State() = delete;
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077 explicit State(const GeometryContext& gctx,
0078 const MagneticFieldContext& ,
0079 const BoundTrackParameters& par,
0080 double ssize = std::numeric_limits<double>::max(),
0081 double stolerance = s_onSurfaceTolerance)
0082 : particleHypothesis(par.particleHypothesis()),
0083 stepSize(ssize),
0084 tolerance(stolerance),
0085 geoContext(gctx) {
0086 Vector3 position = par.position(gctx);
0087 Vector3 direction = par.direction();
0088 pars.template segment<3>(eFreePos0) = position;
0089 pars.template segment<3>(eFreeDir0) = direction;
0090 pars[eFreeTime] = par.time();
0091 pars[eFreeQOverP] = par.parameters()[eBoundQOverP];
0092 if (par.covariance()) {
0093
0094 const auto& surface = par.referenceSurface();
0095
0096 covTransport = true;
0097 cov = BoundSquareMatrix(*par.covariance());
0098 jacToGlobal = surface.boundToFreeJacobian(gctx, position, direction);
0099 }
0100 }
0101
0102
0103 BoundToFreeMatrix jacToGlobal = BoundToFreeMatrix::Zero();
0104
0105
0106 FreeMatrix jacTransport = FreeMatrix::Identity();
0107
0108
0109 Jacobian jacobian = Jacobian::Identity();
0110
0111
0112 FreeVector derivative = FreeVector::Zero();
0113
0114
0115 FreeVector pars = FreeVector::Zero();
0116
0117
0118 ParticleHypothesis particleHypothesis = ParticleHypothesis::pion();
0119
0120
0121 bool covTransport = false;
0122 Covariance cov = Covariance::Zero();
0123
0124
0125 double pathAccumulated = 0.;
0126
0127
0128 std::size_t nSteps = 0;
0129
0130
0131 std::size_t nStepTrials = 0;
0132
0133
0134 ConstrainedStep stepSize;
0135
0136
0137 double previousStepSize = 0.;
0138
0139
0140 double tolerance = s_onSurfaceTolerance;
0141
0142
0143 std::reference_wrapper<const GeometryContext> geoContext;
0144 };
0145
0146 StraightLineStepper() = default;
0147
0148 State makeState(std::reference_wrapper<const GeometryContext> gctx,
0149 std::reference_wrapper<const MagneticFieldContext> mctx,
0150 const BoundTrackParameters& par,
0151 double ssize = std::numeric_limits<double>::max(),
0152 double stolerance = s_onSurfaceTolerance) const {
0153 return State{gctx, mctx, par, ssize, stolerance};
0154 }
0155
0156
0157
0158
0159
0160
0161
0162
0163 void resetState(
0164 State& state, const BoundVector& boundParams,
0165 const BoundSquareMatrix& cov, const Surface& surface,
0166 const double stepSize = std::numeric_limits<double>::max()) const;
0167
0168
0169 Result<Vector3> getField(State& , const Vector3& ) const {
0170
0171 return Result<Vector3>::success({0., 0., 0.});
0172 }
0173
0174
0175
0176
0177 Vector3 position(const State& state) const {
0178 return state.pars.template segment<3>(eFreePos0);
0179 }
0180
0181
0182
0183
0184 Vector3 direction(const State& state) const {
0185 return state.pars.template segment<3>(eFreeDir0);
0186 }
0187
0188
0189
0190
0191 double qOverP(const State& state) const { return state.pars[eFreeQOverP]; }
0192
0193
0194
0195
0196 double absoluteMomentum(const State& state) const {
0197 return particleHypothesis(state).extractMomentum(qOverP(state));
0198 }
0199
0200
0201
0202
0203 Vector3 momentum(const State& state) const {
0204 return absoluteMomentum(state) * direction(state);
0205 }
0206
0207
0208
0209
0210 double charge(const State& state) const {
0211 return particleHypothesis(state).extractCharge(qOverP(state));
0212 }
0213
0214
0215
0216
0217 const ParticleHypothesis& particleHypothesis(const State& state) const {
0218 return state.particleHypothesis;
0219 }
0220
0221
0222
0223
0224 double time(const State& state) const { return state.pars[eFreeTime]; }
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240 Intersection3D::Status updateSurfaceStatus(
0241 State& state, const Surface& surface, std::uint8_t index,
0242 Direction navDir, const BoundaryTolerance& boundaryTolerance,
0243 ActsScalar surfaceTolerance = s_onSurfaceTolerance,
0244 const Logger& logger = getDummyLogger()) const {
0245 return detail::updateSingleSurfaceStatus<StraightLineStepper>(
0246 *this, state, surface, index, navDir, boundaryTolerance,
0247 surfaceTolerance, logger);
0248 }
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258 template <typename object_intersection_t>
0259 void updateStepSize(State& state, const object_intersection_t& oIntersection,
0260 Direction , bool release = true) const {
0261 detail::updateSingleStepSize<StraightLineStepper>(state, oIntersection,
0262 release);
0263 }
0264
0265
0266
0267
0268
0269
0270
0271 void updateStepSize(State& state, double stepSize,
0272 ConstrainedStep::Type stype = ConstrainedStep::actor,
0273 bool release = true) const {
0274 state.previousStepSize = state.stepSize.value();
0275 state.stepSize.update(stepSize, stype, release);
0276 }
0277
0278
0279
0280
0281
0282 double getStepSize(const State& state, ConstrainedStep::Type stype) const {
0283 return state.stepSize.value(stype);
0284 }
0285
0286
0287
0288
0289
0290 void releaseStepSize(State& state, ConstrainedStep::Type stype) const {
0291 state.stepSize.release(stype);
0292 }
0293
0294
0295
0296
0297 std::string outputStepSize(const State& state) const {
0298 return state.stepSize.toString();
0299 }
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315 Result<BoundState> boundState(
0316 State& state, const Surface& surface, bool transportCov = true,
0317 const FreeToBoundCorrection& freeToBoundCorrection =
0318 FreeToBoundCorrection(false)) const;
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328 template <typename propagator_state_t, typename navigator_t>
0329 bool prepareCurvilinearState(
0330 [[maybe_unused]] propagator_state_t& prop_state,
0331 [[maybe_unused]] const navigator_t& navigator) const {
0332
0333 if (prop_state.stepping.pathAccumulated == 0.) {
0334
0335 prop_state.stepping.derivative.template head<3>() =
0336 direction(prop_state.stepping);
0337
0338 prop_state.stepping.derivative(eFreeTime) =
0339 std::hypot(1., prop_state.stepping.particleHypothesis.mass() /
0340 absoluteMomentum(prop_state.stepping));
0341
0342 prop_state.stepping.derivative.template segment<3>(4) =
0343 Acts::Vector3::Zero().transpose();
0344
0345 prop_state.stepping.derivative(eFreeQOverP) = 0.;
0346 }
0347 return true;
0348 }
0349
0350
0351
0352
0353
0354
0355
0356
0357
0358
0359
0360
0361 CurvilinearState curvilinearState(State& state,
0362 bool transportCov = true) const;
0363
0364
0365
0366
0367
0368
0369
0370
0371 void update(State& state, const FreeVector& freeParams,
0372 const BoundVector& boundParams, const Covariance& covariance,
0373 const Surface& surface) const;
0374
0375
0376
0377
0378
0379
0380
0381
0382 void update(State& state, const Vector3& uposition, const Vector3& udirection,
0383 double qop, double time) const;
0384
0385
0386
0387
0388
0389
0390 void transportCovarianceToCurvilinear(State& state) const;
0391
0392
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404 void transportCovarianceToBound(
0405 State& state, const Surface& surface,
0406 const FreeToBoundCorrection& freeToBoundCorrection =
0407 FreeToBoundCorrection(false)) const;
0408
0409
0410
0411
0412
0413
0414
0415
0416
0417
0418
0419 template <typename propagator_state_t, typename navigator_t>
0420 Result<double> step(propagator_state_t& state,
0421 const navigator_t& ) const {
0422
0423 const auto h = state.stepping.stepSize.value() * state.options.direction;
0424 const auto m = state.stepping.particleHypothesis.mass();
0425 const auto p = absoluteMomentum(state.stepping);
0426
0427 const auto dtds = std::hypot(1., m / p);
0428
0429 Vector3 dir = direction(state.stepping);
0430 state.stepping.pars.template segment<3>(eFreePos0) += h * dir;
0431 state.stepping.pars[eFreeTime] += h * dtds;
0432
0433 if (state.stepping.covTransport) {
0434
0435 FreeMatrix D = FreeMatrix::Identity();
0436 D.block<3, 3>(0, 4) = ActsSquareMatrix<3>::Identity() * h;
0437
0438
0439 D(3, 7) = h * m * m * state.stepping.pars[eFreeQOverP] / dtds;
0440
0441 state.stepping.derivative(3) = dtds;
0442
0443 state.stepping.jacTransport = D * state.stepping.jacTransport;
0444 state.stepping.derivative.template head<3>() = dir;
0445 }
0446
0447
0448 state.stepping.pathAccumulated += h;
0449 ++state.stepping.nSteps;
0450 ++state.stepping.nStepTrials;
0451
0452
0453 return h;
0454 }
0455 };
0456
0457 template <typename navigator_t>
0458 struct SupportsBoundParameters<StraightLineStepper, navigator_t>
0459 : public std::true_type {};
0460
0461 }