Skip to content

Commit

Permalink
Only hold on to the navigation state and bound track params
Browse files Browse the repository at this point in the history
  • Loading branch information
niermann999 committed Nov 4, 2024
1 parent f04cf8e commit da5a9e4
Show file tree
Hide file tree
Showing 16 changed files with 150 additions and 96 deletions.
4 changes: 2 additions & 2 deletions core/include/traccc/finding/actors/ckf_aborter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ struct ckf_aborter : detray::actor {
DETRAY_HOST_DEVICE void operator()(state &abrt_state,
propagator_state_t &prop_state) const {

auto &navigation = prop_state._navigation;
auto &stepping = prop_state._stepping;
auto &navigation = prop_state.navigation();
auto &stepping = prop_state.stepping();

abrt_state.count++;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct interaction_register : detray::actor {
DETRAY_HOST_DEVICE void operator()(state &s,
propagator_state_t &prop_state) const {

auto &navigation = prop_state._navigation;
auto &navigation = prop_state.navigation();

// Do not apply material interaction on the sensitive surface - it is
// applied outside the propagator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct gain_matrix_updater {
TRACCC_HOST_DEVICE inline bool operator()(
const mask_group_t& /*mask_group*/, const index_t& /*index*/,
track_state<algebra_t>& trk_state,
bound_track_parameters& bound_params) const {
const bound_track_parameters& bound_params) const {

using shape_type = typename mask_group_t::value_type::shape;

Expand All @@ -57,7 +57,7 @@ struct gain_matrix_updater {
template <size_type D, typename shape_t>
TRACCC_HOST_DEVICE inline bool update(
track_state<algebra_t>& trk_state,
bound_track_parameters& bound_params) const {
const bound_track_parameters& bound_params) const {

static_assert(((D == 1u) || (D == 2u)),
"The measurement dimension should be 1 or 2");
Expand Down Expand Up @@ -123,25 +123,21 @@ struct gain_matrix_updater {
const matrix_type<1, 1> chi2 = matrix_operator().transpose(residual) *
matrix_operator().inverse(R) * residual;

// Set the stepper parameter
bound_params.set_vector(filtered_vec);
bound_params.set_covariance(filtered_cov);

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

// 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);
trk_state.filtered().set_covariance(filtered_cov);
trk_state.filtered_chi2() = matrix_operator().element(chi2, 0, 0);

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

return true;
}
};
Expand Down
11 changes: 7 additions & 4 deletions core/include/traccc/fitting/kalman_filter/kalman_actor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ struct kalman_actor : detray::actor {
TRACCC_HOST_DEVICE void operator()(state& actor_state,
propagator_state_t& propagation) const {

const auto& stepping = propagation._stepping;
auto& navigation = propagation._navigation;
const auto& stepping = propagation.stepping();
auto& navigation = propagation.navigation();

// If the iterator reaches the end, terminate the propagation
if (actor_state.is_complete()) {
Expand All @@ -106,14 +106,17 @@ struct kalman_actor : detray::actor {

const bool res =
sf.template visit_mask<gain_matrix_updater<algebra_t>>(
trk_state, propagation._stepping.bound_params());
trk_state, propagation.stepping().bound_params());

// Abort if the Kalman update fails
if (!res) {
propagation._heartbeat &= navigation.abort();
return;
}

// Update the propagation flow
propagation.stepping().bound_params() = trk_state.filtered();

// Set full jacobian
trk_state.jacobian() = stepping.full_jacobian();

Expand All @@ -122,7 +125,7 @@ struct kalman_actor : detray::actor {
// resolution)
propagation.set_particle(detail::correct_particle_hypothesis(
stepping.particle_hypothesis(),
propagation._stepping.bound_params()));
propagation.stepping().bound_params()));

// Update iterator
actor_state.next();
Expand Down
5 changes: 3 additions & 2 deletions core/include/traccc/fitting/kalman_filter/kalman_fitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,11 @@ class kalman_fitter {

// @TODO: Should be removed once detray is fixed to set the
// volume in the constructor
propagation._navigation.set_volume(seed_params.surface_link().volume());
propagation.navigation().set_volume(
seed_params.surface_link().volume());

// Set overstep tolerance, stepper constraint and mask tolerance
propagation._stepping
propagation.stepping()
.template set_constraint<detray::step::constraint::e_accuracy>(
m_cfg.propagation.stepping.step_constraint);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct kalman_step_aborter : public detray::actor {
propagator_state_t& prop_state) const {

// Convenience reference to the navigation state.
auto& navigation = prop_state._navigation;
auto& navigation = prop_state.navigation();

// Reset the step count if the track is on a sensitive surface.
if (navigation.is_on_sensitive()) {
Expand Down
2 changes: 1 addition & 1 deletion core/src/finding/ckf_algorithm_defdet_cfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

// Local include(s).
#include "find_tracks.hpp"
#include "find_tracks_alt.hpp"
#include "traccc/finding/ckf_algorithm.hpp"

// Detray include(s).
Expand Down
2 changes: 1 addition & 1 deletion core/src/finding/ckf_algorithm_teldet_cfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

// Local include(s).
#include "find_tracks.hpp"
#include "find_tracks_alt.hpp"
#include "traccc/finding/ckf_algorithm.hpp"

// Detray include(s).
Expand Down
6 changes: 3 additions & 3 deletions core/src/finding/find_tracks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ track_candidate_container_types::host find_tracks(
propagation.set_particle(detail::correct_particle_hypothesis(
config.ptc_hypothesis, param));

propagation._stepping
propagation.stepping()
.template set_constraint<detray::step::constraint::e_accuracy>(
config.propagation.stepping.step_constraint);

Expand All @@ -315,7 +315,7 @@ track_candidate_container_types::host find_tracks(

// @TODO: Should be removed once detray is fixed to set the
// volume in the constructor
propagation._navigation.set_volume(param.surface_link().volume());
propagation.navigation().set_volume(param.surface_link().volume());

// Propagate to the next surface
propagator.propagate_sync(propagation,
Expand All @@ -324,7 +324,7 @@ track_candidate_container_types::host find_tracks(
// If a surface found, add the parameter for the next
// step
if (s4.success) {
out_params.push_back(propagation._stepping.bound_params());
out_params.push_back(propagation.stepping().bound_params());
param_to_link[step].push_back(link_id);
}
// Unless the track found a surface, it is considered a
Expand Down
Loading

0 comments on commit da5a9e4

Please sign in to comment.