ATLAS Offline Software
Loading...
Searching...
No Matches
GNNR3_DataStorage.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5
7#include "GNNR3_Geometry.h"
8#include "GNNR3_DataStorage.h"
9
10#include<cmath>
11#include<cstring>
12#include<algorithm>
13
15
16 m_in.clear();
17 m_vn.clear();
18 m_params.clear();
19 m_vn.reserve(1000);
20}
21
23 m_in.clear();
24 m_vn.clear();
25 m_params.clear();
26}
27
29
30 std::vector<std::pair<float, const TrigFTF_GNNR3_Node*> > phiBuckets[32];
31
32 int nBuckets = 31;
33
34 for(const auto& n : m_vn) {
35 int bIdx = (int)(0.5*nBuckets*(n->phi()/(float)M_PI + 1.0f));
36 phiBuckets[bIdx].push_back(std::make_pair(n->phi(), n));
37 }
38
39 for(auto& b : phiBuckets) {
40 std::sort(b.begin(), b.end());
41 }
42
43 int idx = 0;
44 for(const auto& b : phiBuckets) {
45 for(const auto& p : b) {
46 m_vn[idx++] = p.second;
47 }
48 }
49
50}
51
52
54
55 if(m_vn.empty()) return;
56
57 m_params.resize(m_vn.size());
58
59 m_in.resize(m_vn.size());
60 for(auto& v : m_in) v.reserve(50);//reasonably high number of incoming edges per node
61
62 std::transform(m_vn.begin(), m_vn.end(), m_params.begin(),
63 [](const TrigFTF_GNNR3_Node* pN) { std::array<float,5> a = {-100.0, 100.0, pN->phi(), pN->r(), pN->z()}; return a;});
64
65 auto [min_iter, max_iter] = std::minmax_element(m_vn.begin(), m_vn.end(),
66 [](const TrigFTF_GNNR3_Node* s, const TrigFTF_GNNR3_Node* s1) { return (s->r() < s1->r()); });
67 m_maxRadius = (*max_iter)->r();
68 m_minRadius = (*min_iter)->r();
69}
70
72
73 for(unsigned int nIdx=0;nIdx<m_vn.size();nIdx++) {
74
75 float phi = m_params[nIdx][2];
76 if(phi <= M_PI-dphi) continue;
77 m_vPhiNodes.push_back(std::pair<float, unsigned int>(phi - 2*M_PI, nIdx));
78
79 }
80
81 for(unsigned int nIdx=0;nIdx<m_vn.size();nIdx++) {
82 float phi = m_params[nIdx][2];
83 m_vPhiNodes.push_back(std::pair<float, unsigned int>(phi, nIdx));
84 }
85
86 for(unsigned int nIdx=0;nIdx<m_vn.size();nIdx++) {
87
88 float phi = m_params[nIdx][2];
89 if(phi >= -M_PI + dphi) break;
90 m_vPhiNodes.push_back(std::pair<float, unsigned int>(phi + 2*M_PI, nIdx));
91 }
92
93}
94
98
99
103
104int TrigFTF_GNNR3_DataStorage::loadPixelGraphNodes(short layerIndex, const std::vector<TrigFTF_GNNR3_Node>& coll, bool useML) {
105
106 int nLoaded = 0;
107
108 const TrigFTF_GNNR3_Layer* pL = m_geo.getTrigFTF_GNNR3_LayerByIndex(layerIndex);
109
110 if(pL == nullptr) {
111 return -1;
112 }
113
114 bool isBarrel = (pL->m_layer.m_type == 0);
115
116 for(const auto& node : coll) {
117
118 int binIndex = pL->getEtaBin(node.z(), node.r());
119
120 if(binIndex == -1) {
121 continue;
122 }
123
124 if(isBarrel) {
125 m_etaBins.at(binIndex).m_vn.push_back(&node);
126 }
127 else {
128 if (useML) {
129 float cluster_width = node.pixelClusterWidth();
130 if(cluster_width > 0.2) continue;
131 }
132 m_etaBins.at(binIndex).m_vn.push_back(&node);
133 }
134
135 nLoaded++;
136
137 }
138
139 return nLoaded;
140}
141
142int TrigFTF_GNNR3_DataStorage::loadStripGraphNodes(short layerIndex, const std::vector<TrigFTF_GNNR3_Node>& coll) {
143
144 int nLoaded = 0;
145
146 const TrigFTF_GNNR3_Layer* pL = m_geo.getTrigFTF_GNNR3_LayerByIndex(layerIndex);
147
148 if(pL == nullptr) {
149 return -1;
150 }
151
152 for(const auto& node : coll) {
153
154 int binIndex = pL->getEtaBin(node.z(), node.r());
155
156 if(binIndex == -1) {
157 continue;
158 }
159
160 m_etaBins.at(binIndex).m_vn.push_back(&node);
161 nLoaded++;
162 }
163
164 return nLoaded;
165}
166
168
169 unsigned int n=0;
170
171 for(const auto& b : m_etaBins) {
172 n += b.m_vn.size();
173 }
174 return n;
175}
176
178
179 for(auto& b : m_etaBins) b.sortByPhi();
180}
181
183
184 for(auto& b : m_etaBins) {
185 b.initializeNodes();
186 }
187
188 if(!useML) return;
189
190 unsigned int nL = m_geo.num_layers();
191
192 for(unsigned int layerIdx=0;layerIdx<nL;layerIdx++) {
193
194 const TrigFTF_GNNR3_Layer* pL = m_geo.getTrigFTF_GNNR3_LayerByIndex(layerIdx);
195
196 if(pL->m_layer.m_subdet < 20000) {//skip strips volumes: layers in range [1200X-1400X]
197 continue;
198 }
199
200 bool isBarrel = (pL->m_layer.m_type == 0);
201
202 if(!isBarrel) continue;
203
204 int nBins = pL->m_bins.size();
205
206 for(int b=0;b<nBins;b++) {//loop over eta-bins in Layer
207
208 TrigFTF_GNNR3_EtaBin& B = m_etaBins.at(pL->m_bins.at(b));
209
210 if(B.empty()) continue;
211
212 for(unsigned int nIdx=0;nIdx<B.m_vn.size();nIdx++) {
213 float cluster_width = B.m_vn[nIdx]->pixelClusterWidth();
214 //adjusting cuts using fitted boundaries of |cot(theta)| vs. cluster z-width distribution
215 float min_tau = 6.7*(cluster_width - 0.2);//linear fit
216 float max_tau = 1.6 + 0.15/(cluster_width + 0.2) + 6.1*(cluster_width - 0.2);//linear fit + correction for short clusters
217
218 B.m_params[nIdx][0] = min_tau;
219 B.m_params[nIdx][1] = max_tau;
220
221 }
222 }
223 }
224}
225
227 for(auto& b : m_etaBins) b.generatePhiIndexing(dphi);
228}
229
#define M_PI
Scalar phi() const
phi method
static Double_t a
TrigFTF_GNNR3_DataStorage(const TrigFTF_GNNR3_Geometry &)
int loadStripGraphNodes(short, const std::vector< TrigFTF_GNNR3_Node > &)
const TrigFTF_GNNR3_Geometry & m_geo
unsigned int numberOfNodes() const
std::vector< TrigFTF_GNNR3_EtaBin > m_etaBins
int loadPixelGraphNodes(short, const std::vector< TrigFTF_GNNR3_Node > &, bool)
std::vector< std::array< float, 5 > > m_params
std::vector< const TrigFTF_GNNR3_Node * > m_vn
std::vector< std::pair< float, unsigned int > > m_vPhiNodes
std::vector< std::vector< unsigned int > > m_in
const TrigInDetSiLayer & m_layer
std::vector< int > m_bins
int getEtaBin(float, float) const
Definition node.h:24
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.