Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-17 07:59:45

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/EventData/SeedContainer2.hpp"
0012 #include "Acts/EventData/SpacePointContainer2.hpp"
0013 #include "Acts/Seeding2/GbtsConfig.hpp"
0014 #include "Acts/Seeding2/GbtsDataStorage.hpp"
0015 #include "Acts/Seeding2/GbtsGeometry.hpp"
0016 #include "Acts/Seeding2/RoiDescriptor.hpp"
0017 #include "Acts/Utilities/Logger.hpp"
0018 
0019 #include <cstdint>
0020 #include <memory>
0021 #include <string>
0022 #include <utility>
0023 #include <vector>
0024 
0025 namespace Acts::Experimental {
0026 
0027 /// Seed finder implementing the GBTS seeding workflow.
0028 class GraphBasedTrackSeeder {
0029  public:
0030   /// Seed metadata produced by the GBTS algorithm.
0031   struct SeedProperties {
0032     /// Constructor.
0033     /// @param quality Seed quality score
0034     /// @param clone Clone flag
0035     /// @param sps Space point indices
0036     SeedProperties(float quality, std::int32_t clone,
0037                    std::vector<std::uint32_t> sps)
0038         : seedQuality(quality), isClone(clone), spacePoints(std::move(sps)) {}
0039 
0040     /// Seed quality score.
0041     float seedQuality{};
0042     /// Clone flag.
0043     std::int32_t isClone{};
0044     /// Space point indices.
0045     std::vector<std::uint32_t> spacePoints;
0046 
0047     /// Comparison operator.
0048     /// @param o Other seed properties to compare
0049     /// @return True if this is less than other
0050     auto operator<=>(const SeedProperties& o) const = default;
0051   };
0052 
0053   /// Sliding window in phi used to define range used for edge creation
0054   struct SlidingWindow {
0055     /// sliding window position
0056     std::uint32_t firstIt{};
0057     /// window half-width;
0058     float deltaPhi{};
0059     /// active or not
0060     bool hasNodes{};
0061     /// associated eta bin
0062     const GbtsEtaBin* bin{};
0063   };
0064 
0065   /// Constructor.
0066   /// @param config Configuration for the seed finder
0067   /// @param gbtsGeo GBTS geometry
0068   /// @param layerGeometry Layer geometry information
0069   /// @param logger Logging instance
0070   GraphBasedTrackSeeder(const GbtsConfig& config,
0071                         std::unique_ptr<GbtsGeometry> gbtsGeo,
0072                         const std::vector<TrigInDetSiLayer>& layerGeometry,
0073                         std::unique_ptr<const Acts::Logger> logger =
0074                             Acts::getDefaultLogger("Finder",
0075                                                    Acts::Logging::Level::INFO));
0076 
0077   /// Create seeds from space points in a region of interest.
0078   /// @param roi Region of interest descriptor
0079   /// @param spacePoints Space point container
0080   /// @param maxLayers Maximum number of layers
0081   /// @return Container with generated seeds
0082   SeedContainer2 createSeeds(const RoiDescriptor& roi,
0083                              const SpacePointContainer2& spacePoints,
0084                              std::uint32_t maxLayers) const;
0085 
0086  private:
0087   GbtsConfig m_cfg{};
0088 
0089   const std::shared_ptr<const GbtsGeometry> m_geo;
0090 
0091   const std::vector<TrigInDetSiLayer>* m_layerGeometry{};
0092 
0093   GbtsMlLookupTable m_mlLut;
0094 
0095   std::unique_ptr<const Acts::Logger> m_logger =
0096       Acts::getDefaultLogger("Finder", Acts::Logging::Level::INFO);
0097 
0098   const Acts::Logger& logger() const { return *m_logger; }
0099 
0100   /// Create graph nodes from space points.
0101   /// @param spacePoints Space point container
0102   /// @param maxLayers Maximum number of layers
0103   /// @return Vector of node vectors organized by layer
0104   std::vector<std::vector<GbtsNode>> createNodes(
0105       const SpacePointContainer2& spacePoints, std::uint32_t maxLayers) const;
0106 
0107   /// Parse machine learning lookup table from file.
0108   /// @param lutInputFile Path to the lookup table input file
0109   /// @return Parsed machine learning lookup table
0110   GbtsMlLookupTable parseGbtsMlLookupTable(const std::string& lutInputFile);
0111 
0112   /// Build doublet graph from nodes.
0113   /// @param roi Region of interest descriptor
0114   /// @param storage Data storage containing nodes
0115   /// @param edgeStorage Storage for generated edges
0116   /// @return Pair of edge count and maximum level
0117   std::pair<std::int32_t, std::int32_t> buildTheGraph(
0118       const RoiDescriptor& roi, const std::unique_ptr<GbtsDataStorage>& storage,
0119       std::vector<GbtsEdge>& edgeStorage) const;
0120 
0121   /// Run connected component analysis on the graph.
0122   /// @param nEdges Number of edges in the graph
0123   /// @param edgeStorage Storage containing graph edges
0124   /// @return Number of connected components found
0125   std::int32_t runCCA(std::uint32_t nEdges,
0126                       std::vector<GbtsEdge>& edgeStorage) const;
0127 
0128   /// Extract seed candidates from the graph.
0129   /// @param maxLevel Maximum level in the graph
0130   /// @param nEdges Number of edges
0131   /// @param nHits Number of hits
0132   /// @param edgeStorage Storage containing edges
0133   /// @param vSeedCandidates Output vector for seed candidates
0134   void extractSeedsFromTheGraph(
0135       std::uint32_t maxLevel, std::uint32_t nEdges, std::int32_t nHits,
0136       std::vector<GbtsEdge>& edgeStorage,
0137       std::vector<SeedProperties>& vSeedCandidates) const;
0138 
0139   /// Check to see if z0 of segment is within the expected z range of the
0140   /// beamspot
0141   /// @param z0BitMask Sets allowed bins of allowed z value
0142   /// @param z0 Estimated z0 of segments z value at beamspot
0143   /// @param minZ0 Minimum value of beam spot z coordinate
0144   /// @param z0HistoCoeff Scalfactor that converts z coodindate into bin index
0145   /// @return Whether segment is within beamspot range
0146   bool checkZ0BitMask(std::uint16_t z0BitMask, float z0, float minZ0,
0147                       float z0HistoCoeff) const;
0148 };
0149 
0150 }  // namespace Acts::Experimental