Back to home page

EIC code displayed by LXR

 
 

    


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

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/detail/qualifiers.hpp"
0014 
0015 namespace detray {
0016 
0017 namespace detail {
0018 
0019 /// Generate phi tolerance from distance tolerance
0020 ///
0021 /// @param tol is the distance tolerance in mm
0022 /// @param radius is the radius of the shape
0023 ///
0024 /// @return the opening angle of a chord the size of tol (= 2*arcsin(c/(2r)))
0025 /// using a small angle approximation
0026 template <concepts::scalar scalar_t>
0027 constexpr scalar_t phi_tolerance(scalar_t tol, scalar_t radius) {
0028   return radius > 0.f ? tol / radius : tol;
0029 }
0030 // Result of an 'inside' check: First entry precise check, second entry with
0031 // tolerance
0032 template <typename bool_t>
0033 using boundary_check_result = darray<bool_t, 2>;
0034 
0035 }  // namespace detail
0036 
0037 /// Address different types of check results
0038 enum class check_type : std::uint_least8_t {
0039   e_precise = 0u,
0040   e_with_edge = 1u,
0041 };
0042 
0043 /// Get the result of a check with edge tolerance
0044 template <check_type C, typename bool_t>
0045 DETRAY_HOST_DEVICE constexpr bool_t get(
0046     const detail::boundary_check_result<bool_t> result) {
0047   if constexpr (C == check_type::e_precise) {
0048     return result[0];
0049   } else if constexpr (C == check_type::e_with_edge) {
0050     return result[1];
0051   } else {
0052     // Broadcast
0053     return bool_t(false);
0054   }
0055 }
0056 
0057 /// Get the result of a simple tolerance check
0058 template <check_type C, typename bool_t>
0059 DETRAY_HOST_DEVICE constexpr bool_t get(const bool_t& result) {
0060   return result;
0061 }
0062 
0063 }  // namespace detray