106GPUdic(2, 1)
void GPUTPCTrackletConstructor::UpdateTracklet(int32_t , int32_t , int32_t , int32_t ,
GPUsharedref() T& s, GPUTPCThreadMemory&
GPUrestrict()
r,
GPUconstantref()
GPUTPCTracker&
GPUrestrict() tracker,
GPUTPCTrackParam&
GPUrestrict() tParam, int32_t iRow,
calink& rowHit,
calink* rowHits)
111 float y0 =
row.Grid().YMin();
112 float stepY =
row.HstepY();
113 float z0 =
row.Grid().ZMin() - tParam.ZOffset();
114 float stepZ =
row.HstepZ();
121 if ((iRow -
r.mStartRow) & 1) {
128 int32_t seedIH =
r.mCurrIH;
132 float y =
y0 + hh.
x * stepY;
133 float z = z0 + hh.
y * stepZ;
134 if (iRow !=
r.mStartRow || !tracker.Param().par.continuousTracking) {
135 tParam.ConstrainZ(
z, tracker.ISector(), z0,
r.mLastZ);
136 tracker.GetConstantMem()->calibObjects.fastTransformHelper->TransformXYZ(tracker.ISector(), iRow,
x,
y,
z);
138 if (iRow ==
r.mStartRow) {
139 if (tracker.Param().par.continuousTracking) {
140 float refZ = ((
z > 0) ? tracker.Param().rec.tpc.defaultZOffsetOverR : -tracker.Param().rec.tpc.defaultZOffsetOverR) *
x;
142 tracker.GetConstantMem()->calibObjects.fastTransformHelper->TransformXYZ(tracker.ISector(), iRow,
x,
y, zTmp);
144 tParam.SetZOffset(
z - refZ);
150 tParam.SetZOffset(0.f);
155 CADEBUG(printf(
"Tracklet %5d: FIT INIT ROW %3d X %8.3f -",
r.mISH, iRow, tParam.X());
for (int32_t
i = 0;
i < 5;
i++) { printf(
" %8.3f", tParam.Par()[
i]); } printf(
" -");
for (int32_t
i = 0;
i < 15;
i++) { printf(
" %8.3f", tParam.Cov()[
i]); } printf(
"\n"));
157 float dx =
x - tParam.X();
159 if (
r.mNHits >= 10) {
169 float ri = 1.f / CAMath::Sqrt(dx * dx + dy * dy);
170 if (iRow ==
r.mStartRow + 2) {
171 tParam.SetSinPhi(dy * ri);
172 tParam.SetSignCosPhi(dx);
173 tParam.SetDzDs(dz * ri);
175 tracker.GetErrors2Seeding(iRow, tParam, -1.f, err2Y, err2Z);
176 tParam.SetCov(0, err2Y);
177 tParam.SetCov(2, err2Z);
179 float sinPhi, cosPhi;
181 sinPhi = tParam.SinPhi();
182 cosPhi = CAMath::Sqrt(1 - sinPhi * sinPhi);
187 CADEBUG(printf(
"%14s: FIT TRACK ROW %3d X %8.3f -",
"", iRow, tParam.X());
for (int32_t
i = 0;
i < 5;
i++) { printf(
" %8.3f", tParam.Par()[
i]); } printf(
" -");
for (int32_t
i = 0;
i < 15;
i++) { printf(
" %8.3f", tParam.Cov()[
i]); } printf(
"\n"));
188 if (!tParam.TransportToX(
x, sinPhi, cosPhi, tracker.Param().bzCLight,
GPUCA_MAX_SIN_PHI)) {
192 CADEBUG(printf(
"%5s hits %3d: FIT PROP ROW %3d X %8.3f -",
"",
r.mNHits, iRow, tParam.X());
for (int32_t
i = 0;
i < 5;
i++) { printf(
" %8.3f", tParam.Par()[
i]); } printf(
" -");
for (int32_t
i = 0;
i < 15;
i++) { printf(
" %8.3f", tParam.Cov()[
i]); } printf(
"\n"));
194 tracker.GetErrors2Seeding(iRow, tParam.GetZ(), sinPhi, tParam.GetDzDs(), -1.f, err2Y, err2Z);
196 if (
r.mNHits >= 10) {
197 const float sErr2 = tracker.Param().GetSystematicClusterErrorIFC2(
x, tParam.GetY(), tParam.GetZ(), tracker.ISector() >= 18);
200 const float kFactor = tracker.Param().rec.tpc.hitPickUpFactor * tracker.Param().rec.tpc.hitPickUpFactor * 3.5f * 3.5f;
201 float sy2 = kFactor * (tParam.Err2Y() + err2Y);
202 float sz2 = kFactor * (tParam.Err2Z() + err2Z);
203 if (sy2 > tracker.Param().rec.tpc.hitSearchArea2) {
204 sy2 = tracker.Param().rec.tpc.hitSearchArea2;
206 if (sz2 > tracker.Param().rec.tpc.hitSearchArea2) {
207 sz2 = tracker.Param().rec.tpc.hitSearchArea2;
211 if (dy * dy > sy2 || dz * dz > sz2) {
212 if (++
r.mNMissed >= tracker.Param().rec.tpc.trackFollowingMaxRowGapSeed) {
224 CADEBUG(printf(
"%14s: FIT FILT ROW %3d X %8.3f -",
"", iRow, tParam.X());
for (int32_t
i = 0;
i < 5;
i++) { printf(
" %8.3f", tParam.Par()[
i]); } printf(
" -");
for (int32_t
i = 0;
i < 15;
i++) { printf(
" %8.3f", tParam.Cov()[
i]); } printf(
"\n"));
227 r.mNHitsEndRow = ++
r.mNHits;
239 r.mLastY = tParam.Y();
240 r.mLastZ = tParam.Z();
247 if (
r.mStage == 2 && iRow >
r.mEndRow) {
250 if (
r.mNMissed > tracker.Param().rec.tpc.trackFollowingMaxRowGap) {
260 if (!tParam.GetPropagatedYZ(tracker.Param().bzCLight,
x, tmpY, tmpZ)) {
265 tParam.ConstrainZ(tmpZ, tracker.ISector(), z0,
r.mLastZ);
266 tracker.GetConstantMem()->calibObjects.fastTransformHelper->InverseTransformYZtoX(tracker.ISector(), iRow, tmpY, tmpZ,
x);
269 CADEBUG(printf(
"%14s: SEA TRACK ROW %3d X %8.3f -",
"", iRow, tParam.X());
for (int32_t
i = 0;
i < 5;
i++) { printf(
" %8.3f", tParam.Par()[
i]); } printf(
" -");
for (int32_t
i = 0;
i < 15;
i++) { printf(
" %8.3f", tParam.Cov()[
i]); } printf(
"\n"));
270 if (!tParam.TransportToX(
x, tParam.SinPhi(), tParam.GetCosPhi(), tracker.Param().bzCLight,
GPUCA_MAX_SIN_PHI_LOW)) {
275 CADEBUG(printf(
"%14s: SEA PROP ROW %3d X %8.3f -",
"", iRow, tParam.X());
for (int32_t
i = 0;
i < 5;
i++) { printf(
" %8.3f", tParam.Par()[
i]); } printf(
" -");
for (int32_t
i = 0;
i < 15;
i++) { printf(
" %8.3f", tParam.Cov()[
i]); } printf(
"\n"));
278 float yUncorrected = tParam.GetY(), zUncorrected = tParam.GetZ();
280 if (
row.NHits() < 1) {
285#ifndef GPUCA_TEXTURE_FETCH_CONSTRUCTOR
289 tracker.GetConstantMem()->calibObjects.fastTransformHelper->InverseTransformYZtoNominalYZ(tracker.ISector(), iRow, yUncorrected, zUncorrected, yUncorrected, zUncorrected);
291 if (tracker.Param().rec.tpc.rejectEdgeClustersInSeeding && tracker.Param().rejectEdgeClusterByY(yUncorrected, iRow, CAMath::Sqrt(tParam.Err2Y()))) {
298 tracker.GetErrors2Seeding(iRow, *((
GPUTPCTrackParam*)&tParam), -1.f, err2Y, err2Z);
299 if (
r.mNHits >= 10) {
300 const float sErr2 = tracker.Param().GetSystematicClusterErrorIFC2(
x, tParam.GetY(), tParam.GetZ(), tracker.ISector() >= 18);
304 if (CAMath::Abs(yUncorrected) <
x * GPUTPCRow::getTPCMaxY1X()) {
305 const float kFactor = tracker.Param().rec.tpc.hitPickUpFactor * tracker.Param().rec.tpc.hitPickUpFactor * 7.0f * 7.0f;
306 const float maxWindow2 = tracker.Param().rec.tpc.hitSearchArea2;
307 const float sy2 = CAMath::Min(maxWindow2, kFactor * (tParam.Err2Y() + err2Y));
308 const float sz2 = CAMath::Min(maxWindow2, kFactor * (tParam.Err2Z() + err2Z));
311 row.Grid().GetBinArea(yUncorrected, zUncorrected + tParam.ZOffset(), CAMath::Sqrt(sy2), CAMath::Sqrt(sz2), bin, ny, nz);
315 for (int32_t k = -1; ++k <= nz; ) {
317 for (int32_t k = 0; k <= nz; k++) {
319 int32_t nBinsY =
row.Grid().Ny();
320 int32_t mybin = bin + k * nBinsY;
324 for (uint32_t ih = hitFst - 1; ++ih < hitLst; ) {
326 for (uint32_t ih = hitFst; ih < hitLst; ih++) {
329 float y =
y0 + hh.
x * stepY;
330 float z = z0 + hh.
y * stepZ;
331 float dy =
y - yUncorrected;
332 float dz =
z - zUncorrected;
333 if (dy * dy < sy2 && dz * dz < sz2) {
334 float dds = tracker.Param().rec.tpc.trackFollowingYFactor * CAMath::Abs(dy) + CAMath::Abs(dz);
345 if (
r.mNHits == 0 &&
r.mStage < 3) {
357 float y =
y0 + hh.
x * stepY + tParam.GetY() - yUncorrected;
358 float z = z0 + hh.
y * stepZ + tParam.GetZ() - zUncorrected;
360 CADEBUG(printf(
"%14s: SEA Hit %5d (%8.3f %8.3f), Res %f %f\n",
"", best,
y,
z, tParam.Y() -
y, tParam.Z() -
z));
371 CADEBUG(printf(
"%5s hits %3d: SEA FILT ROW %3d X %8.3f -",
"",
r.mNHits, iRow, tParam.X());
for (int32_t
i = 0;
i < 5;
i++) { printf(
" %8.3f", tParam.Par()[
i]); } printf(
" -");
for (int32_t
i = 0;
i < 15;
i++) { printf(
" %8.3f", tParam.Cov()[
i]); } printf(
"\n"));
379 if (!found && tracker.GetConstantMem()->calibObjects.dEdxCalibContainer) {
380 uint32_t pad = CAMath::Float2UIntRn(tracker.Param().tpcGeometry.LinearY2Pad(tracker.ISector(), iRow, yUncorrected));
381 if (pad < tracker.Param().tpcGeometry.NPads(iRow) && tracker.GetConstantMem()->calibObjects.dEdxCalibContainer->isDead(tracker.ISector(), iRow, pad)) {
395 const float z1 = row1.Grid().ZMin() + hh1.
y * row1.HstepZ();
396 const float z2 = row2.Grid().ZMin() + hh2.
y * row2.HstepZ();
397 float oldOffset = tParam.ZOffset();
398 tParam.ShiftZ(z1, z2, tracker.Param().tpcGeometry.Row2X(
r.mFirstRow), tracker.Param().tpcGeometry.Row2X(
r.mLastRow), tracker.Param().bzCLight, tracker.Param().rec.tpc.defaultZOffsetOverR);
399 r.mLastZ -= tParam.ZOffset() - oldOffset;
400 CADEBUG(printf(
"Shifted z from %f to %f\n", oldOffset, tParam.ZOffset()));
412 r.mStartRow =
r.mEndRow =
r.mFirstRow =
r.mLastRow =
id.RowIndex();
413 r.mCurrIH =
id.HitIndex();
416 GPUTPCTrackletConstructor::InitTracklet(tParam);
420 CADEBUG(printf(
"Start tracklet\n"));
423 for (int32_t iStage = -1; ++iStage < 2; ) {
425 for (int32_t iStage = 0; iStage < 2; iStage++) {
427 for (; iRow != iRowEnd; iRow +=
r.mStage == 2 ? -1 : 1) {
431 UpdateTracklet(0, 0, 0, 0, s,
r, tracker, tParam, iRow, rowHits[iRow], rowHits);
433 if (!
r.mGo &&
r.mStage == 2) {
434 for (; iRow >=
r.mStartRow; iRow--) {
439 StoreTracklet(0, 0, 0, 0, s,
r, tracker, tParam, rowHits);
445 float x = tracker.Row(
r.mEndRow).X();
448 if (tParam.GetPropagatedYZ(tracker.Param().bzCLight,
x, tmpY, tmpZ)) {
449 if (tracker.ISector() <
GPUCA_NSECTORS / 2 ? (tmpZ < 0) : (tmpZ > 0)) {
451 }
else if (tracker.ISector() <
GPUCA_NSECTORS / 2 ? (tmpZ > GPUTPCGeometry::TPCLength()) : (tmpZ < -GPUTPCGeometry::TPCLength())) {
452 tmpZ = tracker.ISector() <
GPUCA_NSECTORS / 2 ? GPUTPCGeometry::TPCLength() : -GPUTPCGeometry::TPCLength();
454 tracker.GetConstantMem()->calibObjects.fastTransformHelper->InverseTransformYZtoX(tracker.ISector(), iRow, tmpY, tmpZ,
x);
461 CADEBUG(printf(
"%14s: SEA BACK ROW %3d X %8.3f -",
"", iRow, tParam.X());
for (int32_t
i = 0;
i < 5;
i++) { printf(
" %8.3f", tParam.Par()[
i]); } printf(
" -");
for (int32_t
i = 0;
i < 15;
i++) { printf(
" %8.3f", tParam.Cov()[
i]); } printf(
"\n"));
463 tracker.GetErrors2Seeding(
r.mEndRow, tParam, -1.f, err2Y, err2Z);
464 if (tParam.GetCov(0) < err2Y) {
465 tParam.SetCov(0, err2Y);
467 if (tParam.GetCov(2) < err2Z) {
468 tParam.SetCov(2, err2Z);
470 CADEBUG(printf(
"%14s: SEA ADJUS ROW %3d X %8.3f -",
"", iRow, tParam.X());
for (int32_t
i = 0;
i < 5;
i++) { printf(
" %8.3f", tParam.Par()[
i]); } printf(
" -");
for (int32_t
i = 0;
i < 15;
i++) { printf(
" %8.3f", tParam.Cov()[
i]); } printf(
"\n"));
471 r.mNHits -=
r.mNHitsEndRow;
475 CADEBUG(printf(
"End tracklet\n"));