12#include "detray/builders/grid_builder.hpp"
13#include "detray/builders/homogeneous_material_builder.hpp"
14#include "detray/builders/homogeneous_volume_material_builder.hpp"
15#include "detray/builders/material_map_builder.hpp"
16#include "detray/builders/volume_builder.hpp"
17#include "detray/core/concepts.hpp"
18#include "detray/core/detail/container_buffers.hpp"
19#include "detray/core/detail/container_views.hpp"
20#include "detray/core/detail/surface_lookup.hpp"
21#include "detray/core/name_map.hpp"
22#include "detray/definitions/algebra.hpp"
23#include "detray/definitions/containers.hpp"
24#include "detray/definitions/detail/qualifiers.hpp"
25#include "detray/geometry/volume_descriptor.hpp"
26#include "detray/utils/concepts.hpp"
27#include "detray/utils/print_detector.hpp"
30#include <vecmem/memory/memory_resource.hpp>
42template <
typename detector_t, concepts::transform3D transform3_t>
43void set_transform(detector_t &det,
const transform3_t &trf,
unsigned int i) {
45 "Modifying transforms in the detector will be deprecated! "
46 "Please, use a separate geometry context in this case");
47 det._transforms.at(i) = trf;
58template <concepts::metadata metadata_t,
typename container_t>
62 template <concepts::detector, concepts::gr
id,
typename,
typename>
65 detector<metadata_t, container_t>>;
67 detector<metadata_t, container_t>>;
68 template <concepts::detector, std::
size_t,
typename>
73 detector<metadata_t, container_t> &,
78 using vector_type =
typename container_t::template vector_type<T>;
125 using masks =
typename mask_container::value_types;
132 using material =
typename material_container::value_types;
140 using accel =
typename accelerator_container::value_types;
148 using accel_link =
typename accelerator_container::single_link;
157 dmulti_view<dvector_view<const volume_type>,
158 typename surface_lookup_container::const_view_type,
159 typename transform_container::const_view_type,
160 typename mask_container::const_view_type,
161 typename material_container::const_view_type,
162 typename accelerator_container::const_view_type>;
168 static_assert(concepts::device_view<view_type>,
169 "Detector view type ill-formed");
170 static_assert(concepts::device_view<const_view_type>,
171 "Detector const view type ill-formed");
176 dmulti_buffer<dvector_buffer<volume_type>,
177 typename surface_lookup_container::buffer_type,
178 typename transform_container::buffer_type,
179 typename mask_container::buffer_type,
180 typename material_container::buffer_type,
181 typename accelerator_container::buffer_type>;
183 static_assert(concepts::device_buffer<buffer_type>,
184 "Detector buffer type ill-formed");
188 detector(
const detector &) =
delete;
189 detector &operator=(
const detector &) =
delete;
199 detector &operator=(detector &&other) noexcept = default;
204 explicit detector(vecmem::memory_resource &resource)
205 : _volumes(&resource),
207 _transforms(resource),
209 _materials(resource),
210 _accelerators(resource) {}
215 template <concepts::device_view detector_view_t>
217 : _volumes(
detray::detail::get<0>(det_data.m_view)),
218 _surfaces(
detray::detail::get<1>(det_data.m_view)),
219 _transforms(
detray::detail::get<2>(det_data.m_view)),
220 _masks(
detray::detail::get<3>(det_data.m_view)),
221 _materials(
detray::detail::get<4>(det_data.m_view)),
222 _accelerators(
detray::detail::get<5>(det_data.m_view)) {}
243 return _volumes[volume_index];
251 inline const auto &
volume(
const std::string_view volume_name,
253 return _volumes.at(names.
at(volume_name));
264 v_desc.template set_accel_link<geo_obj_ids::e_volume>(
265 accel::id::e_volume_default, 0u);
269 world.template visit_accelerator<geo_obj_ids::e_volume, volume_search>(
271 return _volumes[volume_index];
281 return _accelerators.template get<accel::id::e_surface_brute_force>().all();
294 template <
typename query_t>
295 DETRAY_HOST_DEVICE
constexpr decltype(
auto)
surface(query_t &&q)
const {
296 return _surfaces.search(std::forward<query_t>(q));
319 return _accelerators;
325 detray::get_data(std::as_const(_surfaces)),
326 detray::get_data(std::as_const(_transforms)),
327 detray::get_data(std::as_const(_masks)),
328 detray::get_data(std::as_const(_materials)),
329 detray::get_data(std::as_const(_accelerators))};
335 detray::get_data(_volumes), detray::get_data(_surfaces),
336 detray::get_data(_transforms), detray::get_data(_masks),
337 detray::get_data(_materials), detray::get_data(_accelerators)};
344 friend std::ostream &
operator<<(std::ostream &os,
const detector &d) {
345 os << utils::print_detector(d) << std::endl;
350 struct volume_search {
353 typename accel_index_t>
354 DETRAY_HOST_DEVICE
inline void operator()(
const accel_coll_t &coll,
355 const accel_index_t index,
357 dindex *
const result)
const {
358 using accel_type =
typename accel_coll_t::value_type;
361 const auto volume_accelerator = coll[index];
364 *result = volume_accelerator.search(p).value();
392template <concepts::metadata metadata_t>
393using detector = detray::detail::detector<metadata_t, host_container_types>;
399template <concepts::metadata metadata_t>
401 detray::detail::detector<metadata_t, const_device_container_types>;
409template <concepts::metadata metadata_t>
417 using host = detray::host::detector<metadata_type>;
421 using device = detray::device::detector<metadata_type>;
433template <concepts::metadata metadata_t,
typename container_t>
auto material_store() const -> const material_container &
Definition detector.hpp:312
friend void set_transform(detector< metadata_t, host_container_types > &, const dtransform3D< typename metadata_t::algebra_type > &, unsigned int)
constexpr decltype(auto) surface(query_t &&q) const
Definition detector.hpp:295
dtransform3D< algebra_type > transform3_type
Definition detector.hpp:97
vector_type< volume_type > volume_container
Definition detector.hpp:152
surface_lookup< surface_type, vector_type > surface_lookup_container
Definition detector.hpp:111
typename accelerator_container::value_types accel
Definition detector.hpp:140
dmulti_view< dvector_view< const volume_type >, typename surface_lookup_container::const_view_type, typename transform_container::const_view_type, typename mask_container::const_view_type, typename material_container::const_view_type, typename accelerator_container::const_view_type > const_view_type
Definition detector.hpp:156
auto get_data() -> const_view_type
Definition detector.hpp:323
typename metadata::template mask_store< vector_type > mask_container
Definition detector.hpp:123
typename material_container::single_link material_link
Definition detector.hpp:146
typename metadata::algebra_type algebra_type
Definition detector.hpp:87
typename accelerator_container::single_link accel_link
Definition detector.hpp:148
dmulti_buffer< dvector_buffer< volume_type >, typename surface_lookup_container::buffer_type, typename transform_container::buffer_type, typename mask_container::buffer_type, typename material_container::buffer_type, typename accelerator_container::buffer_type > buffer_type
Definition detector.hpp:175
auto volumes() const -> const vector_type< volume_type > &
Definition detector.hpp:234
typename metadata::geo_objects geo_obj_ids
Definition detector.hpp:144
auto mask_store() const -> const mask_container &
Definition detector.hpp:308
typename metadata::template material_store< host_container_types > material_container
Definition detector.hpp:129
typename metadata::template accelerator_store< host_container_types > accelerator_container
Definition detector.hpp:137
auto transform_store(const geometry_context &={}) const -> const transform_container &
Definition detector.hpp:301
const auto & portals() const
Definition detector.hpp:279
dpoint2D< algebra_type > point2_type
Definition detector.hpp:91
metadata_t metadata
Definition detector.hpp:83
const auto & volume(const std::string_view volume_name, const name_map &names) const
Definition detector.hpp:251
typename metadata::surface_type surface_type
Definition detector.hpp:107
const auto & volume(const point3_type &p) const
Definition detector.hpp:260
friend std::ostream & operator<<(std::ostream &os, const detector &d)
Definition detector.hpp:344
std::string name(const name_map &names) const
Definition detector.hpp:228
dpoint3D< algebra_type > point3_type
Definition detector.hpp:93
dscalar< algebra_type > scalar_type
Definition detector.hpp:89
typename mask_container::value_types masks
Definition detector.hpp:125
detray::name_map name_map
Definition detector.hpp:101
volume_descriptor< geo_obj_ids, accel_link, material_link > volume_type
Definition detector.hpp:150
const_view_type view_type
Definition detector.hpp:166
detector(detector &&) noexcept=default
dvector3D< algebra_type > vector3_type
Definition detector.hpp:95
auto surfaces() const -> const surface_lookup_container &
Definition detector.hpp:286
typename transform_container::context_type geometry_context
Definition detector.hpp:119
vector_type< surface_type > surface_container
Definition detector.hpp:109
typename metadata::template transform_store< vector_type > transform_container
Definition detector.hpp:116
typename material_container::value_types material
Definition detector.hpp:132
auto accelerator_store() const -> const accelerator_container &
Definition detector.hpp:318
auto get_data() const -> const_view_type
Definition detector.hpp:333
const auto & volume(dindex volume_index) const
Definition detector.hpp:242
detector(detector_view_t &det_data)
Definition detector.hpp:216
Build a grid of a certain shape.
Definition grid_builder.hpp:41
Build a volume containing surfaces with material.
Definition homogeneous_material_builder.hpp:32
Build a volume with homogeneous volume material.
Definition homogeneous_volume_material_builder.hpp:31
Build the material maps for a given volume.
Definition material_map_builder.hpp:47
Facade for a detray detector volume.
Definition tracking_volume.hpp:44
Provides basic functionality to build detector volumes.
Definition volume_builder.hpp:36
The detray detector volume descriptor.
Definition volume_descriptor.hpp:37
Concept for a collection of accelerator (data) that can be stored in the detector.
Definition concepts.hpp:51
Acceleration structure that contains volumes (volume indices).
Definition concepts.hpp:73
Detray include(s).
Definition array_operators.hpp:18
typename detector_traits< D >::buffer detector_buffer_t
Buffer type for transferring detector type D.
Definition detector.hpp:472
get_scalar_t< A, T > dscalar
Scalar type for algebra A and value type T.
Definition algebra.hpp:64
unsigned int dindex
Default index type.
Definition indexing.hpp:18
typename detector_traits< D >::view detector_view_t
Const view type for detector type D.
Definition detector.hpp:468
typename detector_traits< D >::device detector_device_t
Device detector type for metadata type D.
Definition detector.hpp:464
typename detector_traits< D >::metadata_type detector_metadata_t
Some predefined alias types.
Definition detector.hpp:456
get_vector3D_t< A, T > dvector3D
Three-dimensional vector type for algebra A and value type T.
Definition algebra.hpp:80
get_transform3D_t< A, T > dtransform3D
Three-dimensional transform type for algebra A and value type T.
Definition algebra.hpp:84
get_point3D_t< A, T > dpoint3D
Three-dimensional point type for algebra A and value type T.
Definition algebra.hpp:72
get_point2D_t< A, T > dpoint2D
Two-dimensional point type for algebra A and value type T.
Definition algebra.hpp:68
typename detector_traits< D >::host detector_host_t
Host detector type for metadata type D.
Definition detector.hpp:460
Definition detector.hpp:406
Map volume indices to volume names and vice versa.
Definition name_map.hpp:23
decltype(auto) at(dindex idx) const
Returns the name associated with a volume index.
Definition name_map.hpp:64
const std::string & get_detector_name() const
Definition name_map.hpp:31