Skip to content

Commit e790d83

Browse files
committed
Harmonize theta pole check in Kálmán updater
The gain matrix updater currently uses two slightly different methods for checking for theta poles. This means that we sometimes fire an assertion even if the code for gracefully exiting in these cases did not fire. This commit harmonizes the pole checks so that they produce identical results. In the process, it deduplicates the checks to save on compute.
1 parent 9bcb542 commit e790d83

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

core/include/traccc/fitting/kalman_filter/gain_matrix_updater.hpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "traccc/fitting/status_codes.hpp"
1818
#include "traccc/utils/logging.hpp"
1919
#include "traccc/utils/subspace.hpp"
20+
#include "traccc/utils/trigonometric_helpers.hpp"
2021

2122
namespace traccc {
2223

@@ -196,23 +197,23 @@ struct gain_matrix_updater {
196197
trk_state.filtered_params().set_covariance(filtered_cov);
197198
trk_state.filtered_chi2() = chi2_val;
198199

199-
if (math::fmod(trk_state.filtered_params().theta(),
200-
2.f * constant<traccc::scalar>::pi) == 0.f) {
200+
// Wrap the phi and theta angles in their valid ranges
201+
scalar wrapped_phi;
202+
scalar wrapped_theta;
203+
204+
std::tie(wrapped_phi, wrapped_theta) =
205+
detail::wrap_phi_theta(trk_state.filtered_params().phi(),
206+
trk_state.filtered_params().theta());
207+
208+
if (wrapped_theta == 0.f) {
201209
TRACCC_ERROR_HOST_DEVICE(
202-
"Hit theta pole after filtering : %f (unrecoverable error "
203-
"pre-normalization)",
210+
"Hit theta pole after filtering : %f (unrecoverable error)",
204211
trk_state.filtered_params().theta());
205212
return kalman_fitter_status::ERROR_THETA_POLE;
206213
}
207214

208-
// Wrap the phi and theta angles in their valid ranges
209-
normalize_angles(trk_state.filtered_params());
210-
211-
const scalar theta = trk_state.filtered_params().theta();
212-
if (theta <= 0.f || theta >= 2.f * constant<traccc::scalar>::pi) {
213-
TRACCC_ERROR_HOST_DEVICE("Hit theta pole in filtering : %f", theta);
214-
return kalman_fitter_status::ERROR_THETA_POLE;
215-
}
215+
trk_state.filtered_params().set_phi(wrapped_phi);
216+
trk_state.filtered_params().set_theta(wrapped_theta);
216217

217218
assert(!trk_state.filtered_params().is_invalid());
218219

0 commit comments

Comments
 (0)