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;
129 r.mCurrIH = tracker.HitLinkUpData(
row)[
r.mCurrIH];
132 float y =
y0 + hh.
x * stepY;
133 float z = z0 + hh.
y * stepZ;
134 if (iRow !=
r.mStartRow) {
135 if (tracker.Param().par.continuousTracking) {
136 tParam.ConstrainZ(
z, tracker.ISector(), z0,
r.mLastZ);
138 tracker.GetConstantMem()->calibObjects.fastTransformHelper->TransformXYZ(tracker.ISector(), iRow,
x,
y,
z);
140 if (iRow ==
r.mStartRow) {
141 if (tracker.Param().par.continuousTracking) {
142 float refZ = ((
z > 0) ? tracker.Param().rec.tpc.defaultZOffsetOverR : -tracker.Param().rec.tpc.defaultZOffsetOverR) *
x;
144 tracker.GetConstantMem()->calibObjects.fastTransformHelper->TransformXYZ(tracker.ISector(), iRow,
x,
y, zTmp);
146 tParam.SetZOffset(
z - refZ);
152 tParam.SetZOffset(0.f);
157 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"));
159 float dx =
x - tParam.X();
161 if (
r.mNHits >= 10) {
171 float ri = 1.f / CAMath::Sqrt(dx * dx + dy * dy);
172 if (iRow ==
r.mStartRow + 2) {
173 tParam.SetSinPhi(dy * ri);
174 tParam.SetSignCosPhi(dx);
175 tParam.SetDzDs(dz * ri);
177 tracker.GetErrors2Seeding(iRow, tParam, -1.f, err2Y, err2Z);
178 tParam.SetCov(0, err2Y);
179 tParam.SetCov(2, err2Z);
181 float sinPhi, cosPhi;
183 sinPhi = tParam.SinPhi();
184 cosPhi = CAMath::Sqrt(1 - sinPhi * sinPhi);
189 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"));
190 if (!tParam.TransportToX(
x, sinPhi, cosPhi, tracker.Param().bzCLight,
GPUCA_MAX_SIN_PHI)) {
194 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"));
196 tracker.GetErrors2Seeding(iRow, tParam.GetZ(), sinPhi, tParam.GetDzDs(), -1.f, err2Y, err2Z);
198 if (
r.mNHits >= 10) {
199 const float sErr2 = tracker.Param().GetSystematicClusterErrorIFC2(
x, tParam.GetY(), tParam.GetZ(), tracker.ISector() >= 18);
202 const float kFactor = tracker.Param().rec.tpc.hitPickUpFactor * tracker.Param().rec.tpc.hitPickUpFactor * 3.5f * 3.5f;
203 float sy2 = kFactor * (tParam.Err2Y() + err2Y);
204 float sz2 = kFactor * (tParam.Err2Z() + err2Z);
205 if (sy2 > tracker.Param().rec.tpc.hitSearchArea2) {
206 sy2 = tracker.Param().rec.tpc.hitSearchArea2;
208 if (sz2 > tracker.Param().rec.tpc.hitSearchArea2) {
209 sz2 = tracker.Param().rec.tpc.hitSearchArea2;
213 if (dy * dy > sy2 || dz * dz > sz2) {
214 if (++
r.mNMissed >= tracker.Param().rec.tpc.trackFollowingMaxRowGapSeed) {
226 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"));
229 r.mNHitsEndRow = ++
r.mNHits;
241 r.mLastY = tParam.Y();
242 r.mLastZ = tParam.Z();
249 if (
r.mStage == 2 && iRow >
r.mEndRow) {
252 if (
r.mNMissed > tracker.Param().rec.tpc.trackFollowingMaxRowGap) {
262 if (!tParam.GetPropagatedYZ(tracker.Param().bzCLight,
x, tmpY, tmpZ)) {
267 if (tracker.Param().par.continuousTracking) {
268 tParam.ConstrainZ(tmpZ, tracker.ISector(), z0,
r.mLastZ);
270 tracker.GetConstantMem()->calibObjects.fastTransformHelper->InverseTransformYZtoX(tracker.ISector(), iRow, tmpY, tmpZ,
x);
273 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"));
274 if (!tParam.TransportToX(
x, tParam.SinPhi(), tParam.GetCosPhi(), tracker.Param().bzCLight,
GPUCA_MAX_SIN_PHI_LOW)) {
279 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"));
281 [[maybe_unused]]
bool found =
false;
282 float yUncorrected = tParam.GetY(), zUncorrected = tParam.GetZ();
284 if (
row.NHits() < 1) {
291 tracker.GetConstantMem()->calibObjects.fastTransformHelper->InverseTransformYZtoNominalYZ(tracker.ISector(), iRow, yUncorrected, zUncorrected, yUncorrected, zUncorrected);
293 if (tracker.Param().rec.tpc.rejectEdgeClustersInSeeding && tracker.Param().rejectEdgeClusterByY(yUncorrected, iRow, CAMath::Sqrt(tParam.Err2Y()))) {
300 tracker.GetErrors2Seeding(iRow, *((
GPUTPCTrackParam*)&tParam), -1.f, err2Y, err2Z);
301 if (
r.mNHits >= 10) {
302 const float sErr2 = tracker.Param().GetSystematicClusterErrorIFC2(
x, tParam.GetY(), tParam.GetZ(), tracker.ISector() >= 18);
306 if (CAMath::Abs(yUncorrected) <
x * GPUTPCRow::getTPCMaxY1X()) {
307 const float kFactor = tracker.Param().rec.tpc.hitPickUpFactor * tracker.Param().rec.tpc.hitPickUpFactor * 7.0f * 7.0f;
308 const float maxWindow2 = tracker.Param().rec.tpc.hitSearchArea2;
309 const float sy2 = CAMath::Min(maxWindow2, kFactor * (tParam.Err2Y() + err2Y));
310 const float sz2 = CAMath::Min(maxWindow2, kFactor * (tParam.Err2Z() + err2Z));
313 row.Grid().GetBinArea(yUncorrected, zUncorrected + tParam.ZOffset(), CAMath::Sqrt(sy2), CAMath::Sqrt(sz2), bin, ny, nz);
317 for (int32_t k = -1; ++k <= nz; ) {
319 for (int32_t k = 0; k <= nz; k++) {
321 int32_t nBinsY =
row.Grid().Ny();
322 int32_t mybin = bin + k * nBinsY;
323 uint32_t hitFst = firsthit[mybin];
324 uint32_t hitLst = firsthit[mybin + ny + 1];
326 for (uint32_t ih = hitFst - 1; ++ih < hitLst; ) {
328 for (uint32_t ih = hitFst; ih < hitLst; ih++) {
331 float y =
y0 + hh.
x * stepY;
332 float z = z0 + hh.
y * stepZ;
333 float dy =
y - yUncorrected;
334 float dz =
z - zUncorrected;
335 if (dy * dy < sy2 && dz * dz < sz2) {
336 float dds = tracker.Param().rec.tpc.trackFollowingYFactor * CAMath::Abs(dy) + CAMath::Abs(dz);
347 if (
r.mNHits == 0 &&
r.mStage < 3) {
359 float y =
y0 + hh.
x * stepY + tParam.GetY() - yUncorrected;
360 float z = z0 + hh.
y * stepZ + tParam.GetZ() - zUncorrected;
362 CADEBUG(printf(
"%14s: SEA Hit %5d (%8.3f %8.3f), Res %f %f\n",
"", best,
y,
z, tParam.Y() -
y, tParam.Z() -
z));
373 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"));
380 if (!found && tracker.GetConstantMem()->calibObjects.dEdxCalibContainer) {
381 uint32_t pad = CAMath::Float2UIntRn(GPUTPCGeometry::LinearY2Pad(tracker.ISector(), iRow, yUncorrected));
382 if (pad < GPUTPCGeometry::NPads(iRow) && tracker.GetConstantMem()->calibObjects.dEdxCalibContainer->isDead(tracker.ISector(), iRow, pad)) {
394 const cahit2 hh1 = hits1[rowHits[
r.mFirstRow]];
395 const cahit2 hh2 = hits2[rowHits[
r.mLastRow]];
396 const float z1 = row1.Grid().ZMin() + hh1.
y * row1.HstepZ();
397 const float z2 = row2.Grid().ZMin() + hh2.
y * row2.HstepZ();
398 float oldOffset = tParam.ZOffset();
399 tParam.ShiftZ(z1, z2, GPUTPCGeometry::Row2X(
r.mFirstRow), GPUTPCGeometry::Row2X(
r.mLastRow), tracker.Param().bzCLight, tracker.Param().rec.tpc.defaultZOffsetOverR);
400 r.mLastZ -= tParam.ZOffset() - oldOffset;
401 CADEBUG(printf(
"Shifted z from %f to %f\n", oldOffset, tParam.ZOffset()));
413 r.mStartRow =
r.mEndRow =
r.mFirstRow =
r.mLastRow =
id.RowIndex();
414 r.mCurrIH =
id.HitIndex();
417 GPUTPCTrackletConstructor::InitTracklet(tParam);
421 CADEBUG(printf(
"Start tracklet\n"));
424 for (int32_t iStage = -1; ++iStage < 2; ) {
426 for (int32_t iStage = 0; iStage < 2; iStage++) {
428 for (; iRow != iRowEnd; iRow +=
r.mStage == 2 ? -1 : 1) {
432 UpdateTracklet(0, 0, 0, 0, s,
r, tracker, tParam, iRow, rowHits[iRow], rowHits);
434 if (!
r.mGo &&
r.mStage == 2) {
435 for (; iRow >=
r.mStartRow; iRow--) {
440 StoreTracklet(0, 0, 0, 0, s,
r, tracker, tParam, rowHits);
446 float x = tracker.Row(
r.mEndRow).X();
449 if (tParam.GetPropagatedYZ(tracker.Param().bzCLight,
x, tmpY, tmpZ)) {
450 if (tracker.ISector() <
GPUCA_NSECTORS / 2 ? (tmpZ < 0) : (tmpZ > 0)) {
452 }
else if (tracker.ISector() <
GPUCA_NSECTORS / 2 ? (tmpZ > GPUTPCGeometry::TPCLength()) : (tmpZ < -GPUTPCGeometry::TPCLength())) {
453 tmpZ = tracker.ISector() <
GPUCA_NSECTORS / 2 ? GPUTPCGeometry::TPCLength() : -GPUTPCGeometry::TPCLength();
455 tracker.GetConstantMem()->calibObjects.fastTransformHelper->InverseTransformYZtoX(tracker.ISector(), iRow, tmpY, tmpZ,
x);
462 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"));
464 tracker.GetErrors2Seeding(
r.mEndRow, tParam, -1.f, err2Y, err2Z);
465 if (tParam.GetCov(0) < err2Y) {
466 tParam.SetCov(0, err2Y);
468 if (tParam.GetCov(2) < err2Z) {
469 tParam.SetCov(2, err2Z);
471 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"));
472 r.mNHits -=
r.mNHitsEndRow;
476 CADEBUG(printf(
"End tracklet\n"));