Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-24 08:18:36

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/Geometry/ApproachDescriptor.hpp"
0013 #include "Acts/Geometry/GeometryContext.hpp"
0014 #include "Acts/Geometry/GeometryIdentifier.hpp"
0015 #include "Acts/Geometry/GeometryObject.hpp"
0016 #include "Acts/Geometry/Volume.hpp"
0017 #include "Acts/Material/IMaterialDecorator.hpp"
0018 #include "Acts/Propagator/NavigationTarget.hpp"
0019 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0020 #include "Acts/Utilities/BinnedArray.hpp"
0021 #include "Acts/Utilities/Logger.hpp"
0022 
0023 #include <memory>
0024 #include <utility>
0025 
0026 namespace Acts {
0027 
0028 class Surface;
0029 class SurfaceArray;
0030 class ISurfaceMaterial;
0031 class BinUtility;
0032 class Volume;
0033 class VolumeBounds;
0034 class TrackingVolume;
0035 class ApproachDescriptor;
0036 class IMaterialDecorator;
0037 template <typename object_t>
0038 struct NavigationOptions;
0039 
0040 class Layer;
0041 
0042 /// @brief Type alias for a shared pointer to a layer
0043 using LayerPtr = std::shared_ptr<const Layer>;
0044 /// @brief Type alias for a mutable pointer to a layer
0045 /// @details Used for non-const access to layer objects in the geometry
0046 using MutableLayerPtr = std::shared_ptr<Layer>;
0047 /// @brief Type alias for adjacent layer pointers
0048 /// @details Stores pointers to the next inner and outer layers in the detector
0049 using NextLayers = std::pair<const Layer*, const Layer*>;
0050 
0051 /// @enum LayerType
0052 ///
0053 /// For code readability, it distinguishes between different
0054 /// type of layers, which steers the behaviour in the navigation
0055 enum LayerType { navigation = -1, passive = 0, active = 1 };
0056 
0057 /// @class Layer
0058 ///
0059 /// Base Class for a Detector Layer in the Tracking Geometry
0060 ///
0061 /// An actual implemented Detector Layer inheriting from this base
0062 /// class has to inherit from a specific type of Surface as well.
0063 /// In addition, a Layer can carry:
0064 ///
0065 /// A SurfaceArray of Surfaces holding the actual detector elements or
0066 /// subSurfaces.
0067 /// A pointer to the TrackingVolume (can only be set by such)
0068 /// An active/passive code :
0069 /// 0      - active
0070 /// 1      - passive
0071 /// [....] - other
0072 ///
0073 /// The search type for compatible surfaces on a layer is
0074 ///   [ the higher the number, the faster ]:
0075 /// --------- Layer internal ------------------------------------------------
0076 /// -1     - provide all intersection tested without boundary check
0077 ///  0     - provide all intersection tested with boundary check
0078 ///  1     - provide overlap descriptor based without boundary check
0079 ///  2     - provide overlap descriptor based with boundary check
0080 ///
0081 /// A layer can have substructure regarding:
0082 /// - m_ssRepresentingSurface -> always exists (1), can have material (2)
0083 /// - m_ssSensitiveSurfaces   -> can or not exist (0,1), can have material (2)
0084 /// - m_ssApproachSurfaces    -> can or not exist (0,1) cam have material (2)
0085 ///
0086 class Layer : public virtual GeometryObject {
0087   /// Declare the TrackingVolume as a friend, to be able to register previous,
0088   /// next and set the enclosing TrackingVolume
0089   friend class TrackingVolume;
0090   friend class Gen1GeometryClosureVisitor;
0091 
0092  public:
0093   /// Destructor
0094   ~Layer() noexcept override;
0095 
0096   /// Return the entire SurfaceArray, returns a nullptr if no SurfaceArray
0097   /// @return Pointer to the surface array, or nullptr if not set
0098   const SurfaceArray* surfaceArray() const;
0099 
0100   /// Non-const version
0101   /// @return Mutable pointer to the surface array
0102   SurfaceArray* surfaceArray();
0103 
0104   /// Transforms the layer into a Surface representation for extrapolation
0105   /// @note the layer can be hosting many surfaces, but this is the global
0106   /// one to which one can extrapolate
0107   /// @return Reference to the layer's surface representation
0108   virtual const Surface& surfaceRepresentation() const = 0;
0109 
0110   /// Non-const version of surface representation access
0111   /// @return Mutable reference to the layer surface
0112   virtual Surface& surfaceRepresentation() = 0;
0113 
0114   /// Return the Thickness of the Layer
0115   /// this is by definition along the normal vector of the surfaceRepresentation
0116   /// @return The layer thickness value
0117   double thickness() const;
0118 
0119   /// geometrical isOnLayer() method
0120   ///
0121   /// @note using isOnSurface() with Layer specific tolerance
0122   ///
0123   /// @param gctx The current geometry context object, e.g. alignment
0124   /// @param position is the global position to be checked
0125   /// @param boundaryTolerance is the boundary check directive
0126   ///
0127   /// @return boolean that indicates success of the operation
0128   virtual bool isOnLayer(const GeometryContext& gctx, const Vector3& position,
0129                          const BoundaryTolerance& boundaryTolerance =
0130                              BoundaryTolerance::None()) const;
0131 
0132   /// Return method for the approach descriptor, can be nullptr
0133   /// @return Pointer to the approach descriptor, or nullptr if not set
0134   const ApproachDescriptor* approachDescriptor() const;
0135 
0136   /// Non-const version of the approach descriptor
0137   /// @return Mutable pointer to the approach descriptor
0138   ApproachDescriptor* approachDescriptor();
0139 
0140   /// Accept layer according to the following collection directives
0141   ///
0142   /// @tparam options_t Type of the options for navigation
0143   /// @param options Navigation options containing resolution settings
0144   ///
0145   /// @return a boolean whether the layer is accepted for processing
0146   template <typename options_t>
0147   bool resolve(const options_t& options) const {
0148     return resolve(options.resolveSensitive, options.resolveMaterial,
0149                    options.resolvePassive);
0150   }
0151 
0152   /// Accept layer according to the following collection directives
0153   ///
0154   /// @param resolveSensitive is the prescription to find the sensitive surfaces
0155   /// @param resolveMaterial is the precription to find material surfaces
0156   /// @param resolvePassive is the prescription to find all passive surfaces
0157   ///
0158   /// @return a boolean whether the layer is accepted for processing
0159   virtual bool resolve(bool resolveSensitive, bool resolveMaterial,
0160                        bool resolvePassive) const;
0161 
0162   /// @brief Decompose Layer into (compatible) surfaces
0163   ///
0164   /// @param gctx The current geometry context object, e.g. alignment
0165   /// @param position Position parameter for searching
0166   /// @param direction Direction of the parameters for searching
0167   /// @param options The navigation options
0168   ///
0169   /// @return list of intersection of surfaces on the layer
0170   boost::container::small_vector<NavigationTarget, 10> compatibleSurfaces(
0171       const GeometryContext& gctx, const Vector3& position,
0172       const Vector3& direction,
0173       const NavigationOptions<Surface>& options) const;
0174 
0175   /// Surface seen on approach
0176   /// for layers without sub structure, this is the surfaceRepresentation
0177   /// for layers with sub structure, this is the approachSurface
0178   ///
0179   /// @param gctx The current geometry context object, e.g. alignment
0180   /// @param position Position for searching
0181   /// @param direction Direction for searching
0182   /// @param options The  navigation options
0183   ///
0184   /// @return the Surface intersection of the approach surface
0185   NavigationTarget surfaceOnApproach(
0186       const GeometryContext& gctx, const Vector3& position,
0187       const Vector3& direction, const NavigationOptions<Layer>& options) const;
0188 
0189   /// Fast navigation to next layer
0190   ///
0191   /// @param gctx The current geometry context object, e.g. alignment
0192   /// @param position is the start position for the search
0193   /// @param direction is the direction for the search
0194   ///
0195   /// @return the pointer to the next layer
0196   const Layer* nextLayer(const GeometryContext& gctx, const Vector3& position,
0197                          const Vector3& direction) const;
0198 
0199   /// Get the confining TrackingVolume
0200   ///
0201   /// @return the pointer to the enclosing volume
0202   const TrackingVolume* trackingVolume() const;
0203 
0204   ///  Return the abstract volume that represents the layer
0205   ///
0206   /// @return the representing volume of the layer
0207   const Volume* representingVolume() const;
0208 
0209   /// return the LayerType
0210   /// @return The layer type (active, passive, or navigation)
0211   LayerType layerType() const;
0212 
0213  protected:
0214   /// Constructor with pointer to SurfaceArray (passing ownership)
0215   ///
0216   /// @param surfaceArray is the array of sensitive surfaces
0217   /// @param thickness is the normal thickness of the Layer
0218   /// @param ades oapproach descriptor
0219   /// @param laytyp is the layer type if active or passive
0220   explicit Layer(std::unique_ptr<SurfaceArray> surfaceArray,
0221                  double thickness = 0.,
0222                  std::unique_ptr<ApproachDescriptor> ades = nullptr,
0223                  LayerType laytyp = passive);
0224 
0225   ///  private method to set enclosing TrackingVolume, called by friend class
0226   /// only
0227   ///  optionally, the layer can be resized to the dimensions of the
0228   /// TrackingVolume
0229   ///  - Bounds of the Surface are resized
0230   ///  - MaterialSlab dimensions are resized
0231   ///  - SubSurface array boundaries are NOT resized
0232   ///
0233   /// @param tvol is the tracking volume the layer is confined
0234   void encloseTrackingVolume(const TrackingVolume& tvol);
0235 
0236   /// the previous Layer according to BinGenUtils
0237   NextLayers m_nextLayers;
0238 
0239   /// A binutility to find the next layer
0240   /// @todo check if this is needed
0241   const BinUtility* m_nextLayerUtility = nullptr;
0242 
0243   /// SurfaceArray on this layer Surface
0244   ///
0245   /// This array will be modified during signature and constant afterwards, but
0246   /// the C++ type system unfortunately cannot cleanly express this.
0247   ///
0248   std::unique_ptr<const SurfaceArray> m_surfaceArray;
0249 
0250   /// Thickness of the Layer
0251   double m_layerThickness = 0;
0252 
0253   /// descriptor for surface on approach
0254   ///
0255   /// The descriptor may need to be modified during geometry building, and will
0256   /// remain constant afterwards, but again C++ cannot currently express this.
0257   ///
0258   std::unique_ptr<const ApproachDescriptor> m_approachDescriptor;
0259 
0260   /// the enclosing TrackingVolume
0261   const TrackingVolume* m_trackingVolume = nullptr;
0262 
0263   /// Representing Volume
0264   /// can be used as approach surface sources
0265   std::unique_ptr<Volume> m_representingVolume;
0266 
0267   /// make a passive/active either way
0268   LayerType m_layerType;
0269 
0270   /// sub structure indication
0271   /// Substructure flag indicating representing surface configuration
0272   int m_ssRepresentingSurface = 0;
0273   /// Substructure flag indicating sensitive surface configuration
0274   int m_ssSensitiveSurfaces = 0;
0275   /// Substructure flag indicating approach surface configuration
0276   int m_ssApproachSurfaces = 0;
0277 
0278  private:
0279   /// Private helper method to close the geometry
0280   /// - it will assign material to the surfaces if needed
0281   /// - it will set the layer geometry ID for a unique identification
0282   /// - it will also register the internal sub structure
0283   ///
0284   /// @param materialDecorator is a decorator that assigns
0285   ///        optionally the surface material to where they belong
0286   /// @param layerID is the geometry id of the volume
0287   ///                as calculated by the TrackingGeometry
0288   /// @param hook Identifier hook to be applied to surfaces
0289   /// @param logger A @c Logger instance
0290   ///
0291   void closeGeometry(const IMaterialDecorator* materialDecorator,
0292                      const GeometryIdentifier& layerID,
0293                      const GeometryIdentifierHook& hook,
0294                      const Logger& logger = getDummyLogger());
0295 };
0296 
0297 /// Layers are constructed with shared_ptr factories, hence the layer array is
0298 /// describes as:
0299 using LayerArray = BinnedArray<LayerPtr>;
0300 
0301 }  // namespace Acts
0302 
0303 #include "Acts/Geometry/Layer.ipp"