Skip to content

Commit 9a9b471

Browse files
committed
Fix compilation
1 parent f49a2f7 commit 9a9b471

Some content is hidden

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

45 files changed

+1225
-725
lines changed

core/include/detray/builders/bin_fillers.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
// Project include(s).
1111
#include "detray/builders/detail/bin_association.hpp"
12-
#include "detray/navigation/accelerators/concepts.hpp"
1312
#include "detray/utils/grid/detail/axis.hpp"
1413
#include "detray/utils/grid/detail/concepts.hpp"
1514
#include "detray/utils/grid/populators.hpp"

core/include/detray/builders/detector_builder.hpp

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
/** Detray library, part of the ACTS project (R&D line)
22
*
3-
* (c) 2023 CERN for the benefit of the ACTS project
3+
* (c) 2023-2025 CERN for the benefit of the ACTS project
44
*
55
* Mozilla Public License Version 2.0
66
*/
77

88
#pragma once
99

1010
// Project include(s).
11-
#include "detray/builders/grid_factory.hpp"
1211
#include "detray/builders/volume_builder.hpp"
1312
#include "detray/builders/volume_builder_interface.hpp"
1413
#include "detray/core/detector.hpp"
15-
#include "detray/definitions/geometry.hpp"
16-
#include "detray/utils/grid/detail/concepts.hpp"
17-
#include "detray/utils/type_traits.hpp"
1814

1915
// Vecmem include(s)
2016
#include <detray/utils/log.hpp>
@@ -31,7 +27,6 @@ namespace detray {
3127
/// @brief Provides functionality to build a detray detector volume by volume
3228
///
3329
/// @tparam metadata the type definitions for the detector
34-
/// @tparam bfield_bknd_t the type of magnetic field to be used
3530
/// @tparam volume_builder_t the basic volume builder to be used for the
3631
/// geometry data
3732
/// @tparam volume_data_t the data structure that holds the volume builders
@@ -151,49 +146,12 @@ class detector_builder {
151146
return build(resource);
152147
}
153148

154-
/// Put the volumes into a search data structure
155-
/*template <typename... Args>
156-
DETRAY_HOST void set_volume_accelerator([[maybe_unused]] Args&&... args) {
157-
DETRAY_DEBUG("Setting volume finder for detector " << name());
158-
159-
using vol_finder_t = typename detector_type::volume_accelerator;
160-
161-
// Add dummy volume grid for now
162-
if constexpr (concepts::grid<vol_finder_t>) {
163-
164-
// TODO: Construct it correctly with the grid builder
165-
mask<cylinder3D, algebra_type> vgrid_dims{
166-
0u, 0.f, -constant<scalar_type>::pi,
167-
-2000.f, 180.f, constant<scalar_type>::pi,
168-
2000.f};
169-
darray<std::size_t, 3> n_vgrid_bins{1u, 1u, 1u};
170-
171-
darray<std::vector<scalar_type>, 3UL> bin_edges{
172-
std::vector<scalar_type>{0.f, 180.f},
173-
std::vector<scalar_type>{-constant<scalar_type>::pi,
174-
constant<scalar_type>::pi},
175-
std::vector<scalar_type>{-2000.f, 2000.f}};
176-
177-
grid_factory_type<vol_finder_t> vgrid_factory{};
178-
m_vol_finder = vgrid_factory.template new_grid<
179-
axis::open<axis::label::e_r>,
180-
axis::circular<axis::label::e_phi>,
181-
axis::open<axis::label::e_z>, axis::irregular<scalar_type>,
182-
axis::regular<scalar_type>, axis::irregular<scalar_type>>(
183-
vgrid_dims, n_vgrid_bins, {}, bin_edges);
184-
} else {
185-
m_vol_finder = vol_finder_t{args...};
186-
}
187-
}*/
188-
189149
private:
190150
/// Name of the new detector
191151
std::string m_detector_name{"detray_detector"};
192152
/// Data structure that holds a volume builder for every detector volume
193153
volume_data_t<std::unique_ptr<volume_builder_interface<detector_type>>>
194154
m_volumes{};
195-
/// Data structure to find volumes
196-
// typename detector_type::volume_accelerator m_vol_finder{};
197155
};
198156

199157
} // namespace detray

