File indexing completed on 2026-11-25 09:02:17
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Propagator/ConstrainedStep.hpp"
0012 #include "Acts/Surfaces/Surface.hpp"
0013 #include "Acts/Utilities/Helpers.hpp"
0014 #include "Acts/Utilities/Logger.hpp"
0015
0016 #include <cmath>
0017 #include <cstdint>
0018
0019 namespace Acts::detail {
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 template <typename propagator_state_t, typename stepper_t>
0031 bool pathLimitReached(propagator_state_t& state, const stepper_t& stepper,
0032 double pathLimit, const Logger& logger) {
0033 const double distance =
0034 std::abs(pathLimit) - std::abs(stepper.pathLength(state.stepping));
0035 const double tolerance = state.options.surfaceTolerance;
0036 if (std::abs(distance) < std::abs(tolerance)) {
0037 ACTS_VERBOSE("Path limit reached at distance " << distance);
0038 return true;
0039 }
0040 stepper.updateStepSize(state.stepping, distance,
0041 ConstrainedStep::Type::Actor);
0042 ACTS_VERBOSE("Step size updated to the path limit: "
0043 << stepper.outputStepSize(state.stepping));
0044 return false;
0045 }
0046
0047
0048
0049
0050
0051
0052
0053
0054 template <typename propagator_state_t, typename navigator_t>
0055 bool surfaceReached(propagator_state_t& state, const navigator_t& navigator,
0056 const Surface* surface, const Logger& logger) {
0057 if (surface == nullptr ||
0058 navigator.currentSurface(state.navigation) != surface) {
0059 return false;
0060 }
0061 ACTS_VERBOSE("Target surface reached.");
0062 return true;
0063 }
0064
0065
0066
0067
0068
0069
0070 template <typename propagator_state_t, typename navigator_t>
0071 bool endOfWorldReached(propagator_state_t& state,
0072 const navigator_t& navigator) {
0073 return navigator.endOfWorldReached(state.navigation);
0074 }
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085 template <typename propagator_state_t, typename navigator_t>
0086 bool volumeConstraintReached(propagator_state_t& state,
0087 const navigator_t& navigator,
0088 const Logger& logger) {
0089 const auto& constrainToVolumeIds = state.options.constrainToVolumeIds;
0090 const auto& endOfWorldVolumeIds = state.options.endOfWorldVolumeIds;
0091
0092 if (constrainToVolumeIds.empty() && endOfWorldVolumeIds.empty()) {
0093 return false;
0094 }
0095 const auto* currentVolume = navigator.currentVolume(state.navigation);
0096
0097
0098 if (currentVolume == nullptr) {
0099 return false;
0100 }
0101
0102 const auto currentVolumeId =
0103 static_cast<std::uint32_t>(currentVolume->geometryId().volume());
0104
0105 if (!constrainToVolumeIds.empty() &&
0106 !rangeContainsValue(constrainToVolumeIds, currentVolumeId)) {
0107 ACTS_VERBOSE("Abort with volume constraint " << currentVolumeId);
0108 return true;
0109 }
0110
0111 if (!endOfWorldVolumeIds.empty() &&
0112 rangeContainsValue(endOfWorldVolumeIds, currentVolumeId)) {
0113 ACTS_VERBOSE("Abort with additional end of world volume "
0114 << currentVolumeId);
0115 return true;
0116 }
0117
0118 return false;
0119 }
0120
0121
0122
0123
0124
0125
0126
0127 template <typename propagator_state_t, typename navigator_t>
0128 bool anySurfaceReached(propagator_state_t& state,
0129 const navigator_t& navigator) {
0130 const Surface* startSurface = navigator.startSurface(state.navigation);
0131 const Surface* targetSurface = navigator.targetSurface(state.navigation);
0132 const Surface* currentSurface = navigator.currentSurface(state.navigation);
0133
0134
0135
0136 return currentSurface != nullptr && currentSurface != startSurface &&
0137 currentSurface != targetSurface;
0138 }
0139
0140 }