Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-16 07:35:13

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