Skip to content

Commit efef72b

Browse files
authored
Merge pull request #964 from beomki-yeo/remove-full-jacobian
Remove full jacobian from stepper
2 parents b90bf15 + b0a795b commit efef72b

File tree

3 files changed

+40
-35
lines changed

3 files changed

+40
-35
lines changed

core/include/detray/propagator/actors/parameter_transporter.hpp

+37-18
Original file line numberDiff line numberDiff line change
@@ -94,26 +94,12 @@ struct parameter_transporter : actor {
9494
// from curvilinear frame)
9595
if (!bound_params.surface_link().is_invalid()) {
9696

97-
// Previous surface
98-
tracking_surface prev_sf{navigation.detector(),
99-
bound_params.surface_link()};
100-
101-
const bound_to_free_matrix_t bound_to_free_jacobian =
102-
prev_sf.bound_to_free_jacobian(gctx, bound_params);
103-
104-
auto vol = navigation.get_volume();
105-
const auto vol_mat_ptr =
106-
vol.has_material() ? vol.material_parameters(stepping().pos())
107-
: nullptr;
108-
stepping.set_full_jacobian(
109-
sf.template visit_mask<get_full_jacobian_kernel>(
110-
sf.transform(gctx), bound_to_free_jacobian, vol_mat_ptr,
111-
propagation._stepping));
97+
const auto full_jacobian = get_full_jacobian(propagation);
11298

11399
// Calculate surface-to-surface covariance transport
114-
const bound_matrix_t new_cov =
115-
stepping.full_jacobian() * bound_params.covariance() *
116-
matrix::transpose(stepping.full_jacobian());
100+
const bound_matrix_t new_cov = full_jacobian *
101+
bound_params.covariance() *
102+
matrix::transpose(full_jacobian);
117103

118104
stepping.bound_params().set_covariance(new_cov);
119105
}
@@ -126,6 +112,39 @@ struct parameter_transporter : actor {
126112
bound_params.set_surface_link(sf.barcode());
127113
}
128114

115+
template <typename propagator_state_t>
116+
DETRAY_HOST_DEVICE inline bound_matrix_t get_full_jacobian(
117+
propagator_state_t& propagation) const {
118+
119+
const auto& stepping = propagation._stepping;
120+
const auto& navigation = propagation._navigation;
121+
122+
// Geometry context for this track
123+
const auto& gctx = propagation._context;
124+
125+
// Current Surface
126+
const auto sf = navigation.get_surface();
127+
128+
// Bound track params of departure surface
129+
auto& bound_params = stepping.bound_params();
130+
131+
// Previous surface
132+
tracking_surface prev_sf{navigation.detector(),
133+
bound_params.surface_link()};
134+
135+
const bound_to_free_matrix_t bound_to_free_jacobian =
136+
prev_sf.bound_to_free_jacobian(gctx, bound_params);
137+
138+
auto vol = navigation.get_volume();
139+
const auto vol_mat_ptr = vol.has_material()
140+
? vol.material_parameters(stepping().pos())
141+
: nullptr;
142+
143+
return sf.template visit_mask<get_full_jacobian_kernel>(
144+
sf.transform(gctx), bound_to_free_jacobian, vol_mat_ptr,
145+
propagation._stepping);
146+
}
147+
129148
}; // namespace detray
130149

131150
} // namespace detray

core/include/detray/propagator/base_stepper.hpp

-16
Original file line numberDiff line numberDiff line change
@@ -181,18 +181,6 @@ class base_stepper {
181181
return m_jac_transport;
182182
}
183183

184-
/// @returns the current full Jacbian.
185-
DETRAY_HOST_DEVICE
186-
inline const bound_matrix_type &full_jacobian() const {
187-
return m_full_jacobian;
188-
}
189-
190-
/// Set new full Jacbian.
191-
DETRAY_HOST_DEVICE
192-
inline void set_full_jacobian(const bound_matrix_type &jac) {
193-
m_full_jacobian = jac;
194-
}
195-
196184
/// Reset transport Jacbian.
197185
DETRAY_HOST_DEVICE
198186
inline void reset_transport_jacobian() {
@@ -230,10 +218,6 @@ class base_stepper {
230218
/// Jacobian transport matrix
231219
free_matrix_type m_jac_transport = matrix::identity<free_matrix_type>();
232220

233-
/// Full jacobian
234-
bound_matrix_type m_full_jacobian =
235-
matrix::identity<bound_matrix_type>();
236-
237221
/// Bound covariance
238222
bound_track_parameters_type m_bound_params;
239223

tests/integration_tests/cpu/propagator/jacobian_validation.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,9 @@ struct bound_getter : actor {
438438
actor_state.m_path_length = stepping.path_length();
439439
actor_state.m_abs_path_length = stepping.abs_path_length();
440440
actor_state.m_param_destination = stepping.bound_params();
441-
actor_state.m_jacobi = stepping.full_jacobian();
441+
actor_state.m_jacobi =
442+
parameter_transporter<algebra_t>().get_full_jacobian(
443+
propagation);
442444

443445
// Stop navigation if the destination surface found
444446
propagation._heartbeat &= navigation.exit();

0 commit comments

Comments
 (0)