Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:23:22

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2016-2018 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 http://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/BoundaryCheck.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 
0091  public:
0092   /// Default Constructor - deleted
0093   Layer() = delete;
0094 
0095   /// Copy Constructor - deleted
0096   Layer(const Layer&) = delete;
0097 
0098   /// Destructor
0099   virtual ~Layer() = default;
0100 
0101   /// Assignment operator - forbidden, layer assignment must not be ambiguous
0102   ///
0103   /// @param layer is the source layer for assignment
0104   Layer& operator=(const Layer& layer) = delete;
0105 
0106   /// Return the entire SurfaceArray, returns a nullptr if no SurfaceArray
0107   const SurfaceArray* surfaceArray() const;
0108 
0109   /// Non-const version
0110   SurfaceArray* surfaceArray();
0111 
0112   /// Transforms the layer into a Surface representation for extrapolation
0113   /// @note the layer can be hosting many surfaces, but this is the global
0114   /// one to which one can extrapolate
0115   virtual const Surface& surfaceRepresentation() const = 0;
0116 
0117   // Non-const version
0118   virtual Surface& surfaceRepresentation() = 0;
0119 
0120   /// Return the Thickness of the Layer
0121   /// this is by definition along the normal vector of the surfaceRepresentation
0122   double thickness() const;
0123 
0124   /// geometrical isOnLayer() method
0125   ///
0126   /// @note using isOnSurface() with Layer specific tolerance
0127   ///
0128   /// @param gctx The current geometry context object, e.g. alignment
0129   /// @param position is the global position to be checked
0130   /// @param bcheck is the boundary check directive
0131   ///
0132   /// @return boolean that indicates success of the operation
0133   virtual bool isOnLayer(
0134       const GeometryContext& gctx, const Vector3& position,
0135       const BoundaryCheck& bcheck = BoundaryCheck(true)) const;
0136 
0137   /// Return method for the approach descriptor, can be nullptr
0138   const ApproachDescriptor* approachDescriptor() const;
0139 
0140   /// Non-const version of the approach descriptor
0141   ApproachDescriptor* approachDescriptor();
0142 
0143   /// Accept layer according to the following collection directives
0144   ///
0145   /// @tparam options_t Type of the options for navigation
0146   ///
0147   /// @return a boolean whether the layer is accepted for processing
0148   template <typename options_t>
0149   bool resolve(const options_t& options) const {
0150     return resolve(options.resolveSensitive, options.resolveMaterial,
0151                    options.resolvePassive);
0152   }
0153 
0154   /// Accept layer according to the following collection directives
0155   ///
0156   /// @param resolveSensitive is the prescription to find the sensitive surfaces
0157   /// @param resolveMaterial is the precription to find material surfaces
0158   /// @param resolvePassive is the prescription to find all passive surfaces
0159   ///
0160   /// @return a boolean whether the layer is accepted for processing
0161   virtual bool resolve(bool resolveSensitive, bool resolveMaterial,
0162                        bool resolvePassive) const;
0163 
0164   /// @brief Decompose Layer into (compatible) surfaces
0165   ///
0166   /// @param gctx The current geometry context object, e.g. alignment
0167   /// @param position Position parameter for searching
0168   /// @param direction Direction of the parameters for searching
0169   /// @param options The navigation options
0170   ///
0171   /// @return list of intersection of surfaces on the layer
0172   boost::container::small_vector<SurfaceIntersection, 10> compatibleSurfaces(
0173       const GeometryContext& gctx, const Vector3& position,
0174       const Vector3& direction,
0175       const NavigationOptions<Surface>& options) const;
0176 
0177   /// Surface seen on approach
0178   /// for layers without sub structure, this is the surfaceRepresentation
0179   /// for layers with sub structure, this is the approachSurface
0180   ///
0181   /// @param gctx The current geometry context object, e.g. alignment
0182   /// @param position Position for searching
0183   /// @param direction Direction for searching
0184   /// @param options The  navigation options
0185   ///
0186   /// @return the Surface intersection of the approach surface
0187   SurfaceIntersection surfaceOnApproach(
0188       const GeometryContext& gctx, const Vector3& position,
0189       const Vector3& direction, const NavigationOptions<Layer>& options) const;
0190 
0191   /// Fast navigation to next layer
0192   ///
0193   /// @param gctx The current geometry context object, e.g. alignment
0194   /// @param position is the start position for the search
0195   /// @param direction is the direction for the search
0196   ///
0197   /// @return the pointer to the next layer
0198   const Layer* nextLayer(const GeometryContext& gctx, const Vector3& position,
0199                          const Vector3& direction) const;
0200 
0201   /// Get the confining TrackingVolume
0202   ///
0203   /// @return the pointer to the enclosing volume
0204   const TrackingVolume* trackingVolume() const;
0205 
0206   ///  Return the abstract volume that represents the layer
0207   ///
0208   /// @return the representing volume of the layer
0209   const Volume* representingVolume() const;
0210 
0211   /// return the LayerType
0212   LayerType layerType() const;
0213 
0214  protected:
0215   /// Constructor with pointer to SurfaceArray (passing ownership)
0216   ///
0217   /// @param surfaceArray is the array of sensitive surfaces
0218   /// @param thickness is the normal thickness of the Layer
0219   /// @param ades oapproach descriptor
0220   /// @param laytyp is the layer type if active or passive
0221   Layer(std::unique_ptr<SurfaceArray> surfaceArray, 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 = nullptr;
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 = nullptr;
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 = nullptr;
0266 
0267   /// make a passive/active either way
0268   LayerType m_layerType;
0269 
0270   /// sub structure indication
0271   int m_ssRepresentingSurface = 0;
0272   int m_ssSensitiveSurfaces = 0;
0273   int m_ssApproachSurfaces = 0;
0274 
0275  private:
0276   /// Private helper method to close the geometry
0277   /// - it will assign material to the surfaces if needed
0278   /// - it will set the layer geometry ID for a unique identification
0279   /// - it will also register the internal sub structure
0280   ///
0281   /// @param materialDecorator is a decorator that assigns
0282   ///        optionally the surface material to where they belong
0283   /// @param layerID is the geometry id of the volume
0284   ///                as calculated by the TrackingGeometry
0285   /// @param hook Identifier hook to be applied to surfaces
0286   /// @param logger A @c Logger instance
0287   ///
0288   void closeGeometry(const IMaterialDecorator* materialDecorator,
0289                      const GeometryIdentifier& layerID,
0290                      const GeometryIdentifierHook& hook,
0291                      const Logger& logger = getDummyLogger());
0292 };
0293 
0294 /// Layers are constructed with shared_ptr factories, hence the layer array is
0295 /// describes as:
0296 using LayerArray = BinnedArray<LayerPtr>;
0297 
0298 }  // namespace Acts
0299 
0300 #include "Acts/Geometry/detail/Layer.ipp"