Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:23:56

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/definitions/algebra.hpp"
0013 #include "detray/definitions/units.hpp"
0014 #include "detray/geometry/mask.hpp"
0015 #include "detray/geometry/shapes.hpp"
0016 #include "detray/geometry/surface.hpp"
0017 #include "detray/geometry/tracking_volume.hpp"
0018 #include "detray/utils/concepts.hpp"
0019 
0020 // System include(s)
0021 #include <cassert>
0022 #include <optional>
0023 
0024 namespace detray::detail {
0025 
0026 /// @brief Functor to calculate the outermost radius of a cylinder shape.
0027 /// If the shape is not defined by a radius, then null option is returned.
0028 struct outer_radius_getter {
0029  public:
0030   template <typename mask_group_t, concepts::index index_t>
0031   DETRAY_HOST inline auto operator()(const mask_group_t& mask_group,
0032                                      const index_t& index) const {
0033     return outer_radius(mask_group.at(index));
0034   }
0035 
0036   template <typename mask_group_t, concepts::interval idx_range_t>
0037   DETRAY_HOST inline auto operator()(const mask_group_t& mask_group,
0038                                      const idx_range_t& idx_range) const {
0039     // All masks on the same cylinder surface have the same radius
0040     return outer_radius(mask_group.at(idx_range.lower()));
0041   }
0042 
0043  private:
0044   // Struct to access the radius of a surface
0045   template <typename mask_t>
0046   DETRAY_HOST std::optional<typename mask_t::scalar_type> inline outer_radius(
0047       const mask_t& /*mask*/) const {
0048     return std::nullopt;
0049   }
0050 
0051   // Calculates the outer radius for cylinders (2D).
0052   template <concepts::algebra algebra_t>
0053   DETRAY_HOST inline auto outer_radius(
0054       const detray::mask<detray::cylinder2D, algebra_t>& mask) const {
0055     return std::optional(mask[cylinder2D::e_r]);
0056   }
0057 
0058   // Calculates the outer radius for concentric cylinders (2D).
0059   template <concepts::algebra algebra_t>
0060   DETRAY_HOST inline auto outer_radius(
0061       const detray::mask<detray::concentric_cylinder2D, algebra_t>& mask)
0062       const {
0063     return std::optional(mask[concentric_cylinder2D::e_r]);
0064   }
0065 
0066   // Calculates the outer radius for cylinders (3D).
0067   template <concepts::algebra algebra_t>
0068   DETRAY_HOST inline auto outer_radius(
0069       const detray::mask<detray::cylinder3D, algebra_t>& mask) const {
0070     return std::optional(mask[cylinder3D::e_max_r]);
0071   }
0072 };
0073 
0074 }  // namespace detray::detail