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/Seeding2/GbtsConnector.hpp"
0012 
0013 #include <cstdint>
0014 #include <map>
0015 #include <memory>
0016 #include <unordered_map>
0017 #include <vector>
0018 
0019 namespace Acts::Experimental {
0020 
0021 /// Lightweight silicon layer description for GBTS geometry.
0022 struct TrigInDetSiLayer final {
0023   /// Constructor.
0024   /// @param subdet_ Subdetector identifier
0025   /// @param type_ Layer type (0: barrel, +/-n: endcap)
0026   /// @param center_ Reference coordinate
0027   /// @param min_ Minimum boundary
0028   /// @param max_ Maximum boundary
0029   TrigInDetSiLayer(std::int32_t subdet_, std::int16_t type_, float center_,
0030                    float min_, float max_)
0031       : subdet(subdet_),
0032         type(type_),
0033         refCoord(center_),
0034         minBound(min_),
0035         maxBound(max_) {}
0036 
0037   /// Combined subdetector ID.
0038   std::int32_t subdet{};  // combined ID
0039   /// Layer type (0: barrel, +/-n: endcap).
0040   std::int32_t type{};  // 0: barrel, +/-n : endcap
0041   /// Reference coordinate (z for barrel, r for endcap).
0042   float refCoord{};
0043   /// Minimum boundary coordinate.
0044   float minBound{};
0045   /// Maximum boundary coordinate.
0046   float maxBound{};
0047 };
0048 
0049 /// Layer helper with eta-bin access for GBTS seeding.
0050 class GbtsLayer final {
0051  public:
0052   /// Constructor
0053   /// @param ls Silicon layer descriptor
0054   /// @param ew Eta bin width
0055   /// @param bin0 Starting bin index
0056   GbtsLayer(const TrigInDetSiLayer& ls, float ew, std::int32_t bin0);
0057 
0058   // accessors
0059   /// Get eta bin for given z and r coordinates
0060   /// @param zh Z coordinate
0061   /// @param rh Radius coordinate
0062   /// @return Eta bin index
0063   std::int32_t getEtaBin(float zh, float rh) const;
0064 
0065   /// Get minimum radius for bin index
0066   /// @param idx Bin index
0067   /// @return Minimum radius for the bin
0068   float getMinBinRadius(std::int32_t idx) const;
0069   /// Get maximum radius for bin index
0070   /// @param idx Bin index
0071   /// @return Maximum radius for the bin
0072   float getMaxBinRadius(std::int32_t idx) const;
0073 
0074   /// Get number of bins
0075   /// @return Number of bins
0076   std::int32_t numOfBins() const { return m_bins.size(); }
0077 
0078   /// Get bins
0079   /// @return Vector of bin indices
0080   const std::vector<std::int32_t>& getBins() const { return m_bins; }
0081 
0082   /// Get layer
0083   /// @return Reference to the silicon layer
0084   const TrigInDetSiLayer& getLayer() const { return *m_layer; }
0085 
0086   /// Verify bin compatibility
0087   /// @param pL Other layer to compare with
0088   /// @param b1 First bin index
0089   /// @param b2 Second bin index
0090   /// @param minZ0 Minimum z0 coordinate
0091   /// @param maxZ0 Maximum z0 coordinate
0092   /// @return True if bins are compatible
0093   bool verifyBin(const GbtsLayer& pL, std::uint32_t b1, std::uint32_t b2,
0094                  float minZ0, float maxZ0) const;
0095 
0096  private:
0097   /// Layer
0098   const TrigInDetSiLayer* m_layer{};
0099   /// Eta-bin indices
0100   std::vector<std::int32_t> m_bins;
0101   /// Minimum radius per bin
0102   std::vector<float> m_minRadius;
0103   /// Maximum radius per bin
0104   std::vector<float> m_maxRadius;
0105   /// Minimum bin coordinate
0106   std::vector<float> m_minBinCoord;
0107   /// Maximum bin coordinate
0108   std::vector<float> m_maxBinCoord;
0109 
0110   /// Minimum eta
0111   float m_minEta{};
0112   /// Maximum eta
0113   float m_maxEta{};
0114   /// Eta bin
0115   float m_etaBin{};
0116   /// Eta bin width
0117   float m_etaBinWidth{};
0118   /// First radius coordinate
0119   float m_r1{};
0120   /// First z coordinate
0121   float m_z1{};
0122   /// Second radius coordinate
0123   float m_r2{};
0124   /// Second z coordinate
0125   float m_z2{};
0126   /// Number of bins
0127   std::uint32_t m_nBins{};
0128 };
0129 
0130 /// Geometry helper built from silicon layers and connectors.
0131 class GbtsGeometry final {
0132   // map key is a bin
0133   // pair corresponds to outgoing and incoming bins that the current bin can
0134   // connect to
0135   using BinConnections =
0136       std::unordered_map<std::uint32_t, std::pair<std::vector<std::uint32_t>,
0137                                                   std::vector<std::uint32_t>>>;
0138 
0139  public:
0140   /// Constructor
0141   /// @param layerGeometry Silicon layers for geometry
0142   /// @param conn Connector for layer connections
0143   GbtsGeometry(const std::vector<TrigInDetSiLayer>& layerGeometry,
0144                const std::unique_ptr<GbtsConnector>& conn);
0145 
0146   /// Get layer by key
0147   /// @param key Layer key
0148   /// @return Pointer to layer or nullptr
0149   const GbtsLayer* getGbtsLayerByKey(std::uint32_t key) const;
0150   /// Get layer by index
0151   /// @param idx Layer index
0152   /// @return Reference to layer
0153   const GbtsLayer& getGbtsLayerByIndex(std::int32_t idx) const;
0154 
0155   /// Get layer key by index
0156   /// @param idx Layer index
0157   /// @return Layer key
0158   inline std::uint32_t getGbtsLayerKeyByIndex(std::uint32_t idx) const {
0159     return m_layerKeys.at(idx);
0160   }
0161 
0162   /// Get number of eta bins
0163   /// @return Number of eta bins
0164   std::uint32_t numBins() const { return m_nEtaBins; }
0165   /// Get number of layers
0166   /// @return Number of layers
0167   std::uint32_t numLayers() const { return m_layArray.size(); }
0168   /// Get bin groups
0169   /// @return Bin groups vector
0170   const std::vector<std::pair<std::uint32_t, std::vector<std::uint32_t>>>&
0171   binGroups() const {
0172     return m_binGroups;
0173   }
0174 
0175  private:
0176   /// Add new layer
0177   /// @param l Silicon layer to add
0178   /// @param bin0 Starting bin index
0179   /// @return Reference to the newly added layer
0180   const GbtsLayer& addNewLayer(const TrigInDetSiLayer& l, std::uint32_t bin0);
0181 
0182   /// Eta bin width
0183   float m_etaBinWidth{};
0184 
0185   /// Layer map
0186   std::map<std::uint32_t, GbtsLayer*> m_layMap;
0187   /// Layer array
0188   std::vector<std::unique_ptr<GbtsLayer>> m_layArray;
0189   /// Layer keys
0190   std::vector<std::uint32_t> m_layerKeys;
0191   /// Number of eta bins
0192   std::uint32_t m_nEtaBins{};
0193 
0194   /// Bin groups
0195   std::vector<std::pair<std::uint32_t, std::vector<std::uint32_t>>> m_binGroups;
0196 };
0197 
0198 }  // namespace Acts::Experimental