Back to home page

EIC code displayed by LXR

 
 

    


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

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 // TODO: update to C++17 style
0012 #include "Acts/Seeding/GbtsGeometry.hpp"
0013 
0014 #include <array>
0015 #include <limits>
0016 #include <vector>
0017 namespace Acts::Experimental {
0018 
0019 #define MAX_SEG_PER_NODE 1000  // was 30
0020 #define N_SEG_CONNS 6          // was 6
0021 
0022 class GbtsGeometry;
0023 
0024 struct GbtsNode {
0025   explicit GbtsNode(unsigned short l) : m_layer(l) {};
0026 
0027   inline float x() const { return m_x; }
0028   inline float y() const { return m_y; }
0029 
0030   inline float phi() const { return m_phi; }
0031   inline float z() const { return m_z; }
0032   inline float r() const { return m_r; }
0033   inline unsigned short layer() const { return m_layer; }
0034   inline float pixelClusterWidth() const { return m_pcw; }
0035 
0036   inline int sp_idx() const { return m_idx; }
0037 
0038   float m_x{}, m_y{}, m_z{}, m_r{}, m_phi{};
0039   unsigned short m_layer{10000};
0040   unsigned int m_idx{std::numeric_limits<unsigned int>::max()};
0041   float m_pcw{};
0042 };
0043 
0044 class GbtsEtaBin {
0045  public:
0046   struct CompareNodesByPhi {
0047     bool operator()(const GbtsNode* n1, const GbtsNode* n2) {
0048       return n1->phi() < n2->phi();
0049     }
0050   };
0051 
0052   GbtsEtaBin();
0053   ~GbtsEtaBin();
0054 
0055   void sortByPhi();
0056   void initializeNodes();
0057   bool empty() const { return m_vn.empty(); }
0058 
0059   void generatePhiIndexing(float dphi);
0060 
0061   float getMinBinRadius() const { return m_minRadius; }
0062 
0063   float getMaxBinRadius() const { return m_maxRadius; }
0064 
0065   std::vector<const GbtsNode*> m_vn;  // nodes of the graph
0066   std::vector<std::pair<float, unsigned int> > m_vPhiNodes;
0067   std::vector<std::vector<unsigned int> >
0068       m_in;  // vectors of incoming edges, stores indices of edges in the edge
0069              // vector
0070   std::vector<std::array<float, 5> >
0071       m_params;  // node attributes: m_minCutOnTau, m_maxCutOnTau, m_phi, m_r,
0072                  // m_z;
0073 
0074   float m_minRadius{}, m_maxRadius{};
0075 };
0076 
0077 class GbtsDataStorage {
0078  public:
0079   explicit GbtsDataStorage(const GbtsGeometry& g);
0080   ~GbtsDataStorage();
0081 
0082   int loadPixelGraphNodes(short layerIndex, const std::vector<GbtsNode>& coll,
0083                           bool useML);
0084   int loadStripGraphNodes(short layerIndex, const std::vector<GbtsNode>& coll);
0085 
0086   unsigned int numberOfNodes() const;
0087   void sortByPhi();
0088   void initializeNodes(bool useML);
0089   void generatePhiIndexing(float dphi);
0090 
0091   GbtsEtaBin& getEtaBin(int idx) {
0092     if (idx >= static_cast<int>(m_etaBins.size())) {
0093       idx = idx - 1;
0094     }
0095     return m_etaBins.at(idx);
0096   }
0097 
0098  protected:
0099   const GbtsGeometry& m_geo;
0100 
0101   std::vector<GbtsEtaBin> m_etaBins;
0102 };
0103 
0104 class GbtsEdge {
0105  public:
0106   struct CompareLevel {
0107    public:
0108     bool operator()(const GbtsEdge* pE1, const GbtsEdge* pE2) {
0109       return pE1->m_level > pE2->m_level;
0110     }
0111   };
0112 
0113   GbtsEdge(const GbtsNode* n1, const GbtsNode* n2, float p1, float p2, float p3)
0114       : m_n1(n1), m_n2(n2), m_level(1), m_next(1) {
0115     m_p[0] = p1;
0116     m_p[1] = p2;
0117     m_p[2] = p3;
0118   }
0119 
0120   GbtsEdge() = default;
0121 
0122   const GbtsNode* m_n1{nullptr};
0123   const GbtsNode* m_n2{nullptr};
0124 
0125   signed char m_level{-1}, m_next{-1};
0126 
0127   unsigned char m_nNei{0};
0128   float m_p[3]{};
0129 
0130   unsigned int m_vNei[N_SEG_CONNS]{};  // global indices of the connected edges
0131 };
0132 
0133 }  // namespace Acts::Experimental