Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/include/detray/builders/homogeneous_material_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class homogeneous_material_builder final : public volume_decorator<detector_t> {
sf.update_material(offset);
DETRAY_DEBUG_HOST("-> material now: " << sf.material());
}
if constexpr (detector_t::materials::template is_defined<
if constexpr (detector_t::materials::template contains<
material_rod<scalar_type>>()) {
if (sf.material().id() == material_id::e_rod) {
DETRAY_DEBUG_HOST(
Expand All @@ -120,7 +120,7 @@ class homogeneous_material_builder final : public volume_decorator<detector_t> {
<< m_materials.template size<material_id::e_slab>()
<< " slabs into detector materials");

if constexpr (detector_t::materials::template is_defined<
if constexpr (detector_t::materials::template contains<
material_rod<scalar_type>>()) {
DETRAY_DEBUG_HOST("-> Appending "
<< m_materials.template size<material_id::e_rod>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ class homogeneous_material_factory final
mat_idx = this->insert_in_container(mat_coll, mat_slab,
m_links.at(sf_idx).second);
}
if constexpr (detector_t::materials::template is_defined<
if constexpr (detector_t::materials::template contains<
material_rod<scalar_type>>()) {
if (m_links.at(sf_idx).first == material_id::e_rod) {
auto &mat_coll =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class homogeneous_material_generator final
bool is_line{false};
link_t mat_link;

if constexpr (detector_t::materials::template is_defined<
if constexpr (detector_t::materials::template contains<
material_rod<scalar_t>>()) {

using mask_id = typename detector_t::masks::id;
Expand Down
3 changes: 1 addition & 2 deletions core/include/detray/builders/material_map_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,8 @@ struct add_sf_material_map {
typename decltype(mat_grid)::template type<false>;

// Not every mask shape might be used for material maps
if constexpr (materials_t::template is_defined<non_owning_t>()) {
if constexpr (materials_t::template contains<non_owning_t>()) {
DETRAY_VERBOSE_HOST("Filling material grid...");

// Add the material slabs to the grid
for (const auto& bin : bin_data) {
mat_grid.template populate<replace<>>(bin.local_bin_idx,
Expand Down
2 changes: 1 addition & 1 deletion core/include/detray/builders/material_map_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class material_map_generator final : public factory_decorator<detector_t> {
const auto sf_idx{m_surface_range[0] + i};

// Skip line surfaces, if any are defined
if constexpr (detector_t::materials::template is_defined<
if constexpr (detector_t::materials::template contains<
material_rod<scalar_t>>()) {

const mask_id sf_mask_id = sf.mask().id();
Expand Down
15 changes: 8 additions & 7 deletions core/include/detray/builders/surface_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,22 +167,23 @@ class surface_factory : public surface_factory_interface<detector_t> {
return {surfaces_offset, surfaces_offset};
}

constexpr auto mask_id = detector_t::masks::template get_id<
mask<mask_shape_t, algebra_t, volume_link_t>>();
if constexpr (static_cast<std::size_t>(mask_id) >=
detector_t::masks::n_types) {
using mask_t = mask<mask_shape_t, algebra_t, volume_link_t>;

if constexpr (!detector_t::masks::template contains<mask_t>()) {
std::stringstream err_str{};
err_str << "Cannot match shape type to mask ID: Found "
<< mask_shape_t::name << " at mask id " << mask_id;
err_str << "Could not find mask type '" << mask_shape_t::name
<< "' in detector";

DETRAY_FATAL_HOST(err_str.str());
throw std::invalid_argument(err_str.str());
} else {

using surface_t = typename detector_t::surface_type;
using mask_link_t = typename surface_t::mask_link;
using material_link_t = typename surface_t::material_link;

constexpr auto mask_id{
detector_t::masks::template get_id<mask_t>()};

// The material will be added in a later step
constexpr auto no_material{surface_t::material_id::e_none};

Expand Down
50 changes: 32 additions & 18 deletions core/include/detray/core/detail/multi_store.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ class multi_store {
/// @{
using value_types = type_registry<ID, detail::get_value_t<Ts>...>;
template <ID id>
using get_type = typename value_types::template get_type<id>::type;
using get_type = typename value_types::template get_type<id>;
template <typename T>
using get_id = typename value_types::template get_index<T>;
static constexpr ids get_id{value_types::template get_id<T>()};
/// @}

/// Underlying tuple container that can handle vecmem views
Expand Down Expand Up @@ -131,43 +131,49 @@ class multi_store {
/// @returns the collections iterator at the start position.
template <ID id = ID{0}>
DETRAY_HOST_DEVICE constexpr auto begin(const context_type & /*ctx*/ = {}) {
return detail::get<value_types::to_index(id)>(m_tuple_container)
return detail::get<value_types::template to_index<id>()>(
m_tuple_container)
.begin();
}

/// @returns the collections iterator sentinel.
template <ID id = ID{0}>
DETRAY_HOST_DEVICE constexpr auto end(const context_type & /*ctx*/ = {}) {
return detail::get<value_types::to_index(id)>(m_tuple_container).end();
return detail::get<value_types::template to_index<id>()>(
m_tuple_container)
.end();
}

/// @returns a data collection by @tparam ID - const
template <ID id>
DETRAY_HOST_DEVICE constexpr decltype(auto) get(
const context_type & /*ctx*/ = {}) const noexcept {
return detail::get<value_types::to_index(id)>(m_tuple_container);
return detail::get<value_types::template to_index<id>()>(
m_tuple_container);
}

/// @returns a data collection by @tparam ID - non-const
template <ID id>
DETRAY_HOST_DEVICE constexpr decltype(auto) get(
const context_type & /*ctx*/ = {}) noexcept {
return detail::get<value_types::to_index(id)>(m_tuple_container);
return detail::get<value_types::template to_index<id>()>(
m_tuple_container);
}

/// @returns the size of a data collection by @tparam ID
template <ID id>
DETRAY_HOST_DEVICE constexpr auto size(
const context_type & /*ctx*/ = {}) const noexcept -> dindex {
return static_cast<dindex>(
detail::get<value_types::to_index(id)>(m_tuple_container).size());
detail::get<value_types::template to_index<id>()>(m_tuple_container)
.size());
}

/// @returns the number of elements in all collections
template <std::size_t current_idx = 0>
DETRAY_HOST_DEVICE auto total_size(const context_type &ctx = {},
dindex n = 0u) const noexcept -> dindex {
n += size<value_types::to_id(current_idx)>(ctx);
n += size<value_types::template to_id<current_idx>()>(ctx);

if constexpr (current_idx < sizeof...(Ts) - 1) {
return total_size<current_idx + 1>(ctx, n);
Expand All @@ -179,15 +185,16 @@ class multi_store {
template <ID id>
DETRAY_HOST_DEVICE constexpr auto empty(
const context_type & /*ctx*/ = {}) const noexcept -> bool {
return detail::get<value_types::to_index(id)>(m_tuple_container)
return detail::get<value_types::template to_index<id>()>(
m_tuple_container)
.empty();
}

/// @returns true if every collection in container is empty.
template <std::size_t current_idx = 0>
DETRAY_HOST_DEVICE constexpr bool all_empty(const context_type &ctx = {},
bool is_empty = true) const {
is_empty &= empty<value_types::to_id(current_idx)>(ctx);
is_empty &= empty<value_types::template to_id<current_idx>()>(ctx);

if constexpr (current_idx < sizeof...(Ts) - 1) {
return all_empty<current_idx + 1>(ctx, is_empty);
Expand All @@ -198,13 +205,14 @@ class multi_store {
/// Removes and destructs all elements in a specific collection.
template <ID id>
DETRAY_HOST void clear(const context_type & /*ctx*/) {
detail::get<value_types::to_index(id)>(m_tuple_container).clear();
detail::get<value_types::template to_index<id>()>(m_tuple_container)
.clear();
}

/// Removes and destructs all elements in the container.
template <std::size_t current_idx = 0>
DETRAY_HOST void clear_all(const context_type &ctx = {}) {
clear<value_types::to_id(current_idx)>(ctx);
clear<value_types::template to_id<current_idx>()>(ctx);

if constexpr (current_idx < sizeof...(Ts) - 1) {
clear_all<current_idx + 1>(ctx);
Expand All @@ -214,14 +222,16 @@ class multi_store {
/// Reserve memory of size @param n for a collection given by @tparam id
template <ID id>
DETRAY_HOST void reserve(std::size_t n, const context_type & /*ctx*/) {
detail::get<value_types::to_index(id)>(m_tuple_container).reserve(n);
detail::get<value_types::template to_index<id>()>(m_tuple_container)
.reserve(n);
}

/// Resize the underlying container to @param n for a collection given by
/// @tparam id
template <ID id>
DETRAY_HOST void resize(std::size_t n, const context_type & /*ctx*/) {
detail::get<value_types::to_index(id)>(m_tuple_container).resize(n);
detail::get<value_types::template to_index<id>()>(m_tuple_container)
.resize(n);
}

/// Add a new element to a collection
Expand All @@ -236,7 +246,8 @@ class multi_store {
DETRAY_HOST constexpr auto push_back(
const T &arg,
const context_type & /*ctx*/ = {}) noexcept(false) -> void {
auto &coll = detail::get<value_types::to_index(id)>(m_tuple_container);
auto &coll = detail::get<value_types::template to_index<id>()>(
m_tuple_container);
return coll.push_back(arg);
}

Expand All @@ -251,7 +262,8 @@ class multi_store {
template <ID id, typename... Args>
DETRAY_HOST constexpr decltype(auto) emplace_back(
const context_type & /*ctx*/ = {}, Args &&...args) noexcept(false) {
auto &coll = detail::get<value_types::to_index(id)>(m_tuple_container);
auto &coll = detail::get<value_types::template to_index<id>()>(
m_tuple_container);
return coll.emplace_back(std::forward<Args>(args)...);
}

Expand Down Expand Up @@ -291,7 +303,8 @@ class multi_store {
template <std::size_t current_idx = 0>
DETRAY_HOST void append(const multi_store &other,
const context_type &ctx = {}) noexcept(false) {
auto &coll = other.template get<value_types::to_id(current_idx)>();
auto &coll =
other.template get<value_types::template to_id<current_idx>>();
insert(coll, ctx);

if constexpr (current_idx < sizeof...(Ts) - 1) {
Expand All @@ -309,7 +322,8 @@ class multi_store {
template <std::size_t current_idx = 0>
DETRAY_HOST void append(multi_store &&other,
const context_type &ctx = {}) noexcept(false) {
auto &coll = other.template get<value_types::to_id(current_idx)>();
auto &coll =
other.template get<value_types::template to_id<current_idx>()>();
insert(std::move(coll), ctx);

if constexpr (current_idx < sizeof...(Ts) - 1) {
Expand Down
2 changes: 1 addition & 1 deletion core/include/detray/geometry/mask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class mask {
///
/// @returns an intersection status e_inside / e_outside
template <concepts::point point_t>
DETRAY_HOST_DEVICE constexpr dbool<algebra_type> is_inside(
DETRAY_HOST_DEVICE constexpr dbool<algebra_t> is_inside(
const point_t& loc_p,
const scalar_type tol =
std::numeric_limits<scalar_type>::epsilon()) const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
#include "detray/definitions/math.hpp"
#include "detray/definitions/units.hpp"
#include "detray/geometry/coordinates/concentric_cylindrical2D.hpp"
#include "detray/geometry/coordinates/cylindrical2D.hpp"
#include "detray/navigation/intersection/intersection.hpp"
#include "detray/navigation/intersection/ray_cylinder_intersector.hpp"
#include "detray/tracks/ray.hpp"
#include "detray/utils/quadratic_equation.hpp"

// System include(s)
#include <type_traits>
Expand Down
38 changes: 38 additions & 0 deletions core/include/detray/navigation/navigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,44 @@ class navigator {
return is_init;
}

/// @brief Jump to the next candidate. only possible if stepsize is zero!
///
/// In case of surface overlaps, allow the navigator to advance to the
/// current target, without updating the track position
///
/// @param navigation the current navigation state
/// @param cfg the navigation configuration
DETRAY_HOST_DEVICE inline void jump_to_next(
state &navigation, const navigation::config &cfg) const {

assert(navigation.status() > navigation::status::e_on_target);

// Make sure it is possible to jump ahead
if (navigation.trust_level() != navigation::trust_level::e_full ||
!(navigation.is_on_surface() &&
(math::fabs(navigation()) <= cfg.path_tolerance)) ||
navigation.n_candidates() <= 1u ||
navigation.target().sf_desc.barcode().is_invalid()) {
// Instance of 'distance to next' smaller than path tolerance after
// navigation update and not 'on surface' => This is not an overlap,
// so abort the navigaiton
navigation.abort(
"Navigator: Not possible to jump to next candidate");
}

// If the next target is "on surface", the state will automatically
// advance to it
update_navigation_state(navigation, cfg);

// Not a full navigator update: reduce trust level
navigation.set_high_trust();

// Leave for debugging
// navigation.run_inspector(cfg, point3_type{0.f, 0.f, 0.f},
// vector3_type{0.f, 0.f, 0.f},
// "Jumped to next: ");
}

private:
/// Helper method to update the candidates (surface intersections)
/// based on an externally provided trust level. Will (re-)initialize the
Expand Down
13 changes: 7 additions & 6 deletions core/include/detray/utils/consistency_checker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,19 @@ void report_empty(const store_t &store,
[[maybe_unused]] const std::string &store_name,
std::index_sequence<I...> /*seq*/) {

((store.template empty<store_t::value_types::to_id(I)>() ?
((store.template empty<store_t::value_types::template to_id<I>()>()
?
#if DETRAY_LOG_LVL < 0
std::clog << ""
std::clog << ""
#else
// The log macro
// does not compile
// here...
// The log macro
// does not compile
// here...
std::clog << "DETRAY WARNING (HOST): " << __FILENAME__ << ":"
<< __LINE__ << " " << store_name
<< " has empty collection no. " << I << std::endl
#endif
: std::clog << ""),
: std::clog << ""),
...);
}

Expand Down
15 changes: 9 additions & 6 deletions core/include/detray/utils/grid/detail/axis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,16 @@ class multi_axis {
/// determines which axes data are used to build the instance.
/// @returns an axis object, corresponding to the index.
template <std::size_t index>
DETRAY_HOST_DEVICE typename label_matcher<axis_reg::to_id(index)>::type
DETRAY_HOST_DEVICE label_matcher<axis_reg::template to_id<index>()>
get_axis() const {
return {m_edge_offsets[index], &bin_edges()};
}

/// @tparam L label of the axis.
/// @returns an axis object, corresponding to the label.
template <axis::label L>
DETRAY_HOST_DEVICE typename label_matcher<L>::type get_axis() const {
return get_axis<axis_reg::to_index(L)>();
DETRAY_HOST_DEVICE label_matcher<L> get_axis() const {
return get_axis<axis_reg::template to_index<L>()>();
}

/// @tparam axis_t type of the axis.
Expand Down Expand Up @@ -476,7 +476,8 @@ class multi_axis {
DETRAY_HOST_DEVICE void get_axis_nbins(const axis_t &ax,
loc_bin_index &n_bins) const {
// Get the index corresponding to the axis label (e.g. bin_x <=> 0)
constexpr auto loc_idx{axis_reg::to_index(axis_t::bounds_type::label)};
constexpr auto loc_idx{
axis_reg::template to_index<axis_t::bounds_type::label>()};
n_bins[loc_idx] = ax.nbins();
}

Expand All @@ -493,7 +494,8 @@ class multi_axis {
DETRAY_HOST_DEVICE void get_axis_bin(const axis_t &ax, const point_type &p,
loc_bin_index &bin_indices) const {
// Get the index corresponding to the axis label (e.g. bin_x <=> 0)
constexpr auto loc_idx{axis_reg::to_index(axis_t::bounds_type::label)};
constexpr auto loc_idx{
axis_reg::template to_index<axis_t::bounds_type::label>()};
bin_indices[loc_idx] = ax.bin(p[loc_idx]);
}

Expand All @@ -515,7 +517,8 @@ class multi_axis {
const darray<neighbor_t, 2> &nhood,
multi_bin_range<dim> &bin_ranges) const {
// Get the index corresponding to the axis label (e.g. bin_range_x = 0)
constexpr auto loc_idx{axis_reg::to_index(axis_t::bounds_type::label)};
constexpr auto loc_idx{
axis_reg::template to_index<axis_t::bounds_type::label>()};
bin_ranges[loc_idx] = ax.range(p[loc_idx], nhood);
}

Expand Down
Loading
Loading