15#define GPUCA_CADEBUG 0
16#define DEBUG_SINGLE_TRACK -1
34#include "GPUParam.inc"
37#ifdef GPUCA_CADEBUG_ENABLED
42#ifndef GPUCA_GPUCODE_DEVICE
52 constexpr float kDeg2Rad = M_PI / 180.f;
53 CADEBUG(
static constexpr float kSectAngle = 2 * M_PI / 18.f);
60 prop.SetMaterialTPC();
61 prop.SetPolynomialField(&
param.polynomialField);
62 prop.SetMaxSinPhi(maxSinPhi);
63 if (
param.rec.tpc.mergerInterpolateErrors) {
73 float lastUpdateX = -1.f;
78 for (
int32_t iWay = 0; iWay < nWays; iWay++) {
79 int32_t nMissed = 0, nMissed2 = 0;
80 float sumInvSqrtCharge = 0.f;
83 if (iWay && (iWay & 1) == 0) {
84 StoreOuter(&track.OuterParam(), prop.GetAlpha());
87 int32_t resetT0 = initResetT0();
88 const bool refit = (nWays == 1 || iWay >= 1);
89 const bool finalOutInFit = iWay + 2 >= nWays;
90 const bool finalFit = iWay == nWays - 1;
91 const float maxSinForUpdate = CAMath::Sin(70.f * kDeg2Rad);
94 prop.SetSeedingErrors(!(refit && attempt == 0));
95 prop.SetFitInProjections(
true);
96 prop.SetPropagateBzOnly(
param.rec.fitPropagateBzOnly == -1 ? !finalFit :
param.rec.fitPropagateBzOnly);
97 prop.SetMatLUT((
param.rec.useMatLUT && finalFit) ?
merger->GetConstantMem()->calibObjects.matLUT :
nullptr);
98 prop.SetTrack(
this, iWay ? prop.GetAlpha() : Alpha);
99 ConstrainSinPhi(iWay == 0 ? 0.95f : constants::MAX_SIN_PHI_LOW);
100 CADEBUG(printf(
"Fitting track %d way %d (sector %d, alpha %f) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n", iTrk, iWay, CAMath::Float2IntRn(prop.GetAlpha() / kSectAngle) + (mP[1] < 0 ? 18 : 0), prop.GetAlpha()));
104 const bool inFlyDirection = iWay & 1;
105 const int32_t wayDirection = (iWay & 1) ? -1 : 1;
108 for (
int32_t ihit = ihitStart; ihit >= 0 && ihit < maxN; ihit += wayDirection) {
109 const bool crossCE = lastSector != 255 && ((lastSector < 18) ^ (
clusters[ihit].
sector < 18));
122 const bool allowChangeClusters = finalOutInFit && (nWays == 1 || ((iWay & 1) ? (ihit <= CAMath::Max(maxN / 2, maxN - 30)) : (ihit >= CAMath::Min(maxN / 2, 30))));
130 merger->GetConstantMem()->calibObjects.fastTransform->Transform(
clusters[ihit].
sector,
clusters[ihit].
row, cl.getPad(), cl.getTime(), xx, yy, zz, mTOffset);
133 CADEBUG(printf(
"\tHit %3d/%3d Row %3d: Cluster Alpha %8.3f %3d, X %8.3f - Y %8.3f, Z %8.3f (Missed %d)\n", ihit, maxN, (
int32_t)
clusters[ihit].
row, clAlpha, (
int32_t)
clusters[ihit].
sector, xx, yy, zz, nMissed));
137 if (MergeDoubleRowClusters(ihit, wayDirection,
clusters,
merger, prop, xx, yy, zz, maxN, clAlpha, clusterState, allowChangeClusters) == -1) {
143 if (
param.rec.tpc.rejectIFCLowRadiusCluster) {
144 const float r2 = xx * xx + yy * yy;
145 const float rmax = (83.5f +
param.rec.tpc.sysClusErrorMinDist);
146 if (r2 < rmax * rmax) {
152 const auto& cluster =
clusters[ihit];
155 CADEBUG(printf(
"\tSector %2d %11sTrack Alpha %8.3f %s, X %8.3f - Y %8.3f, Z %8.3f - QPt %7.2f (%7.2f), SP %5.2f (%5.2f) %28s --- Cov sY %8.3f sZ %8.3f sSP %8.3f sPt %8.3f - YPt %8.3f\n", (
int32_t)cluster.sector,
"", prop.GetAlpha(), (CAMath::Abs(prop.GetAlpha() - clAlpha) < 0.01 ?
" " :
" R!"), mX, mP[0], mP[1], mP[4], prop.GetQPt0(), mP[2], prop.GetSinPhi0(),
"", sqrtf(mC[0]), sqrtf(mC[2]), sqrtf(mC[5]), sqrtf(mC[14]), mC[10]));
157 if (allowChangeClusters &&
lastRow != 255 && CAMath::Abs(cluster.row -
lastRow) > 1) {
159 bool dodEdx =
param.dodEdxEnabled &&
param.rec.tpc.adddEdxSubThresholdClusters && finalFit && CAMath::Abs(cluster.row -
lastRow) == 2;
160 dodEdx = AttachClustersPropagate(
merger, cluster.sector,
lastRow, cluster.row, iTrk, track.Leg() == 0, prop, inFlyDirection, constants::MAX_SIN_PHI, dodEdx);
162 dEdx.fillSubThreshold(
lastRow - wayDirection);
164 dEdxAlt.fillSubThreshold(
lastRow - wayDirection);
170 int32_t retValProp = prop.PropagateToXAlpha(xx, clAlpha, inFlyDirection);
172 CADEBUG(
if (!CheckCov()){printf(
"INVALID COV AFTER PROPAGATE!!!\n");});
174 if (retValProp == -2)
177 if (prop.PropagateToXAlpha(xx, prop.GetAlpha(), inFlyDirection) == 0) {
178 retValProp = prop.PropagateToXAlpha(xx, clAlpha, inFlyDirection);
181 if (
lastRow == 255 || CAMath::Abs((
int32_t)
lastRow - (
int32_t)cluster.row) > 5 || lastSector != cluster.sector || (
param.rec.tpc.trackFitRejectMode < 0 && -nMissed <=
param.rec.tpc.trackFitRejectMode)) {
186 if (retValProp == 0) {
188 lastSector = cluster.sector;
191 CADEBUG(printf(
"\t%21sPropaga Alpha %8.3f , X %8.3f - Y %8.3f, Z %8.3f - QPt %7.2f (%7.2f), SP %5.2f (%5.2f) --- Res %8.3f %8.3f --- Cov sY %8.3f sZ %8.3f sSP %8.3f sPt %8.3f - YPt %8.3f - PErr %d",
"", prop.GetAlpha(), mX, mP[0], mP[1], mP[4], prop.GetQPt0(), mP[2], prop.GetSinPhi0(), mP[0] - yy, mP[1] - zz, sqrtf(mC[0]), sqrtf(mC[2]), sqrtf(mC[5]), sqrtf(mC[14]), mC[10], retValProp));
195 if (
param.rec.tpc.addErrorsCECrossing) {
196 if (
param.rec.tpc.addErrorsCECrossing >= 2) {
197 AddCovDiagErrorsWithCorrelations(
param.rec.tpc.errorsCECrossing);
199 AddCovDiagErrors(
param.rec.tpc.errorsCECrossing);
201 }
else if (mC[2] < 0.5f) {
206 float uncorrectedY = -1e6f;
207 if (allowChangeClusters) {
208 uncorrectedY = AttachClusters(
merger, cluster.sector, cluster.row, iTrk, track.Leg() == 0, prop);
211 const bool sinPhiErr = mNDF > 0 && CAMath::Abs(prop.GetSinPhi0()) >= maxSinForUpdate;
212 if (mNDF >= 0 && (mC[0] >
param.rec.tpc.trackFitCovLimit || mC[2] >
param.rec.tpc.trackFitCovLimit)) {
215 if (retValProp || sinPhiErr) {
224 int32_t retValUpd = 0, retValInt = 0;
225 float threshold = 3.f + (lastUpdateX >= 0 ? (CAMath::Abs(mX - lastUpdateX) / 2) : 0.f);
226 if (mNDF > (
int32_t)
param.rec.tpc.mergerNonInterpolateRejectMinNDF && (CAMath::Abs(yy - mP[0]) > threshold || CAMath::Abs(zz - mP[1]) > threshold)) {
231 if (
param.rec.tpc.mergerInterpolateErrors && CAMath::Abs(ihit - ihitMergeFirst) <= 1) {
232 if (iWay == nWays - 3) {
234 }
else if (iWay == nWays - 2) {
236 }
else if (iWay == nWays - 1) {
240 rejectChi2 = allowChangeClusters && goodRows > 5;
245 const float time =
merger->GetConstantMem()->ioPtrs.clustersNative ?
merger->GetConstantMem()->ioPtrs.clustersNative->clustersLinear[cluster.num].getTime() : -1.f;
246 const float invSqrtCharge =
merger->GetConstantMem()->ioPtrs.clustersNative ? CAMath::InvSqrt(
merger->GetConstantMem()->ioPtrs.clustersNative->clustersLinear[cluster.num].qMax) : 0.f;
247 const float invCharge =
merger->GetConstantMem()->ioPtrs.clustersNative ? (1.f /
merger->GetConstantMem()->ioPtrs.clustersNative->clustersLinear[cluster.num].qMax) : 0.f;
248 float invAvgCharge = (sumInvSqrtCharge += invSqrtCharge) / ++nAvgCharge;
249 invAvgCharge *= invAvgCharge;
250 prop.GetErr2(err2Y, err2Z,
param, zz, cluster.row, clusterState, cluster.sector,
time, invAvgCharge, invCharge);
256 retValInt = prop.InterpolateReject(
param, yy, zz, clusterState, rejectChi2, &interpolation.
hit[ihit], err2Y, err2Z, deltaZ);
260 if (
param.rec.tpc.rejectEdgeClustersInTrackFit && uncorrectedY > -1e6f &&
param.rejectEdgeClusterByY(uncorrectedY, cluster.row, CAMath::Sqrt(mC[0]))) {
263 retValUpd = prop.Update(yy, zz, cluster.row,
param, clusterState, rejectChi2, refit, err2Y, err2Z);
266 merger->DebugStreamerUpdate(iTrk, ihit, xx, yy, zz, cluster,
merger->GetConstantMem()->ioPtrs.clustersNative->clustersLinear[cluster.num], *
this, prop, interpolation.
hit[ihit], rejectChi2, refit, retValUpd, sumInvSqrtCharge / nAvgCharge * sumInvSqrtCharge / nAvgCharge, yy, zz, clusterState, retValInt, err2Y, err2Z);
270 CADEBUG(
if (!CheckCov()) GPUError(
"INVALID COV AFTER UPDATE!!!"));
271 CADEBUG(printf(
"\t%21sFit Alpha %8.3f , X %8.3f - Y %8.3f, Z %8.3f - QPt %7.2f (%7.2f), SP %5.2f (%5.2f), DzDs %5.2f %16s --- Cov sY %8.3f sZ %8.3f sSP %8.3f sPt %8.3f - YPt %8.3f - FErr %d %d\n",
"", prop.GetAlpha(), mX, mP[0], mP[1], mP[4], prop.GetQPt0(), mP[2], prop.GetSinPhi0(), mP[3],
"", sqrtf(mC[0]), sqrtf(mC[2]), sqrtf(mC[5]), sqrtf(mC[14]), mC[10], retValUpd, retValInt));
275 if (!retValUpd && !retValInt)
279 nMissed = nMissed2 = 0;
283 float dy = mP[0] - prop.Model().
Y();
284 float dz = mP[1] - prop.Model().
Z();
285 if (CAMath::Abs(mP[4]) *
param.qptB5Scaler > 10 && --resetT0 <= 0 && CAMath::Abs(mP[2]) < 0.15f && dy * dy + dz * dz > 1) {
286 CADEBUG(printf(
"Reinit linearization\n"));
287 prop.SetTrack(
this, prop.GetAlpha());
290 if (
param.dodEdxEnabled && finalFit) {
291 bool acc = (clusterState &
param.rec.tpc.dEdxClusterRejectionFlagMask) == 0, accAlt = (clusterState &
param.rec.tpc.dEdxClusterRejectionFlagMaskAlt) == 0;
293 float qtot = 0, qmax = 0, pad = 0, relTime = 0;
294 const int32_t clusterCount = (ihit - ihitMergeFirst) * wayDirection + 1;
295 for (
int32_t iTmp = ihitMergeFirst; iTmp != ihit + wayDirection; iTmp += wayDirection) {
296 const ClusterNative& cl =
merger->GetConstantMem()->ioPtrs.clustersNative->clustersLinear[cluster.num];
297 qtot += cl.getQtot();
298 qmax = CAMath::Max<float>(qmax, cl.
qMax);
300 relTime += cl.getTime();
302 qtot /= clusterCount;
304 relTime /= clusterCount;
305 relTime = relTime - CAMath::Round(relTime);
307 dEdx.fillCluster(qtot, qmax, cluster.row, cluster.sector, mP[2], mP[3],
merger->GetConstantMem()->calibObjects, zz, pad, relTime
GPUCA_DEBUG_STREAMER_CHECK(, iTrk, clusterState));
311 dEdxAlt.fillCluster(qtot, qmax, cluster.row, cluster.sector, mP[2], mP[3],
merger->GetConstantMem()->calibObjects, zz, pad, relTime
GPUCA_DEBUG_STREAMER_CHECK(, iTrk, clusterState));
318 if (retValInt || allowChangeClusters) {
320 }
else if (finalFit) {
331 if (finalOutInFit && !(
merger->Param().rec.tpc.disableRefitAttachment & 4) &&
lastRow != 255 && lastSector != 255) {
333 CADEBUG(printf(
"\t\tSTORING %d lastRow %d row %d out %d\n", iTrk, (
int)
lastRow, (
int)
clusters[(iWay & 1) ? (maxN - 1) : 0].row,
lastRow >
clusters[(iWay & 1) ? (maxN - 1) : 0].row));
335 if (!(iWay & 1) && !finalFit && !track.CCE() && !track.Looper()) {
344 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_accept_track",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"debug_accept_track").data() <<
"iTrk=" << iTrk <<
"outerParam=" << track.OuterParam() <<
"track=" <<
this <<
"ihitStart=" << ihitStart <<
"\n";
347 if (!(N + NTolerated >= (
int32_t)
param.tpcMinHitsB5(mP[4] *
param.qptB5Scaler) && 2 * NTolerated <= CAMath::Max(10, N) && CheckNumericalQuality(covYYUpd))) {
350 if (
param.rec.tpc.minNClustersFinalTrack != -1 && N + NTolerated <
param.rec.tpc.minNClustersFinalTrack) {
354 if (
param.par.dodEdx &&
param.dodEdxEnabled) {
355 dEdx.computedEdx(
merger->MergedTracksdEdx()[iTrk],
param);
357 dEdxAlt.computedEdx(
merger->MergedTracksdEdxAlt()[iTrk],
param);
360 Alpha = prop.GetAlpha();
361 MoveToReference(prop,
param, Alpha);
362 NormalizeAlpha(Alpha);
369 constexpr float kDeg2Rad = M_PI / 180.f;
370 constexpr float kSectAngle = 2 * M_PI / 18.f;
372 if (
param.rec.tpc.trackReferenceX <= 500) {
374 float saveAlpha = Alpha;
375 for (
int32_t attempt = 0; attempt < 3; attempt++) {
376 float dAngle = CAMath::Round(CAMath::ATan2(mP[0], mX) / kDeg2Rad / 20.f) * kSectAngle;
378 if (prop.PropagateToXAlpha(
param.rec.tpc.trackReferenceX, Alpha, 0)) {
382 if (CAMath::Abs(mP[0]) <= mX * CAMath::Tan(kSectAngle / 2.f)) {
389 if (CAMath::Abs(mP[0]) > mX * CAMath::Tan(kSectAngle / 2.f)) {
390 float dAngle = CAMath::Round(CAMath::ATan2(mP[0], mX) / kDeg2Rad / 20.f) * kSectAngle;
399 if (mirrorParameters) {
400 prop.Mirror(inFlyDirection);
403 prop.GetErr2(err2Y, err2Z,
param, toZ,
row, clusterState,
sector, -1.f, 0.f, 0.f);
404 prop.Model().
Y() = mP[0] = toY;
405 prop.Model().Z() = mP[1] = toZ;
412 if (CAMath::Abs(mC[5]) < 0.1f) {
413 mC[5] = mC[5] > 0 ? 0.1f : -0.1f;
418 mC[1] = mC[4] = mC[6] = mC[8] = mC[11] = mC[13] = 0;
419 prop.SetTrack(
this, prop.GetAlpha());
424GPUd() int32_t
GPUTPCGMTrackParam::MergeDoubleRowClusters(int32_t& ihit, int32_t wayDirection,
GPUTPCGMMergedTrackHit*
GPUrestrict()
clusters, const
GPUTPCGMMerger*
GPUrestrict()
merger,
GPUTPCGMPropagator&
GPUrestrict() prop,
float&
GPUrestrict() xx,
float&
GPUrestrict() yy,
float&
GPUrestrict() zz, int32_t maxN,
float clAlpha,
uint8_t&
GPUrestrict() clusterState,
bool rejectChi2)
427 float maxDistY, maxDistZ;
428 prop.GetErr2(maxDistY, maxDistZ,
merger->Param(), zz,
clusters[ihit].row, 0,
clusters[ihit].sector, -1.f, 0.f, 0.f);
429 maxDistY = (maxDistY + mC[0]) * 20.f;
430 maxDistZ = (maxDistZ + mC[2]) * 20.f;
432 if (CAMath::Abs(clAlpha - prop.GetAlpha()) > 1.e-4f) {
433 noReject = prop.RotateToAlpha(clAlpha);
435 float projY = 0, projZ = 0;
437 noReject |= prop.GetPropagatedYZ(xx, projY, projZ);
444 float clamp = cl.getQtot();
447 float dy = cly - projY;
448 float dz = clz - projZ;
449 if (noReject == 0 && (dy * dy > maxDistY || dz * dz > maxDistZ)) {
450 CADEBUG(printf(
"\t\tRejecting double-row cluster: dy %f, dz %f, chiY %f, chiZ %f (Y: trk %f prj %f cl %f - Z: trk %f prj %f cl %f)\n", dy, dz, sqrtf(maxDistY), sqrtf(maxDistZ), mP[0], projY, cly, mP[1], projZ, clz));
455 CADEBUG(printf(
"\t\tMerging hit row %d X %f Y %f Z %f (dy %f, dz %f, chiY %f, chiZ %f)\n",
clusters[ihit].
row, clx, cly, clz, dy, dz, sqrtf(maxDistY), sqrtf(maxDistZ)));
459 clusterState |=
clusters[ihit].state;
465 ihit += wayDirection;
468 CADEBUG(printf(
"\t\tNo matching cluster in double-row, skipping\n"));
482 Merger->GetConstantMem()->calibObjects.fastTransform->InverseTransformYZtoX(
sector, iRow, mP[0], mP[1], X);
483 if (prop.GetPropagatedYZ(X, Y, Z)) {
487 return AttachClusters(Merger,
sector, iRow, iTrack, goodLeg, Y, Z);
492 const auto&
param = Merger->Param();
493 if (
param.rec.tpc.disableRefitAttachment & 1) {
500 if (
row.NHits() == 0) {
504 const float zOffset =
param.par.continuousTracking ? Merger->GetConstantMem()->calibObjects.fastTransform->convVertexTimeToZOffset(
sector, mTOffset,
param.continuousMaxTimeBin) : 0;
505 const float y0 =
row.Grid().YMin();
506 const float stepY =
row.HstepY();
507 const float z0 =
row.Grid().ZMin() - zOffset;
508 const float stepZ =
row.HstepZ();
511 float uncorrectedY, uncorrectedZ;
512 Merger->GetConstantMem()->calibObjects.fastTransform->InverseTransformYZtoNominalYZ(
sector, iRow, Y, Z, uncorrectedY, uncorrectedZ);
513 if (CAMath::Abs(uncorrectedY) >
row.getTPCMaxY()) {
517 bool protect = CAMath::Abs(GetQPt() *
param.qptB5Scaler) <=
param.rec.tpc.rejectQPtB5 && goodLeg;
519 param.GetClusterErrors2(
sector, iRow, Z, mP[2], mP[3], -1.f, 0.f, 0.f, err2Y, err2Z);
520 const float tubeMaxSize2 = protect ?
param.rec.tpc.tubeProtectMaxSize2 :
param.rec.tpc.tubeRemoveMaxSize2;
521 const float tubeMinSize2 = protect ?
param.rec.tpc.tubeProtectMinSize2 : 0.f;
522 float tubeSigma2 = protect ?
param.rec.tpc.tubeProtectSigma2 :
param.rec.tpc.tubeRemoveSigma2;
523 uint32_t pad = CAMath::Float2UIntRn(GPUTPCGeometry::LinearY2Pad(
sector, iRow, uncorrectedY));
524 float time = Merger->GetConstantMem()->calibObjects.fastTransform->InverseTransformInTimeFrame(
sector, uncorrectedZ + (
param.par.continuousTracking ? Merger->GetConstantMem()->calibObjects.fastTransform->convVertexTimeToZOffset(
sector, mTOffset,
param.continuousMaxTimeBin) : 0),
param.continuousMaxTimeBin);
525 if (iRow <
param.rec.tpc.tubeExtraProtectMinRow ||
526 pad < param.rec.tpc.tubeExtraProtectEdgePads || pad >= (
uint32_t)(GPUTPCGeometry::NPads(iRow) -
param.rec.tpc.tubeExtraProtectEdgePads) ||
527 param.GetUnscaledMult(
time) / GPUTPCGeometry::Row2X(iRow) >
param.rec.tpc.tubeExtraProtectMinOccupancy) {
528 tubeSigma2 *= protect ? 2 : 0.5;
530 const float sy2 = CAMath::Max(tubeMinSize2, CAMath::Min(tubeMaxSize2, tubeSigma2 * (err2Y + CAMath::Abs(mC[0]))));
531 const float sz2 = CAMath::Max(tubeMinSize2, CAMath::Min(tubeMaxSize2, tubeSigma2 * (err2Z + CAMath::Abs(mC[2]))));
532 const float tubeY = CAMath::Sqrt(sy2);
533 const float tubeZ = CAMath::Sqrt(sz2);
534 const float sy21 = 1.f / sy2;
535 const float sz21 = 1.f / sz2;
537 row.Grid().GetBinArea(uncorrectedY, uncorrectedZ + zOffset, tubeY, tubeZ, bin, ny, nz);
539 const int32_t idOffset = tracker.Data().ClusterIdOffset();
540 const int32_t*
ids = &(tracker.Data().ClusterDataIndex()[
row.HitNumberOffset()]);
550 for (int32_t k = 0; k <= nz; k++) {
551 const int32_t mybin = bin + k * nBinsY;
552 const uint32_t hitFst = firsthit[mybin];
553 const uint32_t hitLst = firsthit[mybin + ny + 1];
554 for (
uint32_t ih = hitFst; ih < hitLst; ih++) {
557 if constexpr (GPUCA_PAR_NO_ATOMIC_PRECHECK == 0) {
558 if (myWeight <= *
weight) {
562 const cahit2 hh = hits[ih];
563 const float y =
y0 + hh.
x * stepY;
564 const float z = z0 + hh.
y * stepZ;
565 const float dy =
y - uncorrectedY;
566 const float dz =
z - uncorrectedZ;
567 if (dy * dy * sy21 + dz * dz * sz21 <= CAMath::Sqrt(2.f)) {
569 CAMath::AtomicMax(
weight, myWeight);
578 constexpr float kSectAngle = 2 * M_PI / 18.f;
579 if (Merger->Param().rec.tpc.disableRefitAttachment & 2) {
582 if (CAMath::Abs(
lastRow - toRow) < 2) {
586 float xx = mX - GPUTPCGeometry::Row2X(
lastRow);
587 for (int32_t iRow =
lastRow + step; iRow != toRow; iRow +=
step) {
588 if (CAMath::Abs(mP[2]) > maxSinPhi) {
591 if (CAMath::Abs(mP[0]) > CAMath::Abs(mX) * CAMath::Tan(kSectAngle / 2.f)) {
594 int32_t err = prop.PropagateToXAlpha(xx + GPUTPCGeometry::Row2X(iRow), prop.GetAlpha(), inFlyDirection);
598 if (dodEdx && iRow + step == toRow) {
599 float yUncorrected, zUncorrected;
600 Merger->GetConstantMem()->calibObjects.fastTransform->InverseTransformYZtoNominalYZ(
sector, iRow, mP[0], mP[1], yUncorrected, zUncorrected);
601 uint32_t pad = CAMath::Float2UIntRn(GPUTPCGeometry::LinearY2Pad(
sector, iRow, yUncorrected));
602 if (pad >= GPUTPCGeometry::NPads(iRow) || (Merger->GetConstantMem()->calibObjects.dEdxCalibContainer && Merger->GetConstantMem()->calibObjects.dEdxCalibContainer->isDead(
sector, iRow, pad))) {
606 CADEBUG(printf(
"Attaching in row %d\n", iRow));
607 AttachClusters(Merger,
sector, iRow, iTrack, goodLeg, prop);
614 CADEBUG(printf(
"\t%21sStorO Alpha %8.3f , X %8.3f - Y %8.3f, Z %8.3f - QPt %7.2f, SP %5.2f --- Cov sY %8.3f sZ %8.3f sSP %8.3f sPt %8.3f\n",
"",
alpha, mX, mP[0], mP[1], mP[4], mP[2], sqrtf(mC[0]), sqrtf(mC[2]), sqrtf(mC[5]), sqrtf(mC[14])));
616 outerParam->P[
i] = mP[
i];
619 outerParam->C[
i] = mC[
i];
622 outerParam->alpha =
alpha;
627 if (iRow == 0 || iRow == GPUTPCGeometry::NROWS - 1) {
630 if (CAMath::Abs(mP[2]) >= constants::MAX_SIN_PHI) {
633 if (CAMath::Abs(mP[2]) < 0.75) {
636 if ((mP[2] * mP[4] < 0) ^ outwards) {
640 uint32_t nLoopData = CAMath::AtomicAdd(&Merger->Memory()->nLoopData, 1u);
641 if (nLoopData >= Merger->NMaxTracks()) {
642 Merger->raiseError(GPUErrors::ERROR_MERGER_LOOPER_OVERFLOW, nLoopData, Merger->NMaxTracks());
643 CAMath::AtomicExch(&Merger->Memory()->nLoopData, Merger->NMaxTracks());
652 data.outwards = outwards;
653 Merger->LoopData()[nLoopData] =
data;
659 prop.SetMaterialTPC();
660 prop.SetPolynomialField(&Merger->Param().polynomialField);
661 prop.SetMaxSinPhi(constants::MAX_SIN_PHI);
662 prop.SetMatLUT(Merger->Param().rec.useMatLUT ? Merger->GetConstantMem()->calibObjects.matLUT : nullptr);
663 prop.SetSeedingErrors(
false);
664 prop.SetFitInProjections(
true);
665 prop.SetPropagateBzOnly(
false);
668 prop.SetTrack(&
data.param,
data.alpha);
670 data.param.AttachClustersLooper(Merger,
data.sector,
data.row,
data.track,
data.outwards, prop);
672 data.param.AttachClustersLooperFollow(Merger, prop,
data.sector,
data.track,
data.outwards);
679 bool inFlyDirection = (Merger->MergedTracks()[iTrack].Leg() & 1) ^ up;
681 constexpr float kSectAngle = 2 * M_PI / 18.f;
683 bool right = (mP[2] < 0) ^ up;
684 const int32_t sectorSide =
sector >= (
int32_t)(GPUTPCGeometry::NSECTORS / 2) ? (GPUTPCGeometry::NSECTORS / 2) : 0;
685 float lrFactor =
right ^ !up ? 1.f : -1.f;
687 CADEBUG(printf(
"\nCIRCLE Track %d: Sector %d Alpha %f X %f Y %f Z %f SinPhi %f DzDs %f QPt %f - Right %d Up %d lrFactor %f\n", iTrack,
sector, prop.GetAlpha(), mX, mP[0], mP[1], mP[2], mP[3], mP[4], (
int32_t)
right, (
int32_t)up, lrFactor));
690 if (prop.RotateToAlpha(prop.GetAlpha() + (CAMath::Pi() / 2.f) * lrFactor)) {
693 CADEBUG(printf(
"\tRotated: X %f Y %f Z %f SinPhi %f (Alpha %f / %f)\n", mP[0], mX, mP[1], mP[2], prop.GetAlpha(), prop.GetAlpha() + CAMath::Pi() / 2.f));
696 while (CAMath::Abs(mX) <= CAMath::Abs(mP[0]) * CAMath::Tan(kSectAngle / 2.f) + 0.1f) {
697 if (maxTries-- == 0) {
700 if (CAMath::Abs(mP[2]) > 0.7f) {
703 if (up ? (-mP[0] * lrFactor > GPUTPCGeometry::Row2X(GPUTPCGeometry::NROWS - 1)) : (-mP[0] * lrFactor < GPUTPCGeometry::Row2X(0))) {
706 if (!((up ? (-mP[0] * lrFactor >= toX) : (-mP[0] * lrFactor <= toX)) || (
right ^ (mP[2] > 0)))) {
709 int32_t err = prop.PropagateToXAlpha(mX + (up ? 1.f : -1.f), prop.GetAlpha(), inFlyDirection);
711 CADEBUG(printf(
"\t\tpropagation error (%d)\n", err));
714 CADEBUG(printf(
"\tPropagated to y = %f: X %f Z %f SinPhi %f\n", mX, mP[0], mP[1], mP[2]));
715 for (
uint32_t j = 0;
j < GPUTPCGeometry::NROWS;
j++) {
716 float rowX = GPUTPCGeometry::Row2X(
j);
717 if (CAMath::Abs(rowX - (-mP[0] * lrFactor)) < 1.5f) {
718 CADEBUG(printf(
"\t\tAttempt row %d (X %f Y %f Z %f)\n",
j, rowX, mX * lrFactor, mP[1]));
719 AttachClusters(Merger,
sector,
j, iTrack,
false, mX * lrFactor, mP[1]);
723 if (maxTries-- == 0) {
727 if (++
sector >= sectorSide + 18) {
731 if (--
sector < sectorSide) {
735 CADEBUG(printf(
"\tRotating to sector %d: %f --> %f\n",
sector, prop.GetAlpha(),
param.Alpha(
sector) + (CAMath::Pi() / 2.f) * lrFactor));
736 int32_t err = prop.RotateToAlpha(
param.Alpha(
sector) + (CAMath::Pi() / 2.f) * lrFactor);
738 CADEBUG(printf(
"Rotation Error %d\n", err));
741 CADEBUG(printf(
"\tAfter Rotating Alpha %f Position X %f Y %f Z %f SinPhi %f\n", prop.GetAlpha(), mP[0], mX, mP[1], mP[2]));
747 constexpr float kSectAngle = 2 * M_PI / 18.f;
749 float X = mP[2] > 0 ? mP[0] : -mP[0];
750 float Y = mP[2] > 0 ? -mX : mX;
752 float SinPhi = CAMath::Sqrt(1 - mP[2] * mP[2]) * (mP[2] > 0 ? -1 : 1);
753 float b = prop.GetBz(prop.GetAlpha(), mX, mP[0], mP[1]);
755 float dx = outwards ? 1.f : -1.f;
756 const float myRowX = GPUTPCGeometry::Row2X(iRow);
762 float ex = CAMath::Sqrt(1 - SinPhi * SinPhi);
763 float exi = 1.f / ex;
764 float dxBzQ = dx * -
b * mP[4];
765 float newSinPhi = SinPhi + dxBzQ;
766 if (CAMath::Abs(newSinPhi) > constants::MAX_SIN_PHI_LOW) {
770 if (mP[2] > 0 ? (newSinPhi > 0.5) : (newSinPhi < -0.5)) {
775 float h2 = dS * exi * exi;
776 float h4 = .5f * h2 * dxBzQ;
779 Y += dS * SinPhi + h4;
782 if (CAMath::Abs(X) > CAMath::Abs(Y) * CAMath::Tan(kSectAngle / 2.f)) {
788 float paramX = mP[2] > 0 ? -Y : Y;
791 for (int32_t
j = iRow;
j >= 0 &&
j < (
int32_t)GPUTPCGeometry::NROWS && found < 3;
j +=
step) {
792 float rowX = mX + GPUTPCGeometry::Row2X(
j) - myRowX;
793 if (CAMath::Abs(rowX - paramX) < 1.5f) {
795 AttachClusters(Merger,
sector,
j, iTrack,
false, mP[2] > 0 ? X : -X, Z);
806 const auto&
GPUrestrict() cls =
merger->GetConstantMem()->ioPtrs.clustersNative->clustersLinear;
808 const auto tmp = zn > z0 ?
std::
array<
float, 3>{zn, z0, GPUTPCGeometry::Row2X(
clusters[N - 1].
row)} : std::array<float, 3>{z0, zn, GPUTPCGeometry::Row2X(
clusters[0].
row)};
814 if (!
merger->Param().par.continuousTracking) {
818 bool beamlineReached =
false;
819 const float r1 = CAMath::Max(0.0001f, CAMath::Abs(mP[4] *
merger->Param().polynomialField.GetNominalBz()));
821 const float dist2 = mX * mX + mP[0] * mP[0];
822 const float dist1r2 = dist2 * r1 * r1;
824 const float alpha = CAMath::ACos(1 - 0.5f * dist1r2);
825 const float beta = CAMath::ATan2(mP[0], mX);
826 const int32_t comp = mP[2] > CAMath::Sin(beta);
827 const float sinab = CAMath::Sin((comp ? 0.5f : -0.5f) *
alpha + beta);
828 const float res = CAMath::Abs(sinab - mP[2]);
831 const float r = 1.f / r1;
832 const float dS =
alpha *
r;
833 float z0 = dS * mP[3];
834 if (CAMath::Abs(z0) > GPUTPCGeometry::TPCLength()) {
835 z0 = z0 > 0 ? GPUTPCGeometry::TPCLength() : -
GPUTPCGeometry::TPCLength();
838 beamlineReached =
true;
845 if (!beamlineReached) {
846 float refZ = ((
sector < GPUTPCGeometry::NSECTORS / 2) ?
merger->Param().rec.tpc.defaultZOffsetOverR : -
merger->Param().rec.tpc.defaultZOffsetOverR) * clx;
848 merger->GetConstantMem()->calibObjects.fastTransform->TransformIdealZ(
sector, cltmax, basez, mTOffset);
849 deltaZ = basez - refZ;
852 float deltaT =
merger->GetConstantMem()->calibObjects.fastTransform->convDeltaZtoDeltaTimeInTimeFrame(
sector, deltaZ);
854 const float maxT = cltmin -
merger->GetConstantMem()->calibObjects.fastTransform->getT0();
855 const float minT = cltmax -
merger->GetConstantMem()->calibObjects.fastTransform->getMaxDriftTime(
sector);
858 if (mTOffset < minT) {
859 deltaT = minT - mTOffset;
861 if (mTOffset + deltaT > maxT) {
862 deltaT =
maxT - mTOffset;
865 deltaZ +=
merger->GetConstantMem()->calibObjects.fastTransform->convDeltaTimeToDeltaZinTimeFrame(
sector, deltaT);
878 bool ok =
c[0] >= 0 &&
c[2] >= 0 &&
c[5] >= 0 &&
c[9] >= 0 &&
c[14] >= 0 && (
c[1] *
c[1] <=
c[2] *
c[0]) && (
c[3] *
c[3] <=
c[5] *
c[0]) && (
c[4] *
c[4] <=
c[5] *
c[2]) && (
c[6] *
c[6] <=
c[9] *
c[0]) && (
c[7] *
c[7] <=
c[9] *
c[2]) && (
c[8] *
c[8] <=
c[9] *
c[5]) &&
879 (
c[10] *
c[10] <=
c[14] *
c[0]) && (
c[11] *
c[11] <=
c[14] *
c[2]) && (
c[12] *
c[12] <=
c[14] *
c[5]) && (
c[13] *
c[13] <=
c[14] *
c[9]);
886 bool ok = CAMath::Finite(mX) && CAMath::Finite(mChi2);
889 for (int32_t
i = 0;
i < 15;
i++) {
890 ok = ok && CAMath::Finite(
c[
i]);
892 for (int32_t
i = 0;
i < 5;
i++) {
893 ok = ok && CAMath::Finite(mP[
i]);
895 if ((overrideCovYY > 0 ? overrideCovYY :
c[0]) > 4.f * 4.f ||
c[2] > 4.f * 4.f ||
c[5] > 2.f * 2.f ||
c[9] > 2.f * 2.f) {
898 if (CAMath::Abs(mP[2]) > constants::MAX_SIN_PHI) {
920 float Alpha =
track.Alpha();
921 CADEBUG(int32_t nTrackHitsOld = nTrackHits;
float ptOld =
t.QPt());
922 bool ok =
t.Fit(
merger, iTrk,
merger->Clusters() +
track.FirstClusterRef(), nTrackHits, NTolerated, Alpha, attempt, constants::MAX_SIN_PHI, track);
923 CADEBUG(printf(
"Finished Fit Track %d\n", iTrk));
924 CADEBUG(printf(
"OUTPUT hits %d -> %d+%d = %d, QPt %f -> %f, SP %f, OK %d chi2 %f chi2ndf %f\n", nTrackHitsOld, nTrackHits, NTolerated, nTrackHits + NTolerated, ptOld,
t.QPt(),
t.SinPhi(), (int32_t)ok,
t.Chi2(),
t.Chi2() / CAMath::Max(1, nTrackHits)));
926 if (!ok && attempt == 0 &&
merger->Param().rec.tpc.retryRefit) {
930 CADEBUG(printf(
"Track rejected, marking for retry\n"));
931 if (
merger->Param().rec.tpc.retryRefit == 2) {
932 nTrackHits =
track.NClusters();
935 Alpha =
track.Alpha();
936 ok =
t.Fit(
merger, iTrk,
merger->Clusters() +
track.FirstClusterRef(), nTrackHits, NTolerated, Alpha, 1, constants::MAX_SIN_PHI, track);
938 uint32_t nRefit = CAMath::AtomicAdd(&
merger->Memory()->nRetryRefit, 1u);
939 merger->RetryRefitIds()[nRefit] = iTrk;
943 if (CAMath::Abs(
t.QPt()) < 1.e-4f) {
947 CADEBUG(
if (
t.GetX() > 250) { printf(
"ERROR, Track %d at impossible X %f, Pt %f, Looper %d\n", iTrk, t.GetX(), CAMath::Abs(1.f / t.QPt()), (int32_t)merger->MergedTracks()[iTrk].Looper()); });
950 track.SetNClustersFitted(nTrackHits);
952 track.Alpha() = Alpha;
960 CAMath::SinCos(
alpha, sA, cA);
962 float sinPhi0 = mP[2], cosPhi0 = CAMath::Sqrt(1 - mP[2] * mP[2]);
963 float cosPhi = cosPhi0 * cA + sinPhi0 *
sA;
964 float sinPhi = -cosPhi0 *
sA + sinPhi0 * cA;
965 float j0 = cosPhi0 / cosPhi;
966 float j2 = cosPhi / cosPhi0;
967 mX =
x0 * cA + mP[0] *
sA;
968 mP[0] = -
x0 *
sA + mP[0] * cA;
982 SinPhi() = -SinPhi();
1000 mC[14] += errors2[4];
1005 const int32_t diagMap[5] = {0, 2, 5, 9, 14};
1006 const float oldDiag[5] = {mC[0], mC[2], mC[5], mC[9], mC[14]};
1007 for (int32_t
i = 0;
i < 5;
i++) {
1008 mC[diagMap[
i]] += errors2[
i];
1009 for (int32_t
j = 0;
j <
i;
j++) {
1010 mC[diagMap[
i - 1] +
j + 1] *= gpu::CAMath::Sqrt(mC[diagMap[
i]] * mC[diagMap[
j]] / (oldDiag[
i] * oldDiag[
j]));
#define GPUCA_DEBUG_STREAMER_CHECK(...)
#define GPUCA_RTC_CONSTEXPR
#define GPUCA_PAR_MERGER_INTERPOLATION_ERROR_TYPE_A
#define GPUCA_GET_CONSTEXPR(obj, val)
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual sector
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of merger(must be odd to end with inward fit)") AddOptionRTC(trackFitRejectMode
GPUdii() void GPUTPCGMTrackParam
GPUdni() void GPUTPCGMTrackParam
#define DEBUG_SINGLE_TRACK
@ updateErrorClusterRejectedDistance
@ updateErrorClusterRejected
@ updateErrorClusterRejectedEdge
int32_t int32_t int32_t bool float Y
GLfloat GLfloat GLfloat alpha
GLsizei const GLuint const GLfloat * weights
GLuint GLuint GLfloat weight
GLboolean GLboolean GLboolean b
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLuint GLfloat GLfloat y0
GLdouble GLdouble GLdouble z
const bool const int TrackITSInternal< NLayers > & track
Global TPC definitions and constants.
GPUdi() T BetheBlochAleph(T bg
@ streamUpdateTrack
stream update track informations
std::string getTime(uint64_t ts)
@ clustererAndSharedFlags
GPUCA_PAR_MERGER_INTERPOLATION_ERROR_TYPE_A errorY
InterpolationErrorHit hit[constants::MERGER_MAX_TRACK_CLUSTERS]
std::vector< Cluster > clusters