Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:12:54

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