37 this->mTaskArena->execute([&] {
38 mTimeFrameGPU->initialise(this->mTrkParams[iteration], this->mTrkParams[iteration].NLayers, iteration);
41 mTimeFrameGPU->loadIterationParameters(this->mTrkParams[iteration]);
45 mTimeFrameGPU->loadVertices();
47 mTimeFrameGPU->loadROFOverlapTable();
48 mTimeFrameGPU->loadTrackingTopologies();
50 mTimeFrameGPU->loadROFVertexLookupTable();
53 mTimeFrameGPU->loadIndexTableUtils();
55 mTimeFrameGPU->createUsedClustersDeviceArray();
56 mTimeFrameGPU->createClustersDeviceArray();
57 mTimeFrameGPU->createUnsortedClustersDeviceArray();
58 mTimeFrameGPU->createClustersIndexTablesArray();
59 mTimeFrameGPU->createTrackingFrameInfoDeviceArray();
60 mTimeFrameGPU->createROFrameClustersDeviceArray();
62 mTimeFrameGPU->createClusterRadiiDevice();
63 mTimeFrameGPU->uploadClusterRadii();
64 mTimeFrameGPU->createTrackletsLUTDeviceArray();
65 mTimeFrameGPU->createTrackletsBuffersArray();
66 mTimeFrameGPU->createCellsBuffersArray();
67 mTimeFrameGPU->createCellsLUTDeviceArray();
68 mTimeFrameGPU->createClusterOwnersDeviceArray();
71 mTimeFrameGPU->loadROFCutMask(iteration);
85 const auto topology = mTimeFrameGPU->getDeviceTrackingTopologyView();
88 for (
int iLayer{0}; iLayer < this->mTrkParams[iteration].NLayers; ++iLayer) {
89 if (loadFirstPassData) {
90 mTimeFrameGPU->createUsedClustersDevice(iLayer);
91 mTimeFrameGPU->loadUnsortedClustersDevice(iLayer);
92 mTimeFrameGPU->loadROFrameClustersDevice(iLayer);
93 mTimeFrameGPU->sortClustersDevice(iLayer, this->mTrkParams[iteration]);
95 mTimeFrameGPU->recordEvent(iLayer);
98 for (
int linkId{0}; linkId < hostTopology.nLinks; ++linkId) {
99 mTimeFrameGPU->createTrackletsLUTDevice(loadFirstPassData, linkId);
104 mTimeFrameGPU->pushMemoryStack(iteration);
106 const auto nClusters = mTimeFrameGPU->getClusterSizes();
107 const bool useDiamond = this->mTrkParams[iteration].UseDiamond;
110 mTimeFrameGPU->createDiamondDevice(diamondVert);
111 mTimeFrameGPU->recordEvent(0);
113 const Vertex* deviceVertices = useDiamond ? mTimeFrameGPU->getDeviceDiamond() : mTimeFrameGPU->getDeviceVertices();
115 bounded_vector<float> vtxPhiCuts(seedingPass ? hostTopology.nLinks : 0,
116 this->mTrkParams[iteration].VtxPhiCut,
117 this->getMemoryPool().get());
118 auto& linkPhiCuts = seedingPass ? vtxPhiCuts : mTimeFrameGPU->getLinkPhiCuts();
120 for (
int linkId{0}; linkId < hostTopology.nLinks; ++linkId) {
121 const auto link = hostTopology.getLink(linkId);
122 mTimeFrameGPU->waitEvent(linkId,
link.fromLayer);
123 mTimeFrameGPU->waitEvent(linkId,
link.toLayer);
125 mTimeFrameGPU->waitEvent(linkId, 0);
128 const auto scale =
static_cast<double>(
nClusters[
link.fromLayer]);
129 runOnSlab(mTimeFrameGPU->getCapacityEstimator(),
key, scale, [&](
const int capacity) {
130 mTimeFrameGPU->createTrackletsBuffers(linkId, capacity);
131 return TrackingKernels<NLayers>::computeTrackletsInROFsHandler(mTimeFrameGPU->getDeviceIndexTableUtils(),
132 mTimeFrameGPU->getDeviceROFMaskTableView(),
136 mTimeFrameGPU->getDeviceROFOverlapTableView(),
137 mTimeFrameGPU->getDeviceROFVertexLookupTableView(),
141 mTimeFrameGPU->getDeviceArrayClusters(),
143 mTimeFrameGPU->getDeviceROFrameClusters(),
144 (const uint8_t**)mTimeFrameGPU->getDeviceArrayUsedClusters(),
145 mTimeFrameGPU->getDeviceArrayClustersIndexTables(),
146 mTimeFrameGPU->getDeviceArrayTracklets(),
147 mTimeFrameGPU->getDeviceTracklets(),
148 mTimeFrameGPU->getNTracklets(),
150 mTimeFrameGPU->getDeviceTrackletsLUTs(),
151 this->mTrkParams[iteration].PassFlags[IterationStep::SelectUPCVertices],
152 this->mTrkParams[iteration].NSigmaCut,
155 this->mTrkParams[iteration].PVres,
156 mTimeFrameGPU->getDeviceMinRs(),
157 mTimeFrameGPU->getDeviceMaxRs(),
158 mTimeFrameGPU->getPositionResolutions(),
159 this->mTrkParams[iteration].LayerRadii,
160 mTimeFrameGPU->getLinkMSAngles(),
161 mTimeFrameGPU->getFrameworkAllocator(),
162 mTimeFrameGPU->getStreams());
164 mTimeFrameGPU->recordEvent(linkId);
171 const auto topology = mTimeFrameGPU->getDeviceTrackingTopologyView();
172 const auto hostTopology = mTimeFrameGPU->getTrackingTopologyView();
173 for (
int iLayer{0}; iLayer < this->mTrkParams[iteration].NLayers; ++iLayer) {
175 mTimeFrameGPU->loadUnsortedClustersDevice(iLayer);
176 mTimeFrameGPU->loadTrackingFrameInfoDevice(iLayer);
178 mTimeFrameGPU->recordEvent(iLayer);
181 for (
int cellTopologyId{hostTopology.nCells}; cellTopologyId--;) {
182 const auto cellTopology = hostTopology.getCell(cellTopologyId);
183 const auto first = hostTopology.getLink(cellTopology.firstLink);
184 const auto second = hostTopology.getLink(cellTopology.secondLink);
185 const float cellDeltaPhiCut = this->mTrkParams[iteration].PassFlags[
IterationStep::SeedingVertexPass] ? math_utils::cellDeltaPhiBound(this->mBz, this->mTrkParams[iteration].CellDeltaPhiMinPt,
186 this->mTrkParams[iteration].LayerRadii[
first.fromLayer],
187 this->mTrkParams[iteration].LayerRadii[
first.toLayer],
188 this->mTrkParams[iteration].LayerRadii[second.toLayer],
189 mTimeFrameGPU->getLinkMSAngle(cellTopology.firstLink))
190 : o2::constants::math::TwoPI;
191 const float cellTanLNSigma = this->mTrkParams[iteration].CellDeltaTanLambdaNSigma > 0.f
192 ? this->mTrkParams[iteration].CellDeltaTanLambdaNSigma
193 : this->mTrkParams[iteration].NSigmaCut;
194 const int currentLayerTrackletsNum{
static_cast<int>(mTimeFrameGPU->getNTracklets()[cellTopology.firstLink])};
195 if (!currentLayerTrackletsNum || !mTimeFrameGPU->getNTracklets()[cellTopology.secondLink]) {
196 mTimeFrameGPU->getNCells()[cellTopologyId] = 0;
200 mTimeFrameGPU->createCellsLUTDevice(cellTopologyId);
201 mTimeFrameGPU->waitEvent(cellTopologyId, cellTopology.firstLink);
202 mTimeFrameGPU->waitEvent(cellTopologyId, cellTopology.secondLink);
203 mTimeFrameGPU->waitEvent(cellTopologyId,
first.fromLayer);
204 mTimeFrameGPU->waitEvent(cellTopologyId,
first.toLayer);
205 mTimeFrameGPU->waitEvent(cellTopologyId, second.toLayer);
207 const auto scale =
static_cast<double>(currentLayerTrackletsNum);
208 const int emitted = runOnSlab(mTimeFrameGPU->getCapacityEstimator(),
key, scale, [&](
const int capacity) {
209 mTimeFrameGPU->createCellsBuffers(cellTopologyId, capacity);
210 return TrackingKernels<NLayers>::computeCellsHandler(mTimeFrameGPU->getDeviceArrayClusters(),
211 mTimeFrameGPU->getDeviceArrayUnsortedClusters(),
212 mTimeFrameGPU->getDeviceArrayTrackingFrameInfo(),
213 mTimeFrameGPU->getDeviceArrayTracklets(),
214 mTimeFrameGPU->getDeviceArrayTrackletsLUT(),
215 currentLayerTrackletsNum,
218 mTimeFrameGPU->getDeviceCells()[cellTopologyId],
220 mTimeFrameGPU->getDeviceCellLUTs()[cellTopologyId],
222 this->mTrkParams[iteration].MaxChi2ClusterAttachment,
223 this->mTrkParams[iteration].CellDeltaTanLambdaSigma,
226 mTimeFrameGPU->getDeviceLayerxX0(),
227 mTimeFrameGPU->getCapacityEstimator(),
229 !this->mTrkParams[iteration].PassFlags[IterationStep::SeedingVertexPass],
230 mTimeFrameGPU->getFrameworkAllocator(),
231 mTimeFrameGPU->getStreams());
233 mTimeFrameGPU->getNCells()[cellTopologyId] = emitted;
234 mTimeFrameGPU->recordEvent(cellTopologyId);
236 mTimeFrameGPU->syncStreams(
false);
242 const int nCells = mTimeFrameGPU->getNCells()[0];
244 mTimeFrameGPU->setNLinesTotal(0);
247 mTimeFrameGPU->createClusterOwnersDevice();
248 mTimeFrameGPU->createLinesDevice(nCells);
249 mTimeFrameGPU->resetClusterOwnersDevice();
250 mTimeFrameGPU->syncStreams(
false);
254 mTimeFrameGPU->getDeviceArrayClusterOwners(),
255 mTimeFrameGPU->getStream(0));
258 mTimeFrameGPU->getDeviceCells()[0],
259 mTimeFrameGPU->getDeviceArrayClusterOwners(),
260 mTimeFrameGPU->getDeviceROFramesClusters(1),
261 mTimeFrameGPU->getNrof(1),
262 this->mTrkParams[iteration].CellLineSharedClusterCut,
263 mTimeFrameGPU->getDeviceLines(),
264 mTimeFrameGPU->getDeviceLineRof(),
265 mTimeFrameGPU->getDeviceLineClusters(),
266 mTimeFrameGPU->getDeviceLineSlots(),
267 mTimeFrameGPU->getBeamX(),
268 mTimeFrameGPU->getBeamY(),
270 this->mTrkParams[iteration].VtxLineCurvatureScale,
271 this->mTrkParams[iteration].VtxMaxZPositionAllowed,
272 this->mTrkParams[iteration].VtxLineMinPt,
273 mTimeFrameGPU->getDeviceLineZs(),
274 mTimeFrameGPU->getDeviceLineTimes(),
275 mTimeFrameGPU->getDeviceLineChi2(),
276 mTimeFrameGPU->getDeviceLinePt(),
277 mTimeFrameGPU->getFrameworkAllocator(),
278 mTimeFrameGPU->getStream(0));
279 const unsigned int nLines = mTimeFrameGPU->downloadLinesDevice();
282 mTimeFrameGPU->getNrof(1),
283 mTimeFrameGPU->getLineProjSoA(),
284 mTimeFrameGPU->getLineProjSortedSoA(),
285 mTimeFrameGPU->getDeviceLineRof(),
286 mTimeFrameGPU->getDeviceRofLineOffsets(),
287 mTimeFrameGPU->getFrameworkAllocator(),
288 mTimeFrameGPU->getStream(0));
290 const auto& tp = this->mTrkParams[iteration];
291 const float zWindow = 0.5f * tp.VtxClusterCut;
293 mTimeFrameGPU->getLineProjSortedSoA(),
294 mTimeFrameGPU->getDeviceRofLineOffsets(),
295 mTimeFrameGPU->getDeviceLineDensity(),
296 mTimeFrameGPU->getDeviceLineWin(),
298 mTimeFrameGPU->getStream(0));
300 const float fineZWindow = tp.VtxFineZWindow;
301 const bool doFine = fineZWindow > 0.f && fineZWindow < zWindow;
304 mTimeFrameGPU->getLineProjSortedSoA(),
305 mTimeFrameGPU->getDeviceRofLineOffsets(),
306 mTimeFrameGPU->getDeviceLineDensityFine(),
307 mTimeFrameGPU->getDeviceLineWinFine(),
309 mTimeFrameGPU->getStream(0));
313 mTimeFrameGPU->getNrof(1),
314 mTimeFrameGPU->getLineProjSortedSoA(),
315 mTimeFrameGPU->getDeviceRofLineOffsets(),
316 mTimeFrameGPU->getDeviceLineDensity(),
317 mTimeFrameGPU->getDeviceLineWin(),
318 mTimeFrameGPU->getDeviceLineIsPeak(),
319 doFine ? mTimeFrameGPU->getDeviceLineDensityFine() :
nullptr,
320 doFine ? mTimeFrameGPU->getDeviceLineWinFine() :
nullptr,
321 tp.VtxFineMinDensity,
322 doFine ? mTimeFrameGPU->getDeviceLineIsPeakFine() :
nullptr,
323 mTimeFrameGPU->getDevicePeakScan(),
324 mTimeFrameGPU->getDevicePeakLineIdx(),
325 mTimeFrameGPU->getDevicePeakOffsets(),
326 mTimeFrameGPU->getFrameworkAllocator(),
327 mTimeFrameGPU->getStream(0));
329 const float goodLinePtCut = std::abs(mTimeFrameGPU->getBz()) > 0.01f ? tp.VtxGoodLinePtCut : -1.f;
331 mTimeFrameGPU->getDevicePeakLineIdx(),
332 mTimeFrameGPU->getDeviceLineWin(),
333 mTimeFrameGPU->getLineProjSortedSoA(),
334 mTimeFrameGPU->getDeviceLines(),
335 mTimeFrameGPU->getDeviceLineChi2(),
336 mTimeFrameGPU->getDeviceLinePt(),
337 tp.VtxGoodLineChi2Cut,
339 tp.VtxPairCut * tp.VtxPairCut,
341 tp.VtxClusterContributorsCut,
342 mTimeFrameGPU->getBeamX(),
343 mTimeFrameGPU->getBeamY(),
344 doFine ? mTimeFrameGPU->getDeviceLineIsPeakFine() :
nullptr,
346 mTimeFrameGPU->getDeviceVertexCands(),
347 mTimeFrameGPU->getStream(0));
349 const float duplicateZCut = tp.VtxDuplicateZCut > 0.f
350 ? tp.VtxDuplicateZCut
351 : std::max(4.f * tp.VtxPairCut, 0.5f * tp.VtxClusterCut);
353 mTimeFrameGPU->getDevicePeakLineIdx(),
354 mTimeFrameGPU->getDevicePeakOffsets(),
355 mTimeFrameGPU->getLineProjSortedSoA(),
357 tp.VtxDuplicateZScale,
358 mTimeFrameGPU->getDeviceVertexCands(),
359 mTimeFrameGPU->getStream(0));
361 const bool withMC = mTimeFrameGPU->hasMCinformation() && this->mTrkParams[iteration].CreateArtefactLabels;
362 mTimeFrameGPU->downloadVertexCandsDevice();
365 mTimeFrameGPU->downloadPeakMembershipInputs();
367 const auto& lines = mTimeFrameGPU->getHostLines();
368 const auto& lineRof = mTimeFrameGPU->getHostLineRof();
369 const auto& lineClusters = mTimeFrameGPU->getHostLineClusters();
370 const int nRofs = mTimeFrameGPU->getNrof(1);
372 mTimeFrameGPU->getLineLabelFlat() = bounded_vector<o2::MCCompLabel>(nLines,
o2::MCCompLabel(), mTimeFrameGPU->getMemoryPool().
get());
375 const auto l0 = mTimeFrameGPU->getClusterLabels(0, cl[0]);
376 const auto l1 = mTimeFrameGPU->getClusterLabels(1, cl[1]);
377 const auto l2 = mTimeFrameGPU->getClusterLabels(2, cl[2]);
378 for (
const auto&
a : l0) {
382 bool in1{
false}, in2{
false};
383 for (
const auto&
b : l1) {
389 for (
const auto&
c : l2) {
401 for (
unsigned int i{0};
i < nLines; ++
i) {
402 const int rof = lineRof[
i];
403 if (rof < 0 || rof >= nRofs) {
404 LOGP(fatal,
"ITS GPU linearizer: line {} carries out-of-range ROF {} (nRofs={}).",
i, rof, nRofs);
406 const auto& l = lines[
i];
407 mTimeFrameGPU->getLines(rof).emplace_back(std::array<float, 3>{l.originPoint[0], l.originPoint[1], l.originPoint[2]},
408 std::array<float, 3>{l.cosinesDirector[0], l.cosinesDirector[1], l.cosinesDirector[2]},
411 const auto lbl = lineLabel(&lineClusters[3 *
i]);
412 mTimeFrameGPU->getLinesLabel(rof).emplace_back(lbl);
413 mTimeFrameGPU->getLineLabelFlat()[
i] = lbl;
416 mTimeFrameGPU->setNLinesTotal(nLines);
422 const int nRofs = mTimeFrameGPU->getNrof(1);
423 const bool withMC = mTimeFrameGPU->hasMCinformation() && this->mTrkParams[iteration].CreateArtefactLabels;
424 const int suppressLowMultDebris = this->mTrkParams[iteration].VtxSuppressLowMultDebris;
427 const auto& cands = mTimeFrameGPU->getHostVertexCands();
428 const auto& peakOffsets = mTimeFrameGPU->getHostPeakOffsets();
430 std::vector<std::vector<Vertex>> rofVertices(nRofs);
431 std::vector<std::vector<VertexLabel>> rofLabels(nRofs);
432 const float goodSig = this->mTrkParams[iteration].VtxGoodContributorsSignificance;
434 for (
int rofId = 0; rofId < nRofs; ++rofId) {
435 if (skipHighMultRofs &&
436 static_cast<int>(mTimeFrameGPU->getROFVertexLookupTableView().getVertices(1, rofId).getEntries()) > this->mTrkParams[iteration].VertPerRofThreshold) {
440 std::vector<int> accepted;
441 for (
int p = peakOffsets[rofId]; p < peakOffsets[rofId + 1]; ++p) {
443 accepted.push_back(p);
446 std::sort(accepted.begin(), accepted.end(), [&](
const int a,
const int b) { return cands[a].size > cands[b].size; });
450 for (
int p = peakOffsets[rofId]; p < peakOffsets[rofId + 1]; ++p) {
451 if (cands[p].ok && !cands[p].fine) {
452 rofLoad += cands[p].size;
456 const float debrisThreshold = goodSig > 0.f ?
getDebrisThreshold(goodSig, rofLoad, suppressLowMultDebris) : 0.f;
458 for (
const int p : accepted) {
459 const auto&
c = cands[p];
460 if (!rofVertices[rofId].
empty()) {
462 if (
c.nGood < debrisThreshold) {
465 }
else if (
c.size < suppressLowMultDebris) {
469 const float pos[3] = {
c.x,
c.y,
c.z};
475 rofVertices[rofId].push_back(
vertex);
479 const auto& memb = mTimeFrameGPU->getHostPeakMembership();
480 const auto& lines = mTimeFrameGPU->getHostLines();
481 const auto& lineLabelFlat = mTimeFrameGPU->getLineLabelFlat();
482 const int nLab =
static_cast<int>(lineLabelFlat.size());
483 const float pairCut2 = this->mTrkParams[iteration].VtxPairCut * this->mTrkParams[iteration].VtxPairCut;
484 const int k = memb.peakLineIdx[p];
485 const auto tk = memb.times[k];
486 const auto wk = memb.win[k];
487 std::vector<o2::MCCompLabel>
labels;
488 labels.reserve(wk.hi - wk.lo);
489 for (
int j = wk.lo;
j < wk.hi; ++
j) {
490 const auto tj = memb.times[
j];
491 if (!tk.isCompatible(tj)) {
494 const int gi = memb.sortedToLine[
j];
495 if (gi < 0 || gi >= nLab) {
496 LOGP(error,
"Seeding vertexer: member line {} out of range (nLines={}), skipping label", gi, nLab);
502 labels.push_back(lineLabelFlat[gi]);
509 pruneOverpopulatedRofs(rofVertices, rofLabels, this->mTrkParams[iteration].VtxOverpopulatedRofNSigma, suppressLowMultDebris);
512 for (
int rofId = 0; rofId < nRofs; ++rofId) {
513 for (
auto&
vertex : rofVertices[rofId]) {
514 mTimeFrameGPU->addPrimaryVertex(
vertex);
517 for (
auto&
label : rofLabels[rofId]) {
518 mTimeFrameGPU->addPrimaryVertexLabel(
label);
523 auto& pvs = mTimeFrameGPU->getPrimaryVertices();
524 std::vector<size_t>
indices(pvs.size());
526 std::sort(
indices.begin(),
indices.end(), [&pvs](
const size_t i,
const size_t j) {
527 const auto aLower = pvs[i].getTimeStamp().lower();
528 const auto bLower = pvs[j].getTimeStamp().lower();
529 if (aLower != bLower) {
530 return aLower < bLower;
532 return pvs[
i].getNContributors() > pvs[
j].getNContributors();
534 std::decay_t<
decltype(pvs)> sortedVtx(pvs.get_allocator());
535 sortedVtx.reserve(pvs.size());
536 for (
const size_t idx :
indices) {
537 sortedVtx.push_back(pvs[idx]);
541 auto& mc = mTimeFrameGPU->getPrimaryVerticesLabels();
542 std::decay_t<
decltype(mc)> sortedMC(mc.get_allocator());
543 sortedMC.reserve(mc.size());
544 for (
const size_t idx :
indices) {
545 sortedMC.push_back(mc[idx]);
549 mTimeFrameGPU->updateROFVertexLookupTable();
551 mTimeFrameGPU->popMemoryStack(iteration);
557 const auto hostTopology = mTimeFrameGPU->getTrackingTopologyView();
558 bounded_vector<int> sourceTopologies(this->getMemoryPool().
get());
559 sourceTopologies.reserve(hostTopology.nCells);
560 for (
int outerLayer{0}; outerLayer < NLayers; ++outerLayer) {
561 for (
int targetCellTopologyId{0}; targetCellTopologyId < hostTopology.nCells; ++targetCellTopologyId) {
562 const auto targetCellTopology = hostTopology.getCell(targetCellTopologyId);
563 if (targetCellTopology.hitLayerMask.last() != outerLayer) {
566 const int targetCellsNum{
static_cast<int>(mTimeFrameGPU->getNCells()[targetCellTopologyId])};
567 sourceTopologies.clear();
568 size_t sourceCellCount{0};
569 for (
int sourceCellTopologyId{0}; sourceCellTopologyId < hostTopology.nCells; ++sourceCellTopologyId) {
570 const auto sourceCellTopology = hostTopology.getCell(sourceCellTopologyId);
571 const int sourceCellsNum{
static_cast<int>(mTimeFrameGPU->getNCells()[sourceCellTopologyId])};
572 if (!sourceCellsNum || sourceCellTopology.secondLink != targetCellTopology.firstLink) {
575 sourceTopologies.push_back(sourceCellTopologyId);
576 sourceCellCount += sourceCellsNum;
578 if (!targetCellsNum || sourceTopologies.empty()) {
579 mTimeFrameGPU->getNNeighbours()[targetCellTopologyId] = 0;
580 mTimeFrameGPU->createNeighboursDevice(targetCellTopologyId, 0);
581 mTimeFrameGPU->recordEvent(targetCellTopologyId);
584 mTimeFrameGPU->createNeighboursLUTDevice(targetCellTopologyId, targetCellsNum);
585 auto&
stream = mTimeFrameGPU->getStream(targetCellTopologyId);
586 int* outputCounter = mTimeFrameGPU->getDeviceNeighboursLUT(targetCellTopologyId) + targetCellsNum;
588 const auto key = CapacityEstimator::makeKey(SlabSite::Neighbours, iteration, 0, targetCellTopologyId);
589 const auto scale =
static_cast<double>(sourceCellCount);
590 const int emitted = runOnSlab(mTimeFrameGPU->getCapacityEstimator(),
key, scale, [&](
const int capacity) {
591 mTimeFrameGPU->createNeighboursDevice(targetCellTopologyId, capacity);
592 resetOutputCounterHandler(outputCounter, stream);
593 for (const int sourceCellTopologyId : sourceTopologies) {
594 mTimeFrameGPU->waitEvent(targetCellTopologyId, sourceCellTopologyId);
595 TrackingKernels<NLayers>::computeCellNeighboursHandler(mTimeFrameGPU->getDeviceArrayCells(),
596 mTimeFrameGPU->getDeviceArrayCellsLUT(),
597 mTimeFrameGPU->getDeviceNeighbours(targetCellTopologyId),
600 sourceCellTopologyId,
601 targetCellTopologyId,
602 this->mTrkParams[iteration].MaxChi2ClusterAttachment,
604 mTimeFrameGPU->getNCells()[sourceCellTopologyId],
605 mTimeFrameGPU->getFrameworkAllocator(),
609 mTimeFrameGPU->getDeviceNeighboursLUT(targetCellTopologyId),
612 mTimeFrameGPU->getFrameworkAllocator(),
615 mTimeFrameGPU->getNNeighbours()[targetCellTopologyId] = emitted;
616 mTimeFrameGPU->recordEvent(targetCellTopologyId);
619 mTimeFrameGPU->syncStreams(
false);
625 bounded_vector<bounded_vector<int>> firstClusters(this->mTrkParams[iteration].NLayers, bounded_vector<int>(this->getMemoryPool().
get()), this->getMemoryPool().
get());
626 firstClusters.resize(this->mTrkParams[iteration].NLayers);
627 const auto hostTopology = mTimeFrameGPU->getTrackingTopologyView();
628 const bool extendTop = this->mTrkParams[iteration].PassFlags[IterationStep::TrackFollowerTop];
629 const bool extendBot = this->mTrkParams[iteration].PassFlags[IterationStep::TrackFollowerBot];
631 for (
int startLevel{this->mTrkParams[iteration].CellsPerRoad()}; startLevel >= this->mTrkParams[iteration].CellMinimumLevel(); --startLevel) {
633 size_t startCells{0};
634 for (
int startCellTopologyId{0}; startCellTopologyId < hostTopology.nCells; ++startCellTopologyId) {
635 const int startLayer = hostTopology.getCell(startCellTopologyId).hitLayerMask.last();
636 if (this->mTrkParams[iteration].StartLayerMask.has(startLayer)) {
637 startCells += mTimeFrameGPU->getNCells()[startCellTopologyId];
643 const auto key = CapacityEstimator::makeKey(SlabSite::TrackSeeds, iteration, startLevel, 0);
644 auto& estimator = mTimeFrameGPU->getCapacityEstimator();
645 const int nSeeds = runOnSlab(estimator,
key,
static_cast<double>(startCells), [&](
const int capacity) {
646 mTimeFrameGPU->createTrackSeedsDevice(capacity);
648 for (
int startCellTopologyId{0}; startCellTopologyId < hostTopology.nCells; ++startCellTopologyId) {
649 const int startLayer = hostTopology.getCell(startCellTopologyId).hitLayerMask.last();
650 if (!(this->mTrkParams[iteration].StartLayerMask.has(startLayer)) || mTimeFrameGPU->getNCells()[startCellTopologyId] == 0) {
655 mTimeFrameGPU->getDeviceArrayCells(),
656 mTimeFrameGPU->getDeviceCells()[startCellTopologyId],
659 mTimeFrameGPU->getArrayNCells().data(),
660 (
const uint8_t**)mTimeFrameGPU->getDeviceArrayUsedClusters(),
661 mTimeFrameGPU->getDeviceArrayNeighbours(),
662 mTimeFrameGPU->getDeviceArrayNeighboursCellLUT(),
663 mTimeFrameGPU->getDeviceArrayTrackingFrameInfo(),
664 mTimeFrameGPU->getDeviceTrackSeeds(),
667 mTimeFrameGPU->getCapacityEstimator(),
670 this->mTrkParams[iteration].MaxChi2ClusterAttachment,
671 this->mTrkParams[iteration].MaxChi2NDF,
672 this->mTrkParams[iteration].MaxHoles,
673 this->mTrkParams[iteration].getMinSeedingClusters(),
674 this->mTrkParams[iteration].HoleLayerMask,
675 this->mTrkParams[iteration].getNonSeedingLayerMask(),
676 mTimeFrameGPU->getDeviceLayerxX0(),
677 mTimeFrameGPU->getDevicePropagator(),
678 this->mTrkParams[iteration].CorrType,
679 mTimeFrameGPU->getFrameworkAllocator());
681 return cursor; }, estimator.peakCapacity(
key));
683 LOGP(
debug,
"No track seeds found, skipping track finding");
687 mTimeFrameGPU->createTrackExtensionScratchDevice(gpu::gridThreads(gpu::ResidentBlocks.fitTrackSeedsExtended),
688 this->mTrkParams[iteration].TrackFollowerMaxHypotheses);
690 const auto trackKey = CapacityEstimator::makeKey(extendTracks ? SlabSite::TracksExtended : SlabSite::Tracks,
691 iteration, startLevel, 0);
692 const int nTracks = runOnSlab(estimator, trackKey,
static_cast<double>(nSeeds), [&](
const int capacity) {
693 mTimeFrameGPU->createTrackITSExtDevice(capacity);
695 mTimeFrameGPU->getDeviceArrayTrackingFrameInfo(),
696 mTimeFrameGPU->getDeviceArrayUnsortedClusters(),
697 mTimeFrameGPU->getDeviceIndexTableUtils(),
698 mTimeFrameGPU->getDeviceROFMaskTableView(),
699 mTimeFrameGPU->getDeviceROFOverlapTableView(),
700 mTimeFrameGPU->getDeviceArrayClusters(),
701 (
const unsigned char**)mTimeFrameGPU->getDeviceArrayUsedClusters(),
702 mTimeFrameGPU->getDeviceArrayClustersIndexTables(),
703 mTimeFrameGPU->getDeviceROFrameClusters(),
704 mTimeFrameGPU->getDeviceTrackITSExt(),
705 mTimeFrameGPU->getDeviceTrackIndices(),
706 mTimeFrameGPU->getDeviceTrackSeedIndices(),
707 mTimeFrameGPU->getDeviceTrackCounter(),
709 extendTracks ? mTimeFrameGPU->getDeviceActiveTrackExtensionHypotheses() :
nullptr,
710 extendTracks ? mTimeFrameGPU->getDeviceNextTrackExtensionHypotheses() :
nullptr,
711 mTimeFrameGPU->getDeviceLayerRadii(),
712 mTimeFrameGPU->getDeviceMinPts(),
713 mTimeFrameGPU->getDeviceLayerxX0(),
714 static_cast<unsigned int>(nSeeds),
716 this->mTrkParams[iteration].MaxChi2ClusterAttachment,
717 this->mTrkParams[iteration].MaxChi2NDF,
718 this->mTrkParams[iteration].ReseedIfShorter,
719 this->mTrkParams[iteration].RepeatRefitOut,
720 this->mTrkParams[iteration].ShiftRefToCluster,
721 this->mTrkParams[iteration].NLayers,
722 this->mTrkParams[iteration].PhiBins,
723 this->mTrkParams[iteration].TrackFollowerMaxHypotheses,
726 this->mTrkParams[iteration].TrackFollowerNSigmaCutPhi,
727 this->mTrkParams[iteration].TrackFollowerNSigmaCutZ,
728 mTimeFrameGPU->getDevicePropagator(),
729 this->mTrkParams[iteration].CorrType,
730 mTimeFrameGPU->getFrameworkAllocator()); }, estimator.peakCapacity(trackKey));
731 mTimeFrameGPU->createTrackITSExtHost(nTracks);
732 mTimeFrameGPU->downloadTrackITSExtDevice();
734 auto&
tracks = mTimeFrameGPU->getTrackITSExt();
735 const auto& trackIndices = mTimeFrameGPU->getTrackIndices();
736 this->acceptTracks(iteration,
tracks, trackIndices, firstClusters);
737 mTimeFrameGPU->loadUsedClustersDevice();
739 this->markTracks(iteration);
741 mTimeFrameGPU->popMemoryStack(iteration);