Skip to content

Commit

Permalink
Merge pull request #864 from niermann999/ref-stepper-encapsulation
Browse files Browse the repository at this point in the history
Ref: stepper state encapsulation
  • Loading branch information
stephenswat authored Oct 22, 2024
2 parents 2d47f73 + 91e08dc commit bb6a963
Show file tree
Hide file tree
Showing 19 changed files with 392 additions and 298 deletions.
4 changes: 2 additions & 2 deletions core/include/detray/navigation/policies.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct stepper_default_policy : actor {

// Not a severe change to track state expected
// Policy is called after stepsize update -> use prev. step size
if (math::fabs(stepping._prev_step_size) <
if (math::fabs(stepping.prev_step_size()) <
math::fabs(
stepping.constraints().template size<>(stepping.direction())) -
pol_state.tol) {
Expand Down Expand Up @@ -112,7 +112,7 @@ struct stepper_rk_policy : actor {
auto &navigation = propagation._navigation;

// Policy is called after stepsize update -> use prev. step size
const scalar rel_correction{(stepping._prev_step_size - navigation()) /
const scalar rel_correction{(stepping.prev_step_size() - navigation()) /
navigation()};

// Large correction to the stepsize - re-initialize the volume
Expand Down
4 changes: 2 additions & 2 deletions core/include/detray/propagator/actors/aborters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct pathlimit_aborter : actor {

const scalar step_limit =
abrt_state.path_limit() -
math::fabs(prop_state._stepping._abs_path_length);
math::fabs(prop_state._stepping.abs_path_length());

// Check the path limit
if (step_limit <= 0.f) {
Expand Down Expand Up @@ -112,7 +112,7 @@ struct next_surface_aborter : actor {

// Abort at the next sensitive surface
if (navigation.is_on_sensitive() &&
stepping._s > abrt_state.min_step_length) {
stepping.path_from_surface() > abrt_state.min_step_length) {
prop_state._heartbeat &= navigation.abort();
abrt_state.success = true;
}
Expand Down
8 changes: 4 additions & 4 deletions core/include/detray/propagator/actors/parameter_resetter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ struct parameter_resetter : actor {

// Reset the free vector
stepping() = detail::bound_to_free_vector(trf3, mask,
stepping._bound_params);
stepping.bound_params());

// Reset the path length
stepping._s = 0;
stepping.reset_path_from_surface();

// Reset jacobian transport to identity matrix
matrix_operator().set_identity(stepping._jac_transport);
stepping.reset_transport_jacobian();

// Reset the surface index
stepping._prev_sf_id = sf_idx;
stepping.set_prev_sf_index(sf_idx);
}
};

Expand Down
23 changes: 12 additions & 11 deletions core/include/detray/propagator/actors/parameter_transporter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct parameter_transporter : actor {

// Transport jacobian in free coordinate
const free_matrix_t& free_transport_jacobian =
stepping._jac_transport;
stepping.transport_jacobian();

// Path correction factor
free_matrix_t path_correction = jacobian_engine_t::path_correction(
Expand Down Expand Up @@ -107,32 +107,33 @@ struct parameter_transporter : actor {
// Covariance is transported only when the previous surface is an
// actual tracking surface. (i.e. This disables the covariance transport
// from curvilinear frame)
if (stepping._prev_sf_id != detail::invalid_value<dindex>()) {
if (!detail::is_invalid_value(stepping.prev_sf_index())) {

// Previous surface
tracking_surface<detector_type> prev_sf{navigation.detector(),
stepping._prev_sf_id};
stepping.prev_sf_index()};

const bound_to_free_matrix<algebra_t> bound_to_free_jacobian =
prev_sf.bound_to_free_jacobian(ctx, stepping._bound_params);
prev_sf.bound_to_free_jacobian(ctx, stepping.bound_params());

stepping._full_jacobian =
stepping.set_full_jacobian(
sf.template visit_mask<get_full_jacobian_kernel>(
sf.transform(ctx), bound_to_free_jacobian, propagation);
sf.transform(ctx), bound_to_free_jacobian, propagation));

// Calculate surface-to-surface covariance transport
const bound_matrix_t new_cov =
stepping._full_jacobian * stepping._bound_params.covariance() *
matrix_operator().transpose(stepping._full_jacobian);
stepping._bound_params.set_covariance(new_cov);
stepping.full_jacobian() *
stepping.bound_params().covariance() *
matrix_operator().transpose(stepping.full_jacobian());
stepping.bound_params().set_covariance(new_cov);
}

// Convert free to bound vector
stepping._bound_params.set_parameter_vector(
stepping.bound_params().set_parameter_vector(
sf.free_to_bound_vector(ctx, stepping()));

// Set surface link
stepping._bound_params.set_surface_link(sf.barcode());
stepping.bound_params().set_surface_link(sf.barcode());

return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ struct pointwise_material_interactor : actor {

auto &stepping = prop_state._stepping;

this->update(geo_context_type{}, stepping._ptc,
stepping._bound_params, interactor_state,
this->update(geo_context_type{}, stepping.particle_hypothesis(),
stepping.bound_params(), interactor_state,
static_cast<int>(navigation.direction()),
navigation.get_surface());
}
Expand Down
Loading

0 comments on commit bb6a963

Please sign in to comment.