|
|
|||
File indexing completed on 2026-09-19 08:27:28
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 #include "Acts/Definitions/Algebra.hpp" 0012 #include "Acts/Material/Material.hpp" 0013 0014 #include <iosfwd> 0015 #include <limits> 0016 #include <utility> 0017 #include <vector> 0018 0019 // Tell the compiler to optimize the containing block assuming that 0020 // FP may trap. This is sometimes needed with clang to avoid spurious FPEs 0021 // resulting from auto-vectorization. 0022 0023 #if defined(__clang__) && defined(__x86_64__) 0024 #pragma float_control(push) 0025 #pragma float_control(precise, on) 0026 #pragma float_control(except, on) 0027 #endif 0028 0029 namespace Acts { 0030 0031 /// Material description for an object with defined thickness. 0032 /// 0033 /// @ingroup material 0034 /// 0035 /// This is intended to describe concrete surface materials. 0036 /// 0037 /// @see Material for a description of the available parameters. 0038 class MaterialSlab { 0039 public: 0040 /// Create a material slab with no material content 0041 /// @return Empty material slab with zero thickness and no material 0042 static constexpr MaterialSlab Nothing() { 0043 return MaterialSlab(Material::Vacuum(), 0, false); 0044 } 0045 0046 /// Create a vacuum material slab with specified thickness 0047 /// @param thickness The thickness of the vacuum region 0048 /// @return Vacuum material slab with the given thickness 0049 static constexpr MaterialSlab Vacuum(float thickness) { 0050 return MaterialSlab(Material::Vacuum(), thickness, false); 0051 } 0052 0053 /// Combine material properties of two layers by averaging them. 0054 /// 0055 /// @param layerA Input layer A to average over. 0056 /// @param layerB Input layer B to average over. 0057 /// 0058 /// @return The resulting object has the combined thickness of all layers but just 0059 /// one set of appropriately averaged material constants. 0060 static MaterialSlab combineLayers(const MaterialSlab& layerA, 0061 const MaterialSlab& layerB); 0062 0063 /// Compute the average properties for a combined slab of two materials. 0064 /// 0065 /// The averaged material slab has the combined thickness of the two input 0066 /// slabs and assumes the two input materials are homogeneously and 0067 /// continuously mixed throughout the slab. 0068 /// 0069 /// @param slab1 Properties of the first material slab 0070 /// @param material2 Properties of the second material 0071 /// @param thickness2 Thickness of the second material slab. Can be negative to 0072 /// subtract the second material from the first slab. 0073 /// 0074 /// @returns Material slab with the combined thickness and average parameters 0075 static MaterialSlab combine(const MaterialSlab& slab1, 0076 const Material& material2, float thickness2); 0077 0078 /// Combine material properties of multiple layers by averaging them. 0079 /// 0080 /// @param layers Input layers to average over. 0081 /// 0082 /// @return The resulting object has the combined thickness of all layers but just 0083 /// one set of appropriately averaged material constants. 0084 static MaterialSlab combineLayers(const std::vector<MaterialSlab>& layers); 0085 0086 /// Default constructor. 0087 /// 0088 /// TODO consider removing. currently needed for default construction in grids 0089 constexpr MaterialSlab() : m_material(Material::Vacuum()) {} 0090 0091 /// Construct from material description. 0092 /// 0093 /// @param material is the material description 0094 /// @param thickness is the thickness of the material 0095 MaterialSlab(const Material& material, float thickness); 0096 0097 /// Scale the material thickness by the given factor. 0098 /// @param scale Factor by which to scale the thickness 0099 void scaleThickness(float scale); 0100 0101 /// Check if the material is vacuum. 0102 /// @return True if the material is vacuum or thickness is zero/negative 0103 bool isVacuum() const { return m_material.isVacuum() || m_thickness <= 0; } 0104 0105 /// Access the (average) material parameters. 0106 /// @return Reference to the material properties 0107 constexpr const Material& material() const { return m_material; } 0108 /// Return the thickness. 0109 /// @return Material thickness in millimeters 0110 constexpr float thickness() const { return m_thickness; } 0111 /// Return the radiation length fraction. 0112 /// @return Thickness as a fraction of radiation length 0113 constexpr float thicknessInX0() const { return m_thicknessInX0; } 0114 /// Return the nuclear interaction length fraction. 0115 /// @return Thickness as a fraction of nuclear interaction length 0116 constexpr float thicknessInL0() const { return m_thicknessInL0; } 0117 0118 private: 0119 Material m_material; 0120 float m_thickness = 0.0f; 0121 float m_thicknessInX0 = 0.0f; 0122 float m_thicknessInL0 = 0.0f; 0123 0124 static constexpr auto eps = 2 * std::numeric_limits<float>::epsilon(); 0125 0126 constexpr MaterialSlab(const Material& material, float thickness, 0127 [[maybe_unused]] bool dummy) 0128 : m_material(material), m_thickness(thickness) { 0129 m_thicknessInX0 = (eps < material.X0()) ? (thickness / material.X0()) : 0; 0130 m_thicknessInL0 = (eps < material.L0()) ? (thickness / material.L0()) : 0; 0131 } 0132 0133 /// @brief Check if two materials are exactly equal. 0134 /// 0135 /// This is a strict equality check, i.e. the materials must have identical 0136 /// properties. 0137 /// 0138 /// @param lhs is the left hand side material 0139 /// @param rhs is the right hand side material 0140 /// 0141 /// @return true if the materials are equal 0142 friend constexpr bool operator==(const MaterialSlab& lhs, 0143 const MaterialSlab& rhs) { 0144 // t/X0 and t/L0 are dependent variables and need not be checked 0145 return (lhs.m_material == rhs.m_material) && 0146 (lhs.m_thickness == rhs.m_thickness); 0147 } 0148 }; 0149 0150 /// Stream operator for MaterialSlab 0151 /// @param os Output stream 0152 /// @param materialSlab MaterialSlab to output 0153 /// @return Reference to output stream 0154 std::ostream& operator<<(std::ostream& os, const MaterialSlab& materialSlab); 0155 0156 /// @brief Type alias for a vector of material slabs 0157 /// @details Used to store a collection of material slabs in sequence 0158 using MaterialSlabVector = std::vector<MaterialSlab>; 0159 0160 /// @brief Type alias for a matrix of material slabs 0161 /// @details Used to store a 2D collection of material slabs 0162 using MaterialSlabMatrix = std::vector<MaterialSlabVector>; 0163 0164 /// list of point used in the mapping of a volume 0165 using RecordedMaterialVolumePoint = 0166 std::vector<std::pair<Acts::MaterialSlab, std::vector<Acts::Vector3>>>; 0167 0168 } // namespace Acts 0169 0170 #if defined(__clang__) && defined(__x86_64__) 0171 #pragma float_control(pop) 0172 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|