Skip to content

Commit 6c136ae

Browse files
committed
Split the surface implementation
1 parent 5153de2 commit 6c136ae

Some content is hidden

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

41 files changed

+715
-640
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "detray/geometry/coordinates/concentric_cylindrical2D.hpp"
1616
#include "detray/geometry/coordinates/cylindrical2D.hpp"
1717
#include "detray/geometry/coordinates/polar2D.hpp"
18-
#include "detray/geometry/detail/vertexing.hpp"
18+
#include "detray/geometry/detail/vertexer.hpp"
1919
#include "detray/navigation/accelerators/concepts.hpp"
2020
#include "detray/utils/grid/populators.hpp"
2121
#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)
@@ -124,7 +124,7 @@ class material_map_builder final : public volume_decorator<detector_t> {
124124
}
125125

126126
// Construct and append the material map for a given surface shape
127-
auto sf = tracking_surface{det, sf_desc};
127+
auto sf = geometry::surface{det, sf_desc};
128128
[[maybe_unused]] auto [mat_id, mat_idx] = sf.template visit_mask<
129129
detail::add_sf_material_map<materials_t>>(
130130
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/concepts.hpp"
1616
#include "detray/utils/grid/detail/concepts.hpp"
1717

@@ -211,7 +211,7 @@ class volume_builder : public volume_builder_interface<detector_t> {
211211
std::size_t n_portals{0u};
212212
for (auto& sf_desc : m_surfaces) {
213213

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

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

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

-142
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
#include "detray/materials/detail/concepts.hpp"
1515
#include "detray/materials/detail/material_accessor.hpp"
1616
#include "detray/materials/material.hpp"
17-
#include "detray/propagator/detail/jacobian_engine.hpp"
18-
#include "detray/tracks/detail/transform_track_parameters.hpp"
19-
#include "detray/tracks/tracks.hpp"
2017

2118
// System include(s)
2219
#include <limits>
@@ -34,9 +31,6 @@ struct surface_kernels {
3431
using point3_type = dpoint3D<algebra_t>;
3532
using vector3_type = dvector3D<algebra_t>;
3633
using transform3_type = dtransform3D<algebra_t>;
37-
using bound_param_vector_type = bound_parameters_vector<algebra_t>;
38-
using free_param_vector_type = free_parameters_vector<algebra_t>;
39-
using free_matrix_type = free_matrix<algebra_t>;
4034

4135
/// A functor to retrieve the masks shape name
4236
struct get_shape_name {
@@ -159,21 +153,6 @@ struct surface_kernels {
159153
}
160154
};
161155

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

337195
} // namespace detray::detail
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/** Detray library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 2023-2024 CERN for the benefit of the ACTS project
4+
*
5+
* Mozilla Public License Version 2.0
6+
*/
7+
8+
#pragma once
9+
10+
// Project include(s)
11+
#include "detray/definitions/detail/qualifiers.hpp"
12+
#include "detray/geometry/detail/surface_kernels.hpp"
13+
#include "detray/propagator/detail/jacobian_engine.hpp"
14+
#include "detray/tracks/detail/transform_track_parameters.hpp"
15+
#include "detray/tracks/tracks.hpp"
16+
17+
// System include(s)
18+
#include <ostream>
19+
20+
namespace detray::detail {
21+
22+
/// Functors to be used in the @c tracking_surface class
23+
template <typename algebra_t>
24+
struct tracking_surface_kernels : public surface_kernels<algebra_t> {
25+
26+
using vector3_type = dvector3D<algebra_t>;
27+
using transform3_type = dtransform3D<algebra_t>;
28+
using bound_param_vector_type = bound_parameters_vector<algebra_t>;
29+
using free_param_vector_type = free_parameters_vector<algebra_t>;
30+
using free_matrix_type = free_matrix<algebra_t>;
31+
32+
/// A functor to get from a free to a bound vector
33+
struct free_to_bound_vector {
34+
35+
// Visitor to the detector mask store that is called on the mask
36+
// collection that contains the mask (shape) type of the surface
37+
template <typename mask_group_t, typename index_t>
38+
DETRAY_HOST_DEVICE inline bound_param_vector_type operator()(
39+
const mask_group_t& /*mask_group*/, const index_t& /*index*/,
40+
const transform3_type& trf3,
41+
const free_param_vector_type& free_vec) const {
42+
43+
using frame_t = typename mask_group_t::value_type::local_frame;
44+
45+
return detail::free_to_bound_vector<frame_t>(trf3, free_vec);
46+
}
47+
};
48+
49+
/// A functor to get from a bound to a free vector
50+
struct bound_to_free_vector {
51+
52+
template <typename mask_group_t, typename index_t>
53+
DETRAY_HOST_DEVICE inline free_param_vector_type operator()(
54+
const mask_group_t& mask_group, const index_t& index,
55+
const transform3_type& trf3,
56+
const bound_param_vector_type& bound_vec) const {
57+
58+
return detail::bound_to_free_vector(trf3, mask_group[index],
59+
bound_vec);
60+
}
61+
};
62+
63+
/// A functor to get the free-to-bound Jacobian
64+
struct free_to_bound_jacobian {
65+
66+
template <typename mask_group_t, typename index_t>
67+
DETRAY_HOST_DEVICE inline auto operator()(
68+
const mask_group_t& /*mask_group*/, const index_t& /*index*/,
69+
const transform3_type& trf3,
70+
const free_param_vector_type& free_vec) const {
71+
72+
using frame_t = typename mask_group_t::value_type::local_frame;
73+
74+
return detail::jacobian_engine<frame_t>::free_to_bound_jacobian(
75+
trf3, free_vec);
76+
}
77+
};
78+
79+
/// A functor to get the bound-to-free Jacobian
80+
struct bound_to_free_jacobian {
81+
82+
template <typename mask_group_t, typename index_t>
83+
DETRAY_HOST_DEVICE inline auto operator()(
84+
const mask_group_t& mask_group, const index_t& index,
85+
const transform3_type& trf3,
86+
const bound_param_vector_type& bound_vec) const {
87+
88+
using frame_t = typename mask_group_t::value_type::local_frame;
89+
90+
return detail::jacobian_engine<frame_t>::bound_to_free_jacobian(
91+
trf3, mask_group[index], bound_vec);
92+
}
93+
};
94+
95+
/// A functor to get the path correction
96+
struct path_correction {
97+
98+
template <typename mask_group_t, typename index_t,
99+
concepts::scalar scalar_t>
100+
DETRAY_HOST_DEVICE inline free_matrix_type operator()(
101+
const mask_group_t& /*mask_group*/, const index_t& /*index*/,
102+
const transform3_type& trf3, const vector3_type& pos,
103+
const vector3_type& dir, const vector3_type& dtds,
104+
const scalar_t dqopds) const {
105+
106+
using frame_t = typename mask_group_t::value_type::local_frame;
107+
108+
return detail::jacobian_engine<frame_t>::path_correction(
109+
pos, dir, dtds, dqopds, trf3);
110+
}
111+
};
112+
};
113+
114+
} // namespace detray::detail

0 commit comments

Comments
 (0)