Skip to content

Commit 4b59995

Browse files
committed
Split the surface implementation
1 parent e3724d6 commit 4b59995

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+506
-407
lines changed

core/include/detray/builders/detail/bin_association.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "detray/geometry/coordinates/concentric_cylindrical2D.hpp"
1515
#include "detray/geometry/coordinates/cylindrical2D.hpp"
1616
#include "detray/geometry/coordinates/polar2D.hpp"
17-
#include "detray/geometry/detail/vertexing.hpp"
17+
#include "detray/geometry/detail/vertexer.hpp"
1818
#include "detray/navigation/accelerators/concepts.hpp"
1919
#include "detray/utils/grid/populators.hpp"
2020
#include "detray/utils/ranges.hpp"

core/include/detray/builders/detail/portal_accessor.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "detray/definitions/detail/qualifiers.hpp"
1313
#include "detray/geometry/shapes/cylinder2D.hpp"
1414
#include "detray/geometry/shapes/ring2D.hpp"
15-
#include "detray/geometry/tracking_surface.hpp"
15+
#include "detray/geometry/surface.hpp"
1616
#include "detray/geometry/tracking_volume.hpp"
1717

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

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

4343
if (name == "cylinder2D" || name == "concentric_cylinder2D") {

core/include/detray/builders/grid_builder.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "detray/builders/surface_factory_interface.hpp"
1414
#include "detray/builders/volume_builder.hpp"
1515
#include "detray/builders/volume_builder_interface.hpp"
16-
#include "detray/geometry/tracking_surface.hpp"
1716
#include "detray/geometry/tracking_volume.hpp"
1817
#include "detray/utils/grid/detail/concepts.hpp"
1918

core/include/detray/builders/material_map_builder.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "detray/builders/material_map_generator.hpp"
1414
#include "detray/builders/surface_factory_interface.hpp"
1515
#include "detray/builders/volume_builder_interface.hpp"
16-
#include "detray/geometry/tracking_surface.hpp"
16+
#include "detray/geometry/surface.hpp"
1717
#include "detray/materials/material_map.hpp"
1818

1919
// System include(s)
@@ -125,7 +125,7 @@ class material_map_builder final : public volume_decorator<detector_t> {
125125
}
126126

127127
// Construct and append the material map for a given surface shape
128-
auto sf = tracking_surface{det, sf_desc};
128+
auto sf = geometry::surface{det, sf_desc};
129129
[[maybe_unused]] auto [mat_id, mat_idx] = sf.template visit_mask<
130130
detail::add_sf_material_map<materials_t>>(
131131
m_factory, m_bin_data.at(sf_idx), m_n_bins.at(sf_idx),

core/include/detray/builders/volume_builder.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "detray/builders/surface_factory_interface.hpp"
1212
#include "detray/builders/volume_builder_interface.hpp"
1313
#include "detray/definitions/geometry.hpp"
14-
#include "detray/geometry/tracking_surface.hpp"
14+
#include "detray/geometry/surface.hpp"
1515
#include "detray/utils/grid/detail/concepts.hpp"
1616

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

213-
const auto sf = tracking_surface{det, sf_desc};
213+
const auto sf = geometry::surface{det, sf_desc};
214214

215215
sf.template visit_mask<detail::mask_index_update>(sf_desc);
216216
sf_desc.set_volume(m_volume.index());

core/include/detray/geometry/detail/shape_utils.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace detray::detail {
1717
/// @return the opening angle of a chord the size of tol (= 2*arcsin(c/(2r)))
1818
/// using a small angle approximation
1919
template <typename scalar_t>
20-
inline constexpr scalar_t phi_tolerance(scalar_t tol, scalar_t radius) {
20+
constexpr scalar_t phi_tolerance(scalar_t tol, scalar_t radius) {
2121
return tol / radius;
2222
}
2323

core/include/detray/geometry/detail/surface_kernels.hpp

+1-138
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
#pragma once
99

1010
// Project include(s)
11+
#include "detray/definitions/detail/algebra.hpp"
1112
#include "detray/definitions/detail/indexing.hpp"
1213
#include "detray/definitions/detail/qualifiers.hpp"
1314
#include "detray/materials/detail/concepts.hpp"
1415
#include "detray/materials/detail/material_accessor.hpp"
1516
#include "detray/materials/material.hpp"
16-
#include "detray/propagator/detail/jacobian_engine.hpp"
17-
#include "detray/tracks/detail/transform_track_parameters.hpp"
18-
#include "detray/tracks/tracks.hpp"
1917

2018
// System include(s)
2119
#include <limits>
@@ -33,9 +31,6 @@ struct surface_kernels {
3331
using point3_type = dpoint3D<algebra_t>;
3432
using vector3_type = dvector3D<algebra_t>;
3533
using transform3_type = dtransform3D<algebra_t>;
36-
using bound_param_vector_type = bound_parameters_vector<algebra_t>;
37-
using free_param_vector_type = free_parameters_vector<algebra_t>;
38-
using free_matrix_type = free_matrix<algebra_t>;
3934

4035
/// A functor to retrieve the masks shape name
4136
struct get_shape_name {
@@ -158,21 +153,6 @@ struct surface_kernels {
158153
}
159154
};
160155

161-
/// A functor to perform global to local bound transformation
162-
struct global_to_bound {
163-
template <typename mask_group_t, typename index_t>
164-
DETRAY_HOST_DEVICE inline point2_type operator()(
165-
const mask_group_t& /*mask_group*/, const index_t& /*index*/,
166-
const transform3_type& trf3, const point3_type& global,
167-
const vector3_type& dir) const {
168-
using mask_t = typename mask_group_t::value_type;
169-
170-
const point3_type local = mask_t::to_local_frame(trf3, global, dir);
171-
172-
return {local[0], local[1]};
173-
}
174-
};
175-
176156
/// A functor to perform global to local transformation
177157
struct global_to_local {
178158
template <typename mask_group_t, typename index_t>
@@ -210,123 +190,6 @@ struct surface_kernels {
210190
return mask_t::to_global_frame(trf3, local);
211191
}
212192
};
213-
214-
/// A functor to get from a free to a bound vector
215-
struct free_to_bound_vector {
216-
217-
// Visitor to the detector mask store that is called on the mask
218-
// collection that contains the mask (shape) type of the surface
219-
template <typename mask_group_t, typename index_t>
220-
DETRAY_HOST_DEVICE inline bound_param_vector_type operator()(
221-
const mask_group_t& /*mask_group*/, const index_t& /*index*/,
222-
const transform3_type& trf3,
223-
const free_param_vector_type& free_vec) const {
224-
225-
using frame_t = typename mask_group_t::value_type::local_frame;
226-
227-
return detail::free_to_bound_vector<frame_t>(trf3, free_vec);
228-
}
229-
};
230-
231-
/// A functor to get from a bound to a free vector
232-
struct bound_to_free_vector {
233-
234-
template <typename mask_group_t, typename index_t>
235-
DETRAY_HOST_DEVICE inline free_param_vector_type operator()(
236-
const mask_group_t& mask_group, const index_t& index,
237-
const transform3_type& trf3,
238-
const bound_param_vector_type& bound_vec) const {
239-
240-
return detail::bound_to_free_vector(trf3, mask_group[index],
241-
bound_vec);
242-
}
243-
};
244-
245-
/// A functor to get the free-to-bound Jacobian
246-
struct free_to_bound_jacobian {
247-
248-
template <typename mask_group_t, typename index_t>
249-
DETRAY_HOST_DEVICE inline auto operator()(
250-
const mask_group_t& /*mask_group*/, const index_t& /*index*/,
251-
const transform3_type& trf3,
252-
const free_param_vector_type& free_vec) const {
253-
254-
using frame_t = typename mask_group_t::value_type::local_frame;
255-
256-
return detail::jacobian_engine<frame_t>::free_to_bound_jacobian(
257-
trf3, free_vec);
258-
}
259-
};
260-
261-
/// A functor to get the bound-to-free Jacobian
262-
struct bound_to_free_jacobian {
263-
264-
template <typename mask_group_t, typename index_t>
265-
DETRAY_HOST_DEVICE inline auto operator()(
266-
const mask_group_t& mask_group, const index_t& index,
267-
const transform3_type& trf3,
268-
const bound_param_vector_type& bound_vec) const {
269-
270-
using frame_t = typename mask_group_t::value_type::local_frame;
271-
272-
return detail::jacobian_engine<frame_t>::bound_to_free_jacobian(
273-
trf3, mask_group[index], bound_vec);
274-
}
275-
};
276-
277-
/// A functor to get the path correction
278-
struct path_correction {
279-
280-
template <typename mask_group_t, typename index_t, typename scalar_t>
281-
DETRAY_HOST_DEVICE inline free_matrix_type operator()(
282-
const mask_group_t& /*mask_group*/, const index_t& /*index*/,
283-
const transform3_type& trf3, const vector3_type& pos,
284-
const vector3_type& dir, const vector3_type& dtds,
285-
const scalar_t dqopds) const {
286-
287-
using frame_t = typename mask_group_t::value_type::local_frame;
288-
289-
return detail::jacobian_engine<frame_t>::path_correction(
290-
pos, dir, dtds, dqopds, trf3);
291-
}
292-
};
293-
294-
/// A functor to get the local min bounds.
295-
struct local_min_bounds {
296-
297-
template <typename mask_group_t, typename index_t, typename scalar_t>
298-
DETRAY_HOST_DEVICE inline auto operator()(
299-
const mask_group_t& mask_group, const index_t& index,
300-
const scalar_t env =
301-
std::numeric_limits<scalar_t>::epsilon()) const {
302-
303-
return mask_group[index].local_min_bounds(env);
304-
}
305-
};
306-
307-
/// A functor to get the minimum distance to any surface boundary.
308-
struct min_dist_to_boundary {
309-
310-
template <typename mask_group_t, typename index_t, typename point_t>
311-
DETRAY_HOST_DEVICE inline auto operator()(
312-
const mask_group_t& mask_group, const index_t& index,
313-
const point_t& loc_p) const {
314-
315-
return mask_group[index].min_dist_to_boundary(loc_p);
316-
}
317-
};
318-
319-
/// A functor to get the vertices in local coordinates.
320-
struct local_vertices {
321-
322-
template <typename mask_group_t, typename index_t, typename scalar_t>
323-
DETRAY_HOST_DEVICE inline auto operator()(
324-
const mask_group_t& mask_group, const index_t& index,
325-
const dindex n_seg) const {
326-
327-
return mask_group[index].vertices(n_seg);
328-
}
329-
};
330193
};
331194

332195
} // namespace detray::detail

core/include/detray/geometry/detail/vertexing.hpp core/include/detray/geometry/detail/vertexer.hpp

+31-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** Detray library, part of the ACTS project (R&D line)
22
*
3-
* (c) 2021-2023 CERN for the benefit of the ACTS project
3+
* (c) 2021-2024 CERN for the benefit of the ACTS project
44
*
55
* Mozilla Public License Version 2.0
66
*/
@@ -10,10 +10,40 @@
1010
// Project include(s)
1111
#include "detray/definitions/detail/containers.hpp"
1212
#include "detray/definitions/detail/math.hpp"
13+
#include "detray/geometry/surface.hpp"
1314
#include "detray/utils/ranges.hpp"
1415

1516
namespace detray::detail {
1617

18+
template <typename point2_t, typename point3_t>
19+
struct vertexer;
20+
21+
/// Compute vertices in global frame along the boundary of a surface
22+
///
23+
/// @param ctx geometry context
24+
/// @param sf the surface
25+
/// @param n_seg the number of segments used along arcs
26+
///
27+
/// @returns a vector of vetices (3D points)
28+
template <typename detector_t>
29+
DETRAY_HOST constexpr auto get_global_vertices(
30+
const typename detector_t::geometry_context &ctx,
31+
geometry::surface<detector_t> sf, const dindex n_seg) {
32+
using algebra_t = typename detector_t::algebra_type;
33+
using point2_t = dpoint2D<algebra_t>;
34+
using point3_t = dpoint3D<algebra_t>;
35+
36+
auto vertices = sf.template visit_mask<vertexer<point2_t, point3_t>>(n_seg);
37+
const auto &trf = sf.transform(ctx);
38+
39+
const std::size_t n_vertices{vertices.size()};
40+
for (std::size_t i = 0u; i < n_vertices; ++i) {
41+
vertices[i] = trf.point_to_global(vertices[i]);
42+
}
43+
44+
return vertices;
45+
}
46+
1747
/// Generate phi values along an arc
1848
///
1949
/// @param start_phi is the start for the arc generation

core/include/detray/geometry/shapes/annulus2D.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "detray/definitions/units.hpp"
1717
#include "detray/geometry/coordinates/polar2D.hpp"
1818
#include "detray/geometry/detail/shape_utils.hpp"
19-
#include "detray/geometry/detail/vertexing.hpp"
19+
#include "detray/geometry/detail/vertexer.hpp"
2020

2121
// System include(s)
2222
#include <limits>

0 commit comments

Comments
 (0)