Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-08 07:47:29

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/Definitions/Common.hpp"
0013 #include "Acts/Definitions/Direction.hpp"
0014 #include "Acts/Material/MaterialSlab.hpp"
0015 #include "Acts/Utilities/AxisDefinitions.hpp"
0016 
0017 #include <sstream>
0018 #include <vector>
0019 
0020 namespace Acts {
0021 
0022 /// This enum describes the type of surface material mapping
0023 enum class MappingType : std::int8_t {
0024   PreMapping = -1,
0025   Default = 0,
0026   PostMapping = 1,
0027   Sensor = 2
0028 };
0029 
0030 /// @ingroup material
0031 ///
0032 /// Base class of all surface-based material description
0033 ///
0034 /// The class supplies references to @ref MaterialSlab that are associated to a
0035 /// surface, extended by certain special representations (binned, homogeneous).
0036 /// The concrete @ref MaterialSlab can depend on the local position on the
0037 /// surface.
0038 ///
0039 class ISurfaceMaterial {
0040  public:
0041   /// Constructor
0042   ISurfaceMaterial() = default;
0043 
0044   /// Constructor
0045   ///
0046   /// @param splitFactor is the splitting ratio between pre/post update
0047   explicit ISurfaceMaterial(double splitFactor) : m_splitFactor(splitFactor) {}
0048 
0049   /// Constructor
0050   ///
0051   /// @param splitFactor is the splitting ratio between pre/post update
0052   /// @param mappingType is the type of surface mapping associated to the surface
0053   explicit ISurfaceMaterial(double splitFactor, MappingType mappingType)
0054       : m_splitFactor(splitFactor), m_mappingType(mappingType) {}
0055 
0056   /// Destructor
0057   virtual ~ISurfaceMaterial() = default;
0058 
0059   /// Returns the axis directions for the local coordinate system
0060   /// @return Vector of axis directions defining the local coordinate system
0061   virtual std::vector<AxisDirection> localAxisDirections() const = 0;
0062 
0063   /// Scale material
0064   ///
0065   /// @param factor is the scale factor applied
0066   /// @return Reference to this material object for chaining
0067   virtual ISurfaceMaterial& scale(double factor) = 0;
0068 
0069   /// Return method for full material description of the Surface
0070   /// - from local coordinate of the material grid
0071   ///
0072   /// @param lp is the local position used for the (eventual) lookup
0073   ///
0074   /// @return const MaterialSlab
0075   virtual const MaterialSlab& materialSlab(const Vector2& lp) const = 0;
0076 
0077   /// Return method for full material description of the Surface
0078   /// - from the global coordinates
0079   ///
0080   /// @param gp is the global position used for the (eventual) lookup
0081   ///
0082   /// @return const MaterialSlab
0083   /// @deprecated Use materialSlab(const Vector2&) with a prior
0084   ///             Surface::globalToLocal() call to convert the global position.
0085   [[deprecated(
0086       "Use materialSlab(const Vector2& lp) with a prior "
0087       "Surface::globalToLocal() call instead")]] virtual const MaterialSlab&
0088   materialSlab(const Vector3& gp) const = 0;
0089 
0090   /// Return method for fully scaled material description of the Surface
0091   /// - from local coordinate of the material grid
0092   ///
0093   /// @param lp is the local position used for the (eventual) lookup
0094   /// @param pDir is the positive direction through the surface
0095   /// @param mode is the material update directive
0096   ///
0097   /// @return MaterialSlab
0098   virtual MaterialSlab materialSlab(const Vector2& lp, Direction pDir,
0099                                     MaterialUpdateMode mode) const;
0100 
0101   /// Return method for full material description of the Surface
0102   /// - from the global coordinates
0103   ///
0104   /// @param gp is the global position used for the (eventual) lookup
0105   /// @param pDir is the positive direction through the surface
0106   /// @param mode is the material update directive
0107   ///
0108   /// @return MaterialSlab
0109   /// @deprecated Use materialSlab(const Vector2&, Direction, MaterialUpdateMode)
0110   ///             with a prior Surface::globalToLocal() call to convert gp.
0111   [[deprecated(
0112       "Use materialSlab(const Vector2& lp) with a prior "
0113       "Surface::globalToLocal() call instead")]] virtual MaterialSlab
0114   materialSlab(const Vector3& gp, Direction pDir,
0115                MaterialUpdateMode mode) const;
0116 
0117   /// Update pre factor
0118   ///
0119   /// @param pDir is the positive direction through the surface
0120   /// @param mode is the material update directive
0121   /// @return Factor for material scaling based on direction and update mode
0122   double factor(Direction pDir, MaterialUpdateMode mode) const;
0123 
0124   /// Return the type of surface material mapping
0125   ///
0126   /// @return The mapping type indicating how material is associated with the surface
0127   MappingType mappingType() const { return m_mappingType; }
0128 
0129   /// @brief output stream operator
0130   ///
0131   /// Prints information about this object to the output stream using the
0132   /// virtual ISurfaceMaterial::toStream method
0133   ///
0134   /// @return modified output stream object
0135   friend std::ostream& operator<<(std::ostream& out,
0136                                   const ISurfaceMaterial& sm) {
0137     sm.toStream(out);
0138     return out;
0139   }
0140 
0141   /// Output Method for std::ostream, to be overloaded by child classes
0142   /// @param sl Output stream to write to
0143   /// @return Reference to the output stream for chaining
0144   virtual std::ostream& toStream(std::ostream& sl) const = 0;
0145 
0146   /// @brief output into a string
0147   ///
0148   /// @return the string representation
0149   std::string toString() const {
0150     std::stringstream sstrm;
0151     toStream(sstrm);
0152     return sstrm.str();
0153   }
0154 
0155  protected:
0156   /// the split factor in favour of oppositePre
0157   double m_splitFactor{1.};
0158 
0159   /// Use the default mapping type by default
0160   MappingType m_mappingType{MappingType::Default};
0161 };
0162 
0163 }  // namespace Acts