Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:10:54

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