Skip to content

Commit

Permalink
Fix navigation assertions that failed in conjunction with navigation …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
niermann999 authored Oct 30, 2024
1 parent e50e9a0 commit 26680b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion io/include/detray/io/csv/track_parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ inline void write_free_track_params(
for (const auto &[charge, track_param] : track_params) {

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

io::csv::free_track_parameters track_param_data{};
track_param_data.track_id = track_idx;
Expand Down
13 changes: 10 additions & 3 deletions tests/include/detray/test/validation/step_tracer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,16 @@ struct step_tracer : actor {
// Collect the data whenever requested
if (navigation.is_on_surface() || tracer_state.m_collect_every_step) {

step_data_t sd{stepping.step_size(), stepping.path_length(),
stepping.n_total_trials(), navigation.direction(),
navigation.barcode(), stepping(),
const geometry::barcode bcd{navigation.is_on_surface()
? navigation.barcode()
: geometry::barcode{}};

step_data_t sd{stepping.step_size(),
stepping.path_length(),
stepping.n_total_trials(),
navigation.direction(),
bcd,
stepping(),
stepping.transport_jacobian()};

tracer_state.m_steps.push_back(std::move(sd));
Expand Down

0 comments on commit 26680b6

Please sign in to comment.