Back to home page

EIC code displayed by LXR

 
 

    


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

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/concepts.hpp"
0013 #include "detray/definitions/algebra.hpp"
0014 #include "detray/definitions/detail/qualifiers.hpp"
0015 #include "detray/geometry/tracking_volume.hpp"
0016 
0017 // System include(s).
0018 #include <vector>
0019 
0020 namespace detray {
0021 
0022 /// @returns the total number of portals in the detector @param det
0023 template <typename detector_t>
0024 DETRAY_HOST_DEVICE inline std::size_t n_portals(const detector_t& det) {
0025   std::size_t n_portals{0u};
0026 
0027   for (const auto& vol_desc : det.volumes()) {
0028     n_portals += tracking_volume{det, vol_desc}.n_portals();
0029   }
0030 
0031   return n_portals;
0032 }
0033 
0034 /// @returns the total number of sensitive surfaces in the detector @param det
0035 template <typename detector_t>
0036 DETRAY_HOST_DEVICE inline std::size_t n_sensitives(const detector_t& det) {
0037   std::size_t n_sensitives{0u};
0038 
0039   for (const auto& vol_desc : det.volumes()) {
0040     n_sensitives += tracking_volume{det, vol_desc}.n_sensitives();
0041   }
0042 
0043   return n_sensitives;
0044 }
0045 
0046 /// @returns the total number of passive surfaces in the detector @param det
0047 template <typename detector_t>
0048 DETRAY_HOST_DEVICE inline std::size_t n_passives(const detector_t& det) {
0049   std::size_t n_passives{0u};
0050 
0051   for (const auto& vol_desc : det.volumes()) {
0052     n_passives += tracking_volume{det, vol_desc}.n_passives();
0053   }
0054 
0055   return n_passives;
0056 }
0057 
0058 /// @returns the total number of grids in a detector store @param store
0059 template <std::size_t I = 0u, typename store_t>
0060 DETRAY_HOST_DEVICE inline std::size_t n_grids(const store_t& store,
0061                                               std::size_t n = 0u) {
0062   constexpr auto coll_id{types::id_cast<typename store_t::value_types, I>};
0063   using value_type = types::get<typename store_t::value_types, coll_id>;
0064 
0065   if constexpr (detray::concepts::grid<value_type>) {
0066     n += store.template size<coll_id>();
0067   }
0068 
0069   if constexpr (I < store_t::n_collections() - 1u) {
0070     return n_grids<I + 1>(store, n);
0071   }
0072   return n;
0073 }
0074 
0075 /// @returns the total number of surface grids in the detector  @param det
0076 template <typename detector_t>
0077 DETRAY_HOST_DEVICE inline std::size_t n_surface_grids(const detector_t& det) {
0078   return n_grids(det.accelerator_store());
0079 }
0080 
0081 /// @returns the total number of material maps in the detector  @param det
0082 template <typename detector_t>
0083 DETRAY_HOST_DEVICE inline std::size_t n_material_maps(const detector_t& det) {
0084   return n_grids(det.material_store());
0085 }
0086 
0087 /// @returns the total number of material slabs outside of material maps in the
0088 /// detector  @param det
0089 template <typename detector_t>
0090 DETRAY_HOST_DEVICE inline std::size_t n_material_slabs(const detector_t& det) {
0091   if constexpr (detray::concepts::has_material_slabs<detector_t>) {
0092     constexpr auto slab_id{detector_t::material::id::e_material_slab};
0093     return det.material_store().template size<slab_id>();
0094   } else {
0095     return 0u;
0096   }
0097 }
0098 
0099 /// @returns the total number of material rods in the detector  @param det
0100 template <typename detector_t>
0101 DETRAY_HOST_DEVICE inline std::size_t n_material_rods(const detector_t& det) {
0102   if constexpr (detray::concepts::has_material_rods<detector_t>) {
0103     constexpr auto rod_id{detector_t::material::id::e_material_rod};
0104     return det.material_store().template size<rod_id>();
0105   } else {
0106     return 0u;
0107   }
0108 }
0109 
0110 }  // namespace detray