Skip to content

Commit ca3ea37

Browse files
mconcasshahor02
authored andcommitted
ITS-tracking: use flat index tables for clusters
1 parent 9934dc7 commit ca3ea37

5 files changed

Lines changed: 23 additions & 29 deletions

File tree

Detectors/ITSMFT/ITS/tracking/GPU/cuda/TimeFrameGPU.cu

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,8 @@ void TimeFrameGPU<NLayers>::loadToDevice(const int maxLayers)
136136
mClusterExternalIndicesD[iLayer].reset(mClusterExternalIndices[iLayer].data(), static_cast<int>(mClusterExternalIndices[iLayer].size()));
137137
}
138138
} else {
139-
// flatten vector of vectors into single buffer
140-
std::vector<int> flatTables0, flatTables2;
141-
flatTables0.reserve(mConfig.nMaxROFs * (ZBins * PhiBins + 1));
142-
flatTables2.reserve(mConfig.nMaxROFs * (ZBins * PhiBins + 1));
143-
for (size_t rofId{0}; rofId < mNrof; ++rofId) {
144-
const auto& v0 = mIndexTables[rofId][0];
145-
const auto& v2 = mIndexTables[rofId][2];
146-
flatTables0.insert(flatTables0.end(), v0.begin(), v0.end());
147-
flatTables2.insert(flatTables2.end(), v2.begin(), v2.end());
148-
}
149-
mIndexTablesLayer0D.reset(flatTables0.data(), static_cast<int>(flatTables0.size()));
150-
mIndexTablesLayer2D.reset(flatTables2.data(), static_cast<int>(flatTables2.size()));
139+
mIndexTablesLayer0D.reset(getIndexTableWhole(0).data(), static_cast<int>(getIndexTableWhole(0).size()));
140+
mIndexTablesLayer2D.reset(getIndexTableWhole(2).data(), static_cast<int>(getIndexTableWhole(2).size()));
151141
}
152142
gpuThrowOnError();
153143
}

Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ class TimeFrame
9797
gsl::span<Cluster> getClustersOnLayer(int rofId, int layerId);
9898
gsl::span<const Cluster> getClustersOnLayer(int rofId, int layerId) const;
9999
gsl::span<const Cluster> getUnsortedClustersOnLayer(int rofId, int layerId) const;
100-
index_table_t& getIndexTables(int tf);
100+
gsl::span<int> getIndexTable(int rofId, int layerId);
101+
std::vector<int>& getIndexTableWhole(int layerId) { return mIndexTables[layerId]; }
101102
const std::vector<TrackingFrameInfo>& getTrackingFrameInfoOnLayer(int layerId) const;
102103

103104
const TrackingFrameInfo& getClusterTrackingFrameInfo(int layerId, const Cluster& cl) const;
@@ -169,7 +170,7 @@ class TimeFrame
169170
std::vector<std::vector<TrackingFrameInfo>> mTrackingFrameInfo;
170171
std::vector<std::vector<int>> mClusterExternalIndices;
171172
std::vector<std::vector<int>> mROframesClusters;
172-
std::vector<index_table_t> mIndexTables;
173+
std::vector<std::vector<int>> mIndexTables;
173174
int mNrof = 0;
174175

175176
private:
@@ -313,9 +314,13 @@ inline int TimeFrame::getClusterExternalIndex(int layerId, const int clId) const
313314
return mClusterExternalIndices[layerId][clId];
314315
}
315316

316-
inline index_table_t& TimeFrame::getIndexTables(int tf)
317+
inline gsl::span<int> TimeFrame::getIndexTable(int rofId, int layer)
317318
{
318-
return mIndexTables[tf];
319+
if (rofId < 0 || rofId >= mNrof) {
320+
return gsl::span<int>();
321+
}
322+
return {&mIndexTables[layer][rofId * (mIndexTableUtils.getNphiBins() * mIndexTableUtils.getNzBins() + 1)],
323+
static_cast<gsl::span<int>::size_type>(mIndexTableUtils.getNphiBins() * mIndexTableUtils.getNzBins() + 1)};
319324
}
320325

321326
inline std::vector<Line>& TimeFrame::getLines(int tf)

Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,14 @@ void TimeFrame::initialise(const int iteration, const MemoryParameters& memParam
229229
mUsedClusters[iLayer].resize(mUnsortedClusters[iLayer].size(), false);
230230
mPositionResolution[iLayer] = std::hypot(trkParam.LayerMisalignment[iLayer], trkParam.LayerResolution[iLayer]);
231231
}
232-
mIndexTables.resize(mNrof);
232+
mIndexTables.resize(mClusters.size(), std::vector<int>(mNrof * (trkParam.ZBins * trkParam.PhiBins + 1), 0));
233233
mLines.resize(mNrof);
234234
mTrackletClusters.resize(mNrof);
235235
mNTrackletsPerROf.resize(2, std::vector<int>(mNrof + 1, 0));
236236

