Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-12 09:39:37

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/ProtoLayer.hpp"
0015 #include "Acts/Surfaces/SurfaceArray.hpp"
0016 #include "Acts/Utilities/AxisDefinitions.hpp"
0017 #include "Acts/Utilities/BinningType.hpp"
0018 #include "Acts/Utilities/Logger.hpp"
0019 
0020 #include <cstddef>
0021 #include <memory>
0022 #include <optional>
0023 #include <vector>
0024 
0025 namespace ActsTests {
0026 struct LayerCreatorFixture;
0027 }
0028 
0029 namespace Acts {
0030 
0031 class Surface;
0032 class SurfaceArray;
0033 class SurfaceArrayCreator;
0034 class Layer;
0035 
0036 using MutableLayerPtr = std::shared_ptr<Layer>;
0037 
0038 /// @class LayerCreator
0039 ///
0040 /// The LayerCreator is able to build cylinder disc layers or plane layers from
0041 /// detector elements
0042 ///
0043 class LayerCreator {
0044  public:
0045   friend ActsTests::LayerCreatorFixture;
0046   ///  @struct Config
0047   ///  Configuration for the LayerCreator
0048   ///  This is the nested configuration struct for the LayerCreator class
0049   struct Config {
0050     /// surface array helper
0051     std::shared_ptr<const SurfaceArrayCreator> surfaceArrayCreator = nullptr;
0052     /// cylinder module z tolerance: it counts as same z, if ...
0053     double cylinderZtolerance{10.};
0054     /// cylinder module phi tolerance: it counts as same phi, if ...
0055     double cylinderPhiTolerance{0.1};
0056     /// Default z envelope. Can be overridden by proto layer
0057     Envelope defaultEnvelopeZ = zeroEnvelope;
0058     /// Default r envelope. Can be overridden by proto layer
0059     Envelope defaultEnvelopeR = zeroEnvelope;
0060   };
0061 
0062   /// Constructor
0063   ///
0064   /// @param lcConfig is the configuration object
0065   /// @param logger logging instance
0066   explicit LayerCreator(const Config& lcConfig,
0067                         std::unique_ptr<const Logger> logger =
0068                             getDefaultLogger("LayerCreator", Logging::INFO));
0069 
0070   /// returning a cylindrical layer
0071   ///
0072   /// @param gctx is the geometry context with which the geometry is built
0073   /// @param surfaces is the vector of pointers to sensitive surfaces
0074   /// represented by this layer
0075   /// @pre the pointers to the sensitive surfaces in the surfaces vectors all
0076   /// need to be valid, since no check is performed
0077   /// @param binsPhi is number of bins the sensitive surfaces are ordered in phi
0078   /// @param binsZ is number of bins the sensitive surfaces are ordered in Z
0079   /// @param _protoLayer (optional) proto layer specifying the dimensions and
0080   /// envelopes
0081   /// @param transform is the (optional) transform of the layer
0082   /// @param ad possibility to hand over a specific ApproachDescriptor, which is
0083   /// needed for material mapping. Otherwise the default ApproachDescriptor will
0084   /// be taken used for this layer
0085   /// @param neighborWindow Bounds on the neighbor window the lookup derives
0086   ///        from the crossing angle, in bins per grid axis (phi, z)
0087   /// @param overfill Extra cells per direction and axis to fill around each matched cell
0088   ///
0089   /// @return shared pointer to a newly created layer
0090   MutableLayerPtr cylinderLayer(
0091       const GeometryContext& gctx,
0092       std::vector<std::shared_ptr<const Surface>> surfaces, std::size_t binsPhi,
0093       std::size_t binsZ, std::optional<ProtoLayer> _protoLayer = std::nullopt,
0094       const Transform3& transform = Transform3::Identity(),
0095       std::unique_ptr<ApproachDescriptor> ad = nullptr,
0096       SurfaceArray::NeighborWindow neighborWindow = {{0, 0}, {1, 2}},
0097       std::uint8_t overfill = 0) const;
0098 
0099   /// returning a cylindrical layer
0100   ///
0101   /// @param gctx is the geometry context with which the geometry is built
0102   /// @param surfaces is the vector of pointers to sensitive surfaces
0103   /// represented by this layer
0104   /// @pre the pointers to the sensitive surfaces in the surfaces vectors all
0105   /// need to be valid, since no check is performed
0106   /// @param bTypePhi binning type in phi (equidistant/arbitrary)
0107   /// @param bTypeZ binning type in z (equidistant/arbitrary)
0108   /// @param _protoLayer (optional) proto layer specifying the dimensions and
0109   /// envelopes
0110   /// @param transform is the (optional) transform of the layer
0111   /// @param ad possibility to hand over a specific ApproachDescriptor, which is
0112   /// needed for material mapping. Otherwise the default ApproachDescriptor will
0113   /// be taken used for this layer
0114   /// @param neighborWindow Bounds on the neighbor window the lookup derives
0115   ///        from the crossing angle, in bins per grid axis (phi, z)
0116   /// @param overfill Extra cells per direction and axis to fill around each matched cell
0117   ///
0118   /// @return shared pointer to a newly created layer
0119   MutableLayerPtr cylinderLayer(
0120       const GeometryContext& gctx,
0121       std::vector<std::shared_ptr<const Surface>> surfaces,
0122       BinningType bTypePhi, BinningType bTypeZ,
0123       std::optional<ProtoLayer> _protoLayer = std::nullopt,
0124       const Transform3& transform = Transform3::Identity(),
0125       std::unique_ptr<ApproachDescriptor> ad = nullptr,
0126       SurfaceArray::NeighborWindow neighborWindow = {{0, 0}, {1, 2}},
0127       std::uint8_t overfill = 0) const;
0128 
0129   /// returning a disc layer
0130   ///
0131   /// @param gctx is the geometry context with which the geometry is built
0132   /// @param surfaces is the vector of pointers to sensitive surfaces
0133   /// represented by this layer
0134   /// @pre the pointers to the sensitive surfaces in the surfaces vectors all
0135   /// need to be valid, since no check is performed
0136   /// @param binsR is number of bins the sensitive surfaces are ordered in R
0137   /// @param binsPhi is number of bins the sensitive surfaces are ordered in Phi
0138   /// @param transform is the (optional) transform of the layer
0139   /// @param _protoLayer (optional) proto layer specifying the dimensions and
0140   /// envelopes
0141   /// @param ad possibility to hand over a specific ApproachDescriptor, which is
0142   /// needed for material mapping. Otherwise the default ApproachDescriptor will
0143   /// be taken used for this layer
0144   /// @param neighborWindow Bounds on the neighbor window the lookup derives
0145   ///        from the crossing angle, in bins per grid axis (r, phi)
0146   /// @param overfill Extra cells per direction and axis to fill around each matched cell
0147   ///
0148   /// @return shared pointer to a newly created layer
0149   MutableLayerPtr discLayer(
0150       const GeometryContext& gctx,
0151       std::vector<std::shared_ptr<const Surface>> surfaces, std::size_t binsR,
0152       std::size_t binsPhi, std::optional<ProtoLayer> _protoLayer = std::nullopt,
0153       const Transform3& transform = Transform3::Identity(),
0154       std::unique_ptr<ApproachDescriptor> ad = nullptr,
0155       SurfaceArray::NeighborWindow neighborWindow = {{0, 0}, {2, 1}},
0156       std::uint8_t overfill = 0) const;
0157 
0158   /// returning a disc layer
0159   ///
0160   /// @param gctx is the geometry context with which the geometry is built
0161   /// @param surfaces is the vector of pointers to sensitive surfaces
0162   /// represented by this layer
0163   /// @pre the pointers to the sensitive surfaces in the surfaces vectors all
0164   /// need to be valid, since no check is performed
0165   /// @param bTypeR binning type in r (equidistant/arbitrary)
0166   /// @param bTypePhi binning type in phi (equidistant/arbitrary)
0167   /// @param transform is the (optional) transform of the layer
0168   /// @param _protoLayer (optional) proto layer specifying the dimensions and
0169   /// envelopes
0170   /// @param ad possibility to hand over a specific ApproachDescriptor, which is
0171   /// needed for material mapping. Otherwise the default ApproachDescriptor will
0172   /// be taken used for this layer
0173   /// @param neighborWindow Bounds on the neighbor window the lookup derives
0174   ///        from the crossing angle, in bins per grid axis (r, phi)
0175   /// @param overfill Extra cells per direction and axis to fill around each matched cell
0176   ///
0177   /// @return shared pointer to a newly created layer
0178   MutableLayerPtr discLayer(
0179       const GeometryContext& gctx,
0180       std::vector<std::shared_ptr<const Surface>> surfaces, BinningType bTypeR,
0181       BinningType bTypePhi,
0182       std::optional<ProtoLayer> _protoLayer = std::nullopt,
0183       const Transform3& transform = Transform3::Identity(),
0184       std::unique_ptr<ApproachDescriptor> ad = nullptr,
0185       SurfaceArray::NeighborWindow neighborWindow = {{0, 0}, {2, 1}},
0186       std::uint8_t overfill = 0) const;
0187 
0188   /// returning a plane layer
0189   ///
0190   /// @param gctx is the geometry context with which the geometry is built
0191   /// @param [in] surfaces is the vector of pointers to sensitive surfaces
0192   /// represented by this layer
0193   /// @pre the pointers to the sensitive surfaces in the surfaces vectors all
0194   /// need to be valid, since no check is performed
0195   /// @param [in] bins1 is the number of bins in the orthogonal direction to @p
0196   /// bValue
0197   /// @param [in] bins2 is the number of bins in the orthogonal direction to @p
0198   /// bValue
0199   /// @param [in] aDir Direction of the aligned surfaces
0200   /// @param [in] transform is the (optional) transform of the layer
0201   /// @param [in] _protoLayer (optional) proto layer specifying the dimensions
0202   /// and
0203   /// envelopes
0204   /// @param [in] ad possibility to hand over a specific ApproachDescriptor,
0205   /// which is needed for material mapping. Otherwise the default
0206   /// ApproachDescriptor will be taken used for this layer
0207   /// @param neighborWindow Bounds on the neighbor window the lookup derives
0208   ///        from the crossing angle, in bins per grid axis
0209   /// @param overfill Extra cells per direction and axis to fill around each matched cell
0210   ///
0211   /// @return shared pointer to a newly created layer
0212   MutableLayerPtr planeLayer(
0213       const GeometryContext& gctx,
0214       std::vector<std::shared_ptr<const Surface>> surfaces, std::size_t bins1,
0215       std::size_t bins2, AxisDirection aDir,
0216       std::optional<ProtoLayer> _protoLayer = std::nullopt,
0217       const Transform3& transform = Transform3::Identity(),
0218       std::unique_ptr<ApproachDescriptor> ad = nullptr,
0219       SurfaceArray::NeighborWindow neighborWindow = {{0, 0}, {2, 2}},
0220       std::uint8_t overfill = 0) const;
0221 
0222   /// Set the configuration object
0223   /// @param lcConfig is the configuration struct
0224   void setConfiguration(const Config& lcConfig);
0225 
0226   /// Access the configuration object
0227   /// @return Copy of the current configuration object
0228   Config getConfiguration() const;
0229 
0230   /// set logging instance
0231   /// @param newLogger the logger instance
0232   void setLogger(std::unique_ptr<const Logger> newLogger);
0233 
0234   /// associate surfaces contained by this layer to this layer
0235   /// @param layer Layer to associate surfaces with
0236   void associateSurfacesToLayer(Layer& layer) const;
0237 
0238  private:
0239   /// configuration object
0240   Config m_cfg;
0241 
0242   /// Private access method to the logger
0243   const Logger& logger() const { return *m_logger; }
0244 
0245   /// logging instance
0246   std::unique_ptr<const Logger> m_logger;
0247 };
0248 
0249 inline LayerCreator::Config LayerCreator::getConfiguration() const {
0250   return m_cfg;
0251 }
0252 
0253 }  // namespace Acts