Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:41:14

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/Detector/DetectorComponents.hpp"
0013 #include "Acts/Detector/ProtoSupport.hpp"
0014 #include "Acts/Detector/detail/ReferenceGenerators.hpp"
0015 #include "Acts/Detector/interface/IInternalStructureBuilder.hpp"
0016 #include "Acts/Detector/interface/ISurfacesProvider.hpp"
0017 #include "Acts/Geometry/GeometryContext.hpp"
0018 #include "Acts/Surfaces/Surface.hpp"
0019 #include "Acts/Utilities/Logger.hpp"
0020 #include "Acts/Utilities/ProtoAxis.hpp"
0021 
0022 #include <array>
0023 #include <cstddef>
0024 #include <functional>
0025 #include <memory>
0026 #include <optional>
0027 #include <string>
0028 #include <tuple>
0029 #include <vector>
0030 
0031 namespace Acts::Experimental {
0032 
0033 /// @brief This is a builder of layer structures to be contained
0034 /// within a DetectorVolume, it extends the IInternalStructureBuilder
0035 /// interface and provides the internal structure components of
0036 /// DetectorVolume objects to be constructed.
0037 ///
0038 /// It uses the IndexedSurfaceGrid to bin the internal surfaces,
0039 /// and allows for additional support surfaces that are added to the
0040 /// structure and indexing mechanism. Those support structures can
0041 /// also be approximated by planar surfaces, in order to facilitate
0042 /// vectorization of surface intersection calls.
0043 ///
0044 /// The binning can be chosen with a so called `expansion`, a number
0045 /// which indicates the configured expanded bin window in which the
0046 /// surfaces are going to be filled, the details to this strategy
0047 /// can be found in the IndexedGridFiller and IndexedSurfacesGenerator
0048 /// classes.
0049 ///
0050 /// No sub volumes are added to this structure builders, hence,
0051 /// the DetectorVolumeFinder navigation delegate uses the "NoopFinder"
0052 /// breakpoint to indicate the bottom of the volume hierarchy.
0053 ///
0054 class LayerStructureBuilder : public IInternalStructureBuilder {
0055  public:
0056   /// @brief A holder struct for surfaces
0057   class SurfacesHolder final : public ISurfacesProvider {
0058    public:
0059     /// Constructor with predefined surfaces
0060     /// @param isurfaces is the vector of surfaces
0061     explicit SurfacesHolder(std::vector<std::shared_ptr<Surface>> isurfaces)
0062         : m_surfaces(std::move(isurfaces)) {}
0063 
0064     /// Return the surfaces from the holder
0065     /// @param gctx is the geometry context
0066     /// @return Vector of surfaces held by this holder
0067     std::vector<std::shared_ptr<Surface>> surfaces(
0068         [[maybe_unused]] const GeometryContext& gctx) const final {
0069       return m_surfaces;
0070     }
0071 
0072    private:
0073     std::vector<std::shared_ptr<Surface>> m_surfaces = {};
0074   };
0075 
0076   /// @brief Configuration struct for the LayerStructureBuilder
0077   ///
0078   /// It contain:
0079   /// - a source of the surfaces to be built
0080   /// - a definition of surface binning on this layer
0081   /// - a definition of supports to be built
0082   struct Config {
0083     /// Connection point for a function to provide surfaces
0084     std::shared_ptr<ISurfacesProvider> surfacesProvider = nullptr;
0085     /// Definition of Supports
0086     std::vector<ProtoSupport> supports = {};
0087     /// Definition of Binnings
0088     std::vector<std::tuple<DirectedProtoAxis, std::size_t>> binnings = {};
0089     /// Expansion value for the reference generation
0090     double expansionValue = 0.0;
0091     /// Sampling the luminous region for projected reference generation
0092     std::vector<Vector3> luminousRegion = {Vector3(0., 0., -200.),
0093                                            Vector3(0., 0., 200.)};
0094     /// Reference generator to be used
0095     detail::ReferenceGeneratorType referenceGeneratorType =
0096         detail::ReferenceGeneratorType::Polyhedron;
0097     /// Projection surface for projected reference generator
0098     std::shared_ptr<Surface> projectionReferenceSurface = nullptr;
0099     /// Optional extent (if already parsed), will trigger binning autorange
0100     /// check
0101     std::optional<Extent> extent = std::nullopt;
0102     /// Minimum number of surfaces to build an internal structure
0103     /// - otherwise the tryAll options is used
0104     unsigned int nMinimalSurfaces = 4u;
0105     /// Polyhedron approximations: number of segments to be used
0106     /// to approximate a quarter of a circle
0107     unsigned int quarterSegments = 1u;
0108     /// Extra information, mainly for screen output
0109     std::string auxiliary = "";
0110   };
0111 
0112   /// Constructor
0113   ///
0114   /// @param cfg is the configuration struct
0115   /// @param logger logging instance for screen output
0116   explicit LayerStructureBuilder(const Config& cfg,
0117                                  std::unique_ptr<const Logger> logger =
0118                                      getDefaultLogger("LayerStructureBuilder",
0119                                                       Logging::INFO));
0120 
0121   /// The interface definition for internal structure creation
0122   ///
0123   /// @param gctx the geometry context at the creation of the internal structure
0124   ///
0125   /// This will take the surfaces from the surfaces provider and use the binning
0126   /// description to create an internal indexed surface structure.
0127   ///
0128   /// @note if the configuration provides an extent, the range of the binning
0129   ///      will be checked againstit and adapted if necessary
0130   ///
0131   /// @return a consistent set of detector volume internals
0132   InternalStructure construct(const GeometryContext& gctx) const final;
0133 
0134  private:
0135   /// Configuration object
0136   Config m_cfg;
0137 
0138   /// Private access method to the logger
0139   const Logger& logger() const { return *m_logger; }
0140 
0141   /// Logging instance
0142   std::unique_ptr<const Logger> m_logger;
0143 };
0144 
0145 }  // namespace Acts::Experimental