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

Fail the KF if the smoother result is invalid #781

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
20 changes: 15 additions & 5 deletions core/include/traccc/fitting/kalman_filter/gain_matrix_smoother.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct gain_matrix_smoother {
///
/// @return true if the update succeeds
template <typename mask_group_t, typename index_t>
TRACCC_HOST_DEVICE inline void operator()(
TRACCC_HOST_DEVICE inline bool operator()(
const mask_group_t& /*mask_group*/, const index_t& /*index*/,
track_state<algebra_t>& cur_state,
const track_state<algebra_t>& next_state) {
Expand All @@ -49,14 +49,16 @@ struct gain_matrix_smoother {
const auto D = cur_state.get_measurement().meas_dim;
assert(D == 1u || D == 2u);
if (D == 1u) {
smoothe<1u, shape_type>(cur_state, next_state);
return smoothe<1u, shape_type>(cur_state, next_state);
} else if (D == 2u) {
smoothe<2u, shape_type>(cur_state, next_state);
return smoothe<2u, shape_type>(cur_state, next_state);
}

return false;
}

template <size_type D, typename shape_t>
TRACCC_HOST_DEVICE inline void smoothe(
TRACCC_HOST_DEVICE inline bool smoothe(
track_state<algebra_t>& cur_state,
const track_state<algebra_t>& next_state) const {
const auto meas = cur_state.get_measurement();
Expand Down Expand Up @@ -107,6 +109,14 @@ struct gain_matrix_smoother {

cur_state.smoothed().set_vector(smt_vec);
cur_state.smoothed().set_covariance(smt_cov);

// Return false if track is parallel to z-axis or phi is not finite
const scalar theta = cur_state.smoothed().theta();
if (theta <= 0.f || theta >= constant<traccc::scalar>::pi ||
!std::isfinite(cur_state.smoothed().phi())) {
return false;
}

// Wrap the phi in the range of [-pi, pi]
wrap_phi(cur_state.smoothed());

Expand Down Expand Up @@ -134,7 +144,7 @@ struct gain_matrix_smoother {

cur_state.smoothed_chi2() = matrix_operator().element(chi2, 0, 0);

return;
return true;
}
};

Expand Down
Loading