Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:24:06

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 // Project include(s)
0012 #include "detray/core/detail/multi_store.hpp"
0013 #include "detray/core/detail/single_store.hpp"
0014 #include "detray/definitions/algebra.hpp"
0015 #include "detray/definitions/containers.hpp"
0016 #include "detray/definitions/indexing.hpp"
0017 #include "detray/geometry/mask.hpp"
0018 #include "detray/geometry/shapes/concentric_cylinder2D.hpp"
0019 #include "detray/geometry/shapes/cylinder3D.hpp"
0020 #include "detray/geometry/shapes/rectangle2D.hpp"
0021 #include "detray/geometry/shapes/ring2D.hpp"
0022 #include "detray/geometry/shapes/trapezoid2D.hpp"
0023 #include "detray/geometry/surface_descriptor.hpp"
0024 #include "detray/material/material_map.hpp"
0025 #include "detray/material/material_slab.hpp"
0026 #include "detray/navigation/accelerators/brute_force.hpp"
0027 #include "detray/navigation/accelerators/spatial_grid.hpp"
0028 
0029 namespace detray {
0030 
0031 template <concepts::algebra algebra_t>
0032 struct toy_metadata {
0033   using algebra_type = algebra_t;
0034   using scalar_t = dscalar<algebra_type>;
0035 
0036   using nav_link = std::uint_least16_t;
0037 
0038   template <template <typename...> class vector_t = dvector>
0039   using transform_store =
0040       single_store<dtransform3D<algebra_type>, vector_t, geometry_context>;
0041 
0042   using rectangle2D_t = mask<detray::rectangle2D, algebra_type, nav_link>;
0043   using trapezoid2D_t = mask<detray::trapezoid2D, algebra_type, nav_link>;
0044   using concentric_cylinder2D_t =
0045       mask<detray::concentric_cylinder2D, algebra_type, nav_link>;
0046   using ring2D_t = mask<detray::ring2D, algebra_type, nav_link>;
0047 
0048   enum class mask_id : std::uint_least8_t {
0049     e_rectangle2D = 0u,
0050     e_trapezoid2D = 1u,
0051     e_concentric_cylinder2D = 2u,
0052     e_ring2D = 3u,
0053   };
0054 
0055   DETRAY_HOST inline friend std::ostream& operator<<(std::ostream& os,
0056                                                      mask_id id) {
0057     switch (id) {
0058       case mask_id::e_rectangle2D:
0059         os << "e_rectangle2D";
0060         break;
0061       case mask_id::e_trapezoid2D:
0062         os << "e_trapezoid2D";
0063         break;
0064       case mask_id::e_concentric_cylinder2D:
0065         os << "e_concentric_cylinder2D";
0066         break;
0067       case mask_id::e_ring2D:
0068         os << "e_ring2D";
0069         break;
0070       default:
0071         os << "invalid";
0072     }
0073     return os;
0074   };
0075 
0076   template <template <typename...> class vector_t = dvector>
0077   using mask_store = regular_multi_store<mask_id, empty_context, dtuple,
0078                                          vector_t, rectangle2D_t, trapezoid2D_t,
0079                                          concentric_cylinder2D_t, ring2D_t>;
0080 
0081   template <typename container_t>
0082   using concentric_cylinder2D_map_t =
0083       material_map<algebra_type, detray::concentric_cylinder2D, container_t>;
0084   template <typename container_t>
0085   using ring2D_map_t = material_map<algebra_type, detray::ring2D, container_t>;
0086   using material_slab_t = material_slab<scalar_t>;
0087 
0088   enum class material_id : std::uint_least8_t {
0089     e_concentric_cylinder2D_map = 0u,
0090     e_ring2D_map = 1u,
0091     e_material_slab = 2u,
0092     e_none = 3u,
0093   };
0094 
0095   DETRAY_HOST inline friend std::ostream& operator<<(std::ostream& os,
0096                                                      material_id id) {
0097     switch (id) {
0098       case material_id::e_concentric_cylinder2D_map:
0099         os << "e_concentric_cylinder2D_map";
0100         break;
0101       case material_id::e_ring2D_map:
0102         os << "e_ring2D_map";
0103         break;
0104       case material_id::e_material_slab:
0105         os << "e_material_slab";
0106         break;
0107       case material_id::e_none:
0108         os << "e_none";
0109         break;
0110       default:
0111         os << "invalid";
0112     }
0113     return os;
0114   };
0115 
0116   template <typename container_t = host_container_types>
0117   using material_store =
0118       multi_store<material_id, empty_context, dtuple,
0119                   grid_collection<concentric_cylinder2D_map_t<container_t>>,
0120                   grid_collection<ring2D_map_t<container_t>>,
0121                   typename container_t::template vector_type<material_slab_t>>;
0122 
0123   using transform_link = typename transform_store<>::single_link;
0124   using mask_link = typename mask_store<>::range_link;
0125   using material_link = typename material_store<>::single_link;
0126   using surface_type =
0127       surface_descriptor<mask_link, material_link, transform_link, nav_link>;
0128 
0129   template <typename axes_t, typename bin_entry_t, typename container_t>
0130   using static_simple_grid_t =
0131       spatial_grid<algebra_type, axes_t,
0132                    detray::bins::static_array<bin_entry_t, 1>,
0133                    detray::simple_serializer, container_t, false>;
0134 
0135   template <typename container_t>
0136   using surface_concentric_cylinder2D_grid_t =
0137       static_simple_grid_t<axes<detray::concentric_cylinder2D>, surface_type,
0138                            container_t>;
0139   template <typename container_t>
0140   using surface_ring2D_grid_t =
0141       static_simple_grid_t<axes<detray::ring2D>, surface_type, container_t>;
0142 
0143   template <typename axes_t, typename bin_entry_t, typename container_t>
0144   using single_simple_grid_t =
0145       spatial_grid<algebra_type, axes_t, detray::bins::single<bin_entry_t>,
0146                    detray::simple_serializer, container_t, false>;
0147 
0148   template <typename container_t>
0149   using volume_cylinder3D_grid_t =
0150       single_simple_grid_t<axes<detray::cylinder3D>, dindex, container_t>;
0151 
0152   enum class accel_id : std::uint_least8_t {
0153     e_surface_brute_force = 0u,
0154     e_surface_concentric_cylinder2D_grid = 1u,
0155     e_surface_ring2D_grid = 2u,
0156     e_volume_cylinder3D_grid = 3u,
0157     e_surface_default = e_surface_brute_force,
0158     e_volume_default = e_volume_cylinder3D_grid,
0159   };
0160 
0161   DETRAY_HOST inline friend std::ostream& operator<<(std::ostream& os,
0162                                                      accel_id id) {
0163     switch (id) {
0164       case accel_id::e_surface_brute_force:
0165         os << "e_surface_brute_force";
0166         break;
0167       case accel_id::e_surface_concentric_cylinder2D_grid:
0168         os << "e_surface_concentric_cylinder2D_grid";
0169         break;
0170       case accel_id::e_surface_ring2D_grid:
0171         os << "e_surface_ring2D_grid";
0172         break;
0173       case accel_id::e_volume_cylinder3D_grid:
0174         os << "e_volume_cylinder3D_grid";
0175         break;
0176       default:
0177         os << "invalid";
0178     }
0179     return os;
0180   };
0181 
0182   template <typename container_t = host_container_types>
0183   using accelerator_store = multi_store<
0184       accel_id, empty_context, dtuple,
0185       brute_force_collection<surface_type, container_t>,
0186       grid_collection<surface_concentric_cylinder2D_grid_t<container_t>>,
0187       grid_collection<surface_ring2D_grid_t<container_t>>,
0188       grid_collection<volume_cylinder3D_grid_t<container_t>>>;
0189 
0190   enum geo_objects : std::uint_least8_t {
0191     e_passive = 0u,
0192     e_portal = 0u,
0193     e_sensitive = 1u,
0194     e_volume = 2u,
0195     e_size = 3u,
0196     e_all = e_size,
0197   };
0198 
0199   DETRAY_HOST inline friend std::ostream& operator<<(std::ostream& os,
0200                                                      geo_objects id) {
0201     switch (id) {
0202       case geo_objects::e_sensitive:
0203         os << "e_sensitive";
0204         break;
0205       case geo_objects::e_portal:
0206         os << "e_passive/e_portal";
0207         break;
0208       case geo_objects::e_volume:
0209         os << "e_volume";
0210         break;
0211       case geo_objects::e_size:
0212         os << "e_size";
0213         break;
0214       default:
0215         os << "invalid";
0216     }
0217     return os;
0218   };
0219 
0220   using object_link_type =
0221       dmulti_index<dtyped_index<accel_id, dindex>, geo_objects::e_size>;
0222 };
0223 
0224 }  // namespace detray