Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-02 07:50:46

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 namespace Acts {
0020 
0021 /// Material description for an object with defined thickness.
0022 ///
0023 /// This is intended to describe concrete surface materials.
0024 ///
0025 /// @see Material for a description of the available parameters.
0026 class MaterialSlab {
0027  public:
0028   static constexpr MaterialSlab Nothing() {
0029     return MaterialSlab(Material::Vacuum(), 0, false);
0030   }
0031 
0032   static constexpr MaterialSlab Vacuum(float thickness) {
0033     return MaterialSlab(Material::Vacuum(), thickness, false);
0034   }
0035 
0036   /// Combine material properties of two layers by averaging them.
0037   ///
0038   /// @param layerA Input layer A to average over.
0039   /// @param layerB Input layer B to average over.
0040   ///
0041   /// @return The resulting object has the combined thickness of all layers but just
0042   ///         one set of appropriately averaged material constants.
0043   static MaterialSlab combineLayers(const MaterialSlab& layerA,
0044                                     const MaterialSlab& layerB);
0045 
0046   /// Combine material properties of multiple layers by averaging them.
0047   ///
0048   /// @param layers Input layers to average over.
0049   ///
0050   /// @return The resulting object has the combined thickness of all layers but just
0051   ///         one set of appropriately averaged material constants.
0052   static MaterialSlab combineLayers(const std::vector<MaterialSlab>& layers);
0053 
0054   /// Default constructor.
0055   ///
0056   /// TODO consider removing. currently needed for default construction in grids
0057   constexpr MaterialSlab() : m_material(Material::Vacuum()) {}
0058 
0059   /// Construct from material description.
0060   ///
0061   /// @param material  is the material description
0062   /// @param thickness is the thickness of the material
0063   MaterialSlab(const Material& material, float thickness);
0064 
0065   /// Scale the material thickness by the given factor.
0066   void scaleThickness(float scale);
0067 
0068   /// Check if the material is vacuum.
0069   bool isVacuum() const { return m_material.isVacuum() || m_thickness <= 0; }
0070 
0071   /// Access the (average) material parameters.
0072   constexpr const Material& material() const { return m_material; }
0073   /// Return the thickness.
0074   constexpr float thickness() const { return m_thickness; }
0075   /// Return the radiation length fraction.
0076   constexpr float thicknessInX0() const { return m_thicknessInX0; }
0077   /// Return the nuclear interaction length fraction.
0078   constexpr float thicknessInL0() const { return m_thicknessInL0; }
0079 
0080  private:
0081   Material m_material;
0082   float m_thickness = 0.0f;
0083   float m_thicknessInX0 = 0.0f;
0084   float m_thicknessInL0 = 0.0f;
0085 
0086   static constexpr auto eps = 2 * std::numeric_limits<float>::epsilon();
0087 
0088   constexpr MaterialSlab(const Material& material, float thickness,
0089                          [[maybe_unused]] bool dummy)
0090       : m_material(material),
0091         m_thickness(thickness),
0092         m_thicknessInX0((eps < material.X0()) ? (thickness / material.X0())
0093                                               : 0),
0094         m_thicknessInL0((eps < material.L0()) ? (thickness / material.L0())
0095                                               : 0) {}
0096 
0097   /// @brief Check if two materials are exactly equal.
0098   ///
0099   /// This is a strict equality check, i.e. the materials must have identical
0100   /// properties.
0101   ///
0102   /// @param lhs is the left hand side material
0103   /// @param rhs is the right hand side material
0104   ///
0105   /// @return true if the materials are equal
0106   friend constexpr bool operator==(const MaterialSlab& lhs,
0107                                    const MaterialSlab& rhs) {
0108     // t/X0 and t/L0 are dependent variables and need not be checked
0109     return (lhs.m_material == rhs.m_material) &&
0110            (lhs.m_thickness == rhs.m_thickness);
0111   }
0112 };
0113 
0114 std::ostream& operator<<(std::ostream& os, const MaterialSlab& materialSlab);
0115 
0116 // Useful typedefs
0117 using MaterialSlabVector = std::vector<MaterialSlab>;
0118 using MaterialSlabMatrix = std::vector<MaterialSlabVector>;
0119 
0120 /// list of point used in the mapping of a volume
0121 using RecordedMaterialVolumePoint =
0122     std::vector<std::pair<Acts::MaterialSlab, std::vector<Acts::Vector3>>>;
0123 
0124 }  // namespace Acts