Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:27:39

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