@@ -221,6 +221,12 @@ void Digitizer::stepping(const o2::itsmft::Hit& hit, float**& respMatrix, float*
221221 }
222222 LOG (debug) << " Hit end position in sensor frame after adjustment: (" << xyzPositionEnd.X () << " , " << xyzPositionEnd.Y () << " , " << xyzPositionEnd.Z () << " )" ;
223223
224+ LOG (debug) << " Starting stepping through the hit with " << nSteps << " steps" ;
225+ if (nSkip) {
226+ nSteps -= nSkip;
227+ }
228+ LOG (debug) << " Adjusted number of steps after skipping: " << nSteps;
229+
224230 std::set<int > crossedRows, crossedCols;
225231 for (int iStep = nSteps; iStep--;) {
226232 auto pixelCurrentPosLocal = xyzPositionStart + stepVector * iStep;
@@ -276,21 +282,17 @@ void Digitizer::stepping(const o2::itsmft::Hit& hit, float**& respMatrix, float*
276282 if (!respMatrix || !avgHitLocalX || !avgHitLocalZ) {
277283 return ;
278284 }
279- LOG (debug) << " Starting stepping through the hit with " << nSteps << " steps" ;
280- if (nSkip) {
281- nSteps -= nSkip;
282- }
283- LOG (debug) << " Adjusted number of steps after skipping: " << nSteps;
284285
285- int rowPrev = -1 , colPrev = -1 , row = 0 , col = 0 ;
286- auto pixelCurrentPosLocal = xyzPositionStart;
286+ int rowPrev = -1 , colPrev = -1 , row = 0 , col = 0 , nSkipPassive = 0 ;
287287 auto pixelStartPosLocal = xyzPositionStart;
288- for (int iStep = nSteps; iStep--;) {
288+ auto pixelCurrentPosLocal = xyzPositionStart;
289+ for (int iStep{0 }; iStep < nSteps; ++iStep) {
290+ pixelCurrentPosLocal = xyzPositionStart + iStep * stepVector;
289291
290292 // Step does not contribute if it is in the passive area
291293 if (!sSegmentation ->localToDetector (pixelCurrentPosLocal.X (), pixelCurrentPosLocal.Z (), row, col, subdetectorID)) {
292294 LOG (debug) << " Step is in passive area: (" << pixelCurrentPosLocal.X () << " , " << pixelCurrentPosLocal.Z () << " ) is outside the active area of chip " << subdetectorID;
293- pixelCurrentPosLocal += stepVector ;
295+ nSkipPassive++ ;
294296 continue ;
295297 }
296298
@@ -303,18 +305,18 @@ void Digitizer::stepping(const o2::itsmft::Hit& hit, float**& respMatrix, float*
303305 if (rowPrev != -1 && colPrev != -1 ) {
304306 const int irow = rowPrev - rowStart;
305307 const int icol = colPrev - colStart;
306- avgHitLocalX[irow][icol] = 0 .5f * (pixelStartPosLocal.X () + pixelCurrentPosLocal.X () - stepVector.X ());
307- avgHitLocalZ[irow][icol] = 0 .5f * (pixelStartPosLocal.Z () + pixelCurrentPosLocal.Z () - stepVector.Z ());
308+ avgHitLocalX[irow][icol] = 0 .5f * (pixelStartPosLocal.X () + pixelCurrentPosLocal.X () - (nSkipPassive + 1 ) * stepVector.X ());
309+ avgHitLocalZ[irow][icol] = 0 .5f * (pixelStartPosLocal.Z () + pixelCurrentPosLocal.Z () - (nSkipPassive + 1 ) * stepVector.Z ());
310+ LOG (debug) << " avgHitLocalX = " << avgHitLocalX[irow][icol] << " , avgHitLocalZ = " << avgHitLocalZ[irow][icol];
311+ pixelStartPosLocal = pixelCurrentPosLocal;
312+ nSkipPassive = 0 ;
308313 }
309314
310315 // Start the new pixel
311316 rowPrev = row;
312317 colPrev = col;
313- pixelStartPosLocal = pixelCurrentPosLocal;
314318 }
315319
316- pixelCurrentPosLocal += stepVector; // Move to the next step position
317-
318320 for (int irow = digitizerParams.responseMatrixSize ; irow--;) {
319321 int rowDest = row + irow - (digitizerParams.responseMatrixSize / 2 ) - rowStart; // destination row in the respMatrix
320322 if (rowDest < 0 || rowDest >= rowSpan) {
@@ -340,8 +342,8 @@ void Digitizer::stepping(const o2::itsmft::Hit& hit, float**& respMatrix, float*
340342 LOG (debug) << " avgHitLocalX dimensions: " << rowSpan << " x " << colSpan;
341343 LOG (debug) << " avgHitLocalZ dimensions: " << rowSpan << " x " << colSpan;
342344 LOG (debug) << " Finalizing last pixel at (row,col) = (" << rowPrev << " , " << colPrev << " ) with indices (irow,icol) = (" << irow << " , " << icol << " )" ;
343- avgHitLocalX[irow][icol] = 0 .5f * (pixelStartPosLocal.X () + pixelCurrentPosLocal.X () - stepVector.X ());
344- avgHitLocalZ[irow][icol] = 0 .5f * (pixelStartPosLocal.Z () + pixelCurrentPosLocal.Z () - stepVector.Z ());
345+ avgHitLocalX[irow][icol] = 0 .5f * (pixelStartPosLocal.X () + pixelCurrentPosLocal.X () - nSkipPassive * stepVector.X ());
346+ avgHitLocalZ[irow][icol] = 0 .5f * (pixelStartPosLocal.Z () + pixelCurrentPosLocal.Z () - nSkipPassive * stepVector.Z ());
345347 LOG (debug) << " Finalized last pixel average positions: avgHitLocalX = " << avgHitLocalX[irow][icol] << " , avgHitLocalZ = " << avgHitLocalZ[irow][icol];
346348 }
347349 LOG (debug) << " Finalized last pixel for detector ID: " << chipID;
0 commit comments