Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:27:25

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/Surfaces/BoundaryTolerance.hpp"
0019 #include "Acts/Surfaces/SurfaceArray.hpp"
0020 #include "Acts/Utilities/BinnedArray.hpp"
0021 #include "Acts/Utilities/Intersection.hpp"
0022 #include "Acts/Utilities/Logger.hpp"
0023 
0024 #include <memory>
0025 #include <utility>
0026 #include <vector>
0027 
0028 namespace Acts {
0029 
0030 class Surface;
0031 class ISurfaceMaterial;
0032 class BinUtility;
0033 class Volume;
0034 class VolumeBounds;
0035 class TrackingVolume;
0036 class ApproachDescriptor;
0037 class IMaterialDecorator;
0038 template <typename object_t>
0039 struct NavigationOptions;
0040 
0041 // Simple surface intersection
0042 using SurfaceIntersection = ObjectIntersection<Surface>;
0043 
0044 // master typedef
0045 class Layer;
0046 
0047 using LayerPtr = std::shared_ptr<const Layer>;
0048 using MutableLayerPtr = std::shared_ptr<Layer>;
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   /// Default Constructor - deleted
0094   Layer() = delete;
0095 
0096   /// Copy Constructor - deleted
0097   Layer(const Layer&) = delete;
0098 
0099   /// Destructor
0100   virtual ~Layer() = default;
0101 
0102   /// Assignment operator - forbidden, layer assignment must not be ambiguous
0103   ///
0104   /// @param layer is the source layer for assignment
0105   Layer& operator=(const Layer& layer) = delete;
0106 
0107   /// Return the entire SurfaceArray, returns a nullptr if no SurfaceArray
0108   const SurfaceArray* surfaceArray() const;
0109 
0110   /// Non-const version
0111   SurfaceArray* surfaceArray();
0112 
0113   /// Transforms the layer into a Surface representation for extrapolation
0114   /// @note the layer can be hosting many surfaces, but this is the global
0115   /// one to which one can extrapolate
0116   virtual const Surface& surfaceRepresentation() const = 0;
0117 
0118   // Non-const version
0119   virtual Surface& surfaceRepresentation() = 0;
0120 
0121   /// Return the Thickness of the Layer
0122   /// this is by definition along the normal vector of the surfaceRepresentation
0123   double thickness() const;
0124 
0125   /// geometrical isOnLayer() method
0126   ///
0127   /// @note using isOnSurface() with Layer specific tolerance
0128   ///
0129   /// @param gctx The current geometry context object, e.g. alignment
0130   /// @param position is the global position to be checked
0131   /// @param boundaryTolerance is the boundary check directive
0132   ///
0133   /// @return boolean that indicates success of the operation
0134   virtual bool isOnLayer(const GeometryContext& gctx, const Vector3& position,
0135                          const BoundaryTolerance& boundaryTolerance =
0136                              BoundaryTolerance::None()) const;
0137 
0138   /// Return method for the approach descriptor, can be nullptr
0139   const ApproachDescriptor* approachDescriptor() const;
0140 
0141   /// Non-const version of the approach descriptor
0142   ApproachDescriptor* approachDescriptor();
0143 
0144   /// Accept layer according to the following collection directives
0145   ///
0146   /// @tparam options_t Type of the options for navigation
0147   ///
0148   /// @return a boolean whether the layer is accepted for processing
0149   template <typename options_t>
0150   bool resolve(const options_t& options) const {
0151     return resolve(options.resolveSensitive, options.resolveMaterial,
0152                    options.resolvePassive);
0153   }
0154 
0155   /// Accept layer according to the following collection directives
0156   ///
0157   /// @param resolveSensitive is the prescription to find the sensitive surfaces
0158   /// @param resolveMaterial is the precription to find material surfaces
0159   /// @param resolvePassive is the prescription to find all passive surfaces
0160   ///
0161   /// @return a boolean whether the layer is accepted for processing
0162   virtual bool resolve(bool resolveSensitive, bool resolveMaterial,
0163                        bool resolvePassive) const;
0164 
0165   /// @brief Decompose Layer into (compatible) surfaces
0166   ///
0167   /// @param gctx The current geometry context object, e.g. alignment
0168   /// @param position Position parameter for searching
0169   /// @param direction Direction of the parameters for searching
0170   /// @param options The navigation options
0171   ///
0172   /// @return list of intersection of surfaces on the layer
0173   boost::container::small_vector<SurfaceIntersection, 10> compatibleSurfaces(
0174       const GeometryContext& gctx, const Vector3& position,
0175       const Vector3& direction,
0176       const NavigationOptions<Surface>& options) const;
0177 
0178   /// Surface seen on approach
0179   /// for layers without sub structure, this is the surfaceRepresentation
0180   /// for layers with sub structure, this is the approachSurface
0181   ///
0182   /// @param gctx The current geometry context object, e.g. alignment
0183   /// @param position Position for searching
0184   /// @param direction Direction for searching
0185   /// @param options The  navigation options
0186   ///
0187   /// @return the Surface intersection of the approach surface
0188   SurfaceIntersection surfaceOnApproach(
0189       const GeometryContext& gctx, const Vector3& position,
0190       const Vector3& direction, const NavigationOptions<Layer>& options) const;
0191 
0192   /// Fast navigation to next layer
0193   ///
0194   /// @param gctx The current geometry context object, e.g. alignment
0195   /// @param position is the start position for the search
0196   /// @param direction is the direction for the search
0197   ///
0198   /// @return the pointer to the next layer
0199   const Layer* nextLayer(const GeometryContext& gctx, const Vector3& position,
0200                          const Vector3& direction) const;
0201 
0202   /// Get the confining TrackingVolume
0203   ///
0204   /// @return the pointer to the enclosing volume
0205   const TrackingVolume* trackingVolume() const;
0206 
0207   ///  Return the abstract volume that represents the layer
0208   ///
0209   /// @return the representing volume of the layer
0210   const Volume* representingVolume() const;
0211 
0212   /// return the LayerType
0213   LayerType layerType() const;
0214 
0215  protected:
0216   /// Constructor with pointer to SurfaceArray (passing ownership)
0217   ///
0218   /// @param surfaceArray is the array of sensitive surfaces
0219   /// @param thickness is the normal thickness of the Layer
0220   /// @param ades oapproach descriptor
0221   /// @param laytyp is the layer type if active or passive
0222   Layer(std::unique_ptr<SurfaceArray> surfaceArray, double thickness = 0.,
0223         std::unique_ptr<ApproachDescriptor> ades = nullptr,
0224         LayerType laytyp = passive);
0225 
0226   ///  private method to set enclosing TrackingVolume, called by friend class
0227   /// only
0228   ///  optionally, the layer can be resized to the dimensions of the
0229   /// TrackingVolume
0230   ///  - Bounds of the Surface are resized
0231   ///  - MaterialSlab dimensions are resized
0232   ///  - SubSurface array boundaries are NOT resized
0233   ///
0234   /// @param tvol is the tracking volume the layer is confined
0235   void encloseTrackingVolume(const TrackingVolume& tvol);
0236 
0237   /// the previous Layer according to BinGenUtils
0238   NextLayers m_nextLayers;
0239 
0240   /// A binutility to find the next layer
0241   /// @todo check if this is needed
0242   const BinUtility* m_nextLayerUtility = nullptr;
0243 
0244   /// SurfaceArray on this layer Surface
0245   ///
0246   /// This array will be modified during signature and constant afterwards, but
0247   /// the C++ type system unfortunately cannot cleanly express this.
0248   ///
0249   std::unique_ptr<const SurfaceArray> m_surfaceArray = nullptr;
0250 
0251   /// Thickness of the Layer
0252   double m_layerThickness = 0.;
0253 
0254   /// descriptor for surface on approach
0255   ///
0256   /// The descriptor may need to be modified during geometry building, and will
0257   /// remain constant afterwards, but again C++ cannot currently express this.
0258   ///
0259   std::unique_ptr<const ApproachDescriptor> m_approachDescriptor = nullptr;
0260 
0261   /// the enclosing TrackingVolume
0262   const TrackingVolume* m_trackingVolume = nullptr;
0263 
0264   /// Representing Volume
0265   /// can be used as approach surface sources
0266   std::unique_ptr<Volume> m_representingVolume = nullptr;
0267 
0268   /// make a passive/active either way
0269   LayerType m_layerType;
0270 
0271   /// sub structure indication
0272   int m_ssRepresentingSurface = 0;
0273   int m_ssSensitiveSurfaces = 0;
0274   int m_ssApproachSurfaces = 0;
0275 
0276  private:
0277   /// Private helper method to close the geometry
0278   /// - it will assign material to the surfaces if needed
0279   /// - it will set the layer geometry ID for a unique identification
0280   /// - it will also register the internal sub structure
0281   ///
0282   /// @param materialDecorator is a decorator that assigns
0283   ///        optionally the surface material to where they belong
0284   /// @param layerID is the geometry id of the volume
0285   ///                as calculated by the TrackingGeometry
0286   /// @param hook Identifier hook to be applied to surfaces
0287   /// @param logger A @c Logger instance
0288   ///
0289   void closeGeometry(const IMaterialDecorator* materialDecorator,
0290                      const GeometryIdentifier& layerID,
0291                      const GeometryIdentifierHook& hook,
0292                      const Logger& logger = getDummyLogger());
0293 };
0294 
0295 /// Layers are constructed with shared_ptr factories, hence the layer array is
0296 /// describes as:
0297 using LayerArray = BinnedArray<LayerPtr>;
0298 
0299 }  // namespace Acts
0300 
0301 #include "Acts/Geometry/detail/Layer.ipp"