Skip to content

Commit 51058a6

Browse files
committed
Split the surface implementation
1 parent b963369 commit 51058a6

Some content is hidden

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

43 files changed

+743
-644
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/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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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, typename scalar_t>
99+
DETRAY_HOST_DEVICE inline free_matrix_type operator()(
100+
const mask_group_t& /*mask_group*/, const index_t& /*index*/,
101+
const transform3_type& trf3, const vector3_type& pos,
102+
const vector3_type& dir, const vector3_type& dtds,
103+
const scalar_t dqopds) const {
104+
105+
using frame_t = typename mask_group_t::value_type::local_frame;
106+
107+
return detail::jacobian_engine<frame_t>::path_correction(
108+
pos, dir, dtds, dqopds, trf3);
109+
}
110+
};
111+
};
112+
113+
} // namespace detray::detail

0 commit comments

Comments
 (0)