diff --git a/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp b/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp index cab69814517..66025969fa8 100644 --- a/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp +++ b/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp @@ -29,6 +29,7 @@ #include "Acts/Propagator/ConstrainedStep.hpp" #include "Acts/Propagator/Propagator.hpp" #include "Acts/Propagator/StandardAborters.hpp" +#include "Acts/Propagator/detail/LoopProtection.hpp" #include "Acts/Propagator/detail/PointwiseMaterialInteraction.hpp" #include "Acts/Surfaces/BoundaryCheck.hpp" #include "Acts/TrackFinding/CombinatorialKalmanFilterError.hpp" @@ -392,6 +393,13 @@ class CombinatorialKalmanFilter { ACTS_VERBOSE("CombinatorialKalmanFilter step"); + // Initialize path limit reached aborter + if (result.pathLimitReached.internalLimit == + std::numeric_limits::max()) { + detail::setupLoopProtection(state, stepper, result.pathLimitReached, + true, logger()); + } + if (!result.filtered && filterTargetReached(state, stepper, navigator, logger())) { navigator.navigationBreak(state.navigation, true); @@ -488,12 +496,19 @@ class CombinatorialKalmanFilter { } } - if (endOfWorldReached(state, stepper, navigator, logger()) || - result.pathLimitReached(state, stepper, navigator, logger())) { - navigator.targetReached(state.navigation, false); - if (result.activeTips.empty()) { - // we are already done - } else if (result.activeTips.size() == 1) { + bool isEndOfWorldReached = + endOfWorldReached(state, stepper, navigator, logger()); + bool isPathLimitReached = + result.pathLimitReached(state, stepper, navigator, logger()); + if (isEndOfWorldReached || isPathLimitReached) { + if (isEndOfWorldReached) { + ACTS_VERBOSE("End of world reached"); + } + if (isPathLimitReached) { + ACTS_VERBOSE("Path limit reached"); + } + + if (result.activeTips.size() <= 1) { // this was the last track - we are done ACTS_VERBOSE("Kalman filtering finds " << result.lastTrackIndices.size() << " tracks"); @@ -553,7 +568,7 @@ class CombinatorialKalmanFilter { // track parameters for found track indexed with iSmoothed bool isTargetReached = smoothingTargetReached(state, stepper, navigator, logger()); - bool isPathLimitReached = + isPathLimitReached = result.pathLimitReached(state, stepper, navigator, logger()); if (result.smoothed && (isTargetReached || isPathLimitReached)) { ACTS_VERBOSE( @@ -1357,6 +1372,20 @@ class CombinatorialKalmanFilter { } }; + /// Void path limit reached aborter to replace the default since the path + /// limit is handled in the CKF actor internally. + struct StubPathLimitReached { + double internalLimit{}; + + template + bool operator()(propagator_state_t& /*unused*/, const stepper_t& /*unused*/, + const navigator_t& /*unused*/, + const Logger& /*unused*/) const { + return false; + } + }; + public: /// Combinatorial Kalman Filter implementation, calls the Kalman filter /// and smoother @@ -1443,7 +1472,8 @@ class CombinatorialKalmanFilter { r.stateBuffer = stateBuffer; r.stateBuffer->clear(); - auto result = m_propagator.template propagate( + auto result = m_propagator.template propagate< + start_parameters_t, decltype(propOptions), PathLimitReached>( initialParameters, propOptions, false, std::move(inputResult)); if (!result.ok()) {