Skip to content

Commit 0adc2f1

Browse files
committed
ITS: factor common functions out
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent 4bfc97f commit 0adc2f1

File tree

9 files changed

+545
-614
lines changed

9 files changed

+545
-614
lines changed

Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/TrackingKernels.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ void countCellsHandler(const Cluster** sortedClusters,
109109
const float maxChi2ClusterAttachment,
110110
const float cellDeltaTanLambdaSigma,
111111
const float nSigmaCut,
112+
const std::vector<float>& layerxX0Host,
112113
o2::its::ExternalAllocator* alloc,
113114
gpu::Streams& streams);
114115

@@ -127,6 +128,7 @@ void computeCellsHandler(const Cluster** sortedClusters,
127128
const float maxChi2ClusterAttachment,
128129
const float cellDeltaTanLambdaSigma,
129130
const float nSigmaCut,
131+
const std::vector<float>& layerxX0Host,
130132
gpu::Streams& streams);
131133

132134
template <int NLayers>
@@ -180,6 +182,7 @@ void processNeighboursHandler(const int startLayer,
180182
const float bz,
181183
const float MaxChi2ClusterAttachment,
182184
const float maxChi2NDF,
185+
const std::vector<float>& layerxX0Host,
183186
const o2::base::Propagator* propagator,
184187
const o2::base::PropagatorF::MatCorrType matCorrType,
185188
o2::its::ExternalAllocator* alloc);
@@ -191,6 +194,7 @@ void countTrackSeedHandler(TrackSeed<NLayers>* trackSeeds,
191194
int* seedLUT,
192195
const std::vector<float>& layerRadiiHost,
193196
const std::vector<float>& minPtsHost,
197+
const std::vector<float>& layerxX0Host,
194198
const unsigned int nSeeds,
195199
const float Bz,
196200
const int startLevel,
@@ -211,6 +215,7 @@ void computeTrackSeedHandler(TrackSeed<NLayers>* trackSeeds,
211215
const int* seedLUT,
212216
const std::vector<float>& layerRadiiHost,
213217
const std::vector<float>& minPtsHost,
218+
const std::vector<float>& layerxX0Host,
214219
const unsigned int nSeeds,
215220
const unsigned int nTracks,
216221
const float Bz,

Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/Utils.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -343,27 +343,6 @@ struct TypedAllocator {
343343
ExternalAllocator* mInternalAllocator;
344344
};
345345

346-
template <int nLayers>
347-
GPUdii() const int4 getBinsRect(const Cluster& currentCluster, const int layerIndex,
348-
const o2::its::IndexTableUtils<nLayers>* utils,
349-
const float z1, const float z2, float maxdeltaz, float maxdeltaphi)
350-
{
351-
const float zRangeMin = o2::gpu::CAMath::Min(z1, z2) - maxdeltaz;
352-
const float phiRangeMin = (maxdeltaphi > o2::constants::math::PI) ? 0.f : currentCluster.phi - maxdeltaphi;
353-
const float zRangeMax = o2::gpu::CAMath::Max(z1, z2) + maxdeltaz;
354-
const float phiRangeMax = (maxdeltaphi > o2::constants::math::PI) ? o2::constants::math::TwoPI : currentCluster.phi + maxdeltaphi;
355-
356-
if (zRangeMax < -utils->getLayerZ(layerIndex) ||
357-
zRangeMin > utils->getLayerZ(layerIndex) || zRangeMin > zRangeMax) {
358-
return {};
359-
}
360-
361-
return int4{o2::gpu::CAMath::Max(0, utils->getZBinIndex(layerIndex, zRangeMin)),
362-
utils->getPhiBinIndex(math_utils::getNormalizedPhi(phiRangeMin)),
363-
o2::gpu::CAMath::Min(utils->getNzBins() - 1, utils->getZBinIndex(layerIndex, zRangeMax)),
364-
utils->getPhiBinIndex(math_utils::getNormalizedPhi(phiRangeMax))};
365-
}
366-
367346
GPUdii() gpuSpan<const Vertex> getPrimaryVertices(const int rof,
368347
const int* roframesPV,
369348
const int nROF,

Detectors/ITSMFT/ITS/tracking/GPU/cuda/TrackerTraitsGPU.cxx

Lines changed: 27 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "DataFormatsITS/TrackITS.h"
1818

19+
#include "ITStracking/TrackHelpers.h"
1920
#include "ITStrackingGPU/TrackerTraitsGPU.h"
2021
#include "ITStrackingGPU/TrackingKernels.h"
2122
#include "ITStracking/Constants.h"
@@ -184,6 +185,7 @@ void TrackerTraitsGPU<NLayers>::computeLayerCells(const int iteration)
184185
this->mTrkParams[iteration].MaxChi2ClusterAttachment,
185186
this->mTrkParams[iteration].CellDeltaTanLambdaSigma,
186187
this->mTrkParams[iteration].NSigmaCut,
188+
this->mTrkParams[iteration].LayerxX0,
187189
mTimeFrameGPU->getFrameworkAllocator(),
188190
mTimeFrameGPU->getStreams());
189191
mTimeFrameGPU->createCellsBuffers(iLayer);
@@ -204,6 +206,7 @@ void TrackerTraitsGPU<NLayers>::computeLayerCells(const int iteration)
204206
this->mTrkParams[iteration].MaxChi2ClusterAttachment,
205207
this->mTrkParams[iteration].CellDeltaTanLambdaSigma,
206208
this->mTrkParams[iteration].NSigmaCut,
209+
this->mTrkParams[iteration].LayerxX0,
207210
mTimeFrameGPU->getStreams());
208211
}
209212
}
@@ -263,6 +266,10 @@ void TrackerTraitsGPU<NLayers>::findCellsNeighbours(const int iteration)
263266
template <int NLayers>
264267
void TrackerTraitsGPU<NLayers>::findRoads(const int iteration)
265268
{
269+
bounded_vector<bounded_vector<int>> firstClusters(this->mTrkParams[iteration].NLayers, bounded_vector<int>(this->getMemoryPool().get()), this->getMemoryPool().get());
270+
bounded_vector<bounded_vector<int>> sharedFirstClusters(this->mTrkParams[iteration].NLayers, bounded_vector<int>(this->getMemoryPool().get()), this->getMemoryPool().get());
271+
firstClusters.resize(this->mTrkParams[iteration].NLayers);
272+
sharedFirstClusters.resize(this->mTrkParams[iteration].NLayers);
266273
for (int startLevel{this->mTrkParams[iteration].CellsPerRoad()}; startLevel >= this->mTrkParams[iteration].CellMinimumLevel(); --startLevel) {
267274
const int minimumLayer{startLevel - 1};
268275
bounded_vector<TrackSeed<NLayers>> trackSeeds(this->getMemoryPool().get());
@@ -281,10 +288,11 @@ void TrackerTraitsGPU<NLayers>::findRoads(const int iteration)
281288
mTimeFrameGPU->getDeviceArrayTrackingFrameInfo(),
282289
trackSeeds,
283290
this->mBz,
284-
this->mTrkParams[0].MaxChi2ClusterAttachment,
285-
this->mTrkParams[0].MaxChi2NDF,
291+
this->mTrkParams[iteration].MaxChi2ClusterAttachment,
292+
this->mTrkParams[iteration].MaxChi2NDF,
293+
this->mTrkParams[iteration].LayerxX0,
286294
mTimeFrameGPU->getDevicePropagator(),
287-
this->mTrkParams[0].CorrType,
295+
this->mTrkParams[iteration].CorrType,
288296
mTimeFrameGPU->getFrameworkAllocator());
289297
}
290298
// fixme: I don't want to move tracks back and forth, but I need a way to use a thrust::allocator that is aware of our managed memory.
@@ -302,16 +310,17 @@ void TrackerTraitsGPU<NLayers>::findRoads(const int iteration)
302310
mTimeFrameGPU->getDeviceTrackSeedsLUT(),
303311
this->mTrkParams[iteration].LayerRadii,
304312
this->mTrkParams[iteration].MinPt,
313+
this->mTrkParams[iteration].LayerxX0,
305314
trackSeeds.size(),
306315
this->mBz,
307316
startLevel,
308-
this->mTrkParams[0].MaxChi2ClusterAttachment,
309-
this->mTrkParams[0].MaxChi2NDF,
310-
this->mTrkParams[0].ReseedIfShorter,
311-
this->mTrkParams[0].RepeatRefitOut,
312-
this->mTrkParams[0].ShiftRefToCluster,
317+
this->mTrkParams[iteration].MaxChi2ClusterAttachment,
318+
this->mTrkParams[iteration].MaxChi2NDF,
319+
this->mTrkParams[iteration].ReseedIfShorter,
320+
this->mTrkParams[iteration].RepeatRefitOut,
321+
this->mTrkParams[iteration].ShiftRefToCluster,
313322
mTimeFrameGPU->getDevicePropagator(),
314-
this->mTrkParams[0].CorrType,
323+
this->mTrkParams[iteration].CorrType,
315324
mTimeFrameGPU->getFrameworkAllocator());
316325
mTimeFrameGPU->createTrackITSExtDevice(trackSeeds.size());
317326
computeTrackSeedHandler(mTimeFrameGPU->getDeviceTrackSeeds(),
@@ -321,65 +330,26 @@ void TrackerTraitsGPU<NLayers>::findRoads(const int iteration)
321330
mTimeFrameGPU->getDeviceTrackSeedsLUT(),
322331
this->mTrkParams[iteration].LayerRadii,
323332
this->mTrkParams[iteration].MinPt,
333+
this->mTrkParams[iteration].LayerxX0,
324334
trackSeeds.size(),
325335
mTimeFrameGPU->getNTrackSeeds(),
326336
this->mBz,
327337
startLevel,
328-
this->mTrkParams[0].MaxChi2ClusterAttachment,
329-
this->mTrkParams[0].MaxChi2NDF,
330-
this->mTrkParams[0].ReseedIfShorter,
331-
this->mTrkParams[0].RepeatRefitOut,
332-
this->mTrkParams[0].ShiftRefToCluster,
338+
this->mTrkParams[iteration].MaxChi2ClusterAttachment,
339+
this->mTrkParams[iteration].MaxChi2NDF,
340+
this->mTrkParams[iteration].ReseedIfShorter,
341+
this->mTrkParams[iteration].RepeatRefitOut,
342+
this->mTrkParams[iteration].ShiftRefToCluster,
333343
mTimeFrameGPU->getDevicePropagator(),
334-
this->mTrkParams[0].CorrType,
344+
this->mTrkParams[iteration].CorrType,
335345
mTimeFrameGPU->getFrameworkAllocator());
336346
mTimeFrameGPU->downloadTrackITSExtDevice();
337347

