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

Wrap the phi of track parameters in the range of [-pi,pi] #736

Merged
merged 4 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
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
17 changes: 17 additions & 0 deletions core/include/traccc/edm/track_parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

// traccc include
#include "traccc/definitions/common.hpp"
#include "traccc/definitions/math.hpp"
#include "traccc/definitions/primitives.hpp"
#include "traccc/definitions/qualifiers.hpp"
#include "traccc/definitions/track_parametrization.hpp"
Expand All @@ -31,4 +32,20 @@ using bound_covariance = bound_track_parameters::covariance_type;
using bound_track_parameters_collection_types =
collection_types<bound_track_parameters>;

// Wrap the phi of track parameters to [-pi,pi]
TRACCC_HOST_DEVICE
inline void wrap_phi(bound_track_parameters& param) {

traccc::scalar phi = param.phi();
static constexpr traccc::scalar TWOPI =
2.f * traccc::constant<traccc::scalar>::pi;
phi = math::fmod(phi, TWOPI);
if (phi > traccc::constant<traccc::scalar>::pi) {
phi -= TWOPI;
} else if (phi < -traccc::constant<traccc::scalar>::pi) {
phi += TWOPI;
}
param.set_phi(phi);
}

} // namespace traccc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ struct gain_matrix_smoother {

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

matrix_type<D, e_bound_size> H = meas.subs.template projector<D>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ struct gain_matrix_updater {
// Set the stepper parameter
bound_params.set_vector(filtered_vec);
bound_params.set_covariance(filtered_cov);
// Wrap the phi in the range of [-pi, pi]
wrap_phi(bound_params);

// Set the track state parameters
trk_state.filtered().set_vector(filtered_vec);
Expand Down
Loading