GNN-style graph builder (features + edges). Kept for tools that want it.
140 {
142
145
146 const ActsTrk::GeometryContext* gctx = nullptr;
148
149 std::vector<BucketGraphUtils::NodeAux> nodes;
150 std::vector<float> throwawayFeatures;
151 std::vector<int64_t> throwawaySp;
153
154 const int64_t numNodes = static_cast<int64_t>(nodes.size());
155 if (numNodes == 0) {
156 ATH_MSG_WARNING(
"No valid buckets found (all have size 0.0). Skipping graph building.");
157 return StatusCode::SUCCESS;
158 }
159
160 std::vector<int64_t> srcEdges, dstEdges;
167 srcEdges, dstEdges);
170 std::vector<int64_t> newSrc;
171 std::vector<int64_t> newDst;
172 newSrc.reserve(srcEdges.size());
173 newDst.reserve(dstEdges.size());
174 for (
size_t k = 0;
k < srcEdges.size(); ++
k) {
175 const int64_t
u = srcEdges[
k];
176 const int64_t
v = dstEdges[
k];
177 const bool okU = (
u >= 0 &&
u < numNodes);
178 const bool okV = (
v >= 0 &&
v < numNodes);
179 if (okU && okV) {
180 newSrc.push_back(u);
181 newDst.push_back(v);
182 } else {
184 ATH_MSG_DEBUG(
"Drop invalid edge " << k <<
": (" << u <<
"->" << v
185 << "), valid node range [0," << (numNodes-1) << "]");
186 }
187 }
190 << srcEdges.size());
191 srcEdges.swap(newSrc);
192 dstEdges.swap(newDst);
193 }
194 }
195
196 const size_t E = srcEdges.size();
197
198 if (msgLvl(MSG::DEBUG)) {
199
202 for (
unsigned int k = 0;
k < dumpE; ++
k) {
203 ATH_MSG_DEBUG(
"EDGE[" << k <<
"]: " << srcEdges[k] <<
" -> " << dstEdges[k]);
204 }
205 std::vector<int> nodeConnections(numNodes, 0);
206 for (
size_t k = 0;
k < srcEdges.size(); ++
k) {
207 const int64_t
u = srcEdges[
k];
208 const int64_t
v = dstEdges[
k];
209 if (u >= 0 && u < numNodes) nodeConnections[
u]++;
210 if (v >= 0 && v < numNodes) nodeConnections[
v]++;
211 }
212
213 ATH_MSG_INFO(
"=== DEBUGGING: Node Connections (first 10 nodes) ===");
214 const int64_t debugNodeCount = std::min(numNodes, static_cast<int64_t>(10));
215 for (int64_t i = 0;
i < debugNodeCount; ++
i) {
216 ATH_MSG_DEBUG(
"Node[" << i <<
"] connections: " << nodeConnections[i]);
217 }
219
220
221 ATH_MSG_DEBUG(
"=== DEBUGGING: Detailed Edge Connections (first 10 nodes) ===");
222 for (int64_t nodeIdx = 0; nodeIdx < debugNodeCount; ++nodeIdx) {
223 std::stringstream connections;
224 connections << "Node[" << nodeIdx << "] connected to: ";
225 bool foundAny = false;
226
227 for (
size_t k = 0;
k < srcEdges.size(); ++
k) {
228 const int64_t
u = srcEdges[
k];
229 const int64_t
v = dstEdges[
k];
230
231 if (u == nodeIdx) {
232 if (foundAny) connections << ", ";
234 foundAny = true;
235 } else if (v == nodeIdx) {
236 if (foundAny) connections << ", ";
238 foundAny = true;
239 }
240 }
241
242 if (!foundAny) connections << "none";
244 }
246 }
247
250
251 Ort::MemoryInfo memInfo = Ort::MemoryInfo::CreateCpu(OrtDeviceAllocator, OrtMemTypeCPU);
252 std::vector<int64_t> edgeShape{2, static_cast<int64_t>(Efinal)};
253 graphData.
graph->dataTensor.emplace_back(
254 Ort::Value::CreateTensor<int64_t>(memInfo,
257 edgeShape.data(),
258 edgeShape.size()));
259
260 ATH_MSG_DEBUG(
"Built sparse bucket graph: N=" << numNodes <<
", E=" << Efinal);
261 return StatusCode::SUCCESS;
262}
void buildSparseEdges(const std::vector< NodeAux > &nodes, int minLayers, int maxChamberDelta, int maxSectorDelta, double maxDistXY, double maxAbsDz, std::vector< int64_t > &srcEdges, std::vector< int64_t > &dstEdges)
size_t packEdgeIndex(const std::vector< int64_t > &srcEdges, const std::vector< int64_t > &dstEdges, std::vector< int64_t > &edgeIndexPacked)
@ u
Enums for curvilinear frames.
EdgeCounterVec_t edgeIndexPacked
Packed edge index buffer (kept alive for ONNX tensors that reference it) This stores [srcEdges,...