12#if defined(__GNUC__) && !defined(__clang__)
13#pragma GCC diagnostic warning "-Wmaybe-uninitialized"
17#include "detray/core/concepts.hpp"
18#include "detray/definitions/algebra.hpp"
19#include "detray/definitions/math.hpp"
20#include "detray/navigation/detail/print_state.hpp"
21#include "detray/navigation/intersection/intersection.hpp"
22#include "detray/navigation/navigation_config.hpp"
23#include "detray/propagator/base_actor.hpp"
24#include "detray/propagator/base_stepper.hpp"
25#include "detray/propagator/detail/print_stepper_state.hpp"
26#include "detray/propagator/stepping_config.hpp"
27#include "detray/tracks/ray.hpp"
28#include "detray/utils/logging.hpp"
29#include "detray/utils/tuple_helpers.hpp"
32#include "detray/test/utils/data_record.hpp"
46template <
typename... Inspectors>
49 using view_type = dmulti_view<detail::get_view_t<Inspectors>...>;
62 template <concepts::device_view view_t>
65 view, std::make_index_sequence<sizeof...(Inspectors)>{})) {}
75 template <
unsigned int current_id = 0,
typename state_type,
76 concepts::point3D point3_t, concepts::vector3D vector3_t,
80 const point3_t &pos,
const vector3_t &dir,
81 const char *message, Args &&...args) {
83 std::get<current_id>(
_inspectors)(state, cfg, pos, dir, message,
84 std::forward<Args>(args)...);
87 if constexpr (current_id < std::tuple_size<inspector_tuple_t>::value - 1) {
88 return operator()<current_id + 1>(state, cfg, pos, dir, message,
89 std::forward<Args>(args)...);
98 template <
unsigned int current_id = 0,
typename state_type,
typename... Args>
99 DETRAY_HOST_DEVICE
auto operator()(state_type &state,
const char *message,
105 if constexpr (current_id < std::tuple_size<inspector_tuple_t>::value - 1) {
106 return operator()<current_id + 1>(state, message,
107 std::forward<Args>(args)...);
112 template <
typename inspector_t>
113 DETRAY_HOST_DEVICE
constexpr decltype(
auto)
get() {
118 template <
typename inspector_t>
119 DETRAY_HOST_DEVICE
constexpr decltype(
auto)
get()
const {
124 template <std::
size_t I>
125 DETRAY_HOST_DEVICE
constexpr decltype(
auto)
get() {
130 template <std::
size_t I>
131 DETRAY_HOST_DEVICE
constexpr decltype(
auto)
get()
const {
138 template <concepts::device_view view_t, std::size_t... I>
140 view_t &view, std::index_sequence<I...> ) {
141 return detail::make_tuple<std::tuple>(
142 Inspectors(detail::get<I>(view.m_view))...);
146namespace navigation {
150template <concepts::detector detector_t,
151 template <
typename...>
class vector_t =
dvector,
152 status... navigation_status>
174 dvector_view<candidate_record_t> &view)
197 const point3_t &pos,
const vector3_t &dir,
200 DETRAY_VERBOSE_HOST_DEVICE(
"Actor: Check navigation status...");
203 if ((
is_status(state.status(), navigation_status) || ...)) {
204 DETRAY_VERBOSE_HOST_DEVICE(
"Actor: ...Status matched:");
207 const bool first_obj{
211 if ((state.is_on_portal() &&
current_vol != state.volume()) ||
213 state.current().surface().identifier() !=
214 object_trace.back().intersection().surface().identifier()) {
215 DETRAY_VERBOSE_HOST_DEVICE(
"Actor: -> Record surface %d",
216 state.current_surface().index());
218 last_pos = algebra::cast_to<double>(pos);
219 last_dir = algebra::cast_to<double>(dir);
228 template <
typename state_type>
249 constexpr bool is_status(
const status &nav_stat,
const status &ref_stat) {
250 return (nav_stat == ref_stat);
309 const point3_t &track_pos,
const vector3_t &track_dir,
311 const message_generator_t &msg_gen = {}) {
312 std::string msg(message);
314 if constexpr (!std::same_as<message_generator_t, void_generator>) {
317 if (state.status() == navigation::status::e_abort) {
322 debug_stream <<
"----------------------------------------" << std::endl;
325 debug_stream << navigation::print_candidates(state, cfg, track_pos,
336 template <
typename state_type,
typename message_generator_t =
void_generator>
337 auto operator()(
const state_type &state,
const char *message,
338 const message_generator_t &msg_gen = {}) {
339 std::string msg(message);
341 if constexpr (!std::same_as<message_generator_t, void_generator>) {
344 if (state.status() == navigation::status::e_abort) {
349 debug_stream <<
"----------------------------------------" << std::endl;
405 template <
typename state_type, concepts::scalar scalar_t>
407 const char *message,
const scalar_t dist) {
408 std::string msg(message);
411 debug_stream << detray::stepping::print_state(state, dist);
419 template <
typename state_type, concepts::scalar scalar_t>
421 const char *message,
const scalar_t ,
422 const std::size_t n_trials,
const scalar_t step_scalor) {
423 std::string msg(message);
426 debug_stream << detray::stepping::print_state(state, n_trials, step_scalor);
Definition concepts.hpp:77
Definition concepts.hpp:65
Detray include(s).
Definition array_operators.hpp:18
vecmem::vector< value_t > dvector
Vector container backed by vecmem.
Definition containers.hpp:34
unsigned int dindex
Default index type.
Definition indexing.hpp:18
constexpr dindex dindex_invalid
Global invalid index definition.
Definition indexing.hpp:21
dmulti_view< detail::get_view_t< Inspectors >... > view_type
Device view type for the contained inspectors.
Definition inspectors.hpp:49
dmulti_view< detail::get_view_t< const Inspectors >... > const_view_type
Const device view type for the contained inspectors.
Definition inspectors.hpp:51
constexpr auto unroll_views(view_t &view, std::index_sequence< I... >)
Definition inspectors.hpp:139
constexpr decltype(auto) get()
Definition inspectors.hpp:113
auto operator()(state_type &state, const navigation::config &cfg, const point3_t &pos, const vector3_t &dir, const char *message, Args &&...args)
Inspector interface.
Definition inspectors.hpp:78
std::tuple< Inspectors... > inspector_tuple_t
Tuple type storing the inspectors.
Definition inspectors.hpp:54
auto operator()(state_type &state, const char *message, Args &&...args)
Inspector interface.
Definition inspectors.hpp:99
aggregate_inspector(view_t &view)
Construct from the inspector.
Definition inspectors.hpp:63
inspector_tuple_t _inspectors
Inspectors aggregated by this object.
Definition inspectors.hpp:56
constexpr decltype(auto) get() const
Definition inspectors.hpp:119
aggregate_inspector()=default
Default constructor.
Record of a surface intersection along a track.
Definition data_record.hpp:27
dscalar< algebra_type > scalar_type
Scalar type used by this record.
Definition data_record.hpp:35
dpoint3D< algebra_type > point3_type
3D point type used to store positions.
Definition data_record.hpp:37
dvector3D< algebra_type > vector3_type
3D vector type used to store directions.
Definition data_record.hpp:39
Navigation configuration.
Definition navigation_config.hpp:24
constexpr const candidate_record_t & operator[](std::size_t i) const
Definition inspectors.hpp:236
typename candidate_record_t::scalar_type scalar_type
Scalar type used by candidate records.
Definition inspectors.hpp:157
object_tracer()=default
Default constructor.
dindex current_vol
Current volume index.
Definition inspectors.hpp:180
intersection_record< detector_t > candidate_record_t
Record type for an encountered candidate.
Definition inspectors.hpp:155
auto operator()(const state_type &, const char *)
Inspector interface.
Definition inspectors.hpp:229
typename candidate_record_t::point3_type point3_type
3D point type used by candidate records.
Definition inspectors.hpp:159
vector3_type last_dir
Last recorded direction.
Definition inspectors.hpp:186
dvector_view< candidate_record_t > view_type
Mutable device view type for candidate records.
Definition inspectors.hpp:164
vector_t< candidate_record_t > object_trace
Record all objects the navigator encounters.
Definition inspectors.hpp:178
typename candidate_record_t::vector3_type vector3_type
3D vector type used by candidate records.
Definition inspectors.hpp:161
object_tracer(dvector_view< candidate_record_t > &view)
Device-side construction from a vecmem based view type.
Definition inspectors.hpp:173
point3_type last_pos
Last recorded position.
Definition inspectors.hpp:184
const scalar_type inv_pos
Invalid position value used to initialize the trace.
Definition inspectors.hpp:182
dvector_view< const candidate_record_t > const_view_type
Const device view type for candidate records.
Definition inspectors.hpp:166
constexpr bool is_status(const status &nav_stat, const status &ref_stat)
Compares a navigation status with the tracers references.
Definition inspectors.hpp:249
constexpr const auto & trace() const
Definition inspectors.hpp:242
auto operator()(const state_type &state, const navigation::config &, const point3_t &pos, const vector3_t &dir, const char *, Args &&...)
Inspector interface.
Definition inspectors.hpp:195
Definition inspectors.hpp:262
auto operator()(const state_type &state, const char *message, const message_generator_t &msg_gen={})
Inspector interface.
Definition inspectors.hpp:337
std::stringstream debug_stream
Gathers navigation information across navigator update calls.
Definition inspectors.hpp:360
print_inspector & operator=(print_inspector &&other)=default
Move assignemten operator.
~print_inspector()=default
Default destructor.
print_inspector(const print_inspector &other)
Copy constructor ensures that the string stream is set up identically.
Definition inspectors.hpp:269
auto operator()(const state_type &state, const navigation::config &cfg, const point3_t &track_pos, const vector3_t &track_dir, const char *message, const message_generator_t &msg_gen={})
Inspector interface.
Definition inspectors.hpp:308
dvector_view< char > view_type
Mutable device view type for the debug stream.
Definition inspectors.hpp:258
print_inspector & operator=(const print_inspector &other)
Copy assignemten operator ensures that the string stream is set up identically.
Definition inspectors.hpp:283
std::string fata_error_msg
Special message that is collected if the navigator hits a fatal error.
Definition inspectors.hpp:362
print_inspector()=default
Default constructor.
std::string to_string() const
Definition inspectors.hpp:357
dvector_view< const char > const_view_type
Const device view type for the debug stream.
Definition inspectors.hpp:260
print_inspector(print_inspector &&other)=default
Move constructor.
Configuration flags and limits consumed by a stepper.
Definition stepping_config.hpp:29
std::string to_string() const
Definition inspectors.hpp:430
void operator()(const state_type &state, const stepping::config &, const char *message, const scalar_t dist)
Inspector interface.
Definition inspectors.hpp:406
print_inspector(const print_inspector &other)
Copy constructor ensures that the string stream is set up identically.
Definition inspectors.hpp:377
print_inspector & operator=(const print_inspector &other)
Copy assignemten operator ensures that the string stream is set up identically.
Definition inspectors.hpp:384
void operator()(const state_type &state, const stepping::config &, const char *message, const scalar_t, const std::size_t n_trials, const scalar_t step_scalor)
Inspector interface.
Definition inspectors.hpp:420
print_inspector & operator=(print_inspector &&other)=default
Move assignemten operator.
print_inspector()=default
Default constructor.
std::stringstream debug_stream
Gathers stepping information from inside the stepper methods.
Definition inspectors.hpp:399