core/include/detray/builders/grid_builder.hpp

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include "detray/builders/volume_builder.hpp"
1515
#include "detray/builders/volume_builder_interface.hpp"
1616
#include "detray/geometry/tracking_volume.hpp"
17+
#include "detray/navigation/accelerators/concepts.hpp"
18+
#include "detray/navigation/accelerators/spatial_grid.hpp"
1719
#include "detray/utils/grid/detail/concepts.hpp"
1820
#include "detray/utils/log.hpp"
1921

@@ -41,7 +43,7 @@ class grid_builder : public volume_decorator<detector_t> {
4143
using value_type = typename detector_type::surface_type;
4244
using scalar_type = dscalar<algebra_type>;
4345

44-
/// Decorate a volume with a grid
46+
/// Decorate a volume with a surface accelerator grid
4547
DETRAY_HOST
4648
explicit grid_builder(
4749
std::unique_ptr<volume_builder_interface<detector_t>> vol_builder)
@@ -60,13 +62,13 @@ class grid_builder : public volume_decorator<detector_t> {
6062
}
6163

6264
/// Set the surface category this grid should contain (type id in the
63-
/// accelrator link in the volume)
65+
/// accelerator link in the volume descriptor)
6466
void set_type(std::size_t sf_id) {
6567
set_type(static_cast<link_id_t>(sf_id));
6668
}
6769

6870
/// Set the surface category this grid should contain (type id in the
69-
/// accelrator link in the volume)
71+
/// accelerator link in the volume descriptor)
7072
void set_type(link_id_t sf_id) {
7173
// Exclude zero, it is reserved for the brute force method
7274
assert(static_cast<int>(sf_id) > 0);
@@ -192,13 +194,23 @@ class grid_builder : public volume_decorator<detector_t> {
192194
}
193195
}
194196

195-
// Add the grid to the detector and link it to its volume
196-
constexpr auto gid{detector_t::accel::template get_id<grid_t>()};
197-
DETRAY_DEBUG("Adding grid to volume in detector. m_id="
198-
<< m_id << ", gid=" << gid);
197+
// Is the given grid type already an acceleration structure?
198+
using spatial_grid_t =
199+
std::conditional_t<concepts::surface_accelerator<grid_t>, grid_t,
200+
spatial_grid_impl<grid_t>>;
201+
constexpr auto gid{
202+
detector_t::accel::template get_id<spatial_grid_t>()};
203+
const dindex grid_idx{det.accelerator_store().template size<gid>()};
204+
205+
DETRAY_DEBUG("Adding grid to volume in detector. Surface type: "
206+
<< m_id << ", grid: " << gid
207+
<< ", grid idx: " << grid_idx);
208+
209+
// Set: contained surface type, grid type, grid instance index
210+
vol_ptr->set_accel_link(m_id, gid, grid_idx);
211+
212+
// Add to detector
199213
det._accelerators.template push_back<gid>(m_grid);
200-
vol_ptr->set_link(m_id, gid,
201-
det.accelerator_store().template size<gid>() - 1);
202214

203215
DETRAY_DEBUG("Accelerator link: " << vol_ptr->accel_link());
204216

@@ -212,6 +224,7 @@ class grid_builder : public volume_decorator<detector_t> {
212224
private:
213225
link_id_t m_id{link_id_t::e_sensitive};
214226
grid_factory_t m_factory{};
227+
// Data owning grid type, so that surface data can be filled into memory
215228
typename grid_t::template type<true> m_grid{};
216229
bin_filler_t m_bin_filler{};
217230
bool m_add_passives{false};

core/include/detray/builders/surface_factory.hpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,12 @@ class surface_factory : public surface_factory_interface<detector_t> {
162162
return {surfaces_offset, surfaces_offset};
163163
}
164164

165-
constexpr auto mask_id = detector_t::masks::template get_id<
166-
mask<mask_shape_t, algebra_t, volume_link_t>>();
167-
if constexpr (static_cast<std::size_t>(mask_id) >=
168-
detector_t::masks::n_types) {
165+
using mask_t = mask<mask_shape_t, algebra_t, volume_link_t>;
166+
if constexpr (!detector_t::masks::template is_defined<mask_t>()) {
169167

170168
throw std::invalid_argument(
171-
"ERROR: Cannot match shape type to mask ID: Found " +
172-
std::string(mask_shape_t::name) + " at mask id " +
173-
std::to_string(static_cast<std::size_t>(mask_id)));
169+
"ERROR: Cannot match shape type to mask ID. Shape type: " +
170+
std::string(mask_shape_t::name));
174171

175172
} else {
176173

@@ -180,6 +177,8 @@ class surface_factory : public surface_factory_interface<detector_t> {
180177

181178
// The material will be added in a later step
182179
constexpr auto no_material{surface_t::material_id::e_none};
180+
constexpr auto mask_id =
181+
detector_t::masks::template get_id<mask_t>();
183182

184183
for (const auto [idx, bounds_per_mask] :
185184
detray::views::enumerate(m_bounds)) {

core/include/detray/core/detail/alignment.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ typename host_detector_type::view_type misaligned_detector_view(
2525
detray::get_data(
2626
detray::detail::get<4>(det_buffer.m_buffer)), // materials
2727
detray::get_data(
28-
detray::detail::get<5>(det_buffer.m_buffer)), // accelerators
29-
detray::get_data(detray::detail::get<6>(
30-
det_buffer.m_buffer))}; // volume search grid
28+
detray::detail::get<5>(det_buffer.m_buffer))}; // accelerators
3129
return detview;
3230
}
3331

core/include/detray/core/detail/multi_store.hpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "detray/core/detail/tuple_container.hpp"
1515
#include "detray/definitions/detail/qualifiers.hpp"
1616
#include "detray/definitions/indexing.hpp"
17-
#include "detray/utils/type_list.hpp"
1817
#include "detray/utils/type_registry.hpp"
1918
#include "detray/utils/type_traits.hpp"
2019

@@ -29,13 +28,11 @@ namespace detray {
2928
/// @brief Wraps a vecmem enabled tuple and adds functionality to handle data
3029
/// collections @tparam Ts.
3130
///
32-
/// @tparam An enum of type IDs that needs to match the value types of the
33-
/// @tparam Ts pack.
31+
/// @tparam An enum of type IDs that needs to match the value types of the Ts
32+
/// pack.
3433
/// @tparam context_t How to retrieve data according to e.g. conditions data
3534
/// @tparam tuple_t The type of the underlying tuple container.
36-
/// @tparam container_t The type of container to use for the respective
37-
/// data collections.
38-
/// @tparam Ts the data types (value types of the collections)
35+
/// @tparam Ts the data collection types
3936
template <typename ID = std::size_t, typename context_t = empty_context,
4037
template <typename...> class tuple_t = dtuple, typename... Ts>
4138
class multi_store {
@@ -53,10 +50,8 @@ class multi_store {
5350
/// How to find and index a data collection in the store
5451
/// @{
5552
using ids = ID;
56-
template <typename index_t>
57-
using link_type = dtyped_index<ID, index_t>;
58-
using single_link = link_type<dindex>;
59-
using range_link = link_type<index_range_t>;
53+
using single_link = dtyped_index<ID, dindex>;
54+
using range_link = dtyped_index<ID, index_range_t>;
6055
/// @}
6156

6257
/// Allow matching between IDs and collection value types
@@ -387,7 +382,7 @@ class multi_store {
387382
tuple_type m_tuple_container;
388383
};
389384

390-
/// Helper type for a data store that uses a sinlge collection container
385+
/// Helper type for a data store that uses a single collection container
391386
template <typename ID, typename context_t, template <typename...> class tuple_t,
392387
template <typename...> class container_t, typename... Ts>
393388
using regular_multi_store =

core/include/detray/core/detail/single_store.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class single_store {
4343

4444
/// How to find data in the store
4545
/// @{
46-
using link_type = dindex;
4746
using single_link = dindex;
4847
using range_link = dindex_range;
4948
/// @}

core/include/detray/core/detector.hpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,16 @@ class detector {
221221
/// @return the volume by global cartesian @param position - const access
222222
DETRAY_HOST_DEVICE
223223
inline const auto &volume(const point3_type &p) const {
224-
volume_type v_desc{};
225224
// Allow to call the volume search data structure
225+
// TODO: Add volume accelerator builder
226+
volume_type v_desc{};
226227
v_desc.template set_accel_link<geo_obj_ids::e_volume>(
227-
accel::id::e_volume_brute_force, 0u);
228-
tracking_volume world{v_desc, *this};
228+
accel::id::e_default_volume_searcher, 0u);
229+
tracking_volume world{*this, v_desc};
229230

230-
const dindex volume_index =
231-
world.template visit_accelerator<geo_obj_ids::e_volume,
232-
volume_search>(p);
231+
dindex volume_index{0u};
232+
world.template visit_accelerator<geo_obj_ids::e_volume, volume_search>(
233+
p, &volume_index);
233234
return _volumes[volume_index];
234235
}
235236

@@ -309,19 +310,20 @@ class detector {
309310
///@TODO: Move this to a volume search grid type
310311
template <concepts::accelerator_collection accel_coll_t,
311312
typename accel_index_t>
312-
DETRAY_HOST_DEVICE inline dindex operator()(
313-
const accel_coll_t &coll, const accel_index_t index,
314-
const point3_type &p) const {
313+
DETRAY_HOST_DEVICE inline void operator()(const accel_coll_t &coll,
314+
const accel_index_t index,
315+
const point3_type &p,
316+
dindex *const result) const {
317+
318+
using accel_type = typename accel_coll_t::value_type;
315319

316-
const auto volume_accelerator = coll[index];
320+
if constexpr (concepts::volume_accelerator<accel_type>) {
317321

318-
// The 3D cylindrical volume search grid is concentric
319-
const transform3_type identity{};
320-
const auto loc_pos =
321-
volume_accelerator.project(identity, p, identity.translation());
322+
const auto volume_accelerator = coll[index];
322323

323-
// Only one entry per bin
324-
return volume_accelerator.search(loc_pos).value();
324+
// Only one entry per bin
325+
*result = volume_accelerator.search(p).value();
326+
}
325327
}
326328
};
327329

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

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "detray/materials/detail/concepts.hpp"
1515
#include "detray/materials/detail/material_accessor.hpp"
1616
#include "detray/materials/material.hpp"
17+
#include "detray/navigation/accelerators/search_window.hpp"
1718
#include "detray/navigation/concepts.hpp"
1819

1920
namespace detray::detail {
@@ -96,31 +97,33 @@ struct neighborhood_getter {
9697
/// to a surface finder data structure
9798
template <concepts::accelerator_collection accel_coll_t,
9899
typename accel_index_t, typename detector_t, typename track_t,
99-
typename config_t, typename... Args>
100+
concepts::arithmetic window_size_t, typename... Args>
100101
DETRAY_HOST_DEVICE inline void operator()(
101102
const accel_coll_t &coll, const accel_index_t index,
102103
const detector_t &det, const typename detector_t::volume_type &volume,
103-
const track_t &track, const config_t &cfg,
104+
const track_t &track, const search_window<window_size_t, 2> &win_size,
104105
const typename detector_t::geometry_context &ctx,
105106
Args &&...args) const {
106107

108+
using accel_type = typename accel_coll_t::value_type;
109+
107110
decltype(auto) accel = coll[index];
108111

109-
// Run over the surfaces in a single acceleration data structure
110-
for (const auto &sf : accel.search(det, volume, track, cfg, ctx)) {
111-
functor_t{}(sf, std::forward<Args>(args)...);
112+
if constexpr (concepts::surface_accelerator<accel_type>) {
113+
// Run over the surfaces in a single acceleration data structure
114+
for (const auto &sf :
115+
accel.search(det, volume, track, win_size, ctx)) {
116+
functor_t{}(sf, std::forward<Args>(args)...);
117+
}
118+
} else if constexpr (concepts::volume_accelerator<accel_type>) {
119+
// Run over the daughter volumes in a single acceleration data
120+
// structure
121+
for (const dindex daughter_idx :
122+
accel.search(det, volume, track, win_size, ctx)) {
123+
functor_t{}(daughter_idx, std::forward<Args>(args)...);
124+
}
112125
}
113126
}
114127
};
115128

116-
/// Query the maximal number of candidates from the acceleration
117-
struct n_candidates_getter {
118-
template <concepts::accelerator_collection accel_coll_t,
119-
typename accel_index_t>
120-
DETRAY_HOST_DEVICE inline auto operator()(const accel_coll_t &coll,
121-
const accel_index_t index) const {
122-
return coll[index].n_max_candidates();
123-
}
124-
};
125-
126129
} // namespace detray::detail

0 commit comments

Comments
 (0)