Skip to content

Commit d4e7f5a

Browse files
committed
ITS: integrate track extension in road finding
1 parent 4568c80 commit d4e7f5a

12 files changed

Lines changed: 551 additions & 530 deletions

File tree

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class TrackerTraitsGPU final : public TrackerTraits<NLayers>
3535
void computeLayerCells(const int iteration) final;
3636
void findCellsNeighbours(const int iteration) final;
3737
void findRoads(const int iteration) final;
38-
void extendTracks(const int iteration) final;
3938

4039
void setBz(float) final;
4140

@@ -48,11 +47,6 @@ class TrackerTraitsGPU final : public TrackerTraits<NLayers>
4847
int getTFNumberOfCells() const override;
4948

5049
private:
51-
bool hasTrackFollower(const int iteration) const;
52-
53-
void buildTrackExtensionCandidates(const int iteration, typename TrackerTraits<NLayers>::TrackExtensionCandidates& candidatesPerTrack) final;
54-
bool materializeTrackExtensionCandidate(TrackITSExt& track, const typename TrackerTraits<NLayers>::TrackExtensionCandidateN& candidate, const int iteration) final;
55-
5650
IndexTableUtilsN* mDeviceIndexTableUtils;
5751
gpu::TimeFrameGPU<NLayers>* mTimeFrameGPU;
5852
};

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ void countTrackSeedHandler(TrackSeed<NLayers>* trackSeeds,
262262
const std::vector<float>& layerxX0Host,
263263
const unsigned int nSeeds,
264264
const float Bz,
265-
const int startLevel,
266265
const float maxChi2ClusterAttachment,
267266
const float maxChi2NDF,
268267
const int reseedIfShorter,
@@ -276,20 +275,35 @@ template <int NLayers>
276275
void computeTrackSeedHandler(TrackSeed<NLayers>* trackSeeds,
277276
const TrackingFrameInfo** foundTrackingFrameInfo,
278277
const Cluster** unsortedClusters,
278+
const IndexTableUtils<NLayers>* utils,
279+
const typename ROFMaskTable<NLayers>::View& rofMask,
280+
const typename ROFOverlapTable<NLayers>::View& rofOverlaps,
281+
const Cluster** clusters,
282+
const unsigned char** usedClusters,
283+
const int** clustersIndexTables,
284+
const int** ROFClusters,
279285
o2::its::TrackITSExt* tracks,
280286
const int* seedLUT,
287+
TrackExtensionHypothesis<NLayers>* activeHypotheses,
288+
TrackExtensionHypothesis<NLayers>* nextHypotheses,
281289
const std::vector<float>& layerRadiiHost,
282290
const std::vector<float>& minPtsHost,
283291
const std::vector<float>& layerxX0Host,
284292
const unsigned int nSeeds,
285293
const unsigned int nTracks,
286294
const float Bz,
287-
const int startLevel,
288295
const float maxChi2ClusterAttachment,
289296
const float maxChi2NDF,
290297
const int reseedIfShorter,
291298
const bool repeatRefitOut,
292299
const bool shiftRefToCluster,
300+
const int nLayers,
301+
const int phiBins,
302+
const int beamWidth,
303+
const bool extendTop,
304+
const bool extendBot,
305+
const float nSigmaCutPhi,
306+
const float nSigmaCutZ,
293307
const o2::base::Propagator* propagator,
294308
const o2::base::PropagatorF::MatCorrType matCorrType,
295309
o2::its::ExternalAllocator* alloc);

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

Lines changed: 30 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,13 @@ template <int NLayers>
304304
void TrackerTraitsGPU<NLayers>::findRoads(const int iteration)
305305
{
306306
bounded_vector<bounded_vector<int>> firstClusters(this->mTrkParams[iteration].NLayers, bounded_vector<int>(this->getMemoryPool().get()), this->getMemoryPool().get());
307-
bounded_vector<bounded_vector<int>> sharedFirstClusters(this->mTrkParams[iteration].NLayers, bounded_vector<int>(this->getMemoryPool().get()), this->getMemoryPool().get());
308307
firstClusters.resize(this->mTrkParams[iteration].NLayers);
309-
sharedFirstClusters.resize(this->mTrkParams[iteration].NLayers);
310308
const auto hostTopology = mTimeFrameGPU->getTrackingTopologyView();
309+
const bool extendTop = this->mTrkParams[iteration].PassFlags[IterationStep::TrackFollowerTop];
310+
const bool extendBot = this->mTrkParams[iteration].PassFlags[IterationStep::TrackFollowerBot];
311+
const bool extendTracks = extendTop || extendBot;
312+
size_t nExtendedTracks{0};
313+
size_t nExtendedClusters{0};
311314
for (int startLevel{this->mTrkParams[iteration].CellsPerRoad()}; startLevel >= this->mTrkParams[iteration].CellMinimumLevel(); --startLevel) {
312315
bounded_vector<TrackSeed<NLayers>> trackSeeds(this->getMemoryPool().get());
313316
for (int startCellTopologyId{0}; startCellTopologyId < hostTopology.nCells; ++startCellTopologyId) {
@@ -356,7 +359,6 @@ void TrackerTraitsGPU<NLayers>::findRoads(const int iteration)
356359
this->mTrkParams[iteration].LayerxX0,
357360
trackSeeds.size(),
358361
this->mBz,
359-
startLevel,
360362
this->mTrkParams[iteration].MaxChi2ClusterAttachment,
361363
this->mTrkParams[iteration].MaxChi2NDF,
362364
this->mTrkParams[iteration].ReseedIfShorter,
@@ -366,153 +368,57 @@ void TrackerTraitsGPU<NLayers>::findRoads(const int iteration)
366368
this->mTrkParams[iteration].CorrType,
367369
mTimeFrameGPU->getFrameworkAllocator());
368370
mTimeFrameGPU->createTrackITSExtDevice(trackSeeds.size());
371+
if (extendTracks) {
372+
mTimeFrameGPU->createTrackExtensionScratchDevice(kTrackExtensionLaunchThreads, this->mTrkParams[iteration].TrackFollowerBeamWidth);
373+
}
369374
computeTrackSeedHandler(mTimeFrameGPU->getDeviceTrackSeeds(),
370375
mTimeFrameGPU->getDeviceArrayTrackingFrameInfo(),
371376
mTimeFrameGPU->getDeviceArrayUnsortedClusters(),
377+
mTimeFrameGPU->getDeviceIndexTableUtils(),
378+
mTimeFrameGPU->getDeviceROFMaskTableView(),
379+
mTimeFrameGPU->getDeviceROFOverlapTableView(),
380+
mTimeFrameGPU->getDeviceArrayClusters(),
381+
(const unsigned char**)mTimeFrameGPU->getDeviceArrayUsedClusters(),
382+
mTimeFrameGPU->getDeviceArrayClustersIndexTables(),
383+
mTimeFrameGPU->getDeviceROFrameClusters(),
372384
mTimeFrameGPU->getDeviceTrackITSExt(),
373385
mTimeFrameGPU->getDeviceTrackSeedsLUT(),
386+
extendTracks ? mTimeFrameGPU->getDeviceActiveTrackExtensionHypotheses() : nullptr,
387+
extendTracks ? mTimeFrameGPU->getDeviceNextTrackExtensionHypotheses() : nullptr,
374388
this->mTrkParams[iteration].LayerRadii,
375389
this->mTrkParams[iteration].MinPt,
376390
this->mTrkParams[iteration].LayerxX0,
377391
trackSeeds.size(),
378392
mTimeFrameGPU->getNTrackSeeds(),
379393
this->mBz,
380-
startLevel,
381394
this->mTrkParams[iteration].MaxChi2ClusterAttachment,
382395
this->mTrkParams[iteration].MaxChi2NDF,
383396
this->mTrkParams[iteration].ReseedIfShorter,
384397
this->mTrkParams[iteration].RepeatRefitOut,
385398
this->mTrkParams[iteration].ShiftRefToCluster,
399+
this->mTrkParams[iteration].NLayers,
400+
this->mTrkParams[iteration].PhiBins,
401+
this->mTrkParams[iteration].TrackFollowerBeamWidth,
402+
extendTop,
403+
extendBot,
404+
this->mTrkParams[iteration].TrackFollowerNSigmaCutPhi,
405+
this->mTrkParams[iteration].TrackFollowerNSigmaCutZ,
386406
mTimeFrameGPU->getDevicePropagator(),
387407
this->mTrkParams[iteration].CorrType,
388408
mTimeFrameGPU->getFrameworkAllocator());
389409
mTimeFrameGPU->downloadTrackITSExtDevice();
390410

391411
auto& tracks = mTimeFrameGPU->getTrackITSExt();
392-
this->acceptTracks(iteration, tracks, firstClusters);
412+
this->acceptTracks(iteration, tracks, firstClusters, nExtendedTracks, nExtendedClusters);
393413
mTimeFrameGPU->loadUsedClustersDevice();
394414
}
395-
this->markTracks(iteration);
396-
if (!hasTrackFollower(iteration)) {
397-
// wipe the artefact memory
398-
mTimeFrameGPU->popMemoryStack(iteration);
415+
if (extendTracks) {
416+
LOGP(info, "Integrated track extension accepted {} tracks using {} clusters in iteration {}", nExtendedTracks, nExtendedClusters, iteration);
399417
}
400-
};
401-
402-
template <int NLayers>
403-
void TrackerTraitsGPU<NLayers>::extendTracks(const int iteration)
404-
{
405-
TrackerTraits<NLayers>::extendTracks(iteration);
406-
mTimeFrameGPU->loadUsedClustersDevice();
407-
// wipe the artefact memory kept alive for the track follower
418+
this->markTracks(iteration);
419+
// wipe the artefact memory
408420
mTimeFrameGPU->popMemoryStack(iteration);
409-
}
410-
411-
template <int NLayers>
412-
bool TrackerTraitsGPU<NLayers>::hasTrackFollower(const int iteration) const
413-
{
414-
return this->mTrkParams[iteration].PassFlags[IterationStep::TrackFollowerTop] ||
415-
this->mTrkParams[iteration].PassFlags[IterationStep::TrackFollowerBot];
416-
}
417-
418-
template <int NLayers>
419-
void TrackerTraitsGPU<NLayers>::buildTrackExtensionCandidates(const int iteration, typename TrackerTraits<NLayers>::TrackExtensionCandidates& candidatesPerTrack)
420-
{
421-
const auto nTracks = this->mTimeFrame->getTracks().size();
422-
const int beamWidth = std::max(1, this->mTrkParams[iteration].TrackFollowerBeamWidth);
423-
mTimeFrameGPU->syncStreams();
424-
mTimeFrameGPU->loadTrackExtensionStartTracksDevice();
425-
mTimeFrameGPU->createTrackExtensionCandidatesDevice(nTracks);
426-
mTimeFrameGPU->createTrackExtensionScratchDevice(kTrackExtensionLaunchThreads, beamWidth);
427-
std::array<float, NLayers> layerRadii{};
428-
std::array<float, NLayers> layerxX0{};
429-
for (int iLayer{0}; iLayer < this->mTrkParams[iteration].NLayers; ++iLayer) {
430-
layerRadii[iLayer] = this->mTrkParams[iteration].LayerRadii[iLayer];
431-
layerxX0[iLayer] = this->mTrkParams[iteration].LayerxX0[iLayer];
432-
}
433-
computeTrackExtensionCandidatesHandler<NLayers>(mTimeFrameGPU->getDeviceTrackExtensionStartTracks(),
434-
mTimeFrameGPU->getDeviceIndexTableUtils(),
435-
mTimeFrameGPU->getDeviceROFMaskTableView(),
436-
mTimeFrameGPU->getDeviceROFOverlapTableView(),
437-
mTimeFrameGPU->getDeviceArrayClusters(),
438-
(const uint8_t**)mTimeFrameGPU->getDeviceArrayUsedClusters(),
439-
mTimeFrameGPU->getDeviceArrayClustersIndexTables(),
440-
mTimeFrameGPU->getDeviceROFrameClusters(),
441-
mTimeFrameGPU->getDeviceArrayTrackingFrameInfo(),
442-
mTimeFrameGPU->getDeviceTrackExtensionCandidates(),
443-
mTimeFrameGPU->getDeviceTrackExtensionCandidateOffsets(),
444-
mTimeFrameGPU->getDeviceActiveTrackExtensionHypotheses(),
445-
mTimeFrameGPU->getDeviceNextTrackExtensionHypotheses(),
446-
layerRadii,
447-
layerxX0,
448-
static_cast<int>(nTracks),
449-
this->mTrkParams[iteration].NLayers,
450-
this->mTrkParams[iteration].PhiBins,
451-
beamWidth,
452-
this->mTrkParams[iteration].PassFlags[IterationStep::TrackFollowerTop],
453-
this->mTrkParams[iteration].PassFlags[IterationStep::TrackFollowerBot],
454-
this->mBz,
455-
this->mTrkParams[iteration].MaxChi2ClusterAttachment,
456-
this->mTrkParams[iteration].MaxChi2NDF,
457-
this->mTrkParams[iteration].TrackFollowerNSigmaCutPhi,
458-
this->mTrkParams[iteration].TrackFollowerNSigmaCutZ,
459-
mTimeFrameGPU->getDevicePropagator(),
460-
this->mTrkParams[iteration].CorrType,
461-
mTimeFrameGPU->getStream(0));
462-
mTimeFrameGPU->createTrackExtensionResultsDevice(nTracks);
463-
computeTrackExtensionResultsHandler<NLayers>(mTimeFrameGPU->getDeviceTrackExtensionStartTracks(),
464-
mTimeFrameGPU->getDeviceTrackExtensionCandidates(),
465-
mTimeFrameGPU->getDeviceTrackExtensionCandidateOffsets(),
466-
mTimeFrameGPU->getDeviceTrackExtensionResults(),
467-
mTimeFrameGPU->getDeviceArrayTrackingFrameInfo(),
468-
layerxX0,
469-
static_cast<int>(nTracks),
470-
this->mTrkParams[iteration].NLayers,
471-
this->mBz,
472-
this->mTrkParams[iteration].MaxChi2ClusterAttachment,
473-
this->mTrkParams[iteration].MaxChi2NDF,
474-
mTimeFrameGPU->getDevicePropagator(),
475-
this->mTrkParams[iteration].CorrType,
476-
this->mTrkParams[iteration].ShiftRefToCluster,
477-
mTimeFrameGPU->getStream(0));
478-
mTimeFrameGPU->downloadTrackExtensionResultsDevice();
479-
480-
const auto& results = mTimeFrameGPU->getTrackExtensionResults();
481-
for (int iResult{0}; iResult < static_cast<int>(results.size()); ++iResult) {
482-
const auto& result = results[iResult];
483-
if (!result.isValid()) {
484-
continue;
485-
}
486-
auto candidate = result.candidate;
487-
candidate.resultIndex = iResult;
488-
if (candidatesPerTrack.add(candidate.trackIndex, candidate) < 0) {
489-
continue;
490-
}
491-
}
492-
}
493-
494-
template <int NLayers>
495-
bool TrackerTraitsGPU<NLayers>::materializeTrackExtensionCandidate(TrackITSExt& track, const typename TrackerTraits<NLayers>::TrackExtensionCandidateN& candidate, const int iteration)
496-
{
497-
const auto& results = mTimeFrameGPU->getTrackExtensionResults();
498-
if (candidate.resultIndex < 0 || candidate.resultIndex >= static_cast<int>(results.size())) {
499-
return TrackerTraits<NLayers>::materializeTrackExtensionCandidate(track, candidate, iteration);
500-
}
501-
const auto& result = results[candidate.resultIndex];
502-
if (!result.isValid() || result.candidate.trackIndex != candidate.trackIndex) {
503-
return false;
504-
}
505-
track = result.track;
506-
this->updateExtendedTrackTimeStamp(track, iteration);
507-
uint32_t diff{0};
508-
for (int iLayer{0}; iLayer < this->mTrkParams[iteration].NLayers; ++iLayer) {
509-
if (candidate.addedClusters[iLayer] != constants::UnusedIndex) {
510-
diff |= (0x1u << iLayer);
511-
}
512-
}
513-
applyExtendedClustersPattern<NLayers>(track, diff);
514-
return true;
515-
}
421+
};
516422

517423
template <int NLayers>
518424
int TrackerTraitsGPU<NLayers>::getTFNumberOfClusters() const

0 commit comments

Comments
 (0)