Skip to content

Commit 26680b6

Browse files
authored
Fix navigation assertions that failed in conjunction with navigation validation tools (#858)
Fixes two assertions that were triggered by navigation validation tools: - if the step stracer is set to record every step, make sure the barcode is only accessed when actually on surface - since rays return zero for 'qop', make sure the free track parameter momentum is only written to file if it can be retrieved. Otherwise write the (normalized) direction to file
1 parent e50e9a0 commit 26680b6

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

io/include/detray/io/csv/track_parameters.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ inline void write_free_track_params(
134134
for (const auto &[charge, track_param] : track_params) {
135135

136136
const auto &glob_pos = track_param.pos();
137-
const auto &p = track_param.mom(charge);
137+
// Momentum may not be retrievable for straight-line tracks
138+
const auto &p{charge != 0.f ? track_param.mom(charge)
139+
: track_param.dir()};
138140

139141
io::csv::free_track_parameters track_param_data{};
140142
track_param_data.track_id = track_idx;

tests/include/detray/test/validation/step_tracer.hpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,16 @@ struct step_tracer : actor {
9595
// Collect the data whenever requested
9696
if (navigation.is_on_surface() || tracer_state.m_collect_every_step) {
9797

98-
step_data_t sd{stepping.step_size(), stepping.path_length(),
99-
stepping.n_total_trials(), navigation.direction(),
100-
navigation.barcode(), stepping(),
98+
const geometry::barcode bcd{navigation.is_on_surface()
99+
? navigation.barcode()
100+
: geometry::barcode{}};
101+
102+
step_data_t sd{stepping.step_size(),
103+
stepping.path_length(),
104+
stepping.n_total_trials(),
105+
navigation.direction(),
106+
bcd,
107+
stepping(),
101108
stepping.transport_jacobian()};
102109

103110
tracer_state.m_steps.push_back(std::move(sd));

0 commit comments

Comments
 (0)