Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Handle if all branches are stopped after filtering in Core CKF #3555

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 27 additions & 18 deletions Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,9 @@ class CombinatorialKalmanFilter {
result.pathLimitReached(state, stepper, navigator, logger());
const bool isTargetReached =
targetReached(state, stepper, navigator, logger());
if (isEndOfWorldReached || isPathLimitReached || isTargetReached) {
const bool allBranchesStopped = result.activeBranches.empty();
if (isEndOfWorldReached || isPathLimitReached || isTargetReached ||
allBranchesStopped) {
if (isEndOfWorldReached) {
ACTS_VERBOSE("End of world reached");
} else if (isPathLimitReached) {
Expand All @@ -617,20 +619,25 @@ class CombinatorialKalmanFilter {
stepper.releaseStepSize(state.stepping, ConstrainedStep::actor);
}

// Record the active branch and remove it from the list
storeLastActiveBranch(result);
result.activeBranches.pop_back();
if (!allBranchesStopped) {
// Record the active branch and remove it from the list
storeLastActiveBranch(result);
result.activeBranches.pop_back();
} else {
// This can happen if we stopped all branches in the filter step
ACTS_VERBOSE("All branches stopped");
}

// If no more active branches, done with filtering; Otherwise, reset
// propagation state to track state at next active branch
if (result.activeBranches.empty()) {
ACTS_VERBOSE("Kalman filtering finds "
<< result.collectedTracks.size() << " tracks");
result.finished = true;
} else {
if (!result.activeBranches.empty()) {
ACTS_VERBOSE("Propagation jumps to branch with tip = "
<< result.activeBranches.back().tipIndex());
reset(state, stepper, navigator, result);
} else {
ACTS_VERBOSE("Stop Kalman filtering with "
<< result.collectedTracks.size() << " found tracks");
result.finished = true;
}
}
}
Expand All @@ -649,7 +656,8 @@ class CombinatorialKalmanFilter {
typename navigator_t>
void reset(propagator_state_t& state, const stepper_t& stepper,
const navigator_t& navigator, result_type& result) const {
auto currentState = result.activeBranches.back().outermostTrackState();
auto currentBranch = result.activeBranches.back();
auto currentState = currentBranch.outermostTrackState();

// Reset the stepping state
stepper.resetState(state.stepping, currentState.filtered(),
Expand Down Expand Up @@ -791,8 +799,9 @@ class CombinatorialKalmanFilter {
currentBranch = result.activeBranches.back();
prevTip = currentBranch.tipIndex();

if (currentBranch.outermostTrackState().typeFlags().test(
TrackStateFlag::OutlierFlag)) {
auto currentState = currentBranch.outermostTrackState();

if (currentState.typeFlags().test(TrackStateFlag::OutlierFlag)) {
// We don't need to update the stepper given an outlier state
ACTS_VERBOSE("Outlier state detected on surface "
<< surface->geometryId());
Expand All @@ -802,16 +811,16 @@ class CombinatorialKalmanFilter {
<< nBranchesOnSurface << " branches");
// Update stepping state using filtered parameters of last track
// state on this surface
auto ts = result.activeBranches.back().outermostTrackState();
stepper.update(state.stepping,
MultiTrajectoryHelpers::freeFiltered(
state.options.geoContext, ts),
ts.filtered(), ts.filteredCovariance(), *surface);
state.options.geoContext, currentState),
currentState.filtered(),
currentState.filteredCovariance(), *surface);
ACTS_VERBOSE(
"Stepping state is updated with filtered parameter:");
ACTS_VERBOSE("-> "
<< ts.filtered().transpose()
<< " of track state with tip = " << ts.index());
ACTS_VERBOSE("-> " << currentState.filtered().transpose()
<< " of track state with tip = "
<< currentState.index());
}
}
}
Expand Down
Loading