ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
material_slab.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/material/material.hpp"
15#include "detray/material/predefined_materials.hpp"
16
17// System include(s)
18#include <limits>
19#include <ostream>
20
21namespace detray {
22
24template <concepts::scalar scalar_t>
25struct material_slab {
27 using scalar_type = scalar_t;
30
31 constexpr material_slab() = default;
32
37 : m_material(material),
38 m_thickness(thickness),
39 m_thickness_in_X0(thickness / material.X0()),
40 m_thickness_in_L0(thickness / material.L0()) {}
41
46 DETRAY_HOST_DEVICE
47 constexpr bool operator==(const material_slab& rhs) const {
48 return (m_material == rhs.get_material() && m_thickness == rhs.thickness());
49 }
50
53 DETRAY_HOST_DEVICE
54 constexpr explicit operator bool() const {
55 if (m_thickness <= std::numeric_limits<scalar_type>::epsilon() ||
56 m_thickness == std::numeric_limits<scalar_type>::max() ||
57 m_material == vacuum<scalar_type>() ||
58 m_material.mass_density() == 0.f || m_material.molar_density() == 0.f) {
59 return false;
60 }
61 return true;
62 }
63
66 DETRAY_HOST_DEVICE
67 constexpr const material_type& get_material() const { return m_material; }
70 DETRAY_HOST_DEVICE
71 constexpr scalar_type thickness() const { return m_thickness; }
74 DETRAY_HOST_DEVICE
75 constexpr scalar_type thickness_in_X0() const { return m_thickness_in_X0; }
78 DETRAY_HOST_DEVICE
79 constexpr scalar_type thickness_in_L0() const { return m_thickness_in_L0; }
80
85 DETRAY_HOST_DEVICE constexpr scalar_type path_segment(
86 const scalar_type cos_inc_angle,
87 const scalar_type /*unused*/ = 0.f) const {
88 return m_thickness / cos_inc_angle;
89 }
90
95 DETRAY_HOST_DEVICE constexpr scalar_type path_segment_in_X0(
96 const scalar_type cos_inc_angle,
97 const scalar_type /*unused*/ = 0.f) const {
98 return m_thickness_in_X0 / cos_inc_angle;
99 }
100
105 DETRAY_HOST_DEVICE constexpr scalar_type path_segment_in_L0(
106 const scalar_type cos_inc_angle,
107 const scalar_type /*unused*/ = 0.f) const {
108 return m_thickness_in_L0 / cos_inc_angle;
109 }
110
112 DETRAY_HOST
113 friend std::ostream& operator<<(std::ostream& os, const material_slab& mat) {
114 os << "slab: ";
115 os << mat.get_material();
116 os << " | thickness = " << mat.thickness() << " mm";
117
118 return os;
119 }
120
121 private:
122 material_type m_material = {};
123 scalar_type m_thickness = std::numeric_limits<scalar_type>::epsilon();
124 scalar_type m_thickness_in_X0 = std::numeric_limits<scalar_type>::epsilon();
125 scalar_type m_thickness_in_L0 = std::numeric_limits<scalar_type>::epsilon();
126};
127
128} // namespace detray
Detray include(s).
Definition array_operators.hpp:18
constexpr bool operator==(const material_slab &rhs) const
Equality operator.
Definition material_slab.hpp:47
constexpr scalar_type path_segment_in_X0(const scalar_type cos_inc_angle, const scalar_type=0.f) const
Compute the path length through the slab at an incidence angle.
Definition material_slab.hpp:95
scalar_t scalar_type
Definition material_slab.hpp:27
material< scalar_t > material_type
Definition material_slab.hpp:29
constexpr material_slab(const material_type &material, scalar_type thickness)
Constructor.
Definition material_slab.hpp:36
constexpr scalar_type thickness_in_X0() const
Return the radiation length fraction.
Definition material_slab.hpp:75
constexpr scalar_type path_segment_in_L0(const scalar_type cos_inc_angle, const scalar_type=0.f) const
Compute the path length through the slab at an incidence angle.
Definition material_slab.hpp:105
friend std::ostream & operator<<(std::ostream &os, const material_slab &mat)
Definition material_slab.hpp:113
constexpr scalar_type thickness() const
Definition material_slab.hpp:71
constexpr const material_type & get_material() const
Access the (average) material parameters.
Definition material_slab.hpp:67
constexpr scalar_type thickness_in_L0() const
Return the nuclear interaction length fraction.
Definition material_slab.hpp:79
constexpr scalar_type path_segment(const scalar_type cos_inc_angle, const scalar_type=0.f) const
Compute the path length through the slab at an incidence angle.
Definition material_slab.hpp:85
Material composition properties and density data used by interactions.
Definition material.hpp:36
constexpr scalar_type mass_density() const
Definition material.hpp:130
Elements Declaration.
Definition predefined_materials.hpp:34