Skip to content

Commit

Permalink
Update the navigation config to the ODD/ITk defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
niermann999 committed Oct 15, 2024
1 parent ce2f877 commit ce76635
Show file tree
Hide file tree
Showing 18 changed files with 157 additions and 112 deletions.
4 changes: 2 additions & 2 deletions core/include/detray/navigation/navigation_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ struct config {
/// Minimal tolerance: ~ position uncertainty on surface
float min_mask_tolerance{1e-5f * unit<float>::mm};
/// Maximal tolerance: loose tolerance when still far away from surface
float max_mask_tolerance{1.f * unit<float>::mm};
float max_mask_tolerance{3.f * unit<float>::mm};
/// Scale factor on the path used for the mask tolerance calculation
float mask_tolerance_scalor{5e-2f};
/// @}
/// Maximal absolute path distance for a track to be considered 'on surface'
float path_tolerance{1.f * unit<float>::um};
/// How far behind the track position to look for candidates
float overstep_tolerance{-100.f * unit<float>::um};
float overstep_tolerance{-300.f * unit<float>::um};
/// Search window size for grid based acceleration structures
/// (0, 0): only look at current bin
std::array<dindex, 2> search_window = {0u, 0u};
Expand Down
16 changes: 12 additions & 4 deletions core/include/detray/navigation/navigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,8 @@ class navigator {

init(propagation, cfg);

// Fresh initialization, reset trust and hearbeat
// Fresh initialization, reset trust and hearbeat even though we are
// on inner portal
navigation.m_trust_level = navigation::trust_level::e_full;
navigation.m_heartbeat = true;

Expand All @@ -717,9 +718,16 @@ class navigator {
navigation.m_heartbeat &= init(propagation, cfg);

// Sanity check: Should never be the case after complete update call
if (navigation.trust_level() != navigation::trust_level::e_full ||
navigation.is_exhausted()) {
navigation.abort();
if (navigation.trust_level() != navigation::trust_level::e_full) {
// Try to save the navigation flow: Look further behind the track
auto loose_cfg{cfg};
loose_cfg.overstep_tolerance = -10.f * cfg.max_mask_tolerance;
navigation.m_heartbeat &= init(propagation, loose_cfg);

// Unrecoverable
if (navigation.trust_level() != navigation::trust_level::e_full) {
navigation.abort();
}
}

return navigation.m_heartbeat;
Expand Down
6 changes: 4 additions & 2 deletions core/include/detray/propagator/line_stepper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class line_stepper final
/// @return returning the heartbeat, indicating if the stepping is alive
template <typename propagation_state_t>
DETRAY_HOST_DEVICE bool step(propagation_state_t& propagation,
const stepping::config& cfg = {}) const {
const stepping::config& cfg) const {
// Get stepper and navigator states
state& stepping = propagation._stepping;
auto& navigation = propagation._navigation;
Expand Down Expand Up @@ -125,7 +125,9 @@ class line_stepper final
stepping.advance_track();

// Advance jacobian transport
stepping.advance_jacobian();
if (cfg.do_covariance_transport) {
stepping.advance_jacobian();
}

// Count the number of steps
stepping.count_trials();
Expand Down
2 changes: 1 addition & 1 deletion core/include/detray/propagator/propagator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct propagator {

/// Construct from a propagator configuration
DETRAY_HOST_DEVICE
explicit constexpr propagator(const propagation::config &cfg = {})
explicit constexpr propagator(const propagation::config &cfg)
: m_cfg{cfg} {}

/// Propagation that state aggregates a stepping and a navigation state. It
Expand Down
2 changes: 2 additions & 0 deletions tests/include/detray/test/utils/inspectors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ struct print_inspector {
debug_stream << msg << std::endl;

debug_stream << "Volume" << tabs << state.volume() << std::endl;
debug_stream << "Overstep tol:\t\t\t" << cfg.overstep_tolerance
<< std::endl;
debug_stream << "Track pos: [r:" << getter::perp(track_pos)
<< ", z:" << track_pos[2] << "], dir: [" << track_dir[0]
<< ", " << track_dir[1] << ", " << track_dir[2] << "]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ int main(int argc, char **argv) {
cfg_hel_nav.name("telescope_detector_helix_navigation");
cfg_hel_nav.whiteboard(white_board);
cfg_hel_nav.propagation().navigation.overstep_tolerance =
-300.f * unit<float>::um;
-100.f * unit<float>::um;

detail::register_checks<test::helix_navigation>(tel_det, tel_names,
cfg_hel_nav);
Expand Down
14 changes: 10 additions & 4 deletions tests/integration_tests/cpu/material/material_interaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ GTEST_TEST(detray_material, telescope_geometry_energy_loss) {
using propagator_t = propagator<stepper_t, navigator_t, actor_chain_t>;

// Propagator is built from the stepper and navigator
propagator_t p{};
propagation::config prop_cfg{};
prop_cfg.navigation.overstep_tolerance = -100.f * unit<float>::um;
propagator_t p{prop_cfg};

constexpr scalar q{-1.f};
constexpr scalar iniP{10.f * unit<scalar>::GeV};
Expand Down Expand Up @@ -193,7 +195,7 @@ GTEST_TEST(detray_material, telescope_geometry_energy_loss) {
interactor_state, parameter_resetter_state);

// Propagator and its state
alt_propagator_t alt_p{};
alt_propagator_t alt_p{prop_cfg};
alt_propagator_t::state alt_state(alt_bound_param, det);

// Propagate
Expand Down Expand Up @@ -251,7 +253,9 @@ GTEST_TEST(detray_material, telescope_geometry_scattering_angle) {
using propagator_t = propagator<stepper_t, navigator_t, actor_chain_t>;

// Propagator is built from the stepper and navigator
propagator_t p{};
propagation::config prop_cfg{};
prop_cfg.navigation.overstep_tolerance = -100.f * unit<float>::um;
propagator_t p{prop_cfg};

constexpr scalar q{-1.f};
constexpr scalar iniP{10.f * unit<scalar>::GeV};
Expand Down Expand Up @@ -381,7 +385,9 @@ GTEST_TEST(detray_material, telescope_geometry_volume_material) {
using propagator_t = propagator<stepper_t, navigator_t, actor_chain_t>;

// Propagator is built from the stepper and navigator
propagator_t p{};
propagation::config prop_cfg{};
prop_cfg.navigation.overstep_tolerance = -100.f * unit<float>::um;
propagator_t p{prop_cfg};

propagator_t::state state(bound_param, const_bfield, det);

Expand Down
3 changes: 2 additions & 1 deletion tests/integration_tests/cpu/propagator/guided_navigator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ GTEST_TEST(detray_navigation, guided_navigator) {
pathlimit_aborter::state pathlimit{200.f * unit<scalar_t>::cm};

// Propagator
propagator_t p{};
propagation::config prop_cfg{};
propagator_t p{prop_cfg};
propagator_t::state guided_state(track, b_field, telescope_det);

// Propagate
Expand Down
9 changes: 5 additions & 4 deletions tests/integration_tests/cpu/propagator/propagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ GTEST_TEST(detray_propagator, propagator_line_stepper) {
const vector3 mom{1.f, 1.f, 0.f};
free_track_parameters<algebra_t> track(pos, 0.f, mom, -1.f);

propagator_t p{};
propagation::config prop_cfg{};
propagator_t p{prop_cfg};

propagator_t::state state(track, d);

Expand Down Expand Up @@ -384,23 +385,23 @@ INSTANTIATE_TEST_SUITE_P(
INSTANTIATE_TEST_SUITE_P(
detray_propagator_validation2, PropagatorWithRkStepper,
::testing::Values(std::make_tuple(-400.f * unit<scalar_t>::um,
40.f * unit<scalar_t>::mm,
std::numeric_limits<scalar_t>::max(),
vector3{0.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T})));

INSTANTIATE_TEST_SUITE_P(
detray_propagator_validation3, PropagatorWithRkStepper,
::testing::Values(std::make_tuple(-400.f * unit<scalar_t>::um,
40.f * unit<scalar_t>::mm,
std::numeric_limits<scalar_t>::max(),
vector3{1.f * unit<scalar_t>::T,
0.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T})));

INSTANTIATE_TEST_SUITE_P(
detray_propagator_validation4, PropagatorWithRkStepper,
::testing::Values(std::make_tuple(-600.f * unit<scalar_t>::um,
35.f * unit<scalar_t>::mm,
std::numeric_limits<scalar_t>::max(),
vector3{1.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T})));
86 changes: 46 additions & 40 deletions tests/integration_tests/device/cuda/propagator_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,26 +97,29 @@ INSTANTIATE_TEST_SUITE_P(
0.f * unit<scalar_t>::T,
2.f * unit<scalar_t>::T})));

INSTANTIATE_TEST_SUITE_P(CudaPropagatorValidation2, CudaPropConstBFieldMng,
::testing::Values(std::make_tuple(
-400.f * unit<float>::um, 40.f * unit<float>::mm,
vector3_t{0.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T})));

INSTANTIATE_TEST_SUITE_P(CudaPropagatorValidation3, CudaPropConstBFieldMng,
::testing::Values(std::make_tuple(
-400.f * unit<float>::um, 40.f * unit<float>::mm,
vector3_t{1.f * unit<scalar_t>::T,
0.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T})));

INSTANTIATE_TEST_SUITE_P(CudaPropagatorValidation4, CudaPropConstBFieldMng,
::testing::Values(std::make_tuple(
-600.f * unit<float>::um, 35.f * unit<float>::mm,
vector3_t{1.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T})));
INSTANTIATE_TEST_SUITE_P(
CudaPropagatorValidation2, CudaPropConstBFieldMng,
::testing::Values(std::make_tuple(-400.f * unit<float>::um,
std::numeric_limits<float>::max(),
vector3_t{0.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T})));

INSTANTIATE_TEST_SUITE_P(
CudaPropagatorValidation3, CudaPropConstBFieldMng,
::testing::Values(std::make_tuple(-400.f * unit<float>::um,
std::numeric_limits<float>::max(),
vector3_t{1.f * unit<scalar_t>::T,
0.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T})));

INSTANTIATE_TEST_SUITE_P(
CudaPropagatorValidation4, CudaPropConstBFieldMng,
::testing::Values(std::make_tuple(-600.f * unit<float>::um,
std::numeric_limits<float>::max(),
vector3_t{1.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T})));

INSTANTIATE_TEST_SUITE_P(
CudaPropagatorValidation5, CudaPropConstBFieldCpy,
Expand All @@ -126,26 +129,29 @@ INSTANTIATE_TEST_SUITE_P(
0.f * unit<scalar_t>::T,
2.f * unit<scalar_t>::T})));

INSTANTIATE_TEST_SUITE_P(CudaPropagatorValidation6, CudaPropConstBFieldCpy,
::testing::Values(std::make_tuple(
-400.f * unit<float>::um, 40.f * unit<float>::mm,
vector3_t{0.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T})));

INSTANTIATE_TEST_SUITE_P(CudaPropagatorValidation7, CudaPropConstBFieldCpy,
::testing::Values(std::make_tuple(
-400.f * unit<float>::um, 40.f * unit<float>::mm,
vector3_t{1.f * unit<scalar_t>::T,
0.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T})));

INSTANTIATE_TEST_SUITE_P(CudaPropagatorValidation8, CudaPropConstBFieldCpy,
::testing::Values(std::make_tuple(
-600.f * unit<float>::um, 35.f * unit<float>::mm,
vector3_t{1.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T})));
INSTANTIATE_TEST_SUITE_P(
CudaPropagatorValidation6, CudaPropConstBFieldCpy,
::testing::Values(std::make_tuple(-400.f * unit<float>::um,
std::numeric_limits<float>::max(),
vector3_t{0.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T})));

INSTANTIATE_TEST_SUITE_P(
CudaPropagatorValidation7, CudaPropConstBFieldCpy,
::testing::Values(std::make_tuple(-400.f * unit<float>::um,
std::numeric_limits<float>::max(),
vector3_t{1.f * unit<scalar_t>::T,
0.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T})));

INSTANTIATE_TEST_SUITE_P(
CudaPropagatorValidation8, CudaPropConstBFieldCpy,
::testing::Values(std::make_tuple(-600.f * unit<float>::um,
std::numeric_limits<float>::max(),
vector3_t{1.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T,
1.f * unit<scalar_t>::T})));

/// This tests the device propagation in an inhomogenepus magnetic field
TEST(CudaPropagatorValidation9, inhomogeneous_bfield_cpy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ int main(int argc, char **argv) {
cfg_hel_nav.name("telescope_detector_helix_navigation_cuda");
cfg_hel_nav.whiteboard(white_board);
cfg_hel_nav.propagation().navigation.overstep_tolerance =
-300.f * unit<float>::um;
-100.f * unit<float>::um;

detail::register_checks<detray::cuda::helix_navigation>(tel_det, tel_names,
cfg_hel_nav);
Expand Down
Loading

0 comments on commit ce76635

Please sign in to comment.