237237
std::vector<ClusterHelper> cHelper;
238238
std::vector<int> clsPerBin(trkParam.PhiBins * trkParam.ZBins, 0);
239239
for (int rof{0}; rof < mNrof; ++rof) {
240-
mIndexTables[rof].resize(mClusters.size(), std::vector<int>(trkParam.ZBins * trkParam.PhiBins + 1, 0));
241240
if ((int)mMultiplicityCutMask.size() == mNrof && !mMultiplicityCutMask[rof]) {
242241
continue;
243242
}
@@ -290,10 +289,10 @@ void TimeFrame::initialise(const int iteration, const MemoryParameters& memParam
290289
}
291290

292291
for (unsigned int iB{0}; iB < clsPerBin.size(); ++iB) {
293-
mIndexTables[rof][iLayer][iB] = lutPerBin[iB];
292+
mIndexTables[iLayer][rof * (trkParam.ZBins * trkParam.PhiBins + 1) + iB] = lutPerBin[iB];
294293
}
295-
for (auto iB{clsPerBin.size()}; iB < mIndexTables[rof][iLayer].size(); iB++) {
296-
mIndexTables[rof][iLayer][iB] = clustersNum;
294+
for (auto iB{clsPerBin.size()}; iB < (trkParam.ZBins * trkParam.PhiBins + 1); iB++) {
295+
mIndexTables[iLayer][rof * (trkParam.ZBins * trkParam.PhiBins + 1) + iB] = clustersNum;
297296
}
298297
}
299298
}

Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,17 @@ void TrackerTraits::computeLayerTracklets()
113113
const int firstBinIndex{tf->mIndexTableUtils.getBinIndex(selectedBinsRect.x, iPhiBin)};
114114
const int maxBinIndex{firstBinIndex + selectedBinsRect.z - selectedBinsRect.x + 1};
115115
if constexpr (debugLevel) {
116-
if (firstBinIndex < 0 || firstBinIndex > tf->getIndexTables(rof1)[iLayer + 1].size() ||
117-
maxBinIndex < 0 || maxBinIndex > tf->getIndexTables(rof1)[iLayer + 1].size()) {
116+
if (firstBinIndex < 0 || firstBinIndex > tf->getIndexTable(rof1, iLayer + 1).size() ||
117+
maxBinIndex < 0 || maxBinIndex > tf->getIndexTable(rof1, iLayer + 1).size()) {
118118
std::cout << iLayer << "\t" << iCluster << "\t" << zAtRmin << "\t" << zAtRmax << "\t" << sigmaZ * mTrkParams.NSigmaCut << "\t" << tf->getPhiCut(iLayer) << std::endl;
119119
std::cout << currentCluster.zCoordinate << "\t" << primaryVertex.getZ() << "\t" << currentCluster.radius << std::endl;
120120
std::cout << tf->getMinR(iLayer + 1) << "\t" << currentCluster.radius << "\t" << currentCluster.zCoordinate << std::endl;
121121
std::cout << "Illegal access to IndexTable " << firstBinIndex << "\t" << maxBinIndex << "\t" << selectedBinsRect.z << "\t" << selectedBinsRect.x << std::endl;
122122
exit(1);
123123
}
124124
}
125-
const int firstRowClusterIndex = tf->getIndexTables(rof1)[iLayer + 1][firstBinIndex];
126-
const int maxRowClusterIndex = tf->getIndexTables(rof1)[iLayer + 1][maxBinIndex];
125+
const int firstRowClusterIndex = tf->getIndexTable(rof1, iLayer + 1)[firstBinIndex];
126+
const int maxRowClusterIndex = tf->getIndexTable(rof1, iLayer + 1)[maxBinIndex];
127127

128128
for (int iNextCluster{firstRowClusterIndex}; iNextCluster < maxRowClusterIndex; ++iNextCluster) {
129129
if (iNextCluster >= (int)layer1.size()) {
@@ -402,8 +402,8 @@ bool TrackerTraits::trackFollowing(TrackITSExt* track, int rof, bool outward)
402402
int iPhiBin = (selectedBinsRect.y + iPhiCount) % mTrkParams.PhiBins;
403403
const int firstBinIndex{mTimeFrame->mIndexTableUtils.getBinIndex(selectedBinsRect.x, iPhiBin)};
404404
const int maxBinIndex{firstBinIndex + selectedBinsRect.z - selectedBinsRect.x + 1};
405-
const int firstRowClusterIndex = mTimeFrame->getIndexTables(rof)[iLayer][firstBinIndex];
406-
const int maxRowClusterIndex = mTimeFrame->getIndexTables(rof)[iLayer][maxBinIndex];
405+
const int firstRowClusterIndex = mTimeFrame->getIndexTable(rof, iLayer)[firstBinIndex];
406+
const int maxRowClusterIndex = mTimeFrame->getIndexTable(rof, iLayer)[maxBinIndex];
407407

408408
for (int iNextCluster{firstRowClusterIndex}; iNextCluster < maxRowClusterIndex; ++iNextCluster) {
409409
if (iNextCluster >= (int)layer1.size()) {

Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,15 @@ void VertexerTraits::computeTracklets()
139139
trackleterKernelSerial<TrackletMode::Layer0Layer1>(
140140
mTimeFrame->getClustersOnLayer(rofId, 0),
141141
mTimeFrame->getClustersOnLayer(rofId, 1),
142-
mTimeFrame->getIndexTables(rofId)[0].data(),
142+
mTimeFrame->getIndexTable(rofId, 0).data(),
143143
mVrtParams.phiCut,
144144
mTimeFrame->getTracklets()[0],
145145
mTimeFrame->getNTrackletsCluster(rofId, 0),
146146
mIndexTableUtils);
147147
trackleterKernelSerial<TrackletMode::Layer1Layer2>(
148148
mTimeFrame->getClustersOnLayer(rofId, 2),
149149
mTimeFrame->getClustersOnLayer(rofId, 1),
150-
mTimeFrame->getIndexTables(rofId)[2].data(),
150+
mTimeFrame->getIndexTable(rofId, 2).data(),
151151
mVrtParams.phiCut,
152152
mTimeFrame->getTracklets()[1],
153153
mTimeFrame->getNTrackletsCluster(rofId, 1),

0 commit comments

Comments
 (0)