Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:23:22

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2022 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/Detector/ProtoDetector.hpp"
0013 #include "Acts/Geometry/GeometryContext.hpp"
0014 #include "Acts/Geometry/GeometryIdentifier.hpp"
0015 #include "Acts/Geometry/ITrackingGeometryBuilder.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   using SurfaceKDT =
0061       KDTree<2u, std::shared_ptr<Surface>, ActsScalar, std::array, 100>;
0062 
0063   /// Constructor
0064   ///
0065   /// @param [in] cfg is the configuration struct for this builder
0066   /// @param [in] logger logging instance
0067   KDTreeTrackingGeometryBuilder(
0068       const Config& cfg,
0069       std::unique_ptr<const Logger> logger =
0070           getDefaultLogger("KDTreeTrackingGeometryBuilder", Logging::INFO));
0071 
0072   /// TrackingGeometry Interface method
0073   ///
0074   /// @param gctx geometry context of that building call
0075   ///
0076   /// @return a unique pointer to a TrackingGeometry
0077   std::unique_ptr<const TrackingGeometry> trackingGeometry(
0078       const GeometryContext& gctx) const final;
0079 
0080  private:
0081   /// Configuration member
0082   Config m_cfg;
0083 
0084   /// Private access method to the logger
0085   const Logger& logger() const { return *m_logger; }
0086 
0087   /// the logging instance
0088   std::unique_ptr<const Logger> m_logger;
0089 
0090   /// Private construction cache
0091   struct Cache {
0092     std::size_t surfaceCounter = 0;
0093   };
0094 
0095   /// Translate a proto tracking volume into a Acts::TrackingVolume
0096   ///
0097   /// @param cCache is a cache used to extract the built detector elements
0098   /// @param gctx is the current geometry context at building
0099   /// @param kdt is the pre-filled kdt tree for the surface query
0100   /// @param ptVolume the proto volume to be translated
0101   /// @param indent is a screen output indentation
0102   ///
0103   /// @return a new tracking volume
0104   std::shared_ptr<TrackingVolume> translateVolume(
0105       Cache& cCache, const GeometryContext& gctx, const SurfaceKDT& kdt,
0106       const ProtoVolume& ptVolume, const std::string& indent = "") const;
0107 
0108   /// Translate a layer volume
0109   ///
0110   /// @param cCache is a cache used to extract the built detector elements
0111   /// @param gctx is the current geometry context at building
0112   /// @param kdt is the pre-filled kdt tree for the surface query
0113   /// @param plVolume the proto volume representation a layer to be translated
0114   /// @param indent is a screen output indentation
0115   ///
0116   /// @return a new tracking volume
0117   std::shared_ptr<const Layer> translateLayer(
0118       Cache& cCache, const GeometryContext& gctx, const SurfaceKDT& kdt,
0119       const ProtoVolume& plVolume, const std::string& indent = "") const;
0120 };
0121 
0122 }  // namespace Acts