Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /acts/Core/include/Acts/Material/MaterialSlab.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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