@@ -62,12 +62,11 @@ GPUd() bool GPUTPCGMTrackParam::Fit(GPUTPCGMMerger& GPUrestrict() merger, int32_
6262 prop.SetPolynomialField (¶m.polynomialField );
6363 prop.SetMaxSinPhi (maxSinPhi);
6464 if (param.rec .tpc .mergerInterpolateErrors && !rebuilt) {
65- for (uint32_t i = 0 ; i < interpolation.size ; i++) { // TODO: Tune the zeroing size
66- interpolation.hit [i].errorY = - 1 ;
65+ for (uint32_t i = 0 ; i < interpolation.size ; i++) { // TODO: Tune the zeroing range
66+ interpolation.hit [i].markInvalid () ;
6767 }
6868 if (param.rec .tpc .rebuildTrackInFit ) {
69- merger.TrackRebuildHelper ()[iTrk].highInclRowLow = 255 ;
70- merger.TrackRebuildHelper ()[iTrk].highInclRowHigh = 255 ;
69+ merger.TrackRebuildHelper ()[iTrk].highInclRowLow = merger.TrackRebuildHelper ()[iTrk].highInclRowHigh = 255 ;
7170 }
7271 }
7372
@@ -135,22 +134,24 @@ GPUd() bool GPUTPCGMTrackParam::Fit(GPUTPCGMMerger& GPUrestrict() merger, int32_
135134 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));
136135
137136 uint8_t dEdxSubThresholdRow = 255 ;
138- bool doInterpolate = param.rec .tpc .rebuildTrackInFit && (iWay == nWays - 3 || iWay == nWays - 2 );
139137 if (lastPropagateRow != 255 && CAMath::Abs (cluster.row - lastPropagateRow) > 1 ) {
140- bool dodEdx = param.dodEdxEnabled && param.rec .tpc .adddEdxSubThresholdClusters && finalFit && CAMath::Abs (cluster.row - lastUpdateRow) == 2 && cluster.sector == lastSector && currentClusterStatus == 0 ;
141- bool doAttach = allowChangeClusters && !param.rec .tpc .rebuildTrackInFit && !(merger.Param ().rec .tpc .disableRefitAttachment & 2 );
142- if (dodEdx || doAttach || doInterpolate) {
138+ const bool dodEdx = param.dodEdxEnabled && param.rec .tpc .adddEdxSubThresholdClusters && finalFit && CAMath::Abs (cluster.row - lastUpdateRow) == 2 && cluster.sector == lastSector && currentClusterStatus == 0 ;
139+ const bool doAttach = allowChangeClusters && !param.rec .tpc .rebuildTrackInFit && !(merger.Param ().rec .tpc .disableRefitAttachment & 2 );
140+ const uint8_t doInterpolate = (param.rec .tpc .rebuildTrackInFit && iWay == nWays - 3 ) ? 1 : ((param.rec .tpc .rebuildTrackInFit && iWay == nWays - 2 ) ? 2 : 0 );
141+ if (lastUpdateRow != 255 && (dodEdx || doAttach || doInterpolate)) {
143142 int32_t step = cluster.row > lastPropagateRow ? 1 : -1 ;
144- for (int32_t iRow = lastPropagateRow + step; iRow != cluster.row ; iRow += step) {
143+ uint8_t sector = lastSector;
144+
145+ for (int32_t iRow = lastPropagateRow + step, index = interpolationIndex; iRow != cluster.row ; iRow += step, index += wayDirection) {
145146 float tmpX, tmpY, tmpZ;
146- if (prop.GetPropagatedYZ (mX - GPUTPCGeometry::Row2X (iRow - step) + GPUTPCGeometry::Row2X (iRow), tmpY, tmpZ)) {
147+ if (prop.GetPropagatedYZ (GPUTPCGeometry::Row2X (iRow), tmpY, tmpZ)) {
147148 break ;
148149 }
149- merger.GetConstantMem ()->calibObjects .fastTransformHelper ->InverseTransformYZtoX (cluster. sector , iRow, tmpY, tmpZ, tmpX);
150+ merger.GetConstantMem ()->calibObjects .fastTransformHelper ->InverseTransformYZtoX (sector, iRow, tmpY, tmpZ, tmpX);
150151 if (prop.PropagateToXAlpha (tmpX, prop.GetAlpha (), inFlyDirection)) {
151152 break ;
152153 }
153- FitAddRow (iRow, cluster. sector , iTrk, track, prop, inFlyDirection, merger, &dEdxSubThresholdRow, dodEdx, doAttach, doInterpolate);
154+ FitAddRow (iRow, sector, iTrk, track, prop, inFlyDirection, merger, &dEdxSubThresholdRow, dodEdx, doAttach, doInterpolate, interpolation. hit [index], deltaZ, sumInvSqrtCharge, nAvgCharge );
154155 }
155156 }
156157 interpolationIndex += (CAMath::Abs (cluster.row - lastPropagateRow) - 1 ) * wayDirection;
@@ -234,6 +235,7 @@ GPUd() bool GPUTPCGMTrackParam::Fit(GPUTPCGMMerger& GPUrestrict() merger, int32_
234235 merger.TrackRebuildHelper ()[iTrk].highInclRowHigh = cluster.row ;
235236 }
236237 }
238+ // TODO: We can perhaps break here, if we pick up remaining rows
237239 }
238240 continue ;
239241 }
@@ -299,7 +301,7 @@ GPUd() bool GPUTPCGMTrackParam::Fit(GPUTPCGMMerger& GPUrestrict() merger, int32_
299301 return true ;
300302}
301303
302- 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)
304+ 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 )
303305{
304306 if (CAMath::Abs (mP [2 ]) > GPUCA_MAX_SIN_PHI || CAMath::Abs (mP [0 ]) > CAMath::Abs (mX ) * CAMath::Tan (GPUTPCGeometry::kSectAngle () / 2 .f )) {
305307 return ;
@@ -318,6 +320,16 @@ GPUdii() void GPUTPCGMTrackParam::FitAddRow(const int32_t iRow, const uint8_t se
318320 if (doAttach) {
319321 AttachClusters (merger, sector, iRow, iTrk, track.Leg () == 0 , prop);
320322 }
323+ if (doInterpolate) {
324+ if (doInterpolate == 2 ) {
325+ if (inter.isValid () && CAMath::Abs (inter.posY - mP [0 ]) < 4 .f ) {
326+ inter.markInvalid ();
327+ }
328+ FindBestInterpolatedHit (merger, inter, sector, iRow, deltaZ, sumInvSqrtCharge, nAvgCharge, prop, iTrk, false );
329+ } else {
330+ prop.InterpolateFill (&inter);
331+ }
332+ }
321333}
322334
323335GPUdii () void GPUTPCGMTrackParam::HandleCrossCE(const GPUParam& GPUrestrict () param, const uint8_t sector, const uint8_t& lastSector)
@@ -364,10 +376,10 @@ GPUdii() int32_t GPUTPCGMTrackParam::FitHit(GPUTPCGMMerger& GPUrestrict() merger
364376 if (param.rec .tpc .mergerInterpolateErrors ) {
365377 if (iWay == nWays - 2 ) {
366378 if (!param.rec .tpc .rebuildTrackInFit ) {
367- if (inter.errorY < (GPUCA_PAR_MERGER_INTERPOLATION_ERROR_TYPE_A)0 ) {
368- rejectChi2 = true ;
369- } else {
379+ if (inter.isValid ()) {
370380 retValInt = prop.InterpolateReject (param, yy, zz, clusterState, &inter, err2Y, err2Z, deltaZ);
381+ } else {
382+ rejectChi2 = true ;
371383 }
372384 }
373385 } else if (iWay == nWays - 1 ) {
@@ -430,7 +442,7 @@ GPUdii() float GPUTPCGMTrackParam::FindBestInterpolatedHit(GPUTPCGMMerger& GPUre
430442 GPUglobalref () const cahit2* hits = tracker.HitData (rowData);
431443 GPUglobalref () const calink* firsthit = tracker.FirstHitInBin (rowData);
432444 float uncorrectedY = -1e6f, uncorrectedZ;
433- 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 ))) {
445+ if (rowData.NHits () && (inter.isValid () || (!interOnly && param.rec .tpc .rebuildTrackMaxNonIntCov > 0 && mC [0 ] < param.rec .tpc .rebuildTrackMaxNonIntCov && mC [2 ] < param.rec .tpc .rebuildTrackMaxNonIntCov ))) {
434446 const float zOffset = param.par .continuousTracking ? merger.GetConstantMem ()->calibObjects .fastTransformHelper ->getCorrMap ()->convVertexTimeToZOffset (sector, mTOffset , param.continuousMaxTimeBin ) : 0 ;
435447 const float y0 = rowData.Grid ().YMin ();
436448 const float stepY = rowData.HstepY ();
@@ -444,7 +456,7 @@ GPUdii() float GPUTPCGMTrackParam::FindBestInterpolatedHit(GPUTPCGMMerger& GPUre
444456 ImP1 = (float )inter.posZ + deltaZ;
445457 ImC0 = (float )inter.errorY ;
446458 ImC2 = (float )inter.errorZ ;
447- } else if (inter.errorY >= (GPUCA_PAR_MERGER_INTERPOLATION_ERROR_TYPE_A) 0 ) {
459+ } else if (inter.isValid () ) {
448460 const float Iz0 = (float )inter.posY - mP [0 ];
449461 const float Iz1 = (float )inter.posZ + deltaZ - mP [1 ];
450462 const float Iw0 = 1 .f / (mC [0 ] + (float )inter.errorY );
@@ -521,7 +533,7 @@ GPUdii() float GPUTPCGMTrackParam::FindBestInterpolatedHit(GPUTPCGMMerger& GPUre
521533 if (insert < param.rec .tpc .rebuildTrackInFitClusterCandidates ) {
522534 for (int32_t c = CAMath::Min (nCandidates, param.rec .tpc .rebuildTrackInFitClusterCandidates - 1 ); c > insert; c--) {
523535 merger.ClusterCandidates ()[(iTrk * GPUCA_ROW_COUNT + row) * param.rec .tpc .rebuildTrackInFitClusterCandidates + c] = merger.ClusterCandidates ()[(iTrk * GPUCA_ROW_COUNT + row) * param.rec .tpc .rebuildTrackInFitClusterCandidates + c - 1 ];
524- }
536+ } // TODO: Downweight non-interpolated candidates
525537 merger.ClusterCandidates ()[(iTrk * GPUCA_ROW_COUNT + row) * param.rec .tpc .rebuildTrackInFitClusterCandidates + insert] = {.id = (uint32_t )(idOffset + ids[ih] + 2 ), .row = row, .sector = sector, .error = err, .weight = 0 , .best = 0 };
526538 nCandidates += (nCandidates < param.rec .tpc .rebuildTrackInFitClusterCandidates );
527539 }
0 commit comments