ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
material_rod.hpp
1// This file is part of the ACTS project.
2//
3// Copyright (C) 2016 CERN for the benefit of the ACTS project
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
9#pragma once
10
11// Project include(s)
12#include "detray/definitions/algebra.hpp"
13#include "detray/definitions/detail/qualifiers.hpp"
14#include "detray/definitions/math.hpp"
15#include "detray/material/material.hpp"
16#include "detray/material/predefined_materials.hpp"
17
18// System include(s)
19#include <limits>
20#include <ostream>
21
22namespace detray {
23
25template <concepts::scalar scalar_t>
26struct material_rod {
28 using scalar_type = scalar_t;
31
32 constexpr material_rod() = default;
33
38 : m_material(material),
39 m_radius(radius),
40 m_radius_in_X0(radius / material.X0()),
41 m_radius_in_L0(radius / material.L0()) {}
42
47 DETRAY_HOST_DEVICE
48 constexpr bool operator==(const material_rod<scalar_type>& rhs) const {
49 return (m_material == rhs.get_material() && m_radius == rhs.radius());
50 }
51
54 DETRAY_HOST_DEVICE
55 constexpr explicit operator bool() const {
56 if (m_radius <= std::numeric_limits<scalar_type>::epsilon() ||
57 m_material == vacuum<scalar_type>() || m_material.Z() == 0 ||
58 m_material.mass_density() == 0) {
59 return false;
60 }
61 return true;
62 }
63
66 DETRAY_HOST_DEVICE
67 constexpr const material_type& get_material() const { return m_material; }
68
71 DETRAY_HOST_DEVICE
72 constexpr scalar_type radius() const { return m_radius; }
73
76 DETRAY_HOST_DEVICE
77 constexpr scalar_type thickness() const { return m_radius; }
78
84 DETRAY_HOST_DEVICE constexpr scalar_type path_segment(
85 const scalar_type cos_inc_angle, const scalar_type approach) const {
86 // Assume that is.local[0] is radial distance of line intersector
87 if (math::fabs(approach) > m_radius) {
88 return 0.f;
89 }
90
91 const scalar_type sin_inc_angle_2{1.f - cos_inc_angle * cos_inc_angle};
92
93 return 2.f * math::sqrt((m_radius * m_radius - approach * approach) /
94 sin_inc_angle_2);
95 }
96
102 DETRAY_HOST_DEVICE constexpr scalar_type path_segment_in_X0(
103 const scalar_type cos_inc_angle, const scalar_type approach) const {
104 return this->path_segment(cos_inc_angle, approach) / m_material.X0();
105 }
106
112 DETRAY_HOST_DEVICE constexpr scalar_type path_segment_in_L0(
113 const scalar_type cos_inc_angle, const scalar_type approach) const {
114 return this->path_segment(cos_inc_angle, approach) / m_material.L0();
115 }
116
118 DETRAY_HOST
119 friend std::ostream& operator<<(std::ostream& os, const material_rod& mat) {
120 os << "rod: ";
121 os << mat.get_material();
122 os << " | radius = " << mat.radius() << "mm";
123
124 return os;
125 }
126
127 private:
128 material_type m_material = {};
129 scalar_type m_radius = std::numeric_limits<scalar_type>::epsilon();
130 scalar_type m_radius_in_X0 = std::numeric_limits<scalar_type>::epsilon();
131 scalar_type m_radius_in_L0 = std::numeric_limits<scalar_type>::epsilon();
132};
133
134} // namespace detray
Detray include(s).
Definition array_operators.hpp:18
friend std::ostream & operator<<(std::ostream &os, const material_rod &mat)
Definition material_rod.hpp:119
constexpr scalar_type radius() const
Return the rod radius.
Definition material_rod.hpp:72
constexpr scalar_type path_segment_in_L0(const scalar_type cos_inc_angle, const scalar_type approach) const
Compute the path length through the rod for a track crossing.
Definition material_rod.hpp:112
constexpr material_rod(const material_type &material, scalar_type radius)
Construct a rod from a material and its radius.
Definition material_rod.hpp:37
constexpr scalar_type path_segment(const scalar_type cos_inc_angle, const scalar_type approach) const
Compute the path length through the rod for a track crossing.
Definition material_rod.hpp:84
constexpr scalar_type path_segment_in_X0(const scalar_type cos_inc_angle, const scalar_type approach) const
Compute the path length through the rod for a track crossing.
Definition material_rod.hpp:102
constexpr const material_type & get_material() const
Access the (average) material parameters.
Definition material_rod.hpp:67
material< scalar_t > material_type
Bulk material type represented by this rod.
Definition material_rod.hpp:30
constexpr scalar_type thickness() const
Return the rod radius.
Definition material_rod.hpp:77
constexpr bool operator==(const material_rod< scalar_type > &rhs) const
Equality operator.
Definition material_rod.hpp:48
scalar_t scalar_type
Scalar type used for rod dimensions and material properties.
Definition material_rod.hpp:28
Material composition properties and density data used by interactions.
Definition material.hpp:36
constexpr scalar_type Z() const
Definition material.hpp:127
Elements Declaration.
Definition predefined_materials.hpp:34