@@ -61,12 +61,11 @@ GPUd() bool GPUTPCGMTrackParam::Fit(GPUTPCGMMerger& GPUrestrict() merger, int32_
6161 prop.SetPolynomialField (¶m.polynomialField );
6262 prop.SetMaxSinPhi (maxSinPhi);
6363 if (param.rec .tpc .mergerInterpolateErrors && !rebuilt) {
64- for (uint32_t i = 0 ; i < interpolation.size ; i++) { // TODO: Tune the zeroing size
65- interpolation.hit [i].errorY = - 1 ;
64+ for (uint32_t i = 0 ; i < interpolation.size ; i++) { // TODO: Tune the zeroing range
65+ interpolation.hit [i].markInvalid () ;
6666 }
6767 if (param.rec .tpc .rebuildTrackInFit ) {
68- merger.TrackRebuildHelper ()[iTrk].highInclRowLow = 255 ;
69- merger.TrackRebuildHelper ()[iTrk].highInclRowHigh = 255 ;
68+ merger.TrackRebuildHelper ()[iTrk].highInclRowLow = merger.TrackRebuildHelper ()[iTrk].highInclRowHigh = 255 ;
7069 }
7170 }
7271
@@ -134,22 +133,24 @@ GPUd() bool GPUTPCGMTrackParam::Fit(GPUTPCGMMerger& GPUrestrict() merger, int32_
134133 CADEBUG (printf (" \t Hit %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));
135134
136135 uint8_t dEdxSubThresholdRow = 255 ;
137- bool doInterpolate = param.rec .tpc .rebuildTrackInFit && (iWay == nWays - 3 || iWay == nWays - 2 );
138136 if (lastPropagateRow != 255 && CAMath::Abs (cluster.row - lastPropagateRow) > 1 ) {
139- bool dodEdx = param.dodEdxEnabled && param.rec .tpc .adddEdxSubThresholdClusters && finalFit && CAMath::Abs (cluster.row - lastUpdateRow) == 2 && cluster.sector == lastSector && currentClusterStatus == 0 ;
140- bool doAttach = allowChangeClusters && !param.rec .tpc .rebuildTrackInFit && !(merger.Param ().rec .tpc .disableRefitAttachment & 2 );
141- if (dodEdx || doAttach || doInterpolate) {
137+ const bool dodEdx = param.dodEdxEnabled && param.rec .tpc .adddEdxSubThresholdClusters && finalFit && CAMath::Abs (cluster.row - lastUpdateRow) == 2 && cluster.sector == lastSector && currentClusterStatus == 0 ;
138+ const bool doAttach = allowChangeClusters && !param.rec .tpc .rebuildTrackInFit && !(merger.Param ().rec .tpc .disableRefitAttachment & 2 );
139+ const uint8_t doInterpolate = (param.rec .tpc .rebuildTrackInFit && iWay == nWays - 3 ) ? 1 : ((param.rec .tpc .rebuildTrackInFit && iWay == nWays - 2 ) ? 2 : 0 );
140+ if (lastUpdateRow != 255 && (dodEdx || doAttach || doInterpolate)) {
142141 int32_t step = cluster.row > lastPropagateRow ? 1 : -1 ;
143- for (int32_t iRow = lastPropagateRow + step; iRow != cluster.row ; iRow += step) {
142+ uint8_t sector = lastSector;
143+
144+ for (int32_t iRow = lastPropagateRow + step, index = interpolationIndex; iRow != cluster.row ; iRow += step, index += wayDirection) {
144145 float tmpX, tmpY, tmpZ;
145- if (prop.GetPropagatedYZ (mX - GPUTPCGeometry::Row2X (iRow - step) + GPUTPCGeometry::Row2X (iRow), tmpY, tmpZ)) {
146+ if (prop.GetPropagatedYZ (GPUTPCGeometry::Row2X (iRow), tmpY, tmpZ)) {
146147 break ;
147148 }
148- merger.GetConstantMem ()->calibObjects .fastTransform ->InverseTransformYZtoX (cluster. sector , iRow, tmpY, tmpZ, tmpX);
149+ merger.GetConstantMem ()->calibObjects .fastTransform ->InverseTransformYZtoX (sector, iRow, tmpY, tmpZ, tmpX);
149150 if (prop.PropagateToXAlpha (tmpX, prop.GetAlpha (), inFlyDirection)) {
150151 break ;
151152 }
152- FitAddRow (iRow, cluster. sector , iTrk, track, prop, inFlyDirection, merger, &dEdxSubThresholdRow, dodEdx, doAttach, doInterpolate);
153+ FitAddRow (iRow, sector, iTrk, track, prop, inFlyDirection, merger, &dEdxSubThresholdRow, dodEdx, doAttach, doInterpolate, interpolation. hit [index], deltaZ, sumInvSqrtCharge, nAvgCharge );
153154 }
154155 }
155156 interpolationIndex += (CAMath::Abs (cluster.row - lastPropagateRow) - 1 ) * wayDirection;
@@ -233,6 +234,7 @@ GPUd() bool GPUTPCGMTrackParam::Fit(GPUTPCGMMerger& GPUrestrict() merger, int32_
233234 merger.TrackRebuildHelper ()[iTrk].highInclRowHigh = cluster.row ;
234235 }
235236 }
237+ // TODO: We can perhaps break here, if we pick up remaining rows
236238 }
237239 continue ;
238240 }
@@ -298,7 +300,7 @@ GPUd() bool GPUTPCGMTrackParam::Fit(GPUTPCGMMerger& GPUrestrict() merger, int32_
298300 return true ;
299301}
300302
301- GPUdii () void GPUTPCGMTrackParam::FitAddRow(const int32_t iRow, const uint8_t sector, const int32_t iTrk, const GPUTPCGMMergedTrack& GPUrestrict () track, GPUTPCGMPropagator& GPUrestrict() prop, const bool inFlyDirection, GPUTPCGMMerger& GPUrestrict() merger, uint8_t* GPUrestrict() dEdxSubThresholdRow, const bool dodEdx, const bool doAttach, const bool doInterpolate)
303+ GPUdii () void GPUTPCGMTrackParam::FitAddRow(const int32_t iRow, const uint8_t sector, const int32_t iTrk, const GPUTPCGMMergedTrack& GPUrestrict () track, GPUTPCGMPropagator& GPUrestrict() prop, const bool inFlyDirection, GPUTPCGMMerger& GPUrestrict() merger, uint8_t* GPUrestrict() dEdxSubThresholdRow, const bool dodEdx, const bool doAttach, const uint8_t doInterpolate, gputpcgmmergertypes::InterpolationErrorHit& GPUrestrict() inter, const float deltaZ, const float sumInvSqrtCharge, const int32_t nAvgCharge )
302304{
303305 if (CAMath::Abs (mP [2 ]) > constants::MAX_SIN_PHI || CAMath::Abs (mP [0 ]) > CAMath::Abs (mX ) * CAMath::Tan (GPUTPCGeometry::kSectAngle () / 2 .f )) {
304306 return ;
@@ -317,6 +319,16 @@ GPUdii() void GPUTPCGMTrackParam::FitAddRow(const int32_t iRow, const uint8_t se
317319 if (doAttach) {
318320 AttachClusters (merger, sector, iRow, iTrk, track.Leg () == 0 , prop);
319321 }
322+ if (doInterpolate) {
323+ if (doInterpolate == 2 ) {
324+ if (inter.isValid () && CAMath::Abs (inter.posY - mP [0 ]) < 4 .f ) {
325+ inter.markInvalid ();
326+ }
327+ FindBestInterpolatedHit (merger, inter, sector, iRow, deltaZ, sumInvSqrtCharge, nAvgCharge, prop, iTrk, false );
328+ } else {
329+ prop.InterpolateFill (&inter);
330+ }
331+ }
320332}
321333
322334GPUdii () void GPUTPCGMTrackParam::HandleCrossCE(const GPUParam& GPUrestrict () param, const uint8_t sector, const uint8_t& lastSector)
@@ -363,10 +375,10 @@ GPUdii() int32_t GPUTPCGMTrackParam::FitHit(GPUTPCGMMerger& GPUrestrict() merger
363375 if (param.rec .tpc .mergerInterpolateErrors ) {
364376 if (iWay == nWays - 2 ) {
365377 if (!param.rec .tpc .rebuildTrackInFit ) {
366- if (inter.errorY < (GPUCA_PAR_MERGER_INTERPOLATION_ERROR_TYPE_A)0 ) {
367- rejectChi2 = true ;
368- } else {
378+ if (inter.isValid ()) {
369379 retValInt = prop.InterpolateReject (param, yy, zz, clusterState, &inter, err2Y, err2Z, deltaZ);
380+ } else {
381+ rejectChi2 = true ;
370382 }
371383 }
372384 } else if (iWay == nWays - 1 ) {
@@ -429,7 +441,7 @@ GPUdii() float GPUTPCGMTrackParam::FindBestInterpolatedHit(GPUTPCGMMerger& GPUre
429441 GPUglobalref () const cahit2* hits = tracker.HitData (rowData);
430442 GPUglobalref () const calink* firsthit = tracker.FirstHitInBin (rowData);
431443 float uncorrectedY = -1e6f, uncorrectedZ;
432- if (rowData.NHits () && (inter.errorY >= (GPUCA_PAR_MERGER_INTERPOLATION_ERROR_TYPE_A) 0 || (!interOnly && param.rec .tpc .rebuildTrackMaxNonIntCov > 0 && mC [0 ] < param.rec .tpc .rebuildTrackMaxNonIntCov && mC [2 ] < param.rec .tpc .rebuildTrackMaxNonIntCov ))) {
444+ if (rowData.NHits () && (inter.isValid () || (!interOnly && param.rec .tpc .rebuildTrackMaxNonIntCov > 0 && mC [0 ] < param.rec .tpc .rebuildTrackMaxNonIntCov && mC [2 ] < param.rec .tpc .rebuildTrackMaxNonIntCov ))) {
433445 const float zOffset = param.par .continuousTracking ? merger.GetConstantMem ()->calibObjects .fastTransform ->convVertexTimeToZOffset (sector, mTOffset , param.continuousMaxTimeBin ) : 0 ;
434446 const float y0 = rowData.Grid ().YMin ();
435447 const float stepY = rowData.HstepY ();
@@ -443,7 +455,7 @@ GPUdii() float GPUTPCGMTrackParam::FindBestInterpolatedHit(GPUTPCGMMerger& GPUre
443455 ImP1 = (float )inter.posZ + deltaZ;
444456 ImC0 = (float )inter.errorY ;
445457 ImC2 = (float )inter.errorZ ;
446- } else if (inter.errorY >= (GPUCA_PAR_MERGER_INTERPOLATION_ERROR_TYPE_A) 0 ) {
458+ } else if (inter.isValid () ) {
447459 const float Iz0 = (float )inter.posY - mP [0 ];
448460 const float Iz1 = (float )inter.posZ + deltaZ - mP [1 ];
449461 const float Iw0 = 1 .f / (mC [0 ] + (float )inter.errorY );
@@ -520,7 +532,7 @@ GPUdii() float GPUTPCGMTrackParam::FindBestInterpolatedHit(GPUTPCGMMerger& GPUre
520532 if (insert < param.rec .tpc .rebuildTrackInFitClusterCandidates ) {
521533 for (int32_t c = CAMath::Min (nCandidates, param.rec .tpc .rebuildTrackInFitClusterCandidates - 1 ); c > insert; c--) {
522534 merger.ClusterCandidates ()[(iTrk * GPUTPCGeometry::NROWS + row) * param.rec .tpc .rebuildTrackInFitClusterCandidates + c] = merger.ClusterCandidates ()[(iTrk * GPUTPCGeometry::NROWS + row) * param.rec .tpc .rebuildTrackInFitClusterCandidates + c - 1 ];
523- }
535+ } // TODO: Downweight non-interpolated candidates
524536 merger.ClusterCandidates ()[(iTrk * GPUTPCGeometry::NROWS + row) * param.rec .tpc .rebuildTrackInFitClusterCandidates + insert] = {.id = (uint32_t )(idOffset + ids[ih] + 2 ), .row = row, .sector = sector, .error = err, .weight = 0 , .best = 0 };
525537 nCandidates += (nCandidates < param.rec .tpc .rebuildTrackInFitClusterCandidates );
526538 }
0 commit comments