Skip to content

Commit

Permalink
Split the surface implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
niermann999 committed Oct 16, 2024
1 parent e3724d6 commit a0fe7b1
Show file tree
Hide file tree
Showing 43 changed files with 468 additions and 362 deletions.
4 changes: 2 additions & 2 deletions core/include/detray/builders/detail/portal_accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "detray/definitions/detail/qualifiers.hpp"
#include "detray/geometry/shapes/cylinder2D.hpp"
#include "detray/geometry/shapes/ring2D.hpp"
#include "detray/geometry/tracking_surface.hpp"
#include "detray/geometry/surface.hpp"
#include "detray/geometry/tracking_volume.hpp"

// System include(s).
Expand All @@ -37,7 +37,7 @@ auto get_cylinder_portals(const tracking_volume<detector_t> &vol) {

// Loop over all portals
for (const auto &pt_desc : vol.portals()) {
auto pt = tracking_surface{vol.detector(), pt_desc};
auto pt = geometry::surface{vol.detector(), pt_desc};
const std::string name = pt.shape_name();

if (name == "cylinder2D" || name == "concentric_cylinder2D") {
Expand Down
1 change: 0 additions & 1 deletion core/include/detray/builders/grid_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "detray/builders/surface_factory_interface.hpp"
#include "detray/builders/volume_builder.hpp"
#include "detray/builders/volume_builder_interface.hpp"
#include "detray/geometry/tracking_surface.hpp"
#include "detray/geometry/tracking_volume.hpp"
#include "detray/utils/grid/detail/concepts.hpp"

Expand Down
4 changes: 2 additions & 2 deletions core/include/detray/builders/material_map_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "detray/builders/material_map_generator.hpp"
#include "detray/builders/surface_factory_interface.hpp"
#include "detray/builders/volume_builder_interface.hpp"
#include "detray/geometry/tracking_surface.hpp"
#include "detray/geometry/surface.hpp"
#include "detray/materials/material_map.hpp"

// System include(s)
Expand Down Expand Up @@ -125,7 +125,7 @@ class material_map_builder final : public volume_decorator<detector_t> {
}

// Construct and append the material map for a given surface shape
auto sf = tracking_surface{det, sf_desc};
auto sf = geometry::surface{det, sf_desc};
[[maybe_unused]] auto [mat_id, mat_idx] = sf.template visit_mask<
detail::add_sf_material_map<materials_t>>(
m_factory, m_bin_data.at(sf_idx), m_n_bins.at(sf_idx),
Expand Down
4 changes: 2 additions & 2 deletions core/include/detray/builders/volume_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "detray/builders/surface_factory_interface.hpp"
#include "detray/builders/volume_builder_interface.hpp"
#include "detray/definitions/geometry.hpp"
#include "detray/geometry/tracking_surface.hpp"
#include "detray/geometry/surface.hpp"
#include "detray/utils/grid/detail/concepts.hpp"

// System include(s)
Expand Down Expand Up @@ -210,7 +210,7 @@ class volume_builder : public volume_builder_interface<detector_t> {
std::size_t n_portals{0u};
for (auto& sf_desc : m_surfaces) {

const auto sf = tracking_surface{det, sf_desc};
const auto sf = geometry::surface{det, sf_desc};

sf.template visit_mask<detail::mask_index_update>(sf_desc);
sf_desc.set_volume(m_volume.index());
Expand Down
2 changes: 1 addition & 1 deletion core/include/detray/geometry/detail/shape_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace detray::detail {
/// @return the opening angle of a chord the size of tol (= 2*arcsin(c/(2r)))
/// using a small angle approximation
template <typename scalar_t>
inline constexpr scalar_t phi_tolerance(scalar_t tol, scalar_t radius) {
constexpr scalar_t phi_tolerance(scalar_t tol, scalar_t radius) {
return tol / radius;
}

Expand Down
112 changes: 1 addition & 111 deletions core/include/detray/geometry/detail/surface_kernels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
#pragma once

// Project include(s)
#include "detray/definitions/detail/algebra.hpp"
#include "detray/definitions/detail/indexing.hpp"
#include "detray/definitions/detail/qualifiers.hpp"
#include "detray/materials/detail/concepts.hpp"
#include "detray/materials/detail/material_accessor.hpp"
#include "detray/materials/material.hpp"
#include "detray/propagator/detail/jacobian_engine.hpp"
#include "detray/tracks/detail/transform_track_parameters.hpp"
#include "detray/tracks/tracks.hpp"

// System include(s)
#include <limits>
Expand All @@ -33,9 +31,6 @@ struct surface_kernels {
using point3_type = dpoint3D<algebra_t>;
using vector3_type = dvector3D<algebra_t>;
using transform3_type = dtransform3D<algebra_t>;
using bound_param_vector_type = bound_parameters_vector<algebra_t>;
using free_param_vector_type = free_parameters_vector<algebra_t>;
using free_matrix_type = free_matrix<algebra_t>;

/// A functor to retrieve the masks shape name
struct get_shape_name {
Expand Down Expand Up @@ -211,111 +206,6 @@ struct surface_kernels {
}
};

/// A functor to get from a free to a bound vector
struct free_to_bound_vector {

// Visitor to the detector mask store that is called on the mask
// collection that contains the mask (shape) type of the surface
template <typename mask_group_t, typename index_t>
DETRAY_HOST_DEVICE inline bound_param_vector_type operator()(
const mask_group_t& /*mask_group*/, const index_t& /*index*/,
const transform3_type& trf3,
const free_param_vector_type& free_vec) const {

using frame_t = typename mask_group_t::value_type::local_frame;

return detail::free_to_bound_vector<frame_t>(trf3, free_vec);
}
};

/// A functor to get from a bound to a free vector
struct bound_to_free_vector {

template <typename mask_group_t, typename index_t>
DETRAY_HOST_DEVICE inline free_param_vector_type operator()(
const mask_group_t& mask_group, const index_t& index,
const transform3_type& trf3,
const bound_param_vector_type& bound_vec) const {

return detail::bound_to_free_vector(trf3, mask_group[index],
bound_vec);
}
};

/// A functor to get the free-to-bound Jacobian
struct free_to_bound_jacobian {

template <typename mask_group_t, typename index_t>
DETRAY_HOST_DEVICE inline auto operator()(
const mask_group_t& /*mask_group*/, const index_t& /*index*/,
const transform3_type& trf3,
const free_param_vector_type& free_vec) const {

using frame_t = typename mask_group_t::value_type::local_frame;

return detail::jacobian_engine<frame_t>::free_to_bound_jacobian(
trf3, free_vec);
}
};

/// A functor to get the bound-to-free Jacobian
struct bound_to_free_jacobian {

template <typename mask_group_t, typename index_t>
DETRAY_HOST_DEVICE inline auto operator()(
const mask_group_t& mask_group, const index_t& index,
const transform3_type& trf3,
const bound_param_vector_type& bound_vec) const {

using frame_t = typename mask_group_t::value_type::local_frame;

return detail::jacobian_engine<frame_t>::bound_to_free_jacobian(
trf3, mask_group[index], bound_vec);
}
};

/// A functor to get the path correction
struct path_correction {

template <typename mask_group_t, typename index_t, typename scalar_t>
DETRAY_HOST_DEVICE inline free_matrix_type operator()(
const mask_group_t& /*mask_group*/, const index_t& /*index*/,
const transform3_type& trf3, const vector3_type& pos,
const vector3_type& dir, const vector3_type& dtds,
const scalar_t dqopds) const {

using frame_t = typename mask_group_t::value_type::local_frame;

return detail::jacobian_engine<frame_t>::path_correction(
pos, dir, dtds, dqopds, trf3);
}
};

/// A functor to get the local min bounds.
struct local_min_bounds {

template <typename mask_group_t, typename index_t, typename scalar_t>
DETRAY_HOST_DEVICE inline auto operator()(
const mask_group_t& mask_group, const index_t& index,
const scalar_t env =
std::numeric_limits<scalar_t>::epsilon()) const {

return mask_group[index].local_min_bounds(env);
}
};

/// A functor to get the minimum distance to any surface boundary.
struct min_dist_to_boundary {

template <typename mask_group_t, typename index_t, typename point_t>
DETRAY_HOST_DEVICE inline auto operator()(
const mask_group_t& mask_group, const index_t& index,
const point_t& loc_p) const {

return mask_group[index].min_dist_to_boundary(loc_p);
}
};

/// A functor to get the vertices in local coordinates.
struct local_vertices {

Expand Down
Loading

0 comments on commit a0fe7b1

Please sign in to comment.