ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
navigator_base.hpp
1// This file is part of the ACTS project.
2//
3// Copyright (C) 2016 CERN for the benefit of the ACTS project
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
9#pragma once
10
11// Project include(s)
12#include "detray/definitions/detail/qualifiers.hpp"
13#include "detray/definitions/indexing.hpp"
14#include "detray/definitions/navigation.hpp"
15#include "detray/definitions/units.hpp"
16#include "detray/geometry/surface.hpp"
17#include "detray/navigation/detail/intersection_kernel.hpp"
18#include "detray/navigation/detail/navigation_functions.hpp"
19#include "detray/navigation/intersection/intersection.hpp"
20#include "detray/navigation/intersection/ray_intersector.hpp"
21#include "detray/navigation/navigation_config.hpp"
22#include "detray/navigation/navigation_state.hpp"
23#include "detray/utils/logging.hpp"
24
25namespace detray {
26
44template <typename navigator_impl_t>
46 public:
56 template <typename track_t, typename nav_state_t, typename context_t>
57 DETRAY_HOST_DEVICE constexpr void init(
58 const track_t &track, nav_state_t &navigation,
59 const navigation::config &cfg, const context_t &ctx,
60 const bool resolve_overstepping = false) const {
61 // Run local navigation in the current volume
62 navigation::local_navigation(track, navigation, cfg, ctx,
63 resolve_overstepping);
64
65 DETRAY_VERBOSE_HOST("Status: " << navigation.status() << " (next sf.: "
66 << navigation.next_surface().index() << ")");
67 if (navigation.is_on_surface()) {
68 DETRAY_VERBOSE_HOST("-> Current surface: "
69 << navigation.current_surface().index()
70 << ", has material: " << std::boolalpha
71 << navigation.current_surface().has_material()
72 << std::noboolalpha);
73 }
74 DETRAY_VERBOSE_HOST_DEVICE("Update complete: dist to next %f mm",
75 navigation());
76 }
77
94 template <typename track_t, typename nav_state_t, typename context_t>
95 DETRAY_HOST_DEVICE DETRAY_INLINE constexpr bool update(
96 const track_t &track, nav_state_t &navigation,
97 const navigation::config &cfg, const context_t &ctx) const {
98 assert(navigation.is_alive());
99 assert(!track.is_invalid());
100
101 // Update was completely successful (most likely case)
102 if (navigation.trust_level() == navigation::trust_level::e_full) {
103 DETRAY_VERBOSE_HOST_DEVICE(
104 "-> Full trust, nothing left to do: dist to next %f mm",
105 navigation());
106 return false;
107 }
108
109 // Candidates are re-evaluated based on the current trust level.
110 // Should result in 'full trust'
111 constexpr const navigator_impl_t navigation_impl{};
112 bool is_init = navigation_impl.update_impl(track, navigation, cfg, ctx);
113
114 // Otherwise: if we encountered a portal, perform volume switch
115 if (navigation.is_on_portal()) {
116 navigation::volume_switch(track, navigation, cfg, ctx);
117 is_init = true;
118
119 // Reached end of detector
120 if (!navigation.is_alive()) {
121 return false;
122 }
123 }
124 // If no trust could be restored during the update, try to rescue the
125 // navigation stream by re-initializing with loose tolerances
126 if (navigation.trust_level() != navigation::trust_level::e_full ||
127 navigation.cache_exhausted()) {
128 is_init = true;
129 navigation::init_loose_cfg(track, navigation, cfg, ctx);
130
131 navigation.run_inspector(cfg, track.pos(), track.dir(), "Re-init: ");
132 }
133
134 DETRAY_VERBOSE_HOST("Status: " << navigation.status() << " (vol.:"
135 << navigation.volume() << ", next sf.: "
136 << navigation.next_surface().index() << ")");
137 if (navigation.is_on_surface()) {
138 DETRAY_VERBOSE_HOST("-> Current surface: "
139 << navigation.current_surface().index()
140 << ", has material: " << std::boolalpha
141 << navigation.current_surface().has_material()
142 << std::noboolalpha);
143 }
144 DETRAY_VERBOSE_HOST_DEVICE("Update complete: dist to next %f mm",
145 navigation());
146
147 return is_init;
148 }
149};
150
151} // namespace detray
Navigation base class - interface towards the propagator.
Definition navigator_base.hpp:45
constexpr void init(const track_t &track, nav_state_t &navigation, const navigation::config &cfg, const context_t &ctx, const bool resolve_overstepping=false) const
Helper method to initialize a volume.
Definition navigator_base.hpp:57
constexpr bool update(const track_t &track, nav_state_t &navigation, const navigation::config &cfg, const context_t &ctx) const
Complete update of the navigation flow.
Definition navigator_base.hpp:95
Detray include(s).
Definition array_operators.hpp:18
Navigation configuration.
Definition navigation_config.hpp:24