Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: Make surface implementation more concise #861

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion core/include/detray/builders/detail/bin_association.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "detray/geometry/coordinates/concentric_cylindrical2D.hpp"
#include "detray/geometry/coordinates/cylindrical2D.hpp"
#include "detray/geometry/coordinates/polar2D.hpp"
#include "detray/geometry/detail/vertexing.hpp"
#include "detray/geometry/detail/vertexer.hpp"
#include "detray/navigation/accelerators/concepts.hpp"
#include "detray/utils/grid/populators.hpp"
#include "detray/utils/ranges.hpp"
Expand Down
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
139 changes: 1 addition & 138 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 @@ -158,21 +153,6 @@ struct surface_kernels {
}
};

/// A functor to perform global to local bound transformation
struct global_to_bound {
template <typename mask_group_t, typename index_t>
DETRAY_HOST_DEVICE inline point2_type operator()(
const mask_group_t& /*mask_group*/, const index_t& /*index*/,
const transform3_type& trf3, const point3_type& global,
const vector3_type& dir) const {
using mask_t = typename mask_group_t::value_type;

const point3_type local = mask_t::to_local_frame(trf3, global, dir);

return {local[0], local[1]};
}
};

/// A functor to perform global to local transformation
struct global_to_local {
template <typename mask_group_t, typename index_t>
Expand Down Expand Up @@ -210,123 +190,6 @@ struct surface_kernels {
return mask_t::to_global_frame(trf3, local);
}
};

/// 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 {

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 dindex n_seg) const {

return mask_group[index].vertices(n_seg);
}
};
};

} // namespace detray::detail
113 changes: 113 additions & 0 deletions core/include/detray/geometry/detail/tracking_surface_kernels.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/** 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/geometry/detail/surface_kernels.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 <ostream>

namespace detray::detail {

/// Functors to be used in the @c tracking_surface class
template <typename algebra_t>
struct tracking_surface_kernels : public surface_kernels<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 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);
}
};
};

} // namespace detray::detail
Loading
Loading