Skip to content

Commit

Permalink
fix: Fix CKF pathlimit abort (acts-project#2744)
Browse files Browse the repository at this point in the history
The CKF has special path limit treatment during propagation which is overruled by propagation internal path limit aborter in some cases. Here I try to improve this by putting a stub into the propagation
  • Loading branch information
andiwand authored Dec 5, 2023
1 parent 9bfcfc1 commit 04544d9
Showing 1 changed file with 38 additions and 8 deletions.
46 changes: 38 additions & 8 deletions Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -392,6 +393,13 @@ class CombinatorialKalmanFilter {

ACTS_VERBOSE("CombinatorialKalmanFilter step");

// Initialize path limit reached aborter
if (result.pathLimitReached.internalLimit ==
std::numeric_limits<double>::max()) {
detail::setupLoopProtection(state, stepper, result.pathLimitReached,
true, logger());
}

if (!result.filtered &&
filterTargetReached(state, stepper, navigator, logger())) {
navigator.navigationBreak(state.navigation, true);
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 <typename propagator_state_t, typename stepper_t,
typename navigator_t>
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
Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit 04544d9

Please sign in to comment.