6 #include "ExaTrkXUtils.hpp"
14 const std::string&
type,
const std::string&
name,
const IInterface*
parent):
17 declareInterface<IGNNTrackFinder>(
this);
24 return StatusCode::SUCCESS;
40 out<<
"|---------------------------------------------------------------------|"
42 out<<
"| Number output tracks | "<<std::setw(12)
44 out<<
"|---------------------------------------------------------------------|"
50 const std::vector<const Trk::SpacePoint*>& spacepoints,
51 std::vector<std::vector<uint32_t> >& tracks)
const
53 int64_t numSpacepoints = (int64_t)spacepoints.size();
54 std::vector<float> inputValues;
55 std::vector<uint32_t> spacepointIDs;
57 int64_t spacepointFeatures = 3;
59 for(
const auto& sp: spacepoints){
63 float z = sp->globalPosition().z() / 1000.;
64 float r = sp->r() / 1000.;
65 float phi = sp->phi() /
M_PI;
66 inputValues.push_back(
r);
67 inputValues.push_back(phi);
68 inputValues.push_back(
z);
71 spacepointIDs.push_back(sp_idx++);
78 std::vector<int64_t> eInputShape{numSpacepoints, spacepointFeatures};
79 std::vector<Ort::Value> eInputTensor;
82 std::vector<Ort::Value> eOutputTensor;
83 std::vector<float> eOutputData;
91 std::vector<int64_t> edgeList;
93 int64_t numEdges = edgeList.size() / 2;
98 std::vector<Ort::Value> fInputTensor;
99 fInputTensor.push_back(
100 std::move(eInputTensor[0])
103 std::vector<int64_t> fEdgeShape{2, numEdges};
105 std::vector<float> fOutputData;
106 std::vector<Ort::Value> fOutputTensor;
113 std::vector<int64_t> rowIndices;
114 std::vector<int64_t> colIndices;
115 for (int64_t
i = 0;
i < numEdges;
i++){
116 float v = 1.f / (1.f +
std::exp(-fOutputData[
i]));
118 rowIndices.push_back(edgeList[
i]);
119 colIndices.push_back(edgeList[numEdges +
i]);
122 std::vector<int64_t> edgesAfterFiltering;
123 edgesAfterFiltering.insert(edgesAfterFiltering.end(), rowIndices.begin(), rowIndices.end());
124 edgesAfterFiltering.insert(edgesAfterFiltering.end(), colIndices.begin(), colIndices.end());
126 int64_t numEdgesAfterF = edgesAfterFiltering.size() / 2;
131 std::vector<Ort::Value> gInputTensor;
132 gInputTensor.push_back(
133 std::move(fInputTensor[0])
138 std::vector<float> gOutputData;
139 std::vector<Ort::Value> gOutputTensor;
144 for(
auto&
v : gOutputData){
151 std::vector<int32_t> trackLabels(numSpacepoints);
152 weaklyConnectedComponents<int64_t,float,int32_t>(numSpacepoints, rowIndices, colIndices, gOutputData, trackLabels);
154 if (trackLabels.size() == 0)
return StatusCode::SUCCESS;
160 std::map<int32_t, int32_t> trackLableToIds;
162 for(int32_t
idx=0;
idx < numSpacepoints; ++
idx) {
163 int32_t trackLabel = trackLabels[
idx];
167 if(trackLableToIds.find(trackLabel) != trackLableToIds.end()) {
168 trkId = trackLableToIds[trackLabel];
169 tracks[trkId].push_back(spacepointID);
174 tracks.push_back(std::vector<uint32_t>{spacepointID});
175 trackLableToIds[trackLabel] = trkId;
179 return StatusCode::SUCCESS;