338348
auto& tracks = mTimeFrameGPU->getTrackITSExt();
339-
340-
for (auto& track : tracks) {
341-
if (!track.getChi2()) {
342-
continue; // this is to skip the unset tracks that are put at the beginning of the vector by the sorting. To see if this can be optimised.
343-
}
344-
int nShared = 0;
345-
bool isFirstShared{false};
346-
for (int iLayer{0}; iLayer < this->mTrkParams[0].NLayers; ++iLayer) {
347-
if (track.getClusterIndex(iLayer) == constants::UnusedIndex) {
348-
continue;
349-
}
350-
nShared += int(mTimeFrameGPU->isClusterUsed(iLayer, track.getClusterIndex(iLayer)));
351-
isFirstShared |= !iLayer && mTimeFrameGPU->isClusterUsed(iLayer, track.getClusterIndex(iLayer));
352-
}
353-
354-
if (nShared > this->mTrkParams[0].ClusterSharing) {
355-
continue;
356-
}
357-
358-
bool firstCls{true};
359-
TimeEstBC ts;
360-
for (int iLayer{0}; iLayer < this->mTrkParams[0].NLayers; ++iLayer) {
361-
if (track.getClusterIndex(iLayer) == constants::UnusedIndex) {
362-
continue;
363-
}
364-
mTimeFrameGPU->markUsedCluster(iLayer, track.getClusterIndex(iLayer));
365-
int currentROF = mTimeFrameGPU->getClusterROF(iLayer, track.getClusterIndex(iLayer));
366-
auto rofTS = mTimeFrameGPU->getROFOverlapTableView().getLayer(iLayer).getROFTimeBounds(currentROF, true);
367-
if (firstCls) {
368-
ts = rofTS;
369-
} else {
370-
if (!ts.isCompatible(rofTS)) {
371-
LOGP(fatal, "TS {}+/-{} are incompatible with {}+/-{}, this should not happen!", rofTS.getTimeStamp(), rofTS.getTimeStampError(), ts.getTimeStamp(), ts.getTimeStampError());
372-
}
373-
ts += rofTS;
374-
}
375-
}
376-
track.getTimeStamp() = ts.makeSymmetrical();
377-
track.setUserField(0);
378-
track.getParamOut().setUserField(0);
379-
mTimeFrameGPU->getTracks().emplace_back(track);
380-
}
349+
this->acceptTracks(iteration, tracks, firstClusters, sharedFirstClusters);
381350
mTimeFrameGPU->loadUsedClustersDevice();
382351
}
352+
this->markTracks(iteration, sharedFirstClusters);
383353
// wipe the artefact memory
384354
mTimeFrameGPU->popMemoryStack(iteration);
385355
};

0 commit comments

Comments
 (0)