15#define GPUCA_CADEBUG 0
16#define GPUCA_MERGE_LOOPER_MC 0
21#if !defined(GPUCA_GPUCODE) && (defined(GPUCA_MERGER_BY_MC_LABEL) || defined(GPUCA_CADEBUG_ENABLED) || GPUCA_MERGE_LOOPER_MC)
26#ifndef GPUCA_GPUCODE_DEVICE
40#include "GPUDefParametersRuntime.h"
64using namespace gputpcgmmergertypes;
91 GPUd() bool operator()(const int32_t
aa, const int32_t
bb)
96 return a.CCE() >
b.CCE();
99 if (
a.NClusters() !=
b.NClusters()) {
100 return a.NClusters() > b.NClusters();
101 }
if (CAMath::Abs(
a.GetParam().GetQPt()) != CAMath::Abs(
b.GetParam().GetQPt())) {
102 return CAMath::Abs(a.GetParam().GetQPt()) > CAMath::Abs(b.GetParam().GetQPt());
103 }
if (
a.GetParam().GetY() !=
b.GetParam().GetY()) {
104 return a.GetParam().GetY() > b.GetParam().GetY();
108 return a.NClusters() >
b.NClusters();
116 GPUd() bool operator()(const int32_t
aa, const int32_t
bb)
122 return CAMath::Abs(
a.GetParam().GetQPt()) > CAMath::Abs(
b.GetParam().GetQPt());
123 }
if (
a.GetParam().GetY() !=
b.GetParam().GetY()) {
124 return a.GetParam().GetY() >
b.GetParam().GetY();
126 return a.GetParam().GetZ() >
b.GetParam().GetZ();
128 return CAMath::Abs(
a.GetParam().GetQPt()) > CAMath::Abs(
b.GetParam().GetQPt());
136 return GPUCA_DETERMINISTIC_CODE(CAMath::Abs(
a.refz) != CAMath::Abs(
b.refz) ? CAMath::Abs(
a.refz) < CAMath::Abs(
b.refz) :
a.id <
b.id, CAMath::Abs(
a.refz) < CAMath::Abs(
b.refz));
157 mNextSectorInd[mid] = 0;
158 mPrevSectorInd[0] = mid;
159 mNextSectorInd[last] =
NSECTORS / 2;
160 mPrevSectorInd[
NSECTORS / 2] = last;
164#if !defined(GPUCA_GPUCODE) && (defined(GPUCA_MERGER_BY_MC_LABEL) || defined(GPUCA_CADEBUG_ENABLED) || GPUCA_MERGE_LOOPER_MC)
178template <
class T,
class S>
179int64_t GPUTPCGMMerger::GetTrackLabelA(
const S& trk)
const
183 if constexpr (std::is_same_v<S, GPUTPCGMBorderTrack&>) {
184 sectorTrack = &mSectorTrackInfos[trk.TrackID()];
185 nClusters = sectorTrack->OrigTrack()->NHits();
189 auto acc =
GPUTPCTrkLbl<false, GPUTPCTrkLbl_ret>(resolveMCLabels<T>(GetConstantMem()->ioPtrs.clustersNative ? GetConstantMem()->ioPtrs.clustersNative->clustersMCTruth : nullptr, GetConstantMem()->ioPtrs.mcLabelsTPC), 0.5f);
192 if constexpr (std::is_same_v<S, GPUTPCGMBorderTrack&>) {
193 const GPUTPCTracker& tracker = GetConstantMem()->tpcTrackers[sectorTrack->Sector()];
194 const GPUTPCHitId& ic = tracker.TrackHits()[sectorTrack->OrigTrack()->FirstHitID() +
i];
195 id = tracker.Data().ClusterDataIndex(tracker.Data().Row(ic.RowIndex()), ic.HitIndex()) + GetConstantMem()->ioPtrs.clustersNative->clusterOffset[sectorTrack->Sector()][0];
197 id = mClusters[trk.FirstClusterRef() +
i].
num;
201 return acc.computeLabel().id;
205int64_t GPUTPCGMMerger::GetTrackLabel(
const S& trk)
const
207#ifdef GPUCA_TPC_GEOMETRY_O2
208 if (GetConstantMem()->ioPtrs.clustersNative->clustersMCTruth) {
209 return GetTrackLabelA<o2::dataformats::ConstMCTruthContainerView<o2::MCCompLabel>,
S>(trk);
213 return GetTrackLabelA<AliHLTTPCClusterMCLabel, S>(trk);
223 for (uint32_t
i = 0;
i < mMemory->nMergedTracks;
i++) {
226 if (trk.NClusters() == 0) {
227 GPUError(
"FAILURE: Track marked ok but has 0 clusters");
230 if (!trk.CCE() && !trk.MergedLooper()) {
232 while (updTrk->PrevSegment() >= 0) {
233 auto next = &mMergedTracks[updTrk->PrevSegment()];
234 if (!next->MergedLooper()) {
235 GPUError(
"FAILURE: prev segment not marked as merged looper\n");
239 GPUError(
"FAILURE: segment cycle found\n");
244 if (updTrk->NClusters() == 0) {
245 printf(
"FAILURE: segment leg has 0 clusters");
252 GPUInfo(
"Merged Tracks OK");
254 throw std::runtime_error(
"Error during track merging");
261 std::vector<bool> trkUsed(SectorTrackInfoLocalTotal());
262 for (int32_t
i = 0;
i < SectorTrackInfoLocalTotal();
i++) {
266 for (int32_t itr = 0; itr < SectorTrackInfoLocalTotal(); itr++) {
268 if (track.PrevSegmentNeighbour() >= 0 && mSectorTrackInfos[track.PrevSegmentNeighbour()].NextSegmentNeighbour() != itr) {
269 GPUError(
"FAILURE: Invalid reciprocal segment link: %d PrevSegmentNeighbour %d NextSegmentNeighbour %d", itr, track.PrevSegmentNeighbour(), mSectorTrackInfos[track.PrevSegmentNeighbour()].NextSegmentNeighbour());
272 if (track.NextSegmentNeighbour() >= 0 && mSectorTrackInfos[track.NextSegmentNeighbour()].PrevSegmentNeighbour() != itr) {
273 GPUError(
"FAILURE: Invalid reciprocal segment link: %d NextSegmentNeighbour %d PrevSegmentNeighbour %d", itr, track.NextSegmentNeighbour(), mSectorTrackInfos[track.NextSegmentNeighbour()].PrevSegmentNeighbour());
276 if (track.PrevNeighbour() >= 0 && mSectorTrackInfos[track.PrevNeighbour()].NextNeighbour() != itr) {
277 GPUError(
"FAILURE: Invalid reciprocal link: %d PrevNeighbour %d NextNeighbour %d", itr, track.PrevNeighbour(), mSectorTrackInfos[track.PrevNeighbour()].NextNeighbour());
280 if (track.NextNeighbour() >= 0 && mSectorTrackInfos[track.NextNeighbour()].PrevNeighbour() != itr) {
281 GPUError(
"FAILURE: Invalid reciprocal link: %d NextNeighbour %d PrevNeighbour %d", itr, track.NextNeighbour(), mSectorTrackInfos[track.NextNeighbour()].PrevNeighbour());
284 if (track.PrevSegmentNeighbour() >= 0) {
287 if (track.PrevNeighbour() >= 0) {
292 int32_t iTrk = tr - mSectorTrackInfos;
294 GPUError(
"FAILURE: double use");
298 trkUsed[iTrk] =
true;
300 int32_t jtr = tr->NextSegmentNeighbour();
302 tr = &(mSectorTrackInfos[jtr]);
303 if (tr->PrevNeighbour() >= 0) {
304 GPUError(
"FAILURE: Non-base segment has previous leg");
309 jtr = trbase->NextNeighbour();
311 trbase = &(mSectorTrackInfos[jtr]);
313 if (tr->PrevSegmentNeighbour() >= 0) {
314 GPUError(
"FAILURE: Neibhbour leg has previous segment neightbout");
323 for (int32_t
i = 0;
i < SectorTrackInfoLocalTotal();
i++) {
324 if (trkUsed[
i] ==
false) {
325 GPUError(
"FAILURE: trk missed");
330 GPUInfo(
"Merged Track Graph OK");
332 throw std::runtime_error(
"Invalid merge graph");
336void GPUTPCGMMerger::PrintMergeGraph(
const GPUTPCGMSectorTrack* trk, std::ostream& out)
const
339 while (trk->PrevSegmentNeighbour() >= 0) {
340 trk = &mSectorTrackInfos[trk->PrevSegmentNeighbour()];
343 while (trk->PrevNeighbour() >= 0) {
344 trk = &mSectorTrackInfos[trk->PrevNeighbour()];
347 int32_t nextId = trk - mSectorTrackInfos;
348 out <<
"Graph of track " << (orgTrack - mSectorTrackInfos) <<
"\n";
349 while (nextId >= 0) {
350 trk = &mSectorTrackInfos[nextId];
351 if (trk->PrevSegmentNeighbour() >= 0) {
352 out <<
"TRACK TREE INVALID!!! " << trk->PrevSegmentNeighbour() <<
" --> " << nextId <<
"\n";
354 out << (trk == orgTower ?
"--" :
" ");
355 while (nextId >= 0) {
357 if (trk != trk2 && (trk2->PrevNeighbour() >= 0 || trk2->NextNeighbour() >= 0)) {
358 out <<
" (TRACK TREE INVALID!!! " << trk2->PrevNeighbour() <<
" <-- " << nextId <<
" --> " << trk2->NextNeighbour() <<
") ";
361 snprintf(tmp, 128,
" %s%5d(%5.2f)", trk2 == orgTrack ?
"!" :
" ", nextId, trk2->QPt());
363 nextId = trk2->NextSegmentNeighbour();
366 nextId = trk->NextNeighbour();
386 mBorder[
iSector] = mBorderMemory + 2 * nTracks;
388 mBorderRange[
iSector] = mBorderRangeMemory + 2 * nTracks;
396 memMax = (
void*)std::max((
size_t)mem, (size_t)memMax);
400 memMax = (
void*)std::max((
size_t)mem, (size_t)memMax);
404 memMax = (
void*)std::max((
size_t)mem, (size_t)memMax);
407 memMax = (
void*)std::max((
size_t)mem, (size_t)memMax);
421 if (mergerSortTracks) {
446 mClusterStateExt =
nullptr;
496 mNTotalSectorTracks = 0;
498 mNMaxSingleSectorTracks = 0;
501 mNTotalSectorTracks += ntrk;
503 if (mNMaxSingleSectorTracks < ntrk) {
504 mNMaxSingleSectorTracks = ntrk;
508 if (CAMath::Abs(Param().polynomialField.GetNominalBz()) < (gpu_common_constants::kZeroFieldCut * gpu_common_constants::kCLight)) {
521 mNMaxClusters = mNClusters;
523 mNMaxLooperMatches = mNMaxClusters / 4;
530 throw std::runtime_error(
"mNMaxSingleSectorTracks too small");
534 throw std::runtime_error(
"Must run also sector tracking");
543 const int32_t
n =
output ? mMemory->nMergedTracks : SectorTrackInfoLocalTotal();
544 for (int32_t
i = iBlock * nThreads + iThread;
i <
n;
i += nThreads * nBlocks) {
552 prop.SetMaterialTPC();
554 prop.SetSeedingErrors(
true);
555 prop.SetFitInProjections(
false);
556 prop.SetPolynomialField(&Param().polynomialField);
558 trk.X() = inTrack->Param().GetX();
559 trk.
Y() = inTrack->Param().GetY();
560 trk.
Z() = inTrack->Param().GetZ();
561 trk.SinPhi() = inTrack->Param().GetSinPhi();
562 trk.DzDs() = inTrack->Param().GetDzDs();
563 trk.QPt() = inTrack->Param().GetQPt();
564 trk.TOffset() = GetConstantMem()->calibObjects.fastTransformHelper->getCorrMap()->convZOffsetToVertexTime(sector, inTrack->Param().GetZOffset(), Param().continuousMaxTimeBin);
565 const auto tmp = sectorTrack.ClusterTN() > sectorTrack.ClusterT0() ? std::array<float, 2>{sectorTrack.ClusterTN(), sectorTrack.ClusterT0()} : std::array<float, 2>{sectorTrack.ClusterT0(), sectorTrack.ClusterTN()};
566 trk.ShiftZ(
this, sector, tmp[0], tmp[1], inTrack->Param().GetX());
567 sectorTrack.SetX2(0.f);
568 for (int32_t way = 0; way < 2; way++) {
570 prop.SetFitInProjections(
true);
571 prop.SetPropagateBzOnly(
true);
573 trk.ResetCovariance();
574 prop.SetTrack(&trk,
alpha);
575 int32_t
start = way ? inTrack->NHits() - 1 : 0;
576 int32_t
end = way ? 0 : (inTrack->NHits() - 1);
577 int32_t incr = way ? -1 : 1;
581 const GPUTPCTracker& tracker = GetConstantMem()->tpcTrackers[sector];
582 const GPUTPCHitId& ic = tracker.TrackHits()[inTrack->FirstHitID() +
i];
583 int32_t clusterIndex = tracker.Data().ClusterDataIndex(tracker.Data().Row(ic.RowIndex()), ic.HitIndex());
585 const ClusterNative& cl = GetConstantMem()->ioPtrs.clustersNative->clustersLinear[GetConstantMem()->ioPtrs.clustersNative->clusterOffset[sector][0] + clusterIndex];
586 flags = cl.getFlags();
587 GetConstantMem()->calibObjects.fastTransformHelper->Transform(sector,
row, cl.getPad(), cl.getTime(),
x,
y,
z, trk.TOffset());
588 if (prop.PropagateToXAlpha(
x,
alpha, way == 0)) {
591 trk.ConstrainSinPhi();
592 if (prop.Update(
y,
z,
row, Param(),
flags &
GPUTPCGMMergedTrackHit::clustererAndSharedFlags, 0,
false, sector, -1.f, 0.f, 0.f)) {
595 trk.ConstrainSinPhi();
598 sectorTrack.SetParam2(trk);
600 sectorTrack.Set(trk, inTrack,
alpha, sector);
608 const GPUTPCTracker& trk = GetConstantMem()->tpcTrackers[iSector];
609 const GPUTPCHitId& ic1 = trk.TrackHits()[sectorTr->FirstHitID()];
610 const GPUTPCHitId& ic2 = trk.TrackHits()[sectorTr->FirstHitID() + sectorTr->NHits() - 1];
611 int32_t clusterIndex1 = trk.Data().ClusterDataIndex(trk.Data().Row(ic1.RowIndex()), ic1.HitIndex());
612 int32_t clusterIndex2 = trk.Data().ClusterDataIndex(trk.Data().Row(ic2.RowIndex()), ic2.HitIndex());
613 const ClusterNative* cl = GetConstantMem()->ioPtrs.clustersNative->clustersLinear + GetConstantMem()->ioPtrs.clustersNative->clusterOffset[iSector][0];
614 track.SetClusterT(cl[clusterIndex1].
getTime(), cl[clusterIndex2].
getTime());
619 mSectorTrackInfoIndex[
id] = mMemory->nUnpackedTracks;
622GPUd()
void GPUTPCGMMerger::UnpackSectorGlobal(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, int32_t iSector)
624 const GPUTPCTracker& trk = GetConstantMem()->tpcTrackers[iSector];
625 float alpha = Param().Alpha(iSector);
626 const GPUTPCTrack* sectorTr = mMemory->firstExtrapolatedTracks[iSector];
627 uint32_t nLocalTracks = trk.CommonMemory()->nLocalTracks;
628 uint32_t nTracks = *trk.NTracks();
629 for (uint32_t itr = nLocalTracks + iBlock * nThreads + iThread; itr < nTracks; itr += nBlocks * nThreads) {
630 sectorTr = &trk.Tracks()[itr];
631 int32_t localId = mTrackIDs[((sectorTr->LocalTrackId() >> 24) & 0x3F) * mNMaxSingleSectorTracks + (sectorTr->LocalTrackId() & 0xFFFFFF)];
635 uint32_t myTrack = CAMath::AtomicAdd(&mMemory->nUnpackedTracks, 1u);
637 SetTrackClusterT(track, iSector, sectorTr);
638 track.Set(
this, sectorTr,
alpha, iSector);
639 track.SetGlobalSectorTrackCov();
640 track.SetPrevNeighbour(-1);
641 track.SetNextNeighbour(-1);
642 track.SetNextSegmentNeighbour(-1);
643 track.SetPrevSegmentNeighbour(-1);
644 track.SetLocalTrackId(localId | (sectorTr->LocalTrackId() & 0x40000000));
648GPUd()
void GPUTPCGMMerger::UnpackResetIds(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, int32_t iSector)
650 const GPUTPCTracker& trk = GetConstantMem()->tpcTrackers[iSector];
651 uint32_t nLocalTracks = trk.CommonMemory()->nLocalTracks;
652 for (uint32_t
i = iBlock * nThreads + iThread;
i < nLocalTracks;
i += nBlocks * nThreads) {
653 mTrackIDs[iSector * mNMaxSingleSectorTracks +
i] = -1;
657GPUd()
void GPUTPCGMMerger::RefitSectorTracks(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, int32_t iSector)
659 const GPUTPCTracker& trk = GetConstantMem()->tpcTrackers[iSector];
660 uint32_t nLocalTracks = trk.CommonMemory()->nLocalTracks;
662 float alpha = Param().Alpha(iSector);
665 for (uint32_t itr = iBlock * nThreads + iThread; itr < nLocalTracks; itr += nBlocks * nThreads) {
666 sectorTr = &trk.Tracks()[itr];
668 SetTrackClusterT(track, iSector, sectorTr);
669 if (RefitSectorTrack(track, sectorTr,
alpha, iSector)) {
670 track.Set(
this, sectorTr,
alpha, iSector);
676 CADEBUG(GPUInfo(
"INPUT Sector %d, Track %u, QPt %f DzDs %f", iSector, itr, track.QPt(), track.DzDs()));
677 track.SetPrevNeighbour(-1);
678 track.SetNextNeighbour(-1);
679 track.SetNextSegmentNeighbour(-1);
680 track.SetPrevSegmentNeighbour(-1);
681 track.SetExtrapolatedTrackId(0, -1);
682 track.SetExtrapolatedTrackId(1, -1);
683 uint32_t myTrack = CAMath::AtomicAdd(&mMemory->nUnpackedTracks, 1u);
684 mTrackIDs[iSector * mNMaxSingleSectorTracks + sectorTr->LocalTrackId()] = myTrack;
685 mSectorTrackInfos[myTrack] = track;
689GPUd()
void GPUTPCGMMerger::LinkExtrapolatedTracks(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread)
691 for (int32_t itr = SectorTrackInfoGlobalFirst(0) + iBlock * nThreads + iThread; itr < SectorTrackInfoGlobalLast(NSECTORS - 1); itr += nThreads * nBlocks) {
693 GPUTPCGMSectorTrack& localTrack = mSectorTrackInfos[extrapolatedTrack.LocalTrackId() & 0xFFFFFF];
694 int up = (extrapolatedTrack.LocalTrackId() & 0x40000000) ? 1 : 0;
695 localTrack.SetExtrapolatedTrackId(up, itr);
704 float fieldBz = Param().bzCLight;
706 float dAlpha = Param().dAlpha / 2;
710 dAlpha = dAlpha - CAMath::Pi() / 2;
711 }
else if (iBorder == 1) {
712 dAlpha = -dAlpha - CAMath::Pi() / 2;
713 }
else if (iBorder == 2) {
714 x0 = GPUTPCGeometry::Row2X(63);
715 }
else if (iBorder == 3) {
717 x0 = GPUTPCGeometry::Row2X(63);
718 }
else if (iBorder == 4) {
720 x0 = GPUTPCGeometry::Row2X(63);
723 const float maxSin = CAMath::Sin(60.f / 180.f * CAMath::Pi());
724 float cosAlpha = CAMath::Cos(dAlpha);
725 float sinAlpha = CAMath::Sin(dAlpha);
728 for (int32_t itr = iBlock * nThreads + iThread; itr < SectorTrackInfoLocalTotal(); itr += nThreads * nBlocks) {
730 int32_t iSector = track->Sector();
732 if (track->PrevSegmentNeighbour() >= 0 && track->Sector() == mSectorTrackInfos[track->PrevSegmentNeighbour()].Sector()) {
735 if (useOrigTrackParam) {
736 if (CAMath::Abs(track->QPt()) * Param().qptB5Scaler < Param().rec.tpc.mergerLooperQPtB5Limit) {
740 while (track->NextSegmentNeighbour() >= 0 && track->Sector() == mSectorTrackInfos[track->NextSegmentNeighbour()].Sector()) {
741 track = &mSectorTrackInfos[track->NextSegmentNeighbour()];
742 if (track->OrigTrack()->Param().X() < trackMin->OrigTrack()->Param().X()) {
746 trackTmp = *trackMin;
748 if (trackTmp.X2() != 0.f) {
749 trackTmp.UseParam2();
751 trackTmp.Set(
this, trackMin->OrigTrack(), trackMin->Alpha(), trackMin->Sector());
754 if (CAMath::Abs(track->QPt()) * Param().qptB5Scaler < Param().rec.tpc.mergerLooperSecondHorizontalQPtB5Limit) {
755 if (iBorder == 0 && track->NextNeighbour() >= 0) {
758 if (iBorder == 1 && track->PrevNeighbour() >= 0) {
765 if (track->TransportToXAlpha(
this,
x0, sinAlpha, cosAlpha, fieldBz,
b, maxSin)) {
767 b.SetNClusters(track->NClusters());
768 for (int32_t
i = 0;
i < 4;
i++) {
769 if (CAMath::Abs(
b.Cov()[
i]) >= 5.0f) {
773 if (CAMath::Abs(
b.Cov()[4]) >= 0.5f) {
776 uint32_t myTrack = CAMath::AtomicAdd(&nB[iSector], 1u);
777 B[iSector][myTrack] =
b;
783GPUd()
void GPUTPCGMMerger::MergeBorderTracks<0>(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, int32_t iSector1,
GPUTPCGMBorderTrack* B1, int32_t N1, int32_t iSector2,
GPUTPCGMBorderTrack* B2, int32_t N2, int32_t mergeMode)
785 CADEBUG(GPUInfo(
"\nMERGING Sectors %d %d NTracks %d %d CROSS %d", iSector1, iSector2, N1, N2, mergeMode));
787 GPUTPCGMBorderRange* range2 = mBorderRange[iSector2] + *GetConstantMem()->tpcTrackers[iSector2].NTracks();
788 bool sameSector = (iSector1 == iSector2);
789 for (int32_t itr = iBlock * nThreads + iThread; itr < N1; itr += nThreads * nBlocks) {
791 float d = CAMath::Max(0.5f, 3.5f * CAMath::Sqrt(
b.Cov()[1]));
792 if (CAMath::Abs(
b.Par()[4]) * Param().qptB5Scaler >= 20) {
797 CADEBUG(printf(
" Input Sector 1 %d Track %d: ", iSector1, itr);
for (int32_t
i = 0;
i < 5;
i++) { printf(
"%8.3f ",
b.Par()[
i]); } printf(
" - ");
for (int32_t
i = 0;
i < 5;
i++) { printf(
"%8.3f ",
b.Cov()[
i]); } printf(
" - D %8.3f\n", d));
800 range.fMin =
b.Par()[1] +
b.ZOffsetLinear() - d;
801 range.fMax =
b.Par()[1] +
b.ZOffsetLinear() + d;
808 for (int32_t itr = iBlock * nThreads + iThread; itr < N2; itr += nThreads * nBlocks) {
810 float d = CAMath::Max(0.5f, 3.5f * CAMath::Sqrt(
b.Cov()[1]));
811 if (CAMath::Abs(
b.Par()[4]) * Param().qptB5Scaler >= 20) {
816 CADEBUG(printf(
" Input Sector 2 %d Track %d: ", iSector2, itr);
for (int32_t
i = 0;
i < 5;
i++) { printf(
"%8.3f ",
b.Par()[
i]); } printf(
" - ");
for (int32_t
i = 0;
i < 5;
i++) { printf(
"%8.3f ",
b.Cov()[
i]); } printf(
" - D %8.3f\n", d));
819 range.fMin =
b.Par()[1] +
b.ZOffsetLinear() - d;
820 range.fMax =
b.Par()[1] +
b.ZOffsetLinear() + d;
827GPUd()
void GPUTPCGMMerger::MergeBorderTracks<1>(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, int32_t iSector1,
GPUTPCGMBorderTrack* B1, int32_t N1, int32_t iSector2,
GPUTPCGMBorderTrack* B2, int32_t N2, int32_t mergeMode)
829#if !defined(GPUCA_GPUCODE_COMPILEKERNELS)
831 GPUTPCGMBorderRange* range2 = mBorderRange[iSector2] + *GetConstantMem()->tpcTrackers[iSector2].NTracks();
836 }
else if (iBlock == 1) {
841 printf(
"This sorting variant is disabled for RTC");
848#ifndef GPUCA_SPECIALIZE_THRUST_SORTS
849 if (iThread == 0 && iBlock == 0) {
860GPUd()
void GPUTPCGMMerger::MergeBorderTracks<2>(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, int32_t iSector1,
GPUTPCGMBorderTrack* B1, int32_t N1, int32_t iSector2,
GPUTPCGMBorderTrack* B2, int32_t N2, int32_t mergeMode)
863 float factor2ys = Param().rec.tpc.trackMergerFactor2YS;
864 float factor2zt = Param().rec.tpc.trackMergerFactor2ZT;
865 float factor2k = Param().rec.tpc.trackMergerFactor2K;
866 float factor2General = Param().rec.tpc.trackMergerFactor2General;
868 factor2k = factor2General * factor2k;
869 factor2ys = factor2General * factor2ys;
870 factor2zt = factor2General * factor2zt;
872 int32_t minNPartHits = Param().rec.tpc.trackMergerMinPartHits;
873 int32_t minNTotalHits = Param().rec.tpc.trackMergerMinTotalHits;
875 bool sameSector = (iSector1 == iSector2);
878 GPUTPCGMBorderRange* range2 = mBorderRange[iSector2] + *GetConstantMem()->tpcTrackers[iSector2].NTracks();
881 for (int32_t i1 = iBlock * nThreads + iThread; i1 < N1; i1 += nThreads * nBlocks) {
883 while (i2 < N2 && range2[i2].fMax < r1.
fMin) {
888 if (b1.NClusters() < minNPartHits) {
894 for (int32_t k2 = i2; k2 < N2; k2++) {
899 if (sameSector && (r1.
fId >= r2.
fId)) {
905#if defined(GPUCA_MERGER_BY_MC_LABEL) && !defined(GPUCA_GPUCODE)
906 int64_t label1 = GetTrackLabel(b1);
907 int64_t label2 = GetTrackLabel(b2);
908 if (label1 != label2 && label1 != -1)
911 CADEBUG(
if (GetConstantMem()->ioPtrs.mcLabelsTPC) {printf(
"Comparing track %3d to %3d: ", r1.fId, r2.fId); for (int32_t i = 0; i < 5; i++) { printf(
"%8.3f ", b1.Par()[i]); } printf(
" - ");
for (int32_t
i = 0;
i < 5;
i++) { printf(
"%8.3f ", b1.Cov()[
i]); } printf(
"\n%28s",
""); });
912 CADEBUG(
if (GetConstantMem()->ioPtrs.mcLabelsTPC) {for (int32_t i = 0; i < 5; i++) { printf(
"%8.3f ", b2.Par()[i]); } printf(
" - ");
for (int32_t
i = 0;
i < 5;
i++) { printf(
"%8.3f ", b2.Cov()[
i]); } printf(
" - %5s - ", GetTrackLabel(b1) == GetTrackLabel(b2) ?
"CLONE" :
"FAKE"); });
913 if (b2.NClusters() < lBest2) {
914 CADEBUG2(
continue, printf(
"!NCl1\n"));
918 int32_t maxRowDiff = mergeMode == 2 ? 1 : 3;
919 if (CAMath::Abs(b1.Row() - b2.Row()) > maxRowDiff) {
920 CADEBUG2(
continue, printf(
"!ROW\n"));
922 if (CAMath::Abs(b1.Par()[2] - b2.Par()[2]) > 0.5f || CAMath::Abs(b1.Par()[3] - b2.Par()[3]) > 0.5f) {
923 CADEBUG2(
continue, printf(
"!CE SinPhi/Tgl\n"));
929 if (!b1.CheckChi2Y(b2, factor2ys)) {
933 if (!b1.CheckChi2QPt(b2, factor2k)) {
934 CADEBUG2(
continue, printf(
"!QPt\n"));
936 float fys = CAMath::Abs(b1.Par()[4]) * Param().qptB5Scaler < 20 ? factor2ys : (2.f * factor2ys);
937 float fzt = CAMath::Abs(b1.Par()[4]) * Param().qptB5Scaler < 20 ? factor2zt : (2.f * factor2zt);
938 if (!b1.CheckChi2YS(b2, fys)) {
939 CADEBUG2(
continue, printf(
"!YS\n"));
941 if (!b1.CheckChi2ZT(b2, fzt)) {
942 CADEBUG2(
continue, printf(
"!ZT\n"));
944 if (CAMath::Abs(b1.Par()[4]) * Param().qptB5Scaler < 20) {
945 if (b2.NClusters() < minNPartHits) {
946 CADEBUG2(
continue, printf(
"!NCl2\n"));
948 if (b1.NClusters() + b2.NClusters() < minNTotalHits) {
949 CADEBUG2(
continue, printf(
"!NCl3\n"));
952 CADEBUG(printf(
"OK: dZ %8.3f D1 %8.3f D2 %8.3f\n", CAMath::Abs(b1.Par()[1] - b2.Par()[1]), 3.5f * sqrt(b1.Cov()[1]), 3.5f * sqrt(b2.Cov()[1])));
954 lBest2 = b2.NClusters();
955 iBest2 = b2.TrackID();
961 GPUCA_DEBUG_STREAMER_CHECK(
float weight = b1.Par()[4] * b1.Par()[4];
if (o2::utils::DebugStreamer::checkStream(
o2::utils::StreamFlags::streamMergeBorderTracksBest, b1.TrackID(),
weight)) { MergedTrackStreamer(b1, MergedTrackStreamerFindBorderTrack(B2, N2, iBest2),
"merge_best_track", iSector1, iSector2, mergeMode,
weight, o2::utils::DebugStreamer::getSamplingFrequency(
o2::utils::StreamFlags::streamMergeBorderTracksBest)); });
965 CADEBUG(GPUInfo(
"Found match %d %d", b1.TrackID(), iBest2));
967 mTrackLinks[b1.TrackID()] = iBest2;
969 GPUCA_DETERMINISTIC_CODE(CAMath::AtomicMax(&mTrackLinks[iBest2], b1.TrackID()), mTrackLinks[iBest2] = b1.TrackID());
977 if (withinSector == 1) {
979 n1 = n2 = mMemory->tmpCounter[iSector];
980 b1 = b2 = mBorder[iSector];
981 }
else if (withinSector == -1) {
982 jSector = (iSector + NSECTORS / 2);
983 const int32_t
offset = mergeMode == 2 ? NSECTORS : 0;
984 n1 = mMemory->tmpCounter[iSector +
offset];
985 n2 = mMemory->tmpCounter[jSector +
offset];
986 b1 = mBorder[iSector +
offset];
987 b2 = mBorder[jSector +
offset];
989 jSector = mNextSectorInd[iSector];
990 n1 = mMemory->tmpCounter[iSector];
991 n2 = mMemory->tmpCounter[NSECTORS + jSector];
992 b1 = mBorder[iSector];
993 b2 = mBorder[NSECTORS + jSector];
998GPUd()
void GPUTPCGMMerger::MergeBorderTracks(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, int32_t iSector, int8_t withinSector, int8_t mergeMode)
1003 MergeBorderTracksSetup(n1, n2, b1, b2, jSector, iSector, withinSector, mergeMode);
1004 MergeBorderTracks<I>(nBlocks, nThreads, iBlock, iThread, iSector, b1, n1, jSector, b2, n2, mergeMode);
1007#if !defined(GPUCA_GPUCODE) || defined(GPUCA_GPUCODE_DEVICE)
1008template GPUdni()
void GPUTPCGMMerger::MergeBorderTracks<0>(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, int32_t iSector, int8_t withinSector, int8_t mergeMode);
1009template
GPUdni()
void GPUTPCGMMerger::MergeBorderTracks<1>(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, int32_t iSector, int8_t withinSector, int8_t mergeMode);
1010template
GPUdni()
void GPUTPCGMMerger::MergeBorderTracks<2>(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, int32_t iSector, int8_t withinSector, int8_t mergeMode);
1013GPUd()
void GPUTPCGMMerger::MergeWithinSectorsPrepare(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread)
1015 float x0 = GPUTPCGeometry::Row2X(63);
1016 const float maxSin = CAMath::Sin(60.f / 180.f * CAMath::Pi());
1018 for (int32_t itr = iBlock * nThreads + iThread; itr < SectorTrackInfoLocalTotal(); itr += nThreads * nBlocks) {
1020 int32_t iSector = track.Sector();
1022 if (track.TransportToX(
this,
x0, Param().bzCLight,
b, maxSin)) {
1024 CADEBUG(printf(
"WITHIN SECTOR %d Track %d - ", iSector, itr);
for (int32_t
i = 0;
i < 5;
i++) { printf(
"%8.3f ",
b.Par()[
i]); } printf(
" - ");
for (int32_t
i = 0;
i < 5;
i++) { printf(
"%8.3f ",
b.Cov()[
i]); } printf(
"\n"));
1025 b.SetNClusters(track.NClusters());
1026 uint32_t myTrack = CAMath::AtomicAdd(&mMemory->tmpCounter[iSector], 1u);
1027 mBorder[iSector][myTrack] =
b;
1032GPUd()
void GPUTPCGMMerger::MergeSectorsPrepare(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, int32_t border0, int32_t border1, int8_t useOrigTrackParam)
1034 bool part2 = iBlock & 1;
1035 int32_t
border = part2 ? border1 : border0;
1036 GPUAtomic(uint32_t)*
n = mMemory->tmpCounter;
1042 MergeSectorsPrepareStep2((nBlocks + !part2) >> 1, nThreads, iBlock >> 1, iThread,
border,
b,
n, useOrigTrackParam);
1047 start = (elems + nBlocks - 1) / nBlocks * iBlock;
1048 end = (elems + nBlocks - 1) / nBlocks * (iBlock + 1);
1049 end = CAMath::Min(elems,
end);
1058 u = mTrackCCRoots[u];
1059 v = mTrackCCRoots[
v];
1063 int32_t
h = CAMath::Max(u,
v);
1064 int32_t l = CAMath::Min(u,
v);
1066 int32_t old = CAMath::AtomicCAS(&mTrackCCRoots[
h],
h, l);
1071 u = mTrackCCRoots[
h];
1076GPUd()
void GPUTPCGMMerger::ResolveFindConnectedComponentsSetup(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread)
1079 setBlockRange(SectorTrackInfoLocalTotal(), nBlocks, iBlock,
start,
end);
1080 for (int32_t
i =
start + iThread;
i <
end;
i += nThreads) {
1081 mTrackCCRoots[
i] =
i;
1085GPUd()
void GPUTPCGMMerger::ResolveFindConnectedComponentsHookLinks(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread)
1090 setBlockRange(SectorTrackInfoLocalTotal(), nBlocks, iBlock,
start,
end);
1091 for (int32_t itr =
start + iThread; itr <
end; itr += nThreads) {
1092 hookEdge(itr, mTrackLinks[itr]);
1096GPUd()
void GPUTPCGMMerger::ResolveFindConnectedComponentsHookNeighbors(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread)
1099 nBlocks = nBlocks / 4 * 4;
1100 if (iBlock >= nBlocks) {
1105 setBlockRange(SectorTrackInfoLocalTotal(), nBlocks / 4, iBlock / 4,
start,
end);
1107 int32_t myNeighbor = iBlock % 4;
1109 for (int32_t itr =
start + iThread; itr <
end; itr += nThreads) {
1110 int32_t
v = mSectorTrackInfos[itr].AnyNeighbour(myNeighbor);
1115GPUd()
void GPUTPCGMMerger::ResolveFindConnectedComponentsMultiJump(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread)
1119 setBlockRange(SectorTrackInfoLocalTotal(), nBlocks, iBlock,
start,
end);
1120 for (int32_t itr =
start + iThread; itr <
end; itr += nThreads) {
1122 int32_t next = mTrackCCRoots[root];
1128 next = mTrackCCRoots[next];
1129 }
while (root != next);
1130 mTrackCCRoots[itr] = root;
1167 setBlockRange(SectorTrackInfoLocalTotal(), nBlocks, iBlock,
start,
end);
1169 for (int32_t baseIdx = 0; baseIdx < SectorTrackInfoLocalTotal(); baseIdx += nThreads) {
1170 int32_t itr = baseIdx + iThread;
1171 bool inRange = itr < SectorTrackInfoLocalTotal();
1175 itr2 = mTrackLinks[itr];
1178 bool resolveSector = (itr2 > -1);
1179 if (resolveSector) {
1180 int32_t root = mTrackCCRoots[itr];
1181 resolveSector &= (
start <= root) && (root <
end);
1184 int16_t smemIdx = work_group_scan_inclusive_add(int16_t(resolveSector));
1186 if (resolveSector) {
1187 smem.iTrack1[smemIdx - 1] = itr;
1188 smem.iTrack2[smemIdx - 1] = itr2;
1192 if (iThread < nThreads - 1) {
1196 const int32_t nSectors = smemIdx;
1198 for (int32_t
i = 0;
i < nSectors;
i++) {
1199 itr = smem.iTrack1[
i];
1200 itr2 = smem.iTrack2[
i];
1207 bool sameSegment = CAMath::Abs(track1->NClusters() > track2->NClusters() ? track1->QPt() : track2->QPt()) * Param().qptB5Scaler < 2 || track1->QPt() * track2->QPt() > 0;
1212 while (track2->PrevSegmentNeighbour() >= 0) {
1213 track2 = &mSectorTrackInfos[track2->PrevSegmentNeighbour()];
1216 if (track1 == track2) {
1219 while (track1->PrevSegmentNeighbour() >= 0) {
1220 track1 = &mSectorTrackInfos[track1->PrevSegmentNeighbour()];
1221 if (track1 == track2) {
1225 GPUCommonAlgorithm::swap(track1, track1Base);
1226 for (int32_t k = 0; k < 2; k++) {
1228 while (tmp->Neighbour(k) >= 0) {
1229 tmp = &mSectorTrackInfos[tmp->Neighbour(k)];
1230 if (tmp == track2) {
1236 while (track1->NextSegmentNeighbour() >= 0) {
1237 track1 = &mSectorTrackInfos[track1->NextSegmentNeighbour()];
1238 if (track1 == track2) {
1243 while (track1->PrevSegmentNeighbour() >= 0) {
1244 track1 = &mSectorTrackInfos[track1->PrevSegmentNeighbour()];
1247 if (track1 == track2) {
1250 for (int32_t k = 0; k < 2; k++) {
1252 while (tmp->Neighbour(k) >= 0) {
1253 tmp = &mSectorTrackInfos[tmp->Neighbour(k)];
1254 if (tmp == track2) {
1260 float z1min, z1max, z2min, z2max;
1261 z1min = track1->MinClusterT();
1262 z1max = track1->MaxClusterT();
1263 z2min = track2->MinClusterT();
1264 z2max = track2->MaxClusterT();
1265 if (track1 != track1Base) {
1266 z1min = CAMath::Min(z1min, track1Base->MinClusterT());
1267 z1max = CAMath::Max(z1max, track1Base->MaxClusterT());
1269 if (track2 != track2Base) {
1270 z2min = CAMath::Min(z2min, track2Base->MinClusterT());
1271 z2max = CAMath::Max(z2max, track2Base->MaxClusterT());
1273 bool goUp = z2max - z1min > z1max - z2min;
1275 if (track1->Neighbour(goUp) < 0 && track2->Neighbour(!goUp) < 0) {
1276 track1->SetNeighbor(track2 - mSectorTrackInfos, goUp);
1277 track2->SetNeighbor(track1 - mSectorTrackInfos, !goUp);
1281 }
else if (track1->Neighbour(goUp) < 0) {
1282 track2 = &mSectorTrackInfos[track2->Neighbour(!goUp)];
1283 GPUCommonAlgorithm::swap(track1, track2);
1284 }
else if (track2->Neighbour(!goUp) < 0) {
1285 track1 = &mSectorTrackInfos[track1->Neighbour(goUp)];
1287 track1 = &mSectorTrackInfos[track1->Neighbour(goUp)];
1289 track1Base = track1;
1292 track2Base = track2;
1294 while (track1->NextSegmentNeighbour() >= 0) {
1295 track1 = &mSectorTrackInfos[track1->NextSegmentNeighbour()];
1298 track1->SetNextSegmentNeighbour(track2 - mSectorTrackInfos);
1299 track2->SetPrevSegmentNeighbour(track1 - mSectorTrackInfos);
1302 for (int32_t k = 0; k < 2; k++) {
1303 track1 = track1Base;
1304 track2 = track2Base;
1305 while (track2->Neighbour(k) >= 0) {
1306 if (track1->Neighbour(k) >= 0) {
1309 track2->SetNeighbor(-1, k);
1310 track2new->SetNeighbor(-1, k ^ 1);
1312 while (track1->NextSegmentNeighbour() >= 0) {
1313 track1 = &mSectorTrackInfos[track1->NextSegmentNeighbour()];
1315 track1->SetNextSegmentNeighbour(track2new - mSectorTrackInfos);
1316 track2new->SetPrevSegmentNeighbour(track1 - mSectorTrackInfos);
1321 track1->SetNeighbor(track2->Neighbour(k), k);
1322 track2->SetNeighbor(-1, k);
1323 track2new->SetNeighbor(track1 - mSectorTrackInfos, k ^ 1);
1336 if (Param().
rec.tpc.mergerCERowLimit > 0 && CAMath::Abs(track->QPt()) * Param().qptB5Scaler < 0.3f && (cls.row < Param().
rec.tpc.mergerCERowLimit || cls.row >=
GPUCA_ROW_COUNT - Param().
rec.tpc.mergerCERowLimit)) {
1343 auto& cln = mConstantMem->ioPtrs.clustersNative->clustersLinear[cls.num];
1344 GPUTPCConvertImpl::convert(*mConstantMem, cls.sector, cls.row, cln.getPad(), cln.getTime(),
x,
y,
z);
1347 if (!Param().
par.continuousTracking && CAMath::Abs(
z) > 10) {
1350 int32_t sector = track->Sector();
1351 for (int32_t attempt = 0; attempt < 2; attempt++) {
1353 const float x0 = GPUTPCGeometry::Row2X(attempt == 0 ? 63 : cls.
row);
1356 b.SetNClusters(mMergedTracks[itr].NClusters());
1357 if (CAMath::Abs(
b.Cov()[4]) >= 0.5f) {
1360 if (track->CSide()) {
1361 b.SetPar(1,
b.Par()[1] - 2 * (
z -
b.ZOffsetLinear()));
1362 b.SetZOffsetLinear(-
b.ZOffsetLinear());
1365 uint32_t
id = sector + attempt * NSECTORS;
1366 uint32_t myTrack = CAMath::AtomicAdd(&mMemory->tmpCounter[
id], 1u);
1367 mBorder[
id][myTrack] =
b;
1375 const ClusterNative* cls = mConstantMem->ioPtrs.clustersNative->clustersLinear;
1376 for (uint32_t
i = iBlock * nThreads + iThread;
i < mMemory->nMergedTracks;
i += nThreads * nBlocks) {
1377 if (mMergedTracks[
i].CSide() == 0 && mTrackLinks[
i] >= 0) {
1378 if (mTrackLinks[mTrackLinks[
i]] != (int32_t)
i) {
1383 if (!trk[1]->OK() || trk[1]->CCE()) {
1386 bool celooper = (trk[0]->GetParam().GetQPt() * Param().qptB5Scaler > 1 && trk[0]->GetParam().GetQPt() * trk[1]->GetParam().GetQPt() < 0);
1387 celooper |= trk[0]->PrevSegment() != -1 && trk[1]->PrevSegment() != -1;
1388 if (!celooper && trk[0]->GetParam().GetPar(3) * trk[1]->GetParam().GetPar(3) < 0) {
1392 bool needswap =
false;
1393 if (trk[0]->PrevSegment() == -1 && trk[1]->PrevSegment() >= 0) {
1395 }
else if (celooper) {
1396 const float z0max = -CAMath::Min(cls[mClusters[trk[0]->FirstClusterRef()].
num].
getTime(), cls[mClusters[trk[0]->FirstClusterRef() + trk[0]->NClusters() - 1].
num].
getTime());
1397 const float z1max = -CAMath::Min(cls[mClusters[trk[1]->FirstClusterRef()].
num].
getTime(), cls[mClusters[trk[1]->FirstClusterRef() + trk[1]->NClusters() - 1].
num].
getTime());
1398 if (z1max < z0max) {
1402 if (mClusters[trk[0]->FirstClusterRef()].
row > mClusters[trk[1]->FirstClusterRef()].
row) {
1407 GPUCommonAlgorithm::swap(trk[0], trk[1]);
1410 if (Param().
par.continuousTracking) {
1412 const float tmax = CAMath::MaxWithRef(cls[mClusters[trk[0]->FirstClusterRef()].
num].
getTime(), cls[mClusters[trk[0]->FirstClusterRef() + trk[0]->NClusters() - 1].
num].
getTime(),
1413 cls[mClusters[trk[1]->FirstClusterRef()].
num].
getTime(), cls[mClusters[trk[1]->FirstClusterRef() + trk[1]->NClusters() - 1].
num].
getTime(),
1414 &mClusters[trk[0]->FirstClusterRef()], &mClusters[trk[0]->FirstClusterRef() + trk[0]->NClusters() - 1],
1415 &mClusters[trk[1]->FirstClusterRef()], &mClusters[trk[1]->FirstClusterRef() + trk[1]->NClusters() - 1], clsmax);
1416 const float offset = CAMath::Max(tmax - mConstantMem->calibObjects.fastTransformHelper->getCorrMap()->getMaxDriftTime(clsmax->
sector, clsmax->
row, cls[clsmax->
num].getPad()), 0.f);
1417 trk[1]->Param().Z() += mConstantMem->calibObjects.fastTransformHelper->getCorrMap()->convDeltaTimeToDeltaZinTimeFrame(trk[1]->CSide() * NSECTORS / 2, trk[1]->Param().TOffset() -
offset);
1418 trk[1]->Param().TOffset() =
offset;
1420 trk[0]->Param().Z() += mConstantMem->calibObjects.fastTransformHelper->getCorrMap()->convDeltaTimeToDeltaZinTimeFrame(trk[0]->CSide() * NSECTORS / 2, trk[0]->Param().TOffset() -
offset);
1421 trk[0]->Param().TOffset() =
offset;
1426 trk[0]->SetMergedLooperConnected(
true);
1427 trk[0]->SetCCE(
true);
1428 trk[0]->SetLooper(
true);
1429 trk[1]->SetMergedLooperConnected(
true);
1430 trk[1]->SetCCE(
true);
1431 trk[1]->SetLooper(
true);
1435 uint32_t newRef = CAMath::AtomicAdd(&mMemory->nMergedTrackClusters, trk[0]->NClusters() + trk[1]->NClusters());
1436 if (newRef + trk[0]->NClusters() + trk[1]->NClusters() >= mNMaxMergedTrackClusters) {
1437 raiseError(GPUErrors::ERROR_MERGER_CE_HIT_OVERFLOW, newRef + trk[0]->NClusters() + trk[1]->NClusters(), mNMaxMergedTrackClusters);
1438 for (uint32_t k = newRef; k < mNMaxMergedTrackClusters; k++) {
1439 mClusters[k].num = 0;
1440 mClusters[k].state = 0;
1442 CAMath::AtomicExch(&mMemory->nMergedTrackClusters, mNMaxMergedTrackClusters);
1446 int32_t
pos = newRef;
1448 for (int32_t k = 1; k >= 0; k--) {
1449 for (uint32_t
j = 0;
j != trk[k]->NClusters();
j++) {
1450 mClusters[
pos++] = mClusters[trk[k]->FirstClusterRef() +
j];
1453 trk[1]->SetFirstClusterRef(newRef);
1454 trk[1]->SetNClusters(trk[0]->NClusters() + trk[1]->NClusters());
1459 trk[1]->SetCCE(
true);
1460 trk[0]->SetNClusters(0);
1461 trk[0]->SetOK(
false);
1472struct GPUTPCGMMerger_CompareClusterIds {
1476 GPUd() bool operator()(const int16_t
aa, const int16_t
bb)
1480 if (
a.row !=
b.row) {
1489GPUd()
void GPUTPCGMMerger::CollectMergedTracks(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread)
1491 static constexpr int32_t kMaxParts = 16;
1496 int32_t itr = iBlock * nThreads + iThread;
1499 int32_t lastMergedSegment = -1;
1500 bool revertSegments =
false;
1501 bool revertInSegment =
false;
1503 if (trbase && !Param().
rec.tpc.dropLoopers) {
1504 int32_t jtr = trbase->NextNeighbour();
1506 trbase = &(mSectorTrackInfos[jtr]);
1507 if (trbase->PrevSegmentNeighbour() >= 0) {
1510 if (Param().rec.enableCyclicGraphWorkarounds) {
1511 trbase->SetPrevSegmentNeighbour(1000000001);
1513 leg += revertSegments ? 1 : -1;
1520 if (trbase ==
nullptr) {
1521 while (itr < SectorTrackInfoLocalTotal()) {
1522 trbase = &mSectorTrackInfos[itr];
1523 if (trbase->PrevSegmentNeighbour() >= 0 || trbase->PrevNeighbour() >= 0) {
1524 itr += nThreads * nBlocks;
1529 if (itr >= SectorTrackInfoLocalTotal()) {
1532 revertSegments =
false;
1533 revertInSegment =
false;
1534 if (Param().rec.enableCyclicGraphWorkarounds) {
1535 trbase->SetPrevSegmentNeighbour(1000000000);
1537 int32_t jtr = trbase->NextNeighbour();
1540 int32_t lasttr = itr;
1542 if (Param().rec.enableCyclicGraphWorkarounds && &mSectorTrackInfos[jtr] == trbase) {
1547 jtr = mSectorTrackInfos[jtr].NextNeighbour();
1551 revertSegments =
true;
1552 for (uint32_t k = 0; k < 2; k++) {
1553 int32_t ichk = k ? lasttr : itr;
1556 float t = -trchk->MinClusterT();
1559 revertSegments =
false;
1564 int32_t next = trchk->NextSegmentNeighbour();
1565 if (next < 0 || (Param().
rec.enableCyclicGraphWorkarounds && next == ichk)) {
1568 trchk = &mSectorTrackInfos[next];
1571 if (revertSegments) {
1577 int32_t ichk = revertSegments ? itr : lasttr;
1581 if (trchk->OrigTrack()->NHits() >
length) {
1583 length = trchk->OrigTrack()->NHits();
1585 int32_t next = trchk->NextSegmentNeighbour();
1586 if (next < 0 || (Param().
rec.enableCyclicGraphWorkarounds && next == ichk)) {
1589 trchk = &mSectorTrackInfos[next];
1591 revertInSegment = longest->ClusterT0() < longest->ClusterTN();
1594 lastMergedSegment = -1;
1595 itr += nThreads * nBlocks;
1604 if (nParts >= kMaxParts) {
1607 if (nHits + tr->NClusters() > kMaxClusters) {
1610 nHits += tr->NClusters();
1612 trackParts[nParts++] = tr;
1613 for (int32_t
i = 0;
i < 2;
i++) {
1614 if (tr->ExtrapolatedTrackId(
i) != -1) {
1615 if (nParts >= kMaxParts) {
1618 if (nHits + mSectorTrackInfos[tr->ExtrapolatedTrackId(
i)].NClusters() > kMaxClusters) {
1621 trackParts[nParts++] = &mSectorTrackInfos[tr->ExtrapolatedTrackId(
i)];
1622 nHits += mSectorTrackInfos[tr->ExtrapolatedTrackId(
i)].NClusters();
1625 int32_t jtr = tr->NextSegmentNeighbour();
1627 tr = &(mSectorTrackInfos[jtr]);
1628 if (Param().rec.enableCyclicGraphWorkarounds) {
1629 tr->SetPrevSegmentNeighbour(1000000002);
1637 if (nParts > 1 && (!revertInSegment ^ (leg & 1))) {
1640 if (
a->X() !=
b->X()) {
1641 return (a->X() > b->X());
1643 if (
a->Y() !=
b->Y()) {
1644 return (a->Y() > b->Y());
1646 if (
a->Z() !=
b->Z()) {
1647 return (a->Z() > b->Z());
1649 return a->QPt() >
b->QPt();
1651 return (
a->X() >
b->X());
1656 trackCluster trackClusters[kMaxClusters];
1658 for (int32_t ipart = 0; ipart < nParts; ipart++) {
1660 CADEBUG(printf(
"Collect Track %d Part %d QPt %f DzDs %f\n", mMemory->nMergedTracks, ipart, t->QPt(), t->DzDs()));
1661 int32_t nTrackHits = t->NClusters();
1662 trackCluster* c2 = trackClusters + nHits + nTrackHits - 1;
1663 for (int32_t
i = 0;
i < nTrackHits;
i++, c2--) {
1664 const GPUTPCTracker& trk = GetConstantMem()->tpcTrackers[t->Sector()];
1665 const GPUTPCHitId& ic = trk.TrackHits()[t->OrigTrack()->FirstHitID() +
i];
1666 uint32_t
id = trk.Data().ClusterDataIndex(trk.Data().Row(ic.RowIndex()), ic.HitIndex()) + GetConstantMem()->ioPtrs.clustersNative->clusterOffset[t->Sector()][0];
1667 *c2 = trackCluster{
id, (
uint8_t)ic.RowIndex(), t->Sector()};
1669 nHits += nTrackHits;
1675 const bool mustReverse = revertInSegment ^ (leg & 1);
1678 for (int32_t
i = 1;
i < nHits;
i++) {
1679 if ((trackClusters[
i].
row > trackClusters[
i - 1].
row) ^ mustReverse || trackClusters[
i].id == trackClusters[
i - 1].id) {
1685 int32_t firstTrackIndex = 0;
1686 int32_t lastTrackIndex = nParts - 1;
1688 int32_t nTmpHits = 0;
1689 trackCluster trackClustersUnsorted[kMaxClusters];
1690 int16_t clusterIndices[kMaxClusters];
1691 for (int32_t
i = 0;
i < nHits;
i++) {
1692 trackClustersUnsorted[
i] = trackClusters[
i];
1693 clusterIndices[
i] =
i;
1696 GPUCommonAlgorithm::sort(clusterIndices, clusterIndices + nHits, GPUTPCGMMerger_CompareClusterIds(trackClusters, mustReverse));
1699 firstTrackIndex = lastTrackIndex = -1;
1700 for (int32_t
i = 0;
i < nParts;
i++) {
1701 nTmpHits += trackParts[
i]->NClusters();
1702 if (nTmpHits > clusterIndices[0] && firstTrackIndex == -1) {
1703 firstTrackIndex =
i;
1705 if (nTmpHits > clusterIndices[nHits - 1] && lastTrackIndex == -1) {
1710 int32_t nFilteredHits = 0;
1711 int32_t indPrev = -1;
1712 for (int32_t
i = 0;
i < nHits;
i++) {
1713 int32_t ind = clusterIndices[
i];
1714 if (indPrev >= 0 && trackClustersUnsorted[ind].
id == trackClustersUnsorted[indPrev].
id) {
1718 trackClusters[nFilteredHits] = trackClustersUnsorted[ind];
1721 nHits = nFilteredHits;
1724 const uint32_t iMergedTrackFirstCluster = CAMath::AtomicAdd(&mMemory->nMergedTrackClusters, (uint32_t)nHits);
1725 if (iMergedTrackFirstCluster + nHits > mNMaxMergedTrackClusters) {
1726 raiseError(GPUErrors::ERROR_MERGER_HIT_OVERFLOW, iMergedTrackFirstCluster, mNMaxMergedTrackClusters);
1727 CAMath::AtomicExch(&mMemory->nMergedTrackClusters, mNMaxMergedTrackClusters);
1733 for (int32_t
i = 0;
i < nHits;
i++) {
1735 const ClusterNative&
c = GetConstantMem()->ioPtrs.clustersNative->clustersLinear[trackClusters[
i].id];
1738 cl[
i].
row = trackClusters[
i].row;
1739 cl[
i].
num = trackClusters[
i].id;
1740 cl[
i].
sector = trackClusters[
i].sector;
1743 uint32_t iOutputTrack = CAMath::AtomicAdd(&mMemory->nMergedTracks, 1u);
1744 if (iOutputTrack >= mNMaxTracks) {
1745 raiseError(GPUErrors::ERROR_MERGER_TRACK_OVERFLOW, iOutputTrack, mNMaxTracks);
1746 CAMath::AtomicExch(&mMemory->nMergedTracks, mNMaxTracks);
1753 mergedTrack.SetFlags(0);
1754 mergedTrack.SetOK(
true);
1755 mergedTrack.SetLeg(leg);
1756 mergedTrack.SetLooper(leg > 0);
1757 mergedTrack.SetNClusters(nHits);
1758 mergedTrack.SetFirstClusterRef(iMergedTrackFirstCluster);
1759 mergedTrack.SetCSide(
p2.CSide());
1760 mergedTrack.SetMergedLooperConnected(leg > 0);
1761 if (revertSegments) {
1762 mergedTrack.SetPrevSegment(-1);
1763 if (lastMergedSegment >= 0) {
1764 mMergedTracks[lastMergedSegment].SetPrevSegment(iOutputTrack);
1767 mergedTrack.SetPrevSegment(lastMergedSegment);
1769 lastMergedSegment = iOutputTrack;
1772 const float toX = GPUTPCGeometry::Row2X(cl[0].
row);
1775 p1.Y() =
b.Par()[0];
1776 p1.Z() =
b.Par()[1];
1777 p1.SinPhi() =
b.Par()[2];
1782 p1.SinPhi() =
p2.SinPhi();
1784 p1.TOffset() =
p2.TOffset();
1785 p1.DzDs() =
p2.DzDs();
1786 p1.QPt() =
p2.QPt();
1787 mergedTrack.SetAlpha(
p2.Alpha());
1788 if (CAMath::Abs(Param().polynomialField.GetNominalBz()) < (gpu_common_constants::kZeroFieldCut * gpu_common_constants::kCLight)) {
1789 p1.QPt() = 100.f / Param().rec.bz0Pt10MeV;
1800 if (leg == 0 && Param().
rec.tpc.mergeCE) {
1801 auto& cls = mConstantMem->ioPtrs.clustersNative->clustersLinear;
1802 bool CEside = cls[cl[0].
num].getTime() < cls[cl[nHits - 1].
num].getTime();
1803 MergeCEFill(trackParts[CEside ? lastTrackIndex : firstTrackIndex], cl[CEside ? (nHits - 1) : 0], iOutputTrack);
1809GPUd()
void GPUTPCGMMerger::SortTracksPrepare(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread)
1811 for (uint32_t
i = iBlock * nThreads + iThread;
i < mMemory->nMergedTracks;
i += nThreads * nBlocks) {
1812 mTrackOrderProcess[
i] =
i;
1816GPUd()
void GPUTPCGMMerger::PrepareForFit0(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread)
1818 for (uint32_t
i = iBlock * nThreads + iThread;
i < mMemory->nMergedTracks;
i += nBlocks * nThreads) {
1823GPUd()
void GPUTPCGMMerger::SortTracks(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread)
1825#ifndef GPUCA_SPECIALIZE_THRUST_SORTS
1826 if (iThread == 0 && iBlock == 0) {
1827 GPUCommonAlgorithm::sortDeviceDynamic(mTrackOrderProcess, mTrackOrderProcess + mMemory->nMergedTracks,
GPUTPCGMMergerSortTracks_comp(mMergedTracks));
1832GPUd()
void GPUTPCGMMerger::SortTracksQPt(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread)
1834#ifndef GPUCA_SPECIALIZE_THRUST_SORTS
1835 if (iThread == 0 && iBlock == 0) {
1841GPUd()
void GPUTPCGMMerger::PrepareForFit1(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread)
1843 for (uint32_t
i = iBlock * nThreads + iThread;
i < mMemory->nMergedTracks;
i += nBlocks * nThreads) {
1844 mTrackOrderAttach[mTrackSort[
i]] =
i;
1847 for (uint32_t
j = 0;
j < trk.NClusters();
j++) {
1849 CAMath::AtomicAdd(&mSharedCount[mClusters[trk.FirstClusterRef() +
j].num], 1u);
1851 if (!trk.CCE() && !trk.MergedLooper()) {
1852 GPUTPCGMMergedTrack* updTrk = trk.GetFirstSegment(mMergedTracks, Param().
rec.enableCyclicGraphWorkarounds);
1853 const auto &cl0 = mClusters[trk.FirstClusterRef()], &cln = mClusters[updTrk->FirstClusterRef() + updTrk->NClusters() - 1];
1854 const auto&
GPUrestrict() cls = GetConstantMem()->ioPtrs.clustersNative->clustersLinear;
1856 const auto tmp = zn > z0 ?
std::
array<
float, 3>{zn, z0, GPUTPCGeometry::Row2X(cln.row)} : std::array<float, 3>{z0, zn, GPUTPCGeometry::Row2X(cl0.row)};
1857 trk.Param().ShiftZ(
this, cl0.sector, tmp[0], tmp[1], tmp[2]);
1859 while (updTrk->PrevSegment() >= 0) {
1860 auto next = &mMergedTracks[updTrk->PrevSegment()];
1861 if (Param().
rec.enableCyclicGraphWorkarounds && next == &trk) {
1865 updTrk->Param().TOffset() = trk.Param().TOffset();
1872GPUd()
void GPUTPCGMMerger::PrepareForFit2(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread)
1874 for (uint32_t
i = iBlock * nThreads + iThread;
i < mMemory->nMergedTrackClusters;
i += nBlocks * nThreads) {
1875 if (mSharedCount[mClusters[
i].
num] > 1) {
1879 if (mClusterStateExt) {
1880 for (uint32_t
i = iBlock * nThreads + iThread;
i < mNMaxClusters;
i += nBlocks * nThreads) {
1881 uint8_t state = GetConstantMem()->ioPtrs.clustersNative->clustersLinear[
i].getFlags();
1882 if (mSharedCount[
i] > 1) {
1885 mClusterStateExt[
i] =
state;
1892 for (uint32_t
i = iBlock * nThreads + iThread;
i < mMemory->nMergedTracks;
i += nThreads * nBlocks) {
1893 mTrackSort[mTrackOrderAttach[
i]] =
i;
1895 for (uint32_t
i = iBlock * nThreads + iThread;
i < mMemory->nMergedTrackClusters;
i += nThreads * nBlocks) {
1896 mClusterAttachment[mClusters[
i].num] = 0;
1902 for (uint32_t
i = iBlock * nThreads + iThread;
i < mMemory->nMergedTracks;
i += nThreads * nBlocks) {
1904 if (!trk.OK() || trk.NClusters() == 0) {
1907 for (uint32_t
j = 0;
j < trk.NClusters();
j++) {
1908 int32_t
id = mClusters[trk.FirstClusterRef() +
j].num;
1910 uint8_t clusterState = mClusters[trk.FirstClusterRef() +
j].state;
1916 if (trk.Leg() == 0) {
1919 CAMath::AtomicMax(&mClusterAttachment[
id],
weight);
1926 for (uint32_t
i = iBlock * nThreads + iThread;
i < mNMaxClusters;
i += nThreads * nBlocks) {
1927 if (mClusterAttachment[
i] != 0) {
1933GPUd()
void GPUTPCGMMerger::MergeLoopersInit(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread)
1935 const float lowPtThresh = Param().rec.tpc.rejectQPtB5 * 1.1f;
1937 const auto& trk = mMergedTracks[
i];
1938 const auto&
p = trk.GetParam();
1939 const float qptabs = CAMath::Abs(
p.GetQPt());
1940 if (trk.OK() && trk.NClusters() && trk.Leg() == 0 && qptabs * Param().qptB5Scaler > 5.f && qptabs * Param().qptB5Scaler <= lowPtThresh) {
1941 const int32_t sector = mClusters[trk.FirstClusterRef() + trk.NClusters() - 1].sector;
1942 const float refz =
p.GetZ() + GetConstantMem()->calibObjects.fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(sector,
p.GetTOffset(), Param().continuousMaxTimeBin) + (trk.CSide() ? -100 : 100);
1944 CAMath::SinCos(trk.GetAlpha(), sinA, cosA);
1945 float gx = cosA *
p.GetX() - sinA *
p.GetY();
1946 float gy = cosA *
p.GetY() + sinA *
p.GetX();
1947 float bz = Param().polynomialField.GetFieldBz(gx, gy,
p.GetZ());
1948 const float r1 =
p.GetQPt() * bz;
1949 const float r = CAMath::Abs(r1) > 0.0001f ? (1.f / r1) : 10000;
1950 const float mx =
p.GetX() +
r *
p.GetSinPhi();
1951 const float my =
p.GetY() -
r * CAMath::Sqrt(1 -
p.GetSinPhi() *
p.GetSinPhi());
1952 const float gmx = cosA * mx - sinA * my;
1953 const float gmy = cosA * my + sinA * mx;
1954 uint32_t myId = CAMath::AtomicAdd(&mMemory->nLooperMatchCandidates, 1u);
1955 if (myId >= mNMaxLooperMatches) {
1956 raiseError(GPUErrors::ERROR_LOOPER_MATCH_OVERFLOW, myId, mNMaxLooperMatches);
1957 CAMath::AtomicExch(&mMemory->nLooperMatchCandidates, mNMaxLooperMatches);
1978GPUd()
void GPUTPCGMMerger::MergeLoopersSort(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread)
1980#ifndef GPUCA_SPECIALIZE_THRUST_SORTS
1981 if (iThread == 0 && iBlock == 0) {
1987GPUd()
void GPUTPCGMMerger::MergeLoopersMain(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread)
1991#if GPUCA_MERGE_LOOPER_MC && !defined(GPUCA_GPUCODE)
1992 std::vector<int64_t> paramLabels(mMemory->nLooperMatchCandidates);
1993 for (uint32_t
i = 0;
i < mMemory->nLooperMatchCandidates;
i++) {
1994 paramLabels[
i] = GetTrackLabel(mMergedTracks[candidates[
i].
id]);
2000 if (!mRec->GetProcessingSettings().runQA) {
2001 throw std::runtime_error(
"Need QA enabled for the Merge Loopers MC QA");
2006 for (uint32_t
j =
i + 1;
j < mMemory->nLooperMatchCandidates;
j++) {
2008 assert(CAMath::Abs(candidates[
i].refz) <= CAMath::Abs(candidates[
j].refz));
2009 if (CAMath::Abs(candidates[
j].refz) > CAMath::Abs(candidates[
i].refz) + 100.f) {
2012 const float d2xy = CAMath::Sum2(candidates[
i].
x - candidates[
j].
x, candidates[
i].
y - candidates[
j].
y);
2019 float refZI = candidates[
i].refz;
2021 const auto* tmp = trkI->GetFirstSegment(mMergedTracks, Param().
rec.enableCyclicGraphWorkarounds);
2022 if (tmp != trkI && tmp->CSide() == trkI->CSide() && CAMath::Abs(tmp->GetParam().GetZ()) > CAMath::Abs(trkI->GetParam().GetZ())) {
2023 float tmpRefZ = refZI + tmp->GetParam().GetZ() - trkI->GetParam().GetZ();
2024 if (CAMath::Abs(tmpRefZ) < CAMath::Abs(candidates[
j].refz) && CAMath::Abs(tmpRefZ) > CAMath::Abs(refZI)) {
2030 const auto& trk1 = *trkI;
2031 const auto& trk2 = mMergedTracks[candidates[
j].id];
2032 const auto& param1 = trk1.GetParam();
2033 const auto& param2 = trk2.GetParam();
2034 if (CAMath::Abs(param1.GetDzDs()) > 0.03f && CAMath::Abs(param2.GetDzDs()) > 0.03f && param1.GetDzDs() * param2.GetDzDs() * param1.GetQPt() * param2.GetQPt() < 0) {
2039 const float dznormalized = (CAMath::Abs(candidates[
j].refz) - CAMath::Abs(refZI)) / (CAMath::TwoPi() * 0.5f * (CAMath::Abs(param1.GetDzDs()) + CAMath::Abs(param2.GetDzDs())) * 1.f / (0.5f * (CAMath::Abs(param1.GetQPt()) + CAMath::Abs(param2.GetQPt())) * CAMath::Abs(Param().polynomialField.GetNominalBz())));
2040 const float phasecorr = CAMath::Modf((CAMath::ASin(param1.GetSinPhi()) + trk1.GetAlpha() - CAMath::ASin(param2.GetSinPhi()) - trk2.GetAlpha()) / CAMath::TwoPi() + 5.5f, 1.f) - 0.5f;
2041 const float phasecorrdirection = (candidates[
j].refz * param1.GetQPt() * param1.GetDzDs()) > 0 ? 1 : -1;
2042 const float dzcorr = dznormalized + phasecorr * phasecorrdirection;
2043 const bool sameside = !(trk1.CSide() ^ trk2.CSide());
2044 const float dzcorrlimit[4] = {sameside ? 0.018f : 0.012f, sameside ? 0.12f : 0.025f, 0.14f, 0.15f};
2045 const int32_t dzcorrcount = sameside ? 4 : 2;
2046 bool dzcorrok =
false;
2048 for (int32_t k = 0; k < dzcorrcount; k++) {
2049 const float d = CAMath::Abs(dzcorr - 0.5f * k);
2050 if (d <= dzcorrlimit[k]) {
2052 dznorm = d / dzcorrlimit[k];
2061 const float dtgl = param1.GetDzDs() - (param1.GetQPt() * param2.GetQPt() > 0 ? param2.GetDzDs() : -param2.GetDzDs());
2062 const float dqpt = (CAMath::Abs(param1.GetQPt()) - CAMath::Abs(param2.GetQPt())) / CAMath::Min(param1.GetQPt(), param2.GetQPt());
2063 float d = CAMath::Sum2(dtgl * (1.f / 0.03f), dqpt * (1.f / 0.04f)) + d2xy * (1.f / 4.f) + dznorm * (1.f / 0.3f);
2065#if GPUCA_MERGE_LOOPER_MC && !defined(GPUCA_GPUCODE)
2066 const int64_t label1 = paramLabels[
i];
2067 const int64_t label2 = paramLabels[
j];
2068 bool labelEQ = label1 != -1 && label1 == label2;
2069 if (1 || EQ || labelEQ) {
2071 static auto& tup =
GPUROOTDump<TNtuple>::get(
"mergeloopers",
"labeleq:sides:d2xy:tgl1:tgl2:qpt1:qpt2:dz:dzcorr:dtgl:dqpt:dznorm:bs");
2072 tup.Fill((
float)labelEQ, (trk1.CSide() ? 1 : 0) | (trk2.CSide() ? 2 : 0), d2xy, param1.GetDzDs(), param2.GetDzDs(), param1.GetQPt(), param2.GetQPt(),
CAMath::
Abs(candidates[
j].refz) -
CAMath::
Abs(refZI), dzcorr, dtgl, dqpt, dznorm, bs);
2073 static auto tup2 =
GPUROOTDump<TNtuple>::getNew(
"mergeloopers2",
"labeleq:refz1:refz2:tgl1:tgl2:qpt1:qpt2:snp1:snp2:a1:a2:dzn:phasecor:phasedir:dzcorr");
2074 tup2.Fill((
float)labelEQ, refZI, candidates[
j].refz, param1.GetDzDs(), param2.GetDzDs(), param1.GetQPt(), param2.GetQPt(), param1.GetSinPhi(), param2.GetSinPhi(), trk1.GetAlpha(), trk2.GetAlpha(), dznormalized, phasecorr, phasecorrdirection, dzcorr);
2088 mMergedTracks[candidates[
j].id].SetMergedLooperUnconnected(
true);
2089 if (CAMath::Abs(param2.GetQPt() * Param().qptB5Scaler) >= Param().
rec.tpc.rejectQPtB5) {
2090 mMergedTracks[candidates[
i].id].SetMergedLooperUnconnected(
true);
Class of a TPC cluster in TPC-native coordinates (row, time)
A const (ready only) version of MCTruthContainer.
#define get_global_size(dim)
#define get_global_id(dim)
#define GPUCA_DEBUG_STREAMER_CHECK(...)
#define GPUCA_DETERMINISTIC_CODE(det, indet)
#define GPUCA_MERGER_MAX_TRACK_CLUSTERS
#define GPUCA_MAX_SIN_PHI_LOW
#define GPUCA_TRACKLET_SELECTOR_MIN_HITS_B5(QPTB5)
#define GPUCA_MAX_SIN_PHI
#define CADEBUG2(cmd,...)
const GPUTPCGMMerger::trackCluster *const mCmp
constexpr int p1()
constexpr to accelerate the coordinates changing
Class for time synchronization of RawReader instances.
static void computePointerWithAlignment(T *&basePtr, S *&objPtr, size_t nEntries=1)
void AllocateAndInitializeLate()
static GPUROOTDump< T, Args... > getNew(const char *name1, Names... names)
static GPUROOTDump< T, Args... > & get(const char *name1, Names... names)
RecoStepField GetRecoStepsGPU() const
int16_t RegisterMemoryAllocation(T *proc, void *(T::*setPtr)(void *), int32_t type, const char *name="", const GPUMemoryReuse &re=GPUMemoryReuse())
RecoStepField GetRecoSteps() const
const GPUParam & GetParam() const
const GPUConstantMem & GetConstantMem() const
GPUMemorySizeScalers * MemoryScalers()
const GPUSettingsProcessing & GetProcessingSettings() const
virtual const GPUDefParameters & getGPUParameters(bool doGPU) const =0
void * SetPointersRefitScratch(void *mem)
void CheckCollectedTracks()
void RegisterMemoryAllocation()
void * SetPointersMemory(void *mem)
static constexpr const int32_t NSECTORS
void * SetPointersOutput(void *mem)
void InitializeProcessor()
void * SetPointersOutputO2MC(void *mem)
void * SetPointersOutputO2Scratch(void *mem)
void * SetPointersMerger(void *mem)
void * SetPointersOutputO2Clus(void *mem)
void * SetPointersOutputState(void *mem)
void SetMaxData(const GPUTrackingInOutPointers &io)
void * SetPointersOutputO2(void *mem)
int32_t int32_t int32_t bool float float Z
int32_t int32_t int32_t bool float Y
GLint GLint GLsizei GLint border
GLfloat GLfloat GLfloat alpha
GLuint GLuint GLfloat weight
GLboolean GLboolean GLboolean b
GLuint GLsizei GLsizei * length
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLboolean GLboolean GLboolean GLboolean a
GLdouble GLdouble GLdouble z
uint8_t itsSharedClusterMap uint8_t
Node par(int index)
Parameters.
GPUd() const expr uint32_t MultivariatePolynomialHelper< Dim
if(!okForPhiMin(phi0, phi1))
Global TPC definitions and constants.
@ streamMergeBorderTracksBest
stream MergeBorderTracks best track
@ streamMergeBorderTracksAll
stream MergeBorderTracks all tracks
Defining DataPointCompositeObject explicitly as copiable.
std::string getTime(uint64_t ts)
GPUTPCTracker tpcTrackers[GPUCA_NSECTORS]
size_t getValue(size_t maxVal, size_t val)
size_t NTPCMergedTrackHits(size_t tpcSectorTrackHitss)
size_t NTPCMergedTracks(size_t tpcSectorTracks)
@ clustererAndSharedFlags
const o2::tpc::ClusterNativeAccess * clustersNative
const GPUTPCGMMergedTrack & GPUrestrict() b
GPUd() bool operator()(const int32_t aa
const GPUTPCGMMergedTrack *const mCmp
GPUhd() GPUTPCGMMergerSortTracksQPt_comp(GPUTPCGMMergedTrack *cmp)
const GPUTPCGMMergedTrack & GPUrestrict() b
GPUhd() GPUTPCGMMergerSortTracks_comp(GPUTPCGMMergedTrack *cmp)
GPUd() bool operator()(const int32_t aa
const GPUTPCGMMergedTrack *const mCmp
unsigned int nClustersTotal
char const *restrict const cmp