Skip to content
Merged
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: 4 additions & 0 deletions core/include/detray/builders/volume_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ class volume_builder : public volume_builder_interface<detector_t> {

DETRAY_VERBOSE_HOST("Build surfaces...");

assert(!m_surfaces.empty());
assert(!m_transforms.empty());
assert(!m_masks.all_empty());

// Prepare volume data
m_volume.set_index(static_cast<dindex>(det.volumes().size()));

Expand Down
25 changes: 10 additions & 15 deletions core/include/detray/geometry/detail/volume_kernels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace detray::detail {

/// A functor to retrieve the material parameters
/// A functor to retrieve the volume material parameters at a given position
struct get_material_params {
template <typename mat_group_t, typename index_t, concepts::point point_t>
DETRAY_HOST_DEVICE inline auto operator()(const mat_group_t &mat_group,
Expand All @@ -43,9 +43,10 @@ struct get_material_params {
}
};

/// A functor to access the surfaces of a volume
/// A functor to access all surfaces registered in an acceleration structure
/// @tparam functor_t functor that performs a task per surface
template <typename functor_t>
struct surface_getter {
struct apply_to_surfaces {

/// Call operator that forwards the neighborhood search call in a volume
/// to a surface finder data structure
Expand All @@ -54,16 +55,18 @@ struct surface_getter {
const accel_index_t index,
Args &&...args) const {

// Run over the surfaces in a single acceleration data structure
// Iterate through the surface neighbouhood of the track
for (const auto &sf : group[index].all()) {
functor_t{}(sf, std::forward<Args>(args)...);
}
}
};

/// A functor to find surfaces in the neighborhood of a track position
/// @tparam functor_t functor that performs a task per surface in the
/// neighbourhood (e.g. intersection)
template <typename functor_t>
struct neighborhood_getter {
struct apply_to_neighbourhood {

/// Call operator that forwards the neighborhood search call in a volume
/// to a surface finder data structure
Expand All @@ -77,22 +80,14 @@ struct neighborhood_getter {
const typename detector_t::geometry_context &ctx,
Args &&...args) const {

// Get the acceleration structure for the volume
decltype(auto) accel = group[index];

// Run over the surfaces in a single acceleration data structure
// Iterate through the surface neighbouhood of the track
for (const auto &sf : accel.search(det, volume, track, cfg, ctx)) {
functor_t{}(sf, std::forward<Args>(args)...);
}
}
};

/// Query the maximal number of candidates from the acceleration
struct n_candidates_getter {
template <typename accel_group_t, typename accel_index_t>
DETRAY_HOST_DEVICE inline auto operator()(const accel_group_t &group,
const accel_index_t index) const {
return group[index].n_max_candidates();
}
};

} // namespace detray::detail
7 changes: 1 addition & 6 deletions core/include/detray/geometry/surface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,7 @@ class surface {

/// @returns true if the surface carries material.
DETRAY_HOST_DEVICE
constexpr auto has_material() const -> bool {
return m_desc.material().id() !=
static_cast<typename descr_t::material_link::id_type>(
detector_t::materials::id::e_none) &&
!m_desc.material().is_invalid();
}
constexpr bool has_material() const { return m_desc.has_material(); }

/// @returns the mask volume link
DETRAY_HOST_DEVICE
Expand Down
7 changes: 7 additions & 0 deletions core/include/detray/geometry/surface_descriptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ class surface_descriptor {
return m_material;
}

/// @returns true if the surface descriptor has a valid material link
DETRAY_HOST_DEVICE
constexpr auto has_material() const -> bool {
return (m_material.id() != material_link::id_type::e_none) &&
!m_material.is_invalid();
}

/// @returns true if the surface is a senstive detector module.
DETRAY_HOST_DEVICE
constexpr auto is_sensitive() const -> bool {
Expand Down
25 changes: 9 additions & 16 deletions core/include/detray/geometry/tracking_volume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,7 @@ class tracking_volume {

/// @returns true if the volume carries material.
DETRAY_HOST_DEVICE
constexpr auto has_material() const -> bool {
return m_desc.material().id() !=
static_cast<typename descr_t::material_link::id_type>(
detector_t::materials::id::e_none);
}
constexpr bool has_material() const { return m_desc.has_material(); }

/// @returns an iterator pair for the requested type of surfaces.
template <surface_id sf_type = surface_id::e_all>
Expand All @@ -131,11 +127,9 @@ class tracking_volume {
}
}

/// @returns an iterator pair for the requested type of surfaces.
/// @returns an iterator pair for the volume portals.
DETRAY_HOST_DEVICE constexpr decltype(auto) portals() const {
return detray::ranges::subrange{
m_detector.surfaces(),
m_desc.template sf_link<surface_id::e_portal>()};
return surfaces<surface_id::e_portal>();
}

/// @returns the total number of portal surfaces contained in the volume
Expand Down Expand Up @@ -171,15 +165,15 @@ class tracking_volume {
/// @tparam Args types of additional arguments to the functor
template <typename functor_t, typename... Args>
DETRAY_HOST_DEVICE constexpr void visit_surfaces(Args &&...args) const {
visit_surfaces_impl<detail::surface_getter<functor_t>>(
visit_surfaces_impl<detail::apply_to_surfaces<functor_t>>(
std::forward<Args>(args)...);
}

/// Apply a functor to a neighborhood of surfaces around a track position
/// in the volume.
///
/// @tparam functor_t the prescription to be applied to the surfaces (
/// customization point for the navigation)
/// @tparam functor_t the prescription to be applied to the surfaces
/// (customization point for the navigation)
/// @tparam track_t the track around which to build up the neighborhood
/// @tparam Args types of additional arguments to the functor
template <typename functor_t, typename track_t, typename config_t,
Expand All @@ -188,7 +182,7 @@ class tracking_volume {
const config_t &cfg,
const context_t &ctx,
Args &&...args) const {
visit_surfaces_impl<detail::neighborhood_getter<functor_t>>(
visit_surfaces_impl<detail::apply_to_neighbourhood<functor_t>>(
m_detector, m_desc, track, cfg, ctx, std::forward<Args>(args)...);
}

Expand Down Expand Up @@ -331,7 +325,7 @@ class tracking_volume {
private:
/// Apply a functor to all acceleration structures of this volume.
///
/// @tparam functor_t the prescription to be applied to the acc structure
/// @tparam functor_t the prescription to be applied to the acc. structures
/// @tparam Args types of additional arguments to the functor
template <typename functor_t, typename... Args>
DETRAY_HOST_DEVICE constexpr void visit_surfaces_impl(
Expand All @@ -344,8 +338,7 @@ class tracking_volume {
if (const auto &link{m_desc.accel_link(
static_cast<typename descr_t::object_id>(i))};
!link.is_invalid()) {
// Run over the surfaces in a single acceleration data structure
// and apply the functor to the resulting neighborhood
// Get the acc. data structure and apply the functor to it
m_detector.accelerator_store().template visit<functor_t>(
link, std::forward<Args>(args)...);
}
Expand Down
7 changes: 7 additions & 0 deletions core/include/detray/geometry/volume_descriptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,13 @@ class volume_descriptor {
static_cast<typename material_link::index_type>(mat_idx)};
}

/// @returns true if the volume descriptor has a valid material link
DETRAY_HOST_DEVICE
constexpr auto has_material() const -> bool {
return (m_mat_link.id() != material_link::id_type::e_none) &&
!m_mat_link.is_invalid();
}

/// @returns link to all acceleration data structures - const access
DETRAY_HOST_DEVICE constexpr auto accel_link() const
-> const accel_link_type& {
Expand Down
3 changes: 2 additions & 1 deletion core/include/detray/navigation/policies.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "detray/definitions/algebra.hpp"
#include "detray/definitions/detail/qualifiers.hpp"
#include "detray/definitions/math.hpp"
#include "detray/definitions/units.hpp"
#include "detray/propagator/base_actor.hpp"

// system includes
Expand Down Expand Up @@ -114,7 +115,7 @@ struct stepper_rk_policy : actor {
auto &navigation = propagation._navigation;

// In case of an overlap, have navigator re-evaluate the next candidate
if (math::fabs(navigation()) <= 1e-5f) {
if (math::fabs(navigation()) <= 1.f * unit<float>::um) {
navigation.set_high_trust();
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ struct pointwise_material_interactor : actor {
const scalar_type next_qop{(q != 0.f) ? q / next_p : 1.f / next_p};
vector.set_qop((next_p == 0.f) ? inv : next_qop);

DETRAY_DEBUG_HOST_DEVICE("-> new abs. momentum: %f", next_qop);
DETRAY_DEBUG_HOST_DEVICE("-> new abs. momentum: %f", next_p);

DETRAY_DEBUG_HOST_DEVICE("-> Update qop: before: %f, after: %f", q / p,
vector.qop());
Expand Down
4 changes: 2 additions & 2 deletions core/include/detray/propagator/detail/noise_estimation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ DETRAY_HOST_DEVICE constexpr void estimate_external_mask_tolerance(
math::cos(theta_err)};

// Guess the portal envelope distance if there is no next target
constexpr auto max_tol{5.f * unit<scalar_t>::mm};
const scalar_t path{
navigation.is_exhausted()
? 5.f * unit<scalar_t>::mm
? max_tol
: math::fabs(std::as_const(navigation).target().path())};

displ = path * (displ - stepping().dir());
Expand All @@ -97,7 +98,6 @@ DETRAY_HOST_DEVICE constexpr void estimate_external_mask_tolerance(
vector::dot(displ, displ) + accumulated_noise * accumulated_noise));

// Clip to 5mm if the covariances are very large
constexpr auto max_tol{5.f * unit<scalar_t>::mm};
navigation.set_external_tol(navigation.external_tol() > max_tol
? max_tol
: navigation.external_tol());
Expand Down
Loading
Loading