Skip to content

Commit 616bae2

Browse files
committed
Protection for strictly radial tracks in mat.budget query
1 parent 9e581d5 commit 616bae2

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

Detectors/Base/include/DetectorsBase/Ray.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,7 @@ GPUdi() float Ray::crossRadial(float cs, float sn) const
140140
{
141141
// calculate t of crossing with radial line with inclination cosine and sine
142142
float den = mD[0] * sn - mD[1] * cs;
143-
if (o2::gpu::CAMath::Abs(den) < Tiny) {
144-
return InvalidT;
145-
}
146-
return (mP[1] * cs - mP[0] * sn) / den;
143+
return den != 0. ? (mP[1] * cs - mP[0] * sn) / den : InvalidT;
147144
}
148145

149146
//______________________________________________________
@@ -154,8 +151,9 @@ GPUdi() bool Ray::crossCircleR(float r2, float& cross1, float& cross2) const
154151
// t^2*mDistXY2 +- sqrt( mXDxPlusYDy^2 - mDistXY2*(mR02 - r^2) )
155152
//
156153
float det = mXDxPlusYDy2 - mDistXY2 * (mR02 - r2);
157-
if (det < 0)
154+
if (det < 0) {
158155
return false; // no intersection
156+
}
159157
float detRed = o2::gpu::CAMath::Sqrt(det) * mDistXY2i;
160158
cross1 = mXDxPlusYDyRed + detRed; // (-mXDxPlusYDy + det)*mDistXY2i;
161159
cross2 = mXDxPlusYDyRed - detRed; // (-mXDxPlusYDy - det)*mDistXY2i;
@@ -173,7 +171,7 @@ GPUdi() float Ray::crossRadial(const MatLayerCyl& lr, int sliceID) const
173171
GPUdi() float Ray::crossZ(float z) const
174172
{
175173
// calculate t of crossing XY plane at Z
176-
return o2::gpu::CAMath::Abs(mD[2]) > Tiny ? (z - mP[2]) / mD[2] : InvalidT;
174+
return mD[2] != 0. ? (z - mP[2]) / mD[2] : InvalidT;
177175
}
178176

179177
//______________________________________________________

Detectors/Base/src/MatLayerCylSet.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@ GPUd() MatBudget MatLayerCylSet::getMatBudget(float x0, float y0, float z0, floa
277277
checkMorePhi = false;
278278
} else { // last phi slice still not reached
279279
tEndPhi = ray.crossRadial(lr, (stepPhiID > 0 ? phiID + 1 : phiID) % lr.getNPhiSlices());
280+
if (tEndPhi == Ray::InvalidT) {
281+
break; // ray parallel to radial line, abandon check for phi bin change
282+
}
280283
}
281284
auto zID = lr.getZBinID(ray.getZ(tStartPhi));
282285
auto zIDLast = lr.getZBinID(ray.getZ(tEndPhi));
@@ -296,6 +299,9 @@ GPUd() MatBudget MatLayerCylSet::getMatBudget(float x0, float y0, float z0, floa
296299
checkMoreZ = false;
297300
} else {
298301
tEndZ = ray.crossZ(lr.getZBinMin(stepZID > 0 ? zID + 1 : zID));
302+
if (tEndZ == Ray::InvalidT) { // track normal to Z axis, abandon Zbin change test
303+
break;
304+
}
299305
}
300306
// account materials of this step
301307
float step = tEndZ - tStartZ; // the real step is ray.getDist(tEnd-tStart), will rescale all later

0 commit comments

Comments
 (0)