Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:45:45

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