Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-06 08:09:04

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 fully scaled material description of the Surface
0078   /// - from local coordinate of the material grid
0079   ///
0080   /// @param lp is the local position used for the (eventual) lookup
0081   /// @param pDir is the positive direction through the surface
0082   /// @param mode is the material update directive
0083   ///
0084   /// @return MaterialSlab
0085   virtual MaterialSlab materialSlab(const Vector2& lp, Direction pDir,
0086                                     MaterialUpdateMode mode) const;
0087 
0088   /// Update pre factor
0089   ///
0090   /// @param pDir is the positive direction through the surface
0091   /// @param mode is the material update directive
0092   /// @return Factor for material scaling based on direction and update mode
0093   double factor(Direction pDir, MaterialUpdateMode mode) const;
0094 
0095   /// Return the type of surface material mapping
0096   ///
0097   /// @return The mapping type indicating how material is associated with the surface
0098   MappingType mappingType() const { return m_mappingType; }
0099 
0100   /// @brief output stream operator
0101   ///
0102   /// Prints information about this object to the output stream using the
0103   /// virtual ISurfaceMaterial::toStream method
0104   ///
0105   /// @return modified output stream object
0106   friend std::ostream& operator<<(std::ostream& out,
0107                                   const ISurfaceMaterial& sm) {
0108     sm.toStream(out);
0109     return out;
0110   }
0111 
0112   /// Output Method for std::ostream, to be overloaded by child classes
0113   /// @param sl Output stream to write to
0114   /// @return Reference to the output stream for chaining
0115   virtual std::ostream& toStream(std::ostream& sl) const = 0;
0116 
0117   /// @brief output into a string
0118   ///
0119   /// @return the string representation
0120   std::string toString() const {
0121     std::stringstream sstrm;
0122     toStream(sstrm);
0123     return sstrm.str();
0124   }
0125 
0126  protected:
0127   /// the split factor in favour of oppositePre
0128   double m_splitFactor{1.};
0129 
0130   /// Use the default mapping type by default
0131   MappingType m_mappingType{MappingType::Default};
0132 };
0133 
0134 }  // namespace Acts