Back to home page

EIC code displayed by LXR

 
 

    


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

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 #include "detray/definitions/math.hpp"
0015 #include "detray/material/material.hpp"
0016 #include "detray/material/predefined_materials.hpp"
0017 
0018 // System include(s)
0019 #include <limits>
0020 #include <ostream>
0021 
0022 namespace detray {
0023 
0024 // Rod structure to be mapped on the line mask
0025 template <concepts::scalar scalar_t>
0026 struct material_rod {
0027   using scalar_type = scalar_t;
0028   using material_type = material<scalar_t>;
0029 
0030   constexpr material_rod() = default;
0031 
0032   constexpr material_rod(const material_type& material, scalar_type radius)
0033       : m_material(material),
0034         m_radius(radius),
0035         m_radius_in_X0(radius / material.X0()),
0036         m_radius_in_L0(radius / material.L0()) {}
0037 
0038   /// Equality operator
0039   ///
0040   /// @param rhs is the right hand side to be compared to
0041   DETRAY_HOST_DEVICE
0042   constexpr bool operator==(const material_rod<scalar_type>& rhs) const {
0043     return (m_material == rhs.get_material() && m_radius == rhs.radius());
0044   }
0045 
0046   /// Boolean operator
0047   DETRAY_HOST_DEVICE
0048   constexpr explicit operator bool() const {
0049     if (m_radius <= std::numeric_limits<scalar_type>::epsilon() ||
0050         m_material == vacuum<scalar_type>() || m_material.Z() == 0 ||
0051         m_material.mass_density() == 0) {
0052       return false;
0053     }
0054     return true;
0055   }
0056 
0057   /// Access the (average) material parameters.
0058   DETRAY_HOST_DEVICE
0059   constexpr const material_type& get_material() const { return m_material; }
0060 
0061   /// @returns the radius
0062   DETRAY_HOST_DEVICE
0063   constexpr scalar_type radius() const { return m_radius; }
0064 
0065   /// @returns the radius (alias function to keep interfaces homogeneous)
0066   DETRAY_HOST_DEVICE
0067   constexpr scalar_type thickness() const { return m_radius; }
0068 
0069   /// @returns the path segment through the material
0070   ///
0071   /// @param cos_inc_angle cosine of the track incidence angle
0072   /// @param approach the closes approach of the track to the wire
0073   DETRAY_HOST_DEVICE constexpr scalar_type path_segment(
0074       const scalar_type cos_inc_angle, const scalar_type approach) const {
0075     // Assume that is.local[0] is radial distance of line intersector
0076     if (math::fabs(approach) > m_radius) {
0077       return 0.f;
0078     }
0079 
0080     const scalar_type sin_inc_angle_2{1.f - cos_inc_angle * cos_inc_angle};
0081 
0082     return 2.f * math::sqrt((m_radius * m_radius - approach * approach) /
0083                             sin_inc_angle_2);
0084   }
0085 
0086   /// @returns the path segment through the material in X0
0087   ///
0088   /// @param cos_inc_angle cosine of the track incidence angle
0089   /// @param approach the closes approach of the track to the wire
0090   DETRAY_HOST_DEVICE constexpr scalar_type path_segment_in_X0(
0091       const scalar_type cos_inc_angle, const scalar_type approach) const {
0092     return this->path_segment(cos_inc_angle, approach) / m_material.X0();
0093   }
0094 
0095   /// @returns the path segment through the material in L0
0096   ///
0097   /// @param cos_inc_angle cosine of the track incidence angle
0098   /// @param approach the closes approach of the track to the wire
0099   DETRAY_HOST_DEVICE constexpr scalar_type path_segment_in_L0(
0100       const scalar_type cos_inc_angle, const scalar_type approach) const {
0101     return this->path_segment(cos_inc_angle, approach) / m_material.L0();
0102   }
0103 
0104   /// @returns a string stream that prints the material details
0105   DETRAY_HOST
0106   friend std::ostream& operator<<(std::ostream& os, const material_rod& mat) {
0107     os << "rod: ";
0108     os << mat.get_material();
0109     os << " | radius = " << mat.radius() << "mm";
0110 
0111     return os;
0112   }
0113 
0114  private:
0115   material_type m_material = {};
0116   scalar_type m_radius = std::numeric_limits<scalar_type>::epsilon();
0117   scalar_type m_radius_in_X0 = std::numeric_limits<scalar_type>::epsilon();
0118   scalar_type m_radius_in_L0 = std::numeric_limits<scalar_type>::epsilon();
0119 };
0120 
0121 }  // namespace detray