From a0fe7b194843422349d0a38065ad1fc87f97d426 Mon Sep 17 00:00:00 2001 From: Joana Niermann Date: Wed, 16 Oct 2024 16:26:07 +0200 Subject: [PATCH] Split the surface implementation --- .../builders/detail/portal_accessor.hpp | 4 +- core/include/detray/builders/grid_builder.hpp | 1 - .../detray/builders/material_map_builder.hpp | 4 +- .../detray/builders/volume_builder.hpp | 4 +- .../detray/geometry/detail/shape_utils.hpp | 2 +- .../geometry/detail/surface_kernels.hpp | 112 +------------ .../{tracking_surface.hpp => surface.hpp} | 153 ++++-------------- .../materials/detail/material_utils.hpp | 37 +++++ core/include/detray/navigation/detail/ray.hpp | 6 +- core/include/detray/navigation/navigator.hpp | 13 +- .../propagator/actors/parameter_resetter.hpp | 1 - .../actors/parameter_transporter.hpp | 4 +- .../actors/pointwise_material_interactor.hpp | 8 +- .../detray/propagator/base_stepper.hpp | 4 +- .../detail/tracking_surface_kernels.hpp | 112 +++++++++++++ .../detray/propagator/tracking_surface.hpp | 118 ++++++++++++++ .../detray/utils/consistency_checker.hpp | 10 +- .../detray/io/common/geometry_writer.hpp | 6 +- .../io/common/homogeneous_material_writer.hpp | 4 +- .../conversion/information_section.hpp | 4 +- .../svgtools/conversion/intersection.hpp | 7 +- .../plugins/svgtools/conversion/link.hpp | 6 +- .../plugins/svgtools/conversion/portal.hpp | 6 +- .../plugins/svgtools/conversion/surface.hpp | 6 +- .../svgtools/conversion/surface_material.hpp | 4 +- .../plugins/svgtools/conversion/volume.hpp | 6 +- .../detray/plugins/svgtools/illustrator.hpp | 8 +- .../plugins/svgtools/utils/link_utils.hpp | 12 +- .../svgtools/utils/surface_kernels.hpp | 4 +- tests/benchmarks/cpu/intersect_all.cpp | 4 +- .../include/detray/test/cpu/detector_scan.hpp | 1 - .../include/detray/test/cpu/material_scan.hpp | 6 +- .../utils/detectors/build_toy_detector.hpp | 1 - .../include/detray/test/utils/inspectors.hpp | 4 +- .../utils/simulation/random_scatterer.hpp | 8 +- .../test/validation/detector_scanner.hpp | 4 +- .../validation/material_validation_utils.hpp | 2 +- .../navigation_validation_utils.hpp | 19 ++- .../cpu/propagator/jacobian_validation.cpp | 1 + .../cpu/propagator/propagator.cpp | 2 +- tests/unit_tests/cpu/CMakeLists.txt | 2 +- .../{tracking_surface.cpp => surface.cpp} | 109 +++++++------ .../unit_tests/cpu/propagator/rk_stepper.cpp | 1 - 43 files changed, 468 insertions(+), 362 deletions(-) rename core/include/detray/geometry/{tracking_surface.hpp => surface.hpp} (71%) create mode 100644 core/include/detray/materials/detail/material_utils.hpp create mode 100644 core/include/detray/propagator/detail/tracking_surface_kernels.hpp create mode 100644 core/include/detray/propagator/tracking_surface.hpp rename tests/unit_tests/cpu/geometry/{tracking_surface.cpp => surface.cpp} (80%) diff --git a/core/include/detray/builders/detail/portal_accessor.hpp b/core/include/detray/builders/detail/portal_accessor.hpp index b63f532b9..d757cf9d6 100644 --- a/core/include/detray/builders/detail/portal_accessor.hpp +++ b/core/include/detray/builders/detail/portal_accessor.hpp @@ -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). @@ -37,7 +37,7 @@ auto get_cylinder_portals(const tracking_volume &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") { diff --git a/core/include/detray/builders/grid_builder.hpp b/core/include/detray/builders/grid_builder.hpp index d7900fc8e..616a7041f 100644 --- a/core/include/detray/builders/grid_builder.hpp +++ b/core/include/detray/builders/grid_builder.hpp @@ -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" diff --git a/core/include/detray/builders/material_map_builder.hpp b/core/include/detray/builders/material_map_builder.hpp index 39fca3928..0c8fbe660 100644 --- a/core/include/detray/builders/material_map_builder.hpp +++ b/core/include/detray/builders/material_map_builder.hpp @@ -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) @@ -125,7 +125,7 @@ class material_map_builder final : public volume_decorator { } // 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>( m_factory, m_bin_data.at(sf_idx), m_n_bins.at(sf_idx), diff --git a/core/include/detray/builders/volume_builder.hpp b/core/include/detray/builders/volume_builder.hpp index 3c9521fff..88eeba4b3 100644 --- a/core/include/detray/builders/volume_builder.hpp +++ b/core/include/detray/builders/volume_builder.hpp @@ -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) @@ -210,7 +210,7 @@ class volume_builder : public volume_builder_interface { 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(sf_desc); sf_desc.set_volume(m_volume.index()); diff --git a/core/include/detray/geometry/detail/shape_utils.hpp b/core/include/detray/geometry/detail/shape_utils.hpp index 5fa52d421..23cd46b28 100644 --- a/core/include/detray/geometry/detail/shape_utils.hpp +++ b/core/include/detray/geometry/detail/shape_utils.hpp @@ -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 -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; } diff --git a/core/include/detray/geometry/detail/surface_kernels.hpp b/core/include/detray/geometry/detail/surface_kernels.hpp index 695b9384d..48f67bfb7 100644 --- a/core/include/detray/geometry/detail/surface_kernels.hpp +++ b/core/include/detray/geometry/detail/surface_kernels.hpp @@ -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 @@ -33,9 +31,6 @@ struct surface_kernels { using point3_type = dpoint3D; using vector3_type = dvector3D; using transform3_type = dtransform3D; - using bound_param_vector_type = bound_parameters_vector; - using free_param_vector_type = free_parameters_vector; - using free_matrix_type = free_matrix; /// A functor to retrieve the masks shape name struct get_shape_name { @@ -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 - 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(trf3, free_vec); - } - }; - - /// A functor to get from a bound to a free vector - struct bound_to_free_vector { - - template - 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 - 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::free_to_bound_jacobian( - trf3, free_vec); - } - }; - - /// A functor to get the bound-to-free Jacobian - struct bound_to_free_jacobian { - - template - 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::bound_to_free_jacobian( - trf3, mask_group[index], bound_vec); - } - }; - - /// A functor to get the path correction - struct path_correction { - - template - 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::path_correction( - pos, dir, dtds, dqopds, trf3); - } - }; - - /// A functor to get the local min bounds. - struct local_min_bounds { - - template - DETRAY_HOST_DEVICE inline auto operator()( - const mask_group_t& mask_group, const index_t& index, - const scalar_t env = - std::numeric_limits::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 - 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 { diff --git a/core/include/detray/geometry/tracking_surface.hpp b/core/include/detray/geometry/surface.hpp similarity index 71% rename from core/include/detray/geometry/tracking_surface.hpp rename to core/include/detray/geometry/surface.hpp index 932991f8d..a55cdc263 100644 --- a/core/include/detray/geometry/tracking_surface.hpp +++ b/core/include/detray/geometry/surface.hpp @@ -21,7 +21,7 @@ #include #include -namespace detray { +namespace detray::geometry { /// @brief Facade for a detray detector surface. /// @@ -31,16 +31,12 @@ namespace detray { /// that contains the indices into the detector data containers for the /// specific surface instance. template // @TODO: This needs a concept -class tracking_surface { +class surface { /// Surface descriptor type using descr_t = typename detector_t::surface_type; - + /// Implementation using kernels = detail::surface_kernels; - /// Vector type for track parameters in global coordinates - using free_param_vector_type = typename kernels::free_param_vector_type; - /// Vector type for track parameters in local (bound) coordinates - using bound_param_vector_type = typename kernels::bound_param_vector_type; public: using algebra_type = typename detector_t::algebra_type; @@ -52,39 +48,37 @@ class tracking_surface { using context = typename detector_t::geometry_context; /// Not allowed: always needs a detector and a descriptor. - tracking_surface() = delete; + surface() = delete; /// Constructor from detector @param det and surface descriptor /// @param desc from that detector. DETRAY_HOST_DEVICE - constexpr tracking_surface(const detector_t &det, const descr_t &desc) + constexpr surface(const detector_t &det, const descr_t &desc) : m_detector{det}, m_desc{desc} {} /// Constructor from detector @param det and barcode @param bcd in /// that detector. DETRAY_HOST_DEVICE - constexpr tracking_surface(const detector_t &det, - const geometry::barcode bcd) - : tracking_surface(det, det.surface(bcd)) {} + constexpr surface(const detector_t &det, const geometry::barcode bcd) + : surface(det, det.surface(bcd)) {} /// Constructor from detector @param det and surface index @param sf_idx DETRAY_HOST_DEVICE - constexpr tracking_surface(const detector_t &det, const dindex sf_idx) - : tracking_surface(det, det.surface(sf_idx)) {} + constexpr surface(const detector_t &det, const dindex sf_idx) + : surface(det, det.surface(sf_idx)) {} /// Conversion to surface interface around constant detector type template requires(!std::is_const_v) DETRAY_HOST_DEVICE constexpr - operator tracking_surface() const { - return tracking_surface{this->m_detector, - this->m_desc}; + operator surface() const { + return surface{this->m_detector, this->m_desc}; } /// Equality operator /// /// @param rhs is the right hand side to be compared to DETRAY_HOST_DEVICE - constexpr auto operator==(const tracking_surface &rhs) const -> bool { + constexpr auto operator==(const surface &rhs) const -> bool { return (&m_detector == &(rhs.m_detector) && m_desc == rhs.m_desc); } @@ -203,17 +197,6 @@ class tracking_surface { return visit_mask(transform(ctx), p); } - /// @returns the cosine of the incidence angle given a local/bound position - /// @param p and a global direction @param dir - /// @note The direction has to be normalized - template - requires std::is_same_v || - std::is_same_v DETRAY_HOST_DEVICE constexpr auto - cos_angle(const context &ctx, const vector3_type &dir, - const point_t &p) const -> scalar_type { - return math::fabs(vector::dot(dir, normal(ctx, p))); - } - /// @returns a pointer to the material parameters at the local position /// @param loc_p DETRAY_HOST_DEVICE constexpr const material @@ -243,104 +226,28 @@ class tracking_surface { /// @returns the global position to the given local position @param local /// for a given geometry context @param ctx - DETRAY_HOST_DEVICE constexpr point3_type local_to_global( - const context &ctx, const point3_type &local, - const vector3_type &dir) const { + template + requires std::is_same_v || + std::is_same_v + DETRAY_HOST_DEVICE constexpr point3_type local_to_global( + const context &ctx, const point_t &local, + const vector3_type &dir) const { return visit_mask(transform(ctx), local, dir); } - /// @returns the global position to the given bound position @param bound - /// for a given geometry context @param ctx - DETRAY_HOST_DEVICE constexpr point3_type bound_to_global( - const context &ctx, const point2_type &bound, - const vector3_type &dir) const { - return visit_mask(transform(ctx), - bound, dir); - } - - /// @returns the track parametrization projected onto the surface (bound) - DETRAY_HOST_DEVICE - constexpr auto free_to_bound_vector( - const context &ctx, const free_param_vector_type &free_vec) const { - return visit_mask( - transform(ctx), free_vec); - } - - /// @returns the global track parametrization from a bound representation - DETRAY_HOST_DEVICE - constexpr auto bound_to_free_vector( - const context &ctx, const bound_param_vector_type &bound_vec) const { - return visit_mask( - transform(ctx), bound_vec); - } - - /// @returns the jacobian to go from a free to a bound track parametrization - DETRAY_HOST_DEVICE - constexpr auto free_to_bound_jacobian( - const context &ctx, const free_param_vector_type &free_vec) const { - return this - ->template visit_mask( - transform(ctx), free_vec); - } - - /// @returns the jacobian to go from a bound to a free track parametrization - DETRAY_HOST_DEVICE - constexpr auto bound_to_free_jacobian( - const context &ctx, const bound_param_vector_type &bound_vec) const { - return this - ->template visit_mask( - transform(ctx), bound_vec); - } - - /// @returns the path correction term - DETRAY_HOST_DEVICE - constexpr auto path_correction(const context &ctx, const vector3_type &pos, - const vector3_type &dir, - const vector3_type &dtds, - const scalar_type dqopds) const { - return visit_mask( - transform(ctx), pos, dir, dtds, dqopds); - } - - /// @returns the vertices in local frame with @param n_seg the number of - /// segments used along acrs - DETRAY_HOST - constexpr auto local_vertices(const dindex n_seg) const { - return visit_mask(n_seg); - } - /// @returns the vertices in global frame with @param n_seg the number of /// segments used along acrs DETRAY_HOST constexpr auto global_vertices(const context &ctx, const dindex n_seg) const { - auto vertices = local_vertices(n_seg); + auto vertices = visit_mask(n_seg); for (std::size_t i = 0u; i < vertices.size(); ++i) { vertices[i] = transform(ctx).point_to_global(vertices[i]); } return vertices; } - /// @returns the vertices in local frame with @param n_seg the number of - /// segments used along acrs - /// @note the point has to be inside the surface mask - template - DETRAY_HOST constexpr auto min_dist_to_boundary( - const point_t &loc_p) const { - return visit_mask(loc_p); - } - - /// @brief Lower and upper point for minimal axis aligned bounding box. - /// - /// Computes the min and max vertices in a local cartesian frame. - DETRAY_HOST - constexpr auto local_min_bounds( - const scalar_type env = - std::numeric_limits::epsilon()) const { - return visit_mask(env); - } - /// Call a functor on the surfaces mask with additional arguments. /// /// @tparam functor_t the prescription to be applied to the mask @@ -431,14 +338,22 @@ class tracking_surface { return true; } + protected: /// @returns a string stream that prints the surface details DETRAY_HOST - friend std::ostream &operator<<(std::ostream &os, - const tracking_surface &sf) { + friend std::ostream &operator<<(std::ostream &os, const surface &sf) { os << sf.m_desc; return os; } + /// @returns access to the underlying detector object + DETRAY_HOST_DEVICE + const detector_t &detector() const { return m_detector; } + + /// @returns access to the underlying surface descriptor object + DETRAY_HOST_DEVICE + descr_t descriptor() const { return m_desc; } + private: /// Access to the detector stores const detector_t &m_detector; @@ -447,11 +362,11 @@ class tracking_surface { }; template -DETRAY_HOST_DEVICE tracking_surface(const detector_t &, const descr_t &) - ->tracking_surface; +DETRAY_HOST_DEVICE surface(const detector_t &, const descr_t &) + ->surface; template -DETRAY_HOST_DEVICE tracking_surface(const detector_t &, const geometry::barcode) - ->tracking_surface; +DETRAY_HOST_DEVICE surface(const detector_t &, const geometry::barcode) + ->surface; -} // namespace detray +} // namespace detray::geometry diff --git a/core/include/detray/materials/detail/material_utils.hpp b/core/include/detray/materials/detail/material_utils.hpp new file mode 100644 index 000000000..2cefd1d4d --- /dev/null +++ b/core/include/detray/materials/detail/material_utils.hpp @@ -0,0 +1,37 @@ +/** Detray library, part of the ACTS project (R&D line) + * + * (c) 2024 CERN for the benefit of the ACTS project + * + * Mozilla Public License Version 2.0 + */ + +#pragma once + +// Project include(s) +#include "detray/definitions/detail/algebra.hpp" +#include "detray/definitions/detail/math.hpp" +#include "detray/geometry/surface.hpp" + +namespace detray::detail { + +/// Helper function to calculate the incidence angle of a track on a surface +/// +/// @param ctx the geometric context +/// @param sf the geometric surface +/// @param track_dir normalized direction vector of the track +/// @param loc the local/bound position of the track on the surface +/// +/// @returns the cosine of the incidence angle given a local/bound position +template + requires std::is_same_v> || + std::is_same_v> + DETRAY_HOST_DEVICE constexpr dscalar + cos_angle(const typename detector_t::geometry_context &ctx, + geometry::surface sf, + const dvector3D &track_dir, + const point_t &loc) { + return math::fabs(vector::dot(track_dir, sf.normal(ctx, loc))); +} + +} // namespace detray::detail diff --git a/core/include/detray/navigation/detail/ray.hpp b/core/include/detray/navigation/detail/ray.hpp index dc7eea49c..7d6649470 100644 --- a/core/include/detray/navigation/detail/ray.hpp +++ b/core/include/detray/navigation/detail/ray.hpp @@ -25,9 +25,6 @@ class ray { using vector3_type = dvector3D; using transform3_type = dtransform3D; - using free_track_parameters_type = free_track_parameters; - using free_vector_type = typename free_track_parameters_type::vector_type; - ray() = default; /// Parametrized constructor that complies with track interface @@ -41,7 +38,8 @@ class ray { /// Parametrized constructor that complies with track interface /// /// @param track the track state that should be approximated - DETRAY_HOST_DEVICE explicit ray(const free_track_parameters_type &track) + DETRAY_HOST_DEVICE explicit ray( + const free_track_parameters &track) : ray(track.pos(), 0.f, track.dir(), 0.f) {} /// @returns position on the ray (compatible with tracks/intersectors) diff --git a/core/include/detray/navigation/navigator.hpp b/core/include/detray/navigation/navigator.hpp index e0d5e53d9..0f29e0353 100644 --- a/core/include/detray/navigation/navigator.hpp +++ b/core/include/detray/navigation/navigator.hpp @@ -15,6 +15,7 @@ #include "detray/definitions/detail/qualifiers.hpp" #include "detray/definitions/units.hpp" #include "detray/geometry/barcode.hpp" +#include "detray/geometry/surface.hpp" #include "detray/navigation/detail/ray.hpp" #include "detray/navigation/intersection/intersection.hpp" #include "detray/navigation/intersection/ray_intersector.hpp" @@ -256,8 +257,8 @@ class navigator { /// @returns the next surface the navigator intends to reach DETRAY_HOST_DEVICE inline auto next_surface() const { - return tracking_surface{*m_detector, - target().sf_desc}; + return geometry::surface{*m_detector, + target().sf_desc}; } /// @returns current detector surface the navigator is on @@ -265,8 +266,8 @@ class navigator { DETRAY_HOST_DEVICE inline auto get_surface() const { assert(is_on_module() || is_on_portal()); - return tracking_surface{*m_detector, - current().sf_desc}; + return geometry::surface{*m_detector, + current().sf_desc}; } /// @returns current detector volume of the navigation stream @@ -598,7 +599,7 @@ class navigator { const scalar_type mask_tol_scalor, const scalar_type overstep_tol) const { - const auto sf = tracking_surface{det, sf_descr}; + const auto sf = geometry::surface{det, sf_descr}; sf.template visit_mask>( nav_state, detail::ray(track), sf_descr, det.transform_store(), @@ -886,7 +887,7 @@ class navigator { return false; } - const auto sf = tracking_surface{det, candidate.sf_desc}; + const auto sf = geometry::surface{det, candidate.sf_desc}; // Check whether this candidate is reachable by the track return sf.template visit_mask>( diff --git a/core/include/detray/propagator/actors/parameter_resetter.hpp b/core/include/detray/propagator/actors/parameter_resetter.hpp index 9aeeeb71e..d3b1a04cf 100644 --- a/core/include/detray/propagator/actors/parameter_resetter.hpp +++ b/core/include/detray/propagator/actors/parameter_resetter.hpp @@ -10,7 +10,6 @@ // Project include(s). #include "detray/definitions/detail/qualifiers.hpp" #include "detray/definitions/track_parametrization.hpp" -#include "detray/geometry/tracking_surface.hpp" #include "detray/propagator/base_actor.hpp" #include "detray/propagator/detail/jacobian_engine.hpp" diff --git a/core/include/detray/propagator/actors/parameter_transporter.hpp b/core/include/detray/propagator/actors/parameter_transporter.hpp index 94e1c41d5..3856828bf 100644 --- a/core/include/detray/propagator/actors/parameter_transporter.hpp +++ b/core/include/detray/propagator/actors/parameter_transporter.hpp @@ -10,9 +10,9 @@ // Project include(s). #include "detray/definitions/detail/qualifiers.hpp" #include "detray/definitions/track_parametrization.hpp" -#include "detray/geometry/tracking_surface.hpp" #include "detray/propagator/base_actor.hpp" #include "detray/propagator/detail/jacobian_engine.hpp" +#include "detray/propagator/tracking_surface.hpp" namespace detray { @@ -102,7 +102,7 @@ struct parameter_transporter : actor { const geo_cxt_t ctx{}; // Current Surface - const auto sf = navigation.get_surface(); + const auto sf = tracking_surface{navigation.get_surface()}; // Covariance is transported only when the previous surface is an // actual tracking surface. (i.e. This disables the covariance transport diff --git a/core/include/detray/propagator/actors/pointwise_material_interactor.hpp b/core/include/detray/propagator/actors/pointwise_material_interactor.hpp index d1d973b08..21edbee54 100644 --- a/core/include/detray/propagator/actors/pointwise_material_interactor.hpp +++ b/core/include/detray/propagator/actors/pointwise_material_interactor.hpp @@ -10,14 +10,12 @@ // Project include(s). #include "detray/definitions/detail/qualifiers.hpp" #include "detray/definitions/track_parametrization.hpp" -#include "detray/geometry/tracking_surface.hpp" #include "detray/materials/detail/concepts.hpp" #include "detray/materials/detail/material_accessor.hpp" +#include "detray/materials/detail/material_utils.hpp" #include "detray/materials/interaction.hpp" #include "detray/propagator/base_actor.hpp" #include "detray/tracks/bound_track_parameters.hpp" -#include "detray/utils/ranges.hpp" -#include "detray/utils/type_traits.hpp" namespace detray { @@ -165,8 +163,8 @@ struct pointwise_material_interactor : actor { // Closest approach of the track to a line surface. Otherwise this is // ignored. const auto approach{bound_params[e_bound_loc0]}; - const scalar_type cos_inc_angle{math::fabs(sf.cos_angle( - gctx, bound_params.dir(), bound_params.bound_local()))}; + const scalar_type cos_inc_angle{detail::cos_angle( + gctx, sf, bound_params.dir(), bound_params.bound_local())}; const bool succeed = sf.template visit_material( interactor_state, ptc, bound_params, cos_inc_angle, approach); diff --git a/core/include/detray/propagator/base_stepper.hpp b/core/include/detray/propagator/base_stepper.hpp index 749340daa..9eea5943b 100644 --- a/core/include/detray/propagator/base_stepper.hpp +++ b/core/include/detray/propagator/base_stepper.hpp @@ -12,7 +12,7 @@ #include "detray/definitions/pdg_particle.hpp" #include "detray/definitions/units.hpp" #include "detray/geometry/barcode.hpp" -#include "detray/geometry/tracking_surface.hpp" +#include "detray/geometry/surface.hpp" #include "detray/propagator/actors/parameter_resetter.hpp" #include "detray/propagator/constrained_step.hpp" #include "detray/propagator/stepping_config.hpp" @@ -95,7 +95,7 @@ class base_stepper { : _bound_params(bound_params) { // Surface - const auto sf = tracking_surface{det, bound_params.surface_link()}; + const auto sf = geometry::surface{det, bound_params.surface_link()}; const typename detector_t::geometry_context ctx{}; sf.template visit_mask< diff --git a/core/include/detray/propagator/detail/tracking_surface_kernels.hpp b/core/include/detray/propagator/detail/tracking_surface_kernels.hpp new file mode 100644 index 000000000..4fca0a9bc --- /dev/null +++ b/core/include/detray/propagator/detail/tracking_surface_kernels.hpp @@ -0,0 +1,112 @@ +/** Detray library, part of the ACTS project (R&D line) + * + * (c) 2023-2024 CERN for the benefit of the ACTS project + * + * Mozilla Public License Version 2.0 + */ + +#pragma once + +// Project include(s) +#include "detray/definitions/detail/qualifiers.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 + +namespace detray::detail { + +/// Functors to be used in the @c tracking_surface class +template +struct tracking_surface_kernels : public surface_kernels { + + using vector3_type = dvector3D; + using transform3_type = dtransform3D; + using bound_param_vector_type = bound_parameters_vector; + using free_param_vector_type = free_parameters_vector; + using free_matrix_type = free_matrix; + + /// 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 + 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(trf3, free_vec); + } + }; + + /// A functor to get from a bound to a free vector + struct bound_to_free_vector { + + template + 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 + 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::free_to_bound_jacobian( + trf3, free_vec); + } + }; + + /// A functor to get the bound-to-free Jacobian + struct bound_to_free_jacobian { + + template + 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::bound_to_free_jacobian( + trf3, mask_group[index], bound_vec); + } + }; + + /// A functor to get the path correction + struct path_correction { + + template + 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::path_correction( + pos, dir, dtds, dqopds, trf3); + } + }; +}; + +} // namespace detray::detail diff --git a/core/include/detray/propagator/tracking_surface.hpp b/core/include/detray/propagator/tracking_surface.hpp new file mode 100644 index 000000000..6613a9e22 --- /dev/null +++ b/core/include/detray/propagator/tracking_surface.hpp @@ -0,0 +1,118 @@ + +/** Detray library, part of the ACTS project (R&D line) + * + * (c) 2024 CERN for the benefit of the ACTS project + * + * Mozilla Public License Version 2.0 + */ + +#pragma once + +// Project include(s) +#include "detray/definitions/detail/qualifiers.hpp" +#include "detray/geometry/surface.hpp" +#include "detray/propagator/detail/tracking_surface_kernels.hpp" + +// System include(s) +#include + +namespace detray { + +/// @brief Facade for a detray detector surface with tracking capabilities. +template // @TODO: This needs a concept +class tracking_surface : public geometry::surface { + + using base_surface_t = geometry::surface; + + /// Implementation of tracking functionality + using kernels = + detail::tracking_surface_kernels; + /// Vector type for track parameters in global coordinates + using free_param_vector_type = typename kernels::free_param_vector_type; + /// Vector type for track parameters in local (bound) coordinates + using bound_param_vector_type = typename kernels::bound_param_vector_type; + + public: + using algebra_type = typename base_surface_t::algebra_type; + using scalar_type = typename base_surface_t::scalar_type; + using point2_type = typename base_surface_t::point2_type; + using point3_type = typename base_surface_t::point3_type; + using vector3_type = typename base_surface_t::vector3_type; + using transform3_type = typename base_surface_t::transform3_type; + using context = typename base_surface_t::context; + + /// Use base class constructors + using base_surface_t::base_surface_t; + + /// Decorate a geometric surface with tracking functionality + DETRAY_HOST_DEVICE + explicit tracking_surface(const base_surface_t sf) : base_surface_t(sf) {} + + /// Conversion to surface interface around constant detector type + template + requires(!std::is_const_v) DETRAY_HOST_DEVICE constexpr + operator tracking_surface() const { + return tracking_surface{this->m_detector, + this->m_desc}; + } + + /// @returns the track parametrization projected onto the surface (bound) + DETRAY_HOST_DEVICE + constexpr auto free_to_bound_vector( + const context &ctx, const free_param_vector_type &free_vec) const { + return this + ->template visit_mask( + this->transform(ctx), free_vec); + } + + /// @returns the global track parametrization from a bound representation + DETRAY_HOST_DEVICE + constexpr auto bound_to_free_vector( + const context &ctx, const bound_param_vector_type &bound_vec) const { + return this + ->template visit_mask( + this->transform(ctx), bound_vec); + } + + /// @returns the jacobian to go from a free to a bound track parametrization + DETRAY_HOST_DEVICE + constexpr auto free_to_bound_jacobian( + const context &ctx, const free_param_vector_type &free_vec) const { + return this + ->template visit_mask( + this->transform(ctx), free_vec); + } + + /// @returns the jacobian to go from a bound to a free track parametrization + DETRAY_HOST_DEVICE + constexpr auto bound_to_free_jacobian( + const context &ctx, const bound_param_vector_type &bound_vec) const { + return this + ->template visit_mask( + this->transform(ctx), bound_vec); + } + + /// @returns the path correction term + DETRAY_HOST_DEVICE + constexpr auto path_correction(const context &ctx, const vector3_type &pos, + const vector3_type &dir, + const vector3_type &dtds, + const scalar_type dqopds) const { + return this->template visit_mask( + this->transform(ctx), pos, dir, dtds, dqopds); + } +}; + +template +DETRAY_HOST_DEVICE tracking_surface(const detector_t &, const descr_t &) + ->tracking_surface; + +template +DETRAY_HOST_DEVICE tracking_surface(const detector_t &, const geometry::barcode) + ->tracking_surface; + +template +DETRAY_HOST_DEVICE tracking_surface(const geometry::surface) + ->tracking_surface; + +} // namespace detray diff --git a/core/include/detray/utils/consistency_checker.hpp b/core/include/detray/utils/consistency_checker.hpp index cb0f589c3..f8eec2790 100644 --- a/core/include/detray/utils/consistency_checker.hpp +++ b/core/include/detray/utils/consistency_checker.hpp @@ -8,7 +8,7 @@ #pragma once // Project include(s) -#include "detray/geometry/tracking_surface.hpp" +#include "detray/geometry/surface.hpp" #include "detray/geometry/tracking_volume.hpp" #include "detray/materials/detail/concepts.hpp" #include "detray/materials/predefined_materials.hpp" @@ -56,7 +56,7 @@ struct surface_checker { const detector_t &det, const dindex vol_idx, const typename detector_t::name_map &names) const { - const auto sf = tracking_surface{det, sf_descr}; + const auto sf = geometry::surface{det, sf_descr}; const auto vol = tracking_volume{det, vol_idx}; std::stringstream err_stream{}; err_stream << "VOLUME \"" << print_volume_name(vol, names) << "\":\n"; @@ -93,7 +93,7 @@ struct surface_checker { // Check that the same surface is registered in the detector surface // lookup const auto sf_from_lkp = - tracking_surface{det, det.surface(sf.barcode())}; + geometry::surface{det, det.surface(sf.barcode())}; if (sf_from_lkp != sf) { err_stream << "ERROR: Surfaces in volume and detector lookups " << "differ:\n In volume acceleration data structure: " @@ -121,7 +121,7 @@ struct surface_checker { if (ref_descr.volume() != check_descr.volume()) { std::stringstream err_stream{}; err_stream << "Incorrect volume index on surface: " - << tracking_surface{det, check_descr}; + << geometry::surface{det, check_descr}; throw std::invalid_argument(err_stream.str()); } @@ -330,7 +330,7 @@ inline bool check_consistency(const detector_t &det, const bool verbose = false, // Check the surfaces in the detector's surface lookup for (const auto &[idx, sf_desc] : detray::views::enumerate(det.surfaces())) { - const auto sf = tracking_surface{det, sf_desc}; + const auto sf = geometry::surface{det, sf_desc}; const auto vol = tracking_volume{det, sf.volume()}; err_stream << "VOLUME \"" << print_volume_name(vol, names) << "\":\n"; diff --git a/io/include/detray/io/common/geometry_writer.hpp b/io/include/detray/io/common/geometry_writer.hpp index 0b290a495..6c5935a4b 100644 --- a/io/include/detray/io/common/geometry_writer.hpp +++ b/io/include/detray/io/common/geometry_writer.hpp @@ -10,7 +10,7 @@ // Project include(s) #include "detray/definitions/detail/indexing.hpp" #include "detray/geometry/mask.hpp" -#include "detray/geometry/tracking_surface.hpp" +#include "detray/geometry/surface.hpp" #include "detray/io/common/detail/basic_converter.hpp" #include "detray/io/common/detail/type_info.hpp" #include "detray/io/frontend/payloads.hpp" @@ -103,7 +103,7 @@ class geometry_writer { /// Convert a detector surface @param sf into its io payload template - static surface_payload convert(const tracking_surface& sf, + static surface_payload convert(const geometry::surface& sf, std::size_t sf_idx) { surface_payload sf_data; @@ -137,7 +137,7 @@ class geometry_writer { for (const auto& sf_desc : det.surfaces()) { if (sf_desc.volume() == vol_desc.index()) { vol_data.surfaces.push_back( - convert(tracking_surface{det, sf_desc}, sf_idx++)); + convert(geometry::surface{det, sf_desc}, sf_idx++)); } } diff --git a/io/include/detray/io/common/homogeneous_material_writer.hpp b/io/include/detray/io/common/homogeneous_material_writer.hpp index 23fa943d0..98801a72d 100644 --- a/io/include/detray/io/common/homogeneous_material_writer.hpp +++ b/io/include/detray/io/common/homogeneous_material_writer.hpp @@ -8,7 +8,7 @@ #pragma once // Project include(s) -#include "detray/geometry/tracking_surface.hpp" +#include "detray/geometry/surface.hpp" #include "detray/geometry/tracking_volume.hpp" #include "detray/io/common/detail/basic_converter.hpp" #include "detray/io/common/detail/type_info.hpp" @@ -104,7 +104,7 @@ class homogeneous_material_writer { for (const auto& sf_desc : vol.surfaces()) { // Convert material slabs and rods - const auto sf = tracking_surface{det, sf_desc}; + const auto sf = geometry::surface{det, sf_desc}; material_slab_payload mslp = sf.template visit_material(sf_idx); diff --git a/plugins/svgtools/include/detray/plugins/svgtools/conversion/information_section.hpp b/plugins/svgtools/include/detray/plugins/svgtools/conversion/information_section.hpp index 988b218bf..fec1b2daa 100644 --- a/plugins/svgtools/include/detray/plugins/svgtools/conversion/information_section.hpp +++ b/plugins/svgtools/include/detray/plugins/svgtools/conversion/information_section.hpp @@ -8,7 +8,7 @@ #pragma once // Project include(s) -#include "detray/geometry/tracking_surface.hpp" +#include "detray/geometry/surface.hpp" #include "detray/plugins/svgtools/meta/proto/information_section.hpp" // Actsvg include(s) @@ -37,7 +37,7 @@ inline std::string point_to_string(point3_t point) { template inline auto information_section( const typename detector_t::geometry_context& context, - const detray::tracking_surface& d_surface) { + const detray::geometry::surface& d_surface) { using point3_t = typename detector_t::point3_type; diff --git a/plugins/svgtools/include/detray/plugins/svgtools/conversion/intersection.hpp b/plugins/svgtools/include/detray/plugins/svgtools/conversion/intersection.hpp index 95444a53c..9c3dc54c2 100644 --- a/plugins/svgtools/include/detray/plugins/svgtools/conversion/intersection.hpp +++ b/plugins/svgtools/include/detray/plugins/svgtools/conversion/intersection.hpp @@ -8,6 +8,9 @@ #pragma once // Project include(s) +#include "detray/geometry/surface.hpp" + +// Plugin include(s) #include "detray/plugins/svgtools/conversion/landmark.hpp" #include "detray/plugins/svgtools/meta/proto/intersection.hpp" @@ -32,13 +35,13 @@ inline auto intersection(const detector_t& detector, for (const auto& intr : intersections) { - const detray::tracking_surface sf{detector, intr.sf_desc}; + const detray::geometry::surface sf{detector, intr.sf_desc}; if (sf.barcode().is_invalid()) { continue; } const point2_t bound{intr.local[0], intr.local[1]}; - const auto position = sf.bound_to_global(gctx, bound, dir); + const auto position = sf.local_to_global(gctx, bound, dir); const auto p_lm = svgtools::conversion::landmark(position, style); p_ir._landmarks.push_back(p_lm); diff --git a/plugins/svgtools/include/detray/plugins/svgtools/conversion/link.hpp b/plugins/svgtools/include/detray/plugins/svgtools/conversion/link.hpp index ac1dae9ec..d5a402d6c 100644 --- a/plugins/svgtools/include/detray/plugins/svgtools/conversion/link.hpp +++ b/plugins/svgtools/include/detray/plugins/svgtools/conversion/link.hpp @@ -8,7 +8,9 @@ #pragma once // Project include(s) -#include "detray/geometry/tracking_surface.hpp" +#include "detray/geometry/surface.hpp" + +// Plugin include(s) #include "detray/plugins/svgtools/utils/link_utils.hpp" #include "detray/plugins/svgtools/utils/surface_kernels.hpp" @@ -21,7 +23,7 @@ namespace detray::svgtools::conversion { template inline auto link(const typename detector_t::geometry_context& context, const detector_t& detector, - const detray::tracking_surface& d_portal) { + const detray::geometry::surface& d_portal) { using point3_container_t = std::vector; using p_link_t = typename actsvg::proto::portal::link; diff --git a/plugins/svgtools/include/detray/plugins/svgtools/conversion/portal.hpp b/plugins/svgtools/include/detray/plugins/svgtools/conversion/portal.hpp index 1a04b8b18..0217c1ff2 100644 --- a/plugins/svgtools/include/detray/plugins/svgtools/conversion/portal.hpp +++ b/plugins/svgtools/include/detray/plugins/svgtools/conversion/portal.hpp @@ -8,7 +8,9 @@ #pragma once // Project include(s) -#include "detray/geometry/tracking_surface.hpp" +#include "detray/geometry/surface.hpp" + +// Plugin include(s) #include "detray/plugins/svgtools/conversion/link.hpp" #include "detray/plugins/svgtools/conversion/surface.hpp" #include "detray/plugins/svgtools/styling/styling.hpp" @@ -24,7 +26,7 @@ namespace detray::svgtools::conversion { template auto portal(const typename detector_t::geometry_context& context, const detector_t& detector, - const detray::tracking_surface& d_portal, + const detray::geometry::surface& d_portal, const view_t& view, const styling::portal_style& style = styling::tableau_colorblind::portal_style, diff --git a/plugins/svgtools/include/detray/plugins/svgtools/conversion/surface.hpp b/plugins/svgtools/include/detray/plugins/svgtools/conversion/surface.hpp index bc2aed36e..d54c4a234 100644 --- a/plugins/svgtools/include/detray/plugins/svgtools/conversion/surface.hpp +++ b/plugins/svgtools/include/detray/plugins/svgtools/conversion/surface.hpp @@ -10,7 +10,9 @@ // Project include(s) #include "detray/geometry/mask.hpp" #include "detray/geometry/shapes.hpp" -#include "detray/geometry/tracking_surface.hpp" +#include "detray/geometry/surface.hpp" + +// Plugin include(s) #include "detray/plugins/svgtools/conversion/surface_material.hpp" #include "detray/plugins/svgtools/styling/styling.hpp" @@ -207,7 +209,7 @@ struct surface_converter { template auto surface(const typename detector_t::geometry_context& context, const detector_t& detector, - const detray::tracking_surface& d_surface, + const detray::geometry::surface& d_surface, const view_t& view, const styling::surface_style& style = styling::tableau_colorblind::surface_style_sensitive, diff --git a/plugins/svgtools/include/detray/plugins/svgtools/conversion/surface_material.hpp b/plugins/svgtools/include/detray/plugins/svgtools/conversion/surface_material.hpp index 97489d34d..0a497c78f 100644 --- a/plugins/svgtools/include/detray/plugins/svgtools/conversion/surface_material.hpp +++ b/plugins/svgtools/include/detray/plugins/svgtools/conversion/surface_material.hpp @@ -8,7 +8,7 @@ #pragma once // Project include(s) -#include "detray/geometry/tracking_surface.hpp" +#include "detray/geometry/surface.hpp" #include "detray/utils/grid/detail/concepts.hpp" // Plugin include(s) @@ -143,7 +143,7 @@ struct material_converter { /// @returns An actsvg proto surface material the material map. template auto surface_material(const detector_t& detector, - const detray::tracking_surface& d_surface, + const detray::geometry::surface& d_surface, const view_t& view, const styling::surface_material_style& style = styling::tableau_colorblind::material_style) { diff --git a/plugins/svgtools/include/detray/plugins/svgtools/conversion/volume.hpp b/plugins/svgtools/include/detray/plugins/svgtools/conversion/volume.hpp index bac3ab988..ab8924f56 100644 --- a/plugins/svgtools/include/detray/plugins/svgtools/conversion/volume.hpp +++ b/plugins/svgtools/include/detray/plugins/svgtools/conversion/volume.hpp @@ -8,8 +8,10 @@ #pragma once // Project include(s) -#include "detray/geometry/tracking_surface.hpp" +#include "detray/geometry/surface.hpp" #include "detray/geometry/tracking_volume.hpp" + +// Plugin include(s) #include "detray/plugins/svgtools/conversion/portal.hpp" #include "detray/plugins/svgtools/conversion/surface.hpp" #include "detray/plugins/svgtools/conversion/surface_grid.hpp" @@ -65,7 +67,7 @@ auto volume(const typename detector_t::geometry_context& context, for (const auto& desc : d_volume.surfaces()) { - const auto sf = detray::tracking_surface{detector, desc}; + const auto sf = detray::geometry::surface{detector, desc}; if (sf.is_portal()) { if (!hide_portals) { diff --git a/plugins/svgtools/include/detray/plugins/svgtools/illustrator.hpp b/plugins/svgtools/include/detray/plugins/svgtools/illustrator.hpp index 12ebca55d..e1de19abd 100644 --- a/plugins/svgtools/include/detray/plugins/svgtools/illustrator.hpp +++ b/plugins/svgtools/include/detray/plugins/svgtools/illustrator.hpp @@ -8,7 +8,7 @@ #pragma once // Project include(s) -#include "detray/geometry/tracking_surface.hpp" +#include "detray/geometry/surface.hpp" #include "detray/plugins/svgtools/conversion/detector.hpp" #include "detray/plugins/svgtools/conversion/grid.hpp" #include "detray/plugins/svgtools/conversion/information_section.hpp" @@ -107,7 +107,7 @@ class illustrator { const typename detector_t::geometry_context& gctx = {}) const { const auto surface = - detray::tracking_surface{_detector, index}; + detray::geometry::surface{_detector, index}; actsvg::svg::object ret, material; const auto& style = _style._detector_style._volume_style; @@ -206,7 +206,7 @@ class illustrator { const view_t& view) const { const auto surface = - detray::tracking_surface{_detector, index}; + detray::geometry::surface{_detector, index}; if (_hide_material) { return actsvg::svg::object{}; @@ -523,7 +523,7 @@ class illustrator { prefix + "_record", p_ir, view)); // The intersection record is always sorted by path length - const auto sf{detray::tracking_surface{ + const auto sf{detray::geometry::surface{ _detector, intersections.back().sf_desc}}; const auto final_pos = sf.local_to_global( gctx, intersections.back().local, trajectory.dir(0.f)); diff --git a/plugins/svgtools/include/detray/plugins/svgtools/utils/link_utils.hpp b/plugins/svgtools/include/detray/plugins/svgtools/utils/link_utils.hpp index a1c03e6ca..4f4873dde 100644 --- a/plugins/svgtools/include/detray/plugins/svgtools/utils/link_utils.hpp +++ b/plugins/svgtools/include/detray/plugins/svgtools/utils/link_utils.hpp @@ -8,10 +8,12 @@ #pragma once // Project include(s) -#include "detray/geometry/tracking_surface.hpp" -#include "detray/plugins/svgtools/utils/surface_kernels.hpp" +#include "detray/geometry/surface.hpp" #include "detray/utils/invalid_values.hpp" +// Plugin include(s) +#include "detray/plugins/svgtools/utils/surface_kernels.hpp" + // System include(s) #include #include @@ -21,7 +23,7 @@ namespace detray::svgtools::utils { /// @brief Checks if the detray surface has a volume link. template inline auto is_not_world_portal( - const detray::tracking_surface& d_portal) { + const detray::geometry::surface& d_portal) { const auto d_link_idx = d_portal.template visit_mask(); return !detail::is_invalid_value(d_link_idx); } @@ -31,7 +33,7 @@ inline auto is_not_world_portal( template inline auto get_linked_volume( const detector_t& detector, - const detray::tracking_surface& d_portal) { + const detray::geometry::surface& d_portal) { assert(is_not_world_portal(d_portal)); const auto d_link_idx = d_portal.template visit_mask(); return tracking_volume{detector, d_link_idx}; @@ -43,7 +45,7 @@ inline auto get_linked_volume( template inline auto link_points(const typename detector_t::geometry_context& context, const detector_t& detector, - const detray::tracking_surface& d_portal, + const detray::geometry::surface& d_portal, typename detector_t::vector3_type dir, const double link_length) { assert(is_not_world_portal(d_portal)); diff --git a/plugins/svgtools/include/detray/plugins/svgtools/utils/surface_kernels.hpp b/plugins/svgtools/include/detray/plugins/svgtools/utils/surface_kernels.hpp index 12b769697..2f72dfdb3 100644 --- a/plugins/svgtools/include/detray/plugins/svgtools/utils/surface_kernels.hpp +++ b/plugins/svgtools/include/detray/plugins/svgtools/utils/surface_kernels.hpp @@ -11,7 +11,7 @@ #include "detray/definitions/units.hpp" #include "detray/geometry/mask.hpp" #include "detray/geometry/shapes.hpp" -#include "detray/geometry/tracking_surface.hpp" +#include "detray/geometry/surface.hpp" #include "detray/geometry/tracking_volume.hpp" // System include(s) @@ -231,7 +231,7 @@ struct link_end_getter { const vector3_t& surface_normal) const { for (const auto& desc : volume.portals()) { - const detray::tracking_surface surface{detector, desc}; + const detray::geometry::surface surface{detector, desc}; if (auto r = surface.template visit_mask()) { if (*r > mask[shape_t::e_r]) { diff --git a/tests/benchmarks/cpu/intersect_all.cpp b/tests/benchmarks/cpu/intersect_all.cpp index 0aa7b3cf2..44b88071e 100644 --- a/tests/benchmarks/cpu/intersect_all.cpp +++ b/tests/benchmarks/cpu/intersect_all.cpp @@ -8,7 +8,7 @@ // Project include(s) #include "detray/core/detector.hpp" #include "detray/definitions/units.hpp" -#include "detray/geometry/tracking_surface.hpp" +#include "detray/geometry/surface.hpp" #include "detray/navigation/detail/ray.hpp" #include "detray/navigation/intersection/ray_intersector.hpp" #include "detray/navigation/intersection_kernel.hpp" @@ -77,7 +77,7 @@ void BM_INTERSECT_ALL(benchmark::State &state) { // Loop over all surfaces in detector for (const sf_desc_t &sf_desc : d.surfaces()) { - const auto sf = tracking_surface{d, sf_desc}; + const auto sf = geometry::surface{d, sf_desc}; sf.template visit_mask< intersection_initialize>( intersections, detail::ray(track), sf_desc, transforms, diff --git a/tests/include/detray/test/cpu/detector_scan.hpp b/tests/include/detray/test/cpu/detector_scan.hpp index 869e408ff..abc967ed3 100644 --- a/tests/include/detray/test/cpu/detector_scan.hpp +++ b/tests/include/detray/test/cpu/detector_scan.hpp @@ -8,7 +8,6 @@ #pragma once // Project include(s) -#include "detray/geometry/tracking_surface.hpp" #include "detray/navigation/detail/ray.hpp" #include "detray/navigation/volume_graph.hpp" diff --git a/tests/include/detray/test/cpu/material_scan.hpp b/tests/include/detray/test/cpu/material_scan.hpp index 59a34e65e..ffc3141c4 100644 --- a/tests/include/detray/test/cpu/material_scan.hpp +++ b/tests/include/detray/test/cpu/material_scan.hpp @@ -8,6 +8,7 @@ #pragma once // Project include(s) +#include "detray/geometry/surface.hpp" #include "detray/navigation/detail/ray.hpp" // Detray IO include(s) @@ -151,7 +152,7 @@ class material_scan : public test::fixture_base<> { } const auto sf = - tracking_surface{m_det, record.intersection.sf_desc}; + geometry::surface{m_det, record.intersection.sf_desc}; if (!sf.has_material()) { continue; @@ -160,7 +161,8 @@ class material_scan : public test::fixture_base<> { const auto &p = record.intersection.local; const auto mat_params = sf.template visit_material< material_validator::get_material_params>( - point2_t{p[0], p[1]}, sf.cos_angle(m_gctx, ray.dir(), p)); + point2_t{p[0], p[1]}, + detail::cos_angle(m_gctx, sf, ray.dir(), p)); const scalar_t seg{mat_params.path}; const scalar_t t{mat_params.thickness}; diff --git a/tests/include/detray/test/utils/detectors/build_toy_detector.hpp b/tests/include/detray/test/utils/detectors/build_toy_detector.hpp index cee8e27d6..7fae8ae07 100644 --- a/tests/include/detray/test/utils/detectors/build_toy_detector.hpp +++ b/tests/include/detray/test/utils/detectors/build_toy_detector.hpp @@ -21,7 +21,6 @@ #include "detray/definitions/detail/indexing.hpp" #include "detray/definitions/units.hpp" #include "detray/detectors/toy_metadata.hpp" -#include "detray/geometry/tracking_surface.hpp" #include "detray/geometry/tracking_volume.hpp" #include "detray/materials/mixture.hpp" #include "detray/materials/predefined_materials.hpp" diff --git a/tests/include/detray/test/utils/inspectors.hpp b/tests/include/detray/test/utils/inspectors.hpp index a286fff7a..d0fd73736 100644 --- a/tests/include/detray/test/utils/inspectors.hpp +++ b/tests/include/detray/test/utils/inspectors.hpp @@ -13,7 +13,7 @@ #endif // Project include(s) -#include "detray/geometry/tracking_surface.hpp" +#include "detray/geometry/surface.hpp" #include "detray/navigation/detail/ray.hpp" #include "detray/navigation/navigation_config.hpp" #include "detray/navigation/navigator.hpp" @@ -277,7 +277,7 @@ struct print_inspector { for (const auto &sf_cand : state) { const auto &local = sf_cand.local; const auto pos = - tracking_surface{state.detector(), sf_cand.sf_desc} + geometry::surface{state.detector(), sf_cand.sf_desc} .local_to_global(geo_ctx_t{}, local, track_dir); debug_stream << sf_cand; diff --git a/tests/include/detray/test/utils/simulation/random_scatterer.hpp b/tests/include/detray/test/utils/simulation/random_scatterer.hpp index 45aaec7b1..25c1f621b 100644 --- a/tests/include/detray/test/utils/simulation/random_scatterer.hpp +++ b/tests/include/detray/test/utils/simulation/random_scatterer.hpp @@ -12,13 +12,13 @@ #include "detray/definitions/pdg_particle.hpp" #include "detray/definitions/track_parametrization.hpp" #include "detray/definitions/units.hpp" -#include "detray/geometry/tracking_surface.hpp" #include "detray/materials/detail/concepts.hpp" +#include "detray/materials/detail/material_accessor.hpp" +#include "detray/materials/detail/material_utils.hpp" #include "detray/materials/interaction.hpp" #include "detray/propagator/base_actor.hpp" #include "detray/tracks/bound_track_parameters.hpp" #include "detray/utils/axis_rotation.hpp" -#include "detray/utils/ranges.hpp" #include "detray/utils/unit_vectors.hpp" // Detray test include(s) @@ -148,8 +148,8 @@ struct random_scatterer : actor { auto& bound_params = stepping._bound_params; const auto sf = navigation.get_surface(); const scalar_type cos_inc_angle{ - sf.cos_angle(geo_context_type{}, bound_params.dir(), - bound_params.bound_local())}; + detail::cos_angle(geo_context_type{}, sf, bound_params.dir(), + bound_params.bound_local())}; sf.template visit_material(simulator_state, ptc, bound_params, cos_inc_angle, diff --git a/tests/include/detray/test/validation/detector_scanner.hpp b/tests/include/detray/test/validation/detector_scanner.hpp index 1f9977fe8..a164dd7e3 100644 --- a/tests/include/detray/test/validation/detector_scanner.hpp +++ b/tests/include/detray/test/validation/detector_scanner.hpp @@ -8,7 +8,7 @@ #pragma once // Project include(s) -#include "detray/geometry/tracking_surface.hpp" +#include "detray/geometry/surface.hpp" #include "detray/navigation/detail/trajectories.hpp" #include "detray/navigation/intersection/intersection.hpp" #include "detray/navigation/intersection_kernel.hpp" @@ -87,7 +87,7 @@ struct brute_force_scan { // Loop over all surfaces in the detector for (const sf_desc_t &sf_desc : detector.surfaces()) { // Retrieve candidate(s) from the surface - const auto sf = tracking_surface{detector, sf_desc}; + const auto sf = geometry::surface{detector, sf_desc}; sf.template visit_mask( intersections, traj, sf_desc, trf_store, sf.is_portal() ? std::array{0.f, 0.f} diff --git a/tests/include/detray/test/validation/material_validation_utils.hpp b/tests/include/detray/test/validation/material_validation_utils.hpp index 1e38fd0c3..08a278913 100644 --- a/tests/include/detray/test/validation/material_validation_utils.hpp +++ b/tests/include/detray/test/validation/material_validation_utils.hpp @@ -201,7 +201,7 @@ struct material_tracer : detray::actor { // Fetch the material parameters and pathlength through the material const auto mat_params = sf.template visit_material( - loc_pos, sf.cos_angle(gctx, glob_dir, loc_pos)); + loc_pos, detail::cos_angle(gctx, sf, glob_dir, loc_pos)); const scalar_t seg{mat_params.path}; const scalar_t t{mat_params.thickness}; diff --git a/tests/include/detray/test/validation/navigation_validation_utils.hpp b/tests/include/detray/test/validation/navigation_validation_utils.hpp index 2c0171720..d566139c3 100644 --- a/tests/include/detray/test/validation/navigation_validation_utils.hpp +++ b/tests/include/detray/test/validation/navigation_validation_utils.hpp @@ -8,6 +8,7 @@ #pragma once // Project include(s) +#include "detray/geometry/surface.hpp" #include "detray/navigation/navigator.hpp" #include "detray/propagator/actor_chain.hpp" #include "detray/propagator/actors/aborters.hpp" @@ -31,6 +32,18 @@ namespace detray::navigation_validator { +/// A functor to get the minimum distance to any surface boundary. +struct min_dist_to_boundary { + + template + 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); + } +}; + /// B-field placeholder for straight-line navigation struct empty_bfield {}; @@ -386,10 +399,12 @@ auto write_dist_to_boundary( for (const auto &missed_sfi : missed_inters_vec) { const auto &track = entry.first; - const auto sf = tracking_surface{det, missed_sfi.sf_desc.barcode()}; + const auto sf = + geometry::surface{det, missed_sfi.sf_desc.barcode()}; const auto vol = tracking_volume{det, sf.volume()}; - const auto dist = sf.min_dist_to_boundary(missed_sfi.local); + const auto dist = + sf.template visit_mask(missed_sfi.local); const auto glob_pos = sf.local_to_global( gctx, missed_sfi.local, track.dir(missed_sfi.path)); diff --git a/tests/integration_tests/cpu/propagator/jacobian_validation.cpp b/tests/integration_tests/cpu/propagator/jacobian_validation.cpp index 0fb3adf26..137ba679b 100644 --- a/tests/integration_tests/cpu/propagator/jacobian_validation.cpp +++ b/tests/integration_tests/cpu/propagator/jacobian_validation.cpp @@ -14,6 +14,7 @@ #include "detray/propagator/actors/parameter_transporter.hpp" #include "detray/propagator/propagator.hpp" #include "detray/propagator/rk_stepper.hpp" +#include "detray/propagator/tracking_surface.hpp" // Detray test include(s) #include "detray/test/utils/detectors/build_telescope_detector.hpp" diff --git a/tests/integration_tests/cpu/propagator/propagator.cpp b/tests/integration_tests/cpu/propagator/propagator.cpp index 9ac31f746..3c3bd62ff 100644 --- a/tests/integration_tests/cpu/propagator/propagator.cpp +++ b/tests/integration_tests/cpu/propagator/propagator.cpp @@ -10,7 +10,6 @@ #include "detray/definitions/units.hpp" #include "detray/detectors/bfield.hpp" -#include "detray/geometry/tracking_surface.hpp" #include "detray/navigation/detail/trajectories.hpp" #include "detray/navigation/navigator.hpp" #include "detray/propagator/actor_chain.hpp" @@ -21,6 +20,7 @@ #include "detray/propagator/base_actor.hpp" #include "detray/propagator/line_stepper.hpp" #include "detray/propagator/rk_stepper.hpp" +#include "detray/propagator/tracking_surface.hpp" #include "detray/tracks/tracks.hpp" // Detray test include(s) diff --git a/tests/unit_tests/cpu/CMakeLists.txt b/tests/unit_tests/cpu/CMakeLists.txt index 07c9e4eaa..13a9c9eab 100644 --- a/tests/unit_tests/cpu/CMakeLists.txt +++ b/tests/unit_tests/cpu/CMakeLists.txt @@ -52,7 +52,7 @@ macro(detray_add_cpu_test algebra) "geometry/masks/trapezoid2D.cpp" "geometry/masks/unbounded.cpp" "geometry/masks/unmasked.cpp" - "geometry/tracking_surface.cpp" + "geometry/surface.cpp" "geometry/tracking_volume.cpp" "grid2/axis.cpp" "grid2/grid2.cpp" diff --git a/tests/unit_tests/cpu/geometry/tracking_surface.cpp b/tests/unit_tests/cpu/geometry/surface.cpp similarity index 80% rename from tests/unit_tests/cpu/geometry/tracking_surface.cpp rename to tests/unit_tests/cpu/geometry/surface.cpp index 25bed70a6..211f48b6e 100644 --- a/tests/unit_tests/cpu/geometry/tracking_surface.cpp +++ b/tests/unit_tests/cpu/geometry/surface.cpp @@ -6,9 +6,10 @@ */ // Project include(s) -#include "detray/geometry/tracking_surface.hpp" +#include "detray/geometry/surface.hpp" #include "detray/definitions/detail/indexing.hpp" +#include "detray/materials/detail/material_utils.hpp" //< cos incidence angle // Detray test include(s) #include "detray/test/utils/detectors/build_toy_detector.hpp" @@ -90,10 +91,10 @@ GTEST_TEST(detray_geometry, surface_toy_detector) { using detector_t = detector; - using scalar_t = tracking_surface::scalar_type; - using point2_t = tracking_surface::point2_type; - using point3_t = tracking_surface::point3_type; - using vector3_t = tracking_surface::vector3_type; + using scalar_t = geometry::surface::scalar_type; + using point2_t = geometry::surface::point2_type; + using point3_t = geometry::surface::point3_type; + using vector3_t = geometry::surface::vector3_type; vecmem::host_memory_resource host_mr; toy_det_config toy_cfg{}; @@ -106,7 +107,7 @@ GTEST_TEST(detray_geometry, surface_toy_detector) { // Disc // const auto disc_descr = toy_det.surfaces()[1u]; - const auto disc = tracking_surface{toy_det, disc_descr}; + const auto disc = geometry::surface{toy_det, disc_descr}; // IDs ASSERT_EQ(disc.barcode(), disc_descr.barcode()); @@ -138,23 +139,25 @@ GTEST_TEST(detray_geometry, surface_toy_detector) { // Cos incidence angle auto dir = vector::normalize(vector3_t{1.f, 0.f, 1.f}); - ASSERT_NEAR(disc.cos_angle(ctx, dir, point3_t{0.f, 0.f, 0.f}), + ASSERT_NEAR(detail::cos_angle(ctx, disc, dir, point3_t{0.f, 0.f, 0.f}), constant::inv_sqrt2, tol); - ASSERT_NEAR(disc.cos_angle(ctx, dir, point2_t{0.f, 0.f}), + ASSERT_NEAR(detail::cos_angle(ctx, disc, dir, point2_t{0.f, 0.f}), constant::inv_sqrt2, tol); dir = vector::normalize(vector3_t{1.f, 1.f, 0.f}); - ASSERT_NEAR(disc.cos_angle(ctx, dir, point3_t{1.f, 0.5f, 0.f}), 0.f, tol); - ASSERT_NEAR(disc.cos_angle(ctx, dir, point2_t{1.f, 0.5f}), 0.f, tol); + ASSERT_NEAR(detail::cos_angle(ctx, disc, dir, point3_t{1.f, 0.5f, 0.f}), + 0.f, tol); + ASSERT_NEAR(detail::cos_angle(ctx, disc, dir, point2_t{1.f, 0.5f}), 0.f, + tol); dir = vector::normalize(vector3_t{1.f, 0.f, constant::pi}); scalar_t cos_inc_angle{ constant::pi / std::sqrt(1.f + std::pow(constant::pi, 2.f))}; - ASSERT_NEAR(disc.cos_angle(ctx, dir, point3_t{2.f, 1.f, 0.f}), + ASSERT_NEAR(detail::cos_angle(ctx, disc, dir, point3_t{2.f, 1.f, 0.f}), + cos_inc_angle, tol); + ASSERT_NEAR(detail::cos_angle(ctx, disc, dir, point2_t{2.f, 1.f}), cos_inc_angle, tol); - ASSERT_NEAR(disc.cos_angle(ctx, dir, point2_t{2.f, 1.f}), cos_inc_angle, - tol); // Coordinate transformations point3_t glob_pos = {4.f, 7.f, 4.f}; @@ -168,7 +171,7 @@ GTEST_TEST(detray_geometry, surface_toy_detector) { // Roundtrip point3_t global = disc.local_to_global(ctx, local, {}); - point3_t global2 = disc.bound_to_global(ctx, bound, {}); + point3_t global2 = disc.local_to_global(ctx, bound, {}); ASSERT_NEAR(glob_pos[0], global[0], tol); ASSERT_NEAR(glob_pos[1], global[1], tol); @@ -189,7 +192,7 @@ GTEST_TEST(detray_geometry, surface_toy_detector) { // Rectangle // const auto rec_descr = toy_det.surfaces()[604u]; - const auto rec = tracking_surface{toy_det, rec_descr}; + const auto rec = geometry::surface{toy_det, rec_descr}; // IDs ASSERT_EQ(rec.barcode(), rec_descr.barcode()); @@ -219,19 +222,22 @@ GTEST_TEST(detray_geometry, surface_toy_detector) { // Incidence angle dir = vector::normalize(global); - ASSERT_NEAR(rec.cos_angle(ctx, dir, point3_t{0.f, 0.f, 0.f}), 1.f, tol); - ASSERT_NEAR(rec.cos_angle(ctx, dir, point2_t{0.f, 0.f}), 1.f, tol); + ASSERT_NEAR(detail::cos_angle(ctx, rec, dir, point3_t{0.f, 0.f, 0.f}), 1.f, + tol); + ASSERT_NEAR(detail::cos_angle(ctx, rec, dir, point2_t{0.f, 0.f}), 1.f, tol); dir = vector::normalize(vector3_t{0.f, -global[2], global[1]}); - ASSERT_NEAR(rec.cos_angle(ctx, dir, point3_t{1.f, 0.5f, 0.f}), 0.f, tol); - ASSERT_NEAR(rec.cos_angle(ctx, dir, point2_t{1.f, 0.5f}), 0.f, tol); + ASSERT_NEAR(detail::cos_angle(ctx, rec, dir, point3_t{1.f, 0.5f, 0.f}), 0.f, + tol); + ASSERT_NEAR(detail::cos_angle(ctx, rec, dir, point2_t{1.f, 0.5f}), 0.f, + tol); dir = vector::normalize(vector3_t{1.f, 0.f, constant::pi}); cos_inc_angle = std::fabs(vector::dot(dir, global)); - ASSERT_NEAR(rec.cos_angle(ctx, dir, point3_t{2.f, 1.f, 0.f}), cos_inc_angle, - tol); - ASSERT_NEAR(rec.cos_angle(ctx, dir, point2_t{2.f, 1.f}), cos_inc_angle, - tol); + ASSERT_NEAR(detail::cos_angle(ctx, rec, dir, point3_t{2.f, 1.f, 0.f}), + cos_inc_angle, tol); + ASSERT_NEAR(detail::cos_angle(ctx, rec, dir, point2_t{2.f, 1.f}), + cos_inc_angle, tol); // Coordinate transformation roundtrip glob_pos = {4.f, 7.f, 4.f}; @@ -251,7 +257,7 @@ GTEST_TEST(detray_geometry, surface_toy_detector) { ASSERT_NEAR(glob_pos[2], global[2], tol); bound = rec.global_to_bound(ctx, glob_pos, {}); - global = rec.bound_to_global(ctx, bound, {}); + global = rec.local_to_global(ctx, bound, {}); ASSERT_NEAR(global[0], glob_pos[0], tol); ASSERT_NEAR(global[1], glob_pos[1], tol); ASSERT_NEAR(global[2], glob_pos[2], tol); @@ -265,7 +271,7 @@ GTEST_TEST(detray_geometry, surface_toy_detector) { // Concentric Cylinder // const auto cyl_descr = toy_det.surfaces()[8u]; - const auto cyl = tracking_surface{toy_det, cyl_descr}; + const auto cyl = geometry::surface{toy_det, cyl_descr}; // IDs ASSERT_EQ(cyl.barcode(), cyl_descr.barcode()); @@ -318,24 +324,25 @@ GTEST_TEST(detray_geometry, surface_toy_detector) { 0.f, tol); // Incidence angle - ASSERT_NEAR(cyl.cos_angle(ctx, x_axis, - point3_t{r * constant::pi, 0.f, r}), + ASSERT_NEAR(detail::cos_angle(ctx, cyl, x_axis, + point3_t{r * constant::pi, 0.f, r}), + 1.f, tol); + ASSERT_NEAR(detail::cos_angle(ctx, cyl, x_axis, + point2_t{r * constant::pi, 0.f}), 1.f, tol); - ASSERT_NEAR( - cyl.cos_angle(ctx, x_axis, point2_t{r * constant::pi, 0.f}), - 1.f, tol); - ASSERT_NEAR(cyl.cos_angle(ctx, z_axis, - point3_t{r * constant::pi_2, 0.f, r}), - 0.f, tol); ASSERT_NEAR( - cyl.cos_angle(ctx, z_axis, point2_t{r * constant::pi_2, 0.f}), + detail::cos_angle(ctx, cyl, z_axis, + point3_t{r * constant::pi_2, 0.f, r}), 0.f, tol); + ASSERT_NEAR(detail::cos_angle(ctx, cyl, z_axis, + point2_t{r * constant::pi_2, 0.f}), + 0.f, tol); dir = vector::normalize(vector3_t{1.f, 1.f, 0.f}); - ASSERT_NEAR(cyl.cos_angle(ctx, dir, point3_t{0.f, 1.f, r}), + ASSERT_NEAR(detail::cos_angle(ctx, cyl, dir, point3_t{0.f, 1.f, r}), constant::inv_sqrt2, tol); - ASSERT_NEAR(cyl.cos_angle(ctx, dir, point2_t{0.f, 1.f}), + ASSERT_NEAR(detail::cos_angle(ctx, cyl, dir, point2_t{0.f, 1.f}), constant::inv_sqrt2, tol); // Coordinate transformation roundtrip @@ -357,7 +364,7 @@ GTEST_TEST(detray_geometry, surface_toy_detector) { ASSERT_NEAR(glob_pos[2], global[2], tol); bound = cyl.global_to_bound(ctx, glob_pos, {}); - global = cyl.bound_to_global(ctx, bound, {}); + global = cyl.local_to_global(ctx, bound, {}); ASSERT_NEAR(global[0], glob_pos[0], tol); ASSERT_NEAR(global[1], glob_pos[1], tol); ASSERT_NEAR(global[2], glob_pos[2], tol); @@ -377,10 +384,10 @@ GTEST_TEST(detray_geometry, surface_wire_chamber) { using detector_t = detector; - using scalar_t = tracking_surface::scalar_type; - using point2_t = tracking_surface::point2_type; - using point3_t = tracking_surface::point3_type; - using vector3_t = tracking_surface::vector3_type; + using scalar_t = geometry::surface::scalar_type; + using point2_t = geometry::surface::point2_type; + using point3_t = geometry::surface::point3_type; + using vector3_t = geometry::surface::vector3_type; vecmem::host_memory_resource host_mr; wire_chamber_config<> cfg{}; @@ -392,7 +399,7 @@ GTEST_TEST(detray_geometry, surface_wire_chamber) { // Line // const auto line_descr = wire_chmbr.surfaces()[23u]; - const auto line = tracking_surface{wire_chmbr, line_descr}; + const auto line = geometry::surface{wire_chmbr, line_descr}; // IDs ASSERT_EQ(line.barcode(), line_descr.barcode()); @@ -425,17 +432,21 @@ GTEST_TEST(detray_geometry, surface_wire_chamber) { // Cos incidence angle auto dir = vector::normalize(global); - ASSERT_NEAR(line.cos_angle(ctx, dir, point3_t{1.f, 0.f, 0.f}), 1.f, tol); - ASSERT_NEAR(line.cos_angle(ctx, dir, point2_t{1.f, 0.f}), 1.f, tol); + ASSERT_NEAR(detail::cos_angle(ctx, line, dir, point3_t{1.f, 0.f, 0.f}), 1.f, + tol); + ASSERT_NEAR(detail::cos_angle(ctx, line, dir, point2_t{1.f, 0.f}), 1.f, + tol); dir = vector::normalize(vector3_t{0.f, -global[2], global[1]}); - ASSERT_NEAR(line.cos_angle(ctx, dir, point3_t{1.f, 100.f, 0.f}), 0.f, tol); - ASSERT_NEAR(line.cos_angle(ctx, dir, point2_t{1.f, 100.f}), 0.f, tol); + ASSERT_NEAR(detail::cos_angle(ctx, line, dir, point3_t{1.f, 100.f, 0.f}), + 0.f, tol); + ASSERT_NEAR(detail::cos_angle(ctx, line, dir, point2_t{1.f, 100.f}), 0.f, + tol); dir = vector3_t{-0.685475f, -0.0404595f, 0.726971f}; - ASSERT_NEAR(line.cos_angle(ctx, dir, point3_t{2.f, 1.f, 0.f}), + ASSERT_NEAR(detail::cos_angle(ctx, line, dir, point3_t{2.f, 1.f, 0.f}), constant::inv_sqrt2, 0.0005); - ASSERT_NEAR(line.cos_angle(ctx, dir, point2_t{2.f, 1.f}), + ASSERT_NEAR(detail::cos_angle(ctx, line, dir, point2_t{2.f, 1.f}), constant::inv_sqrt2, 0.0005); // Coordinate transformation roundtrip @@ -460,7 +471,7 @@ GTEST_TEST(detray_geometry, surface_wire_chamber) { ASSERT_NEAR(glob_pos[2], global[2], red_tol); point2_t bound = line.global_to_bound(ctx, glob_pos, dir); - global = line.bound_to_global(ctx, bound, dir); + global = line.local_to_global(ctx, bound, dir); ASSERT_NEAR(global[0], glob_pos[0], red_tol); ASSERT_NEAR(global[1], glob_pos[1], red_tol); ASSERT_NEAR(global[2], glob_pos[2], red_tol); diff --git a/tests/unit_tests/cpu/propagator/rk_stepper.cpp b/tests/unit_tests/cpu/propagator/rk_stepper.cpp index 8f13e616f..641181d6e 100644 --- a/tests/unit_tests/cpu/propagator/rk_stepper.cpp +++ b/tests/unit_tests/cpu/propagator/rk_stepper.cpp @@ -12,7 +12,6 @@ #include "detray/core/detector.hpp" #include "detray/definitions/units.hpp" #include "detray/detectors/bfield.hpp" -#include "detray/geometry/tracking_surface.hpp" #include "detray/io/utils/file_handle.hpp" #include "detray/navigation/detail/trajectories.hpp" #include "detray/propagator/line_stepper.hpp"