@@ -21,29 +21,27 @@ struct parameter_transporter : actor {
2121
2222 // / @name Type definitions for the struct
2323 // / @{
24-
24+ using scalar_type = dscalar< algebra_t >;
2525 // Transformation matching this struct
2626 using transform3_type = dtransform3D<algebra_t >;
27- // scalar_type
28- using scalar_type = dscalar<algebra_t >;
2927 // Matrix actor
3028 using matrix_operator = dmatrix_operator<algebra_t >;
31- // 2D matrix type
32- template <std::size_t ROWS, std::size_t COLS>
33- using matrix_type = dmatrix<algebra_t , ROWS, COLS>;
3429 // bound matrix type
3530 using bound_matrix_t = bound_matrix<algebra_t >;
31+ // Matrix type for bound to free jacobian
32+ using bound_to_free_matrix_t = bound_to_free_matrix<algebra_t >;
3633 // / @}
3734
3835 struct get_full_jacobian_kernel {
3936
4037 template <typename mask_group_t , typename index_t ,
41- typename propagator_state_t >
38+ typename stepper_state_t >
4239 DETRAY_HOST_DEVICE inline bound_matrix_t operator ()(
4340 const mask_group_t & /* mask_group*/ , const index_t & /* index*/ ,
4441 const transform3_type& trf3,
45- const bound_to_free_matrix<algebra_t >& bound_to_free_jacobian,
46- const propagator_state_t & propagation) const {
42+ const bound_to_free_matrix_t & bound_to_free_jacobian,
43+ const material<scalar_type>* vol_mat_ptr,
44+ const stepper_state_t & stepping) const {
4745
4846 using frame_t = typename mask_group_t ::value_type::shape::
4947 template local_frame_type<algebra_t >;
@@ -54,32 +52,23 @@ struct parameter_transporter : actor {
5452 using free_to_bound_matrix_t =
5553 typename jacobian_engine_t ::free_to_bound_matrix_type;
5654
57- // Stepper and Navigator states
58- auto & stepping = propagation._stepping ;
59-
60- // Free vector
61- const auto & free_params = stepping ();
62-
6355 // Free to bound jacobian at the destination surface
6456 const free_to_bound_matrix_t free_to_bound_jacobian =
65- jacobian_engine_t::free_to_bound_jacobian (trf3, free_params);
66-
67- // Transport jacobian in free coordinate
68- const free_matrix_t & free_transport_jacobian =
69- stepping.transport_jacobian ();
57+ jacobian_engine_t::free_to_bound_jacobian (trf3, stepping ());
7058
7159 // Path correction factor
72- free_matrix_t path_correction = jacobian_engine_t::path_correction (
73- stepping ().pos (), stepping ().dir (), stepping.dtds (),
74- stepping.dqopds (), trf3);
60+ const free_matrix_t path_correction =
61+ jacobian_engine_t::path_correction (
62+ stepping ().pos (), stepping ().dir (), stepping.dtds (),
63+ stepping.dqopds (vol_mat_ptr), trf3);
7564
7665 const free_matrix_t correction_term =
7766 matrix_operator ()
7867 .template identity <e_free_size, e_free_size>() +
7968 path_correction;
8069
8170 return free_to_bound_jacobian * correction_term *
82- free_transport_jacobian * bound_to_free_jacobian;
71+ stepping. transport_jacobian () * bound_to_free_jacobian;
8372 }
8473 };
8574
@@ -94,46 +83,51 @@ struct parameter_transporter : actor {
9483 return ;
9584 }
9685
97- using detector_type = typename propagator_state_t ::detector_type;
98- using geo_cxt_t = typename detector_type::geometry_context;
99- const geo_cxt_t ctx{};
86+ typename propagator_state_t ::detector_type::geometry_context ctx{};
10087
10188 // Current Surface
10289 const auto sf = navigation.get_surface ();
10390
91+ // Bound track params of departure surface
92+ auto & bound_params = stepping.bound_params ();
93+
10494 // Covariance is transported only when the previous surface is an
10595 // actual tracking surface. (i.e. This disables the covariance transport
10696 // from curvilinear frame)
107- if (!detail::is_invalid_value (stepping. prev_sf_index () )) {
97+ if (!bound_params. surface_link (). is_invalid ( )) {
10898
10999 // Previous surface
110- tracking_surface<detector_type> prev_sf{navigation.detector (),
111- stepping. prev_sf_index ()};
100+ tracking_surface prev_sf{navigation.detector (),
101+ bound_params. surface_link ()};
112102
113- const bound_to_free_matrix< algebra_t > bound_to_free_jacobian =
114- prev_sf.bound_to_free_jacobian (ctx, stepping. bound_params () );
103+ const bound_to_free_matrix_t bound_to_free_jacobian =
104+ prev_sf.bound_to_free_jacobian (ctx, bound_params);
115105
106+ auto vol = navigation.get_volume ();
107+ const auto vol_mat_ptr =
108+ vol.has_material () ? vol.material_parameters (stepping ().pos ())
109+ : nullptr ;
116110 stepping.set_full_jacobian (
117111 sf.template visit_mask <get_full_jacobian_kernel>(
118- sf.transform (ctx), bound_to_free_jacobian, propagation));
112+ sf.transform (ctx), bound_to_free_jacobian, vol_mat_ptr,
113+ propagation._stepping ));
119114
120115 // Calculate surface-to-surface covariance transport
121116 const bound_matrix_t new_cov =
122- stepping.full_jacobian () *
123- stepping.bound_params ().covariance () *
117+ stepping.full_jacobian () * bound_params.covariance () *
124118 matrix_operator ().transpose (stepping.full_jacobian ());
119+
125120 stepping.bound_params ().set_covariance (new_cov);
126121 }
127122
128123 // Convert free to bound vector
129- stepping. bound_params () .set_parameter_vector (
124+ bound_params.set_parameter_vector (
130125 sf.free_to_bound_vector (ctx, stepping ()));
131126
132127 // Set surface link
133- stepping.bound_params ().set_surface_link (sf.barcode ());
134-
135- return ;
128+ bound_params.set_surface_link (sf.barcode ());
136129 }
130+
137131}; // namespace detray
138132
139133} // namespace detray
0 commit comments