|
||||
File indexing completed on 2025-01-18 09:27:40
0001 // This file is part of the Acts project. 0002 // 0003 // Copyright (C) 2016-2020 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 http://mozilla.org/MPL/2.0/. 0008 0009 #pragma once 0010 0011 #include "Acts/Definitions/Algebra.hpp" 0012 0013 #include <iosfwd> 0014 #include <limits> 0015 #include <utility> 0016 0017 namespace Acts { 0018 0019 /// Material description for interactions with matter. 0020 /// @defgroup Material Material 0021 /// 0022 /// The following parameters are used to specify the material and its 0023 /// interactions with traversing particles: 0024 /// 0025 /// - radiation length X0 (native length units) 0026 /// - nuclear interaction length L0 (native length units) 0027 /// - relative atomic mass Ar (unitless number) 0028 /// - nuclear charge number Z (elementary charge e) 0029 /// - molar density (native amount-of-substance unit / (native length unit)³) 0030 /// 0031 /// The parameters can be effective or average parameters e.g. when a mixture 0032 /// of materials is described. 0033 /// 0034 /// @note Always use the opaque parameters vector to serialize/deserialize the 0035 /// material information. Since the internal storage might be different from 0036 /// the external accessors, this ensures that always the numerically optimal 0037 /// parameters are stored. Use the `ParametersVector` type and do not assume 0038 /// any particular size since we might consider to store more parameters in 0039 /// the future. 0040 class Material { 0041 public: 0042 using ParametersVector = Eigen::Matrix<float, 5, 1>; 0043 0044 // Both mass and molar density are stored as a float and can thus not be 0045 // distinguished by their types. Just changing the last element in the 0046 // previously existing constructor that took five floats as input to represent 0047 // molar density instead of mass density could have lead to significant 0048 // confusion compared to the previous behaviour. To avoid any ambiguity, 0049 // construction from separate material parameters must happen through the 0050 // following named constructors. 0051 0052 /// Construct from material parameters using the molar density. 0053 /// 0054 /// @param x0 is the radiation length 0055 /// @param l0 is the nuclear interaction length 0056 /// @param ar is the relative atomic mass 0057 /// @param z is the nuclear charge number 0058 /// @param molarRho is the molar density 0059 static Material fromMolarDensity(float x0, float l0, float ar, float z, 0060 float molarRho); 0061 /// Construct from material parameters using the mass density. 0062 /// 0063 /// @param x0 is the radiation length 0064 /// @param l0 is the nuclear interaction length 0065 /// @param ar is the relative atomic mass 0066 /// @param z is the nuclear charge number 0067 /// @param massRho is the mass density 0068 /// 0069 /// @warning Due to the choice of native mass units, using the mass density 0070 /// can lead to numerical problems. Typical mass densities lead to 0071 /// computations with values differing by 20+ orders of magnitude. 0072 static Material fromMassDensity(float x0, float l0, float ar, float z, 0073 float massRho); 0074 /// Construct a vacuum representation. 0075 Material() = default; 0076 /// Construct from an encoded parameters vector. 0077 Material(const ParametersVector& parameters); 0078 0079 Material(Material&& mat) = default; 0080 Material(const Material& mat) = default; 0081 ~Material() = default; 0082 Material& operator=(Material&& mat) = default; 0083 Material& operator=(const Material& mat) = default; 0084 0085 /// Check if the material is valid, i.e. it is not vacuum. 0086 constexpr operator bool() const { return 0.0f < m_ar; } 0087 0088 /// Return the radition length. Infinity in case of vacuum. 0089 constexpr float X0() const { return m_x0; } 0090 /// Return the nuclear interaction length. Infinity in case of vacuum. 0091 constexpr float L0() const { return m_l0; } 0092 /// Return the relative atomic mass. 0093 constexpr float Ar() const { return m_ar; } 0094 /// Return the nuclear charge number. 0095 constexpr float Z() const { return m_z; } 0096 /// Return the molar density. 0097 constexpr float molarDensity() const { return m_molarRho; } 0098 /// Return the molar electron density. 0099 constexpr float molarElectronDensity() const { return m_z * m_molarRho; } 0100 /// Return the mass density. 0101 float massDensity() const; 0102 /// Return the mean electron excitation energy. 0103 float meanExcitationEnergy() const; 0104 0105 /// Encode the properties into an opaque parameters vector. 0106 ParametersVector parameters() const; 0107 0108 private: 0109 float m_x0 = std::numeric_limits<float>::infinity(); 0110 float m_l0 = std::numeric_limits<float>::infinity(); 0111 float m_ar = 0.0f; 0112 float m_z = 0.0f; 0113 float m_molarRho = 0.0f; 0114 0115 friend constexpr bool operator==(const Material& lhs, const Material& rhs) { 0116 return (lhs.m_x0 == rhs.m_x0) && (lhs.m_l0 == rhs.m_l0) && 0117 (lhs.m_ar == rhs.m_ar) && (lhs.m_z == rhs.m_z) && 0118 (lhs.m_molarRho == rhs.m_molarRho); 0119 } 0120 friend constexpr bool operator!=(const Material& lhs, const Material& rhs) { 0121 return !(lhs == rhs); 0122 } 0123 }; 0124 0125 std::ostream& operator<<(std::ostream& os, const Material& material); 0126 0127 } // namespace Acts
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |