Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:22:24

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/GeometryContext.hpp"
0013 #include "Acts/Geometry/GeometryIdentifier.hpp"
0014 #include "Acts/Geometry/ITrackingGeometryBuilder.hpp"
0015 #include "Acts/Geometry/ProtoDetector.hpp"
0016 #include "Acts/Geometry/TrackingGeometryBuilder.hpp"
0017 #include "Acts/Utilities/KDTree.hpp"
0018 #include "Acts/Utilities/Logger.hpp"
0019 
0020 #include <array>
0021 #include <cstddef>
0022 #include <memory>
0023 #include <string>
0024 #include <vector>
0025 
0026 namespace Acts {
0027 
0028 class TrackingGeometry;
0029 class Layer;
0030 class LayerCreator;
0031 class Surface;
0032 class ITrackingVolumeHelper;
0033 class TrackingVolume;
0034 
0035 /// A Tracking Geometry builder restricted to cylindrical geometries
0036 ///
0037 /// It takes some helper tools and a vector of surface objects,
0038 /// together with a ProtoDetector description that is used to query a
0039 /// KDTree for contained surfaces in structures defined by the proto
0040 /// volume.
0041 class KDTreeTrackingGeometryBuilder : public ITrackingGeometryBuilder {
0042  public:
0043   /// Nested Configuration for this TrackingGeometryBuilder
0044   struct Config {
0045     /// The tracking volume helper for detector construction
0046     std::shared_ptr<const ITrackingVolumeHelper> trackingVolumeHelper = nullptr;
0047     /// The layer creator - for sensitives
0048     std::shared_ptr<const LayerCreator> layerCreator = nullptr;
0049     /// The created surfaces
0050     std::vector<std::shared_ptr<Surface>> surfaces = {};
0051     /// The proto tracking geometry description
0052     ProtoDetector protoDetector;
0053     /// Optional geometry identifier hook to be used during closure
0054     std::shared_ptr<const GeometryIdentifierHook> geometryIdentifierHook =
0055         std::make_shared<GeometryIdentifierHook>();
0056     /// For screen output
0057     std::string hierarchyIndent = "  ";
0058   };
0059 
0060   /// Type alias for 2D KDTree containing surface pointers
0061   using SurfaceKDT =
0062       KDTree<2u, std::shared_ptr<Surface>, double, std::array, 100>;
0063 
0064   /// Constructor
0065   ///
0066   /// @param [in] cfg is the configuration struct for this builder
0067   /// @param [in] logger logging instance
0068   explicit KDTreeTrackingGeometryBuilder(
0069       const Config& cfg,
0070       std::unique_ptr<const Logger> logger =
0071           getDefaultLogger("KDTreeTrackingGeometryBuilder", Logging::INFO));
0072 
0073   /// TrackingGeometry Interface method
0074   ///
0075   /// @param gctx geometry context of that building call
0076   ///
0077   /// @return a unique pointer to a TrackingGeometry
0078   std::unique_ptr<const TrackingGeometry> trackingGeometry(
0079       const GeometryContext& gctx) const final;
0080 
0081  private:
0082   /// Configuration member
0083   Config m_cfg;
0084 
0085   /// Private access method to the logger
0086   const Logger& logger() const { return *m_logger; }
0087 
0088   /// the logging instance
0089   std::unique_ptr<const Logger> m_logger;
0090 
0091   /// Private construction cache
0092   struct Cache {
0093     std::size_t surfaceCounter = 0;
0094   };
0095 
0096   /// Translate a proto tracking volume into a Acts::TrackingVolume
0097   ///
0098   /// @param cCache is a cache used to extract the built detector elements
0099   /// @param gctx is the current geometry context at building
0100   /// @param kdt is the pre-filled kdt tree for the surface query
0101   /// @param ptVolume the proto volume to be translated
0102   /// @param indent is a screen output indentation
0103   ///
0104   /// @return a new tracking volume
0105   std::shared_ptr<TrackingVolume> translateVolume(
0106       Cache& cCache, const GeometryContext& gctx, const SurfaceKDT& kdt,
0107       const ProtoVolume& ptVolume, const std::string& indent = "") const;
0108 
0109   /// Translate a layer volume
0110   ///
0111   /// @param cCache is a cache used to extract the built detector elements
0112   /// @param gctx is the current geometry context at building
0113   /// @param kdt is the pre-filled kdt tree for the surface query
0114   /// @param plVolume the proto volume representation a layer to be translated
0115   /// @param indent is a screen output indentation
0116   ///
0117   /// @return a new tracking volume
0118   std::shared_ptr<const Layer> translateLayer(
0119       Cache& cCache, const GeometryContext& gctx, const SurfaceKDT& kdt,
0120       const ProtoVolume& plVolume, const std::string& indent = "") const;
0121 };
0122 
0123 }  // namespace Acts