Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-03-28 07:45:25

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/Seeding2/GbtsLayerConnection.hpp"
0012 
0013 #include <cstdint>
0014 #include <map>
0015 #include <unordered_map>
0016 #include <vector>
0017 
0018 namespace Acts::Experimental {
0019 
0020 /// GBTS layer types
0021 enum class GbtsLayerType { Barrel = 0, Endcap = 1 };
0022 
0023 /// Lightweight layer description for GBTS geometry.
0024 struct GbtsLayerDescription final {
0025   /// Combined subdetector ID.
0026   std::int32_t id{};
0027   /// Layer type (barrel or endcap).
0028   GbtsLayerType type{};
0029   /// Reference coordinate (z for barrel, r for endcap).
0030   float refCoord{};
0031   /// Minimum boundary coordinate.
0032   float minBound{};
0033   /// Maximum boundary coordinate.
0034   float maxBound{};
0035 };
0036 
0037 /// Layer helper with eta-bin access for GBTS seeding.
0038 class GbtsLayer final {
0039  public:
0040   /// @param layerDescription Layer description for the layer
0041   /// @param etaBinWidth Eta bin width
0042   /// @param bin0 Starting bin index
0043   GbtsLayer(const GbtsLayerDescription& layerDescription, float etaBinWidth,
0044             std::int32_t bin0);
0045 
0046   /// Get eta bin for given z and r coordinates
0047   /// @param zh Z coordinate
0048   /// @param rh Radius coordinate
0049   /// @return Eta bin index
0050   std::int32_t getEtaBin(float zh, float rh) const;
0051 
0052   /// Get number of bins
0053   /// @return Number of bins
0054   std::int32_t numOfBins() const { return m_bins.size(); }
0055 
0056   /// Get bins
0057   /// @return Vector of bin indices
0058   const std::vector<std::int32_t>& bins() const { return m_bins; }
0059 
0060   /// Get the layer description
0061   /// @return Reference to the layer description
0062   const GbtsLayerDescription& layerDescription() const {
0063     return m_layerDescription;
0064   }
0065 
0066   /// Verify bin compatibility
0067   /// @param otherLayer Other layer to compare with
0068   /// @param b1 First bin index
0069   /// @param b2 Second bin index
0070   /// @param minZ0 Minimum z0 coordinate
0071   /// @param maxZ0 Maximum z0 coordinate
0072   /// @return True if bins are compatible
0073   bool checkCompatibility(const GbtsLayer& otherLayer, std::uint32_t b1,
0074                           std::uint32_t b2, float minZ0, float maxZ0) const;
0075 
0076  private:
0077   /// Layer description
0078   GbtsLayerDescription m_layerDescription;
0079 
0080   /// Eta-bin indices
0081   std::vector<std::int32_t> m_bins;
0082   /// Minimum radius per bin
0083   std::vector<float> m_minRadius;
0084   /// Maximum radius per bin
0085   std::vector<float> m_maxRadius;
0086   /// Minimum bin coordinate
0087   std::vector<float> m_minBinCoord;
0088   /// Maximum bin coordinate
0089   std::vector<float> m_maxBinCoord;
0090 
0091   /// Minimum eta
0092   float m_minEta{};
0093   /// Maximum eta
0094   float m_maxEta{};
0095   /// Eta bin
0096   float m_etaBin{};
0097   /// First radius coordinate
0098   float m_r1{};
0099   /// First z coordinate
0100   float m_z1{};
0101   /// Second radius coordinate
0102   float m_r2{};
0103   /// Second z coordinate
0104   float m_z2{};
0105   /// Number of bins
0106   std::uint32_t m_nBins{};
0107 };
0108 
0109 /// Geometry helper built from layers and connectors.
0110 class GbtsGeometry final {
0111   // map key is a bin
0112   // pair corresponds to outgoing and incoming bins that the current bin can
0113   // connect to
0114   using BinConnections =
0115       std::unordered_map<std::uint32_t, std::pair<std::vector<std::uint32_t>,
0116                                                   std::vector<std::uint32_t>>>;
0117 
0118  public:
0119   /// Constructor
0120   /// @param layerDescriptions Layer descriptions for the layers
0121   /// @param layerConnections Layer connections map
0122   GbtsGeometry(const std::vector<GbtsLayerDescription>& layerDescriptions,
0123                const GbtsLayerConnectionMap& layerConnections);
0124 
0125   /// Get number of eta bins
0126   /// @return Number of eta bins
0127   std::uint32_t numBins() const { return m_nEtaBins; }
0128 
0129   /// Get number of layers
0130   /// @return Number of layers
0131   std::uint32_t numLayers() const { return m_layers.size(); }
0132 
0133   /// Get bin groups
0134   /// @return Bin groups vector
0135   const std::vector<std::pair<std::uint32_t, std::vector<std::uint32_t>>>&
0136   binGroups() const {
0137     return m_binGroups;
0138   }
0139 
0140   /// Get layer by ID
0141   /// @param id Layer ID
0142   /// @return Pointer to layer or nullptr
0143   const GbtsLayer* layerById(std::uint32_t id) const;
0144 
0145   /// Get layer by index
0146   /// @param idx Layer index
0147   /// @return Reference to layer
0148   const GbtsLayer& layerByIndex(std::int32_t idx) const;
0149 
0150   /// Get layer ID by index
0151   /// @param idx Layer index
0152   /// @return Layer ID
0153   inline std::uint32_t layerIdByIndex(std::uint32_t idx) const {
0154     return m_layers.at(idx).layerDescription().id;
0155   }
0156 
0157  private:
0158   /// @param layerDescription Layer description for the layer
0159   /// @param bin0 Starting bin index
0160   /// @return Reference to the newly added layer
0161   const GbtsLayer& createLayer(const GbtsLayerDescription& layerDescription,
0162                                std::uint32_t bin0);
0163 
0164   /// Eta bin width
0165   float m_etaBinWidth{};
0166 
0167   /// Layer array
0168   std::vector<GbtsLayer> m_layers;
0169   /// Layer per user ID map
0170   std::map<std::uint32_t, std::uint32_t> m_layerFromUserIdMap;
0171   /// Number of eta bins
0172   std::uint32_t m_nEtaBins{};
0173 
0174   /// Bin groups
0175   std::vector<std::pair<std::uint32_t, std::vector<std::uint32_t>>> m_binGroups;
0176 };
0177 
0178 }  // namespace Acts::Experimental