Skip to content

Commit c226ccb

Browse files
authored
Use fastAtan2 with protection against radial tracks (#15642)
1 parent 0de4119 commit c226ccb

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

Detectors/Base/include/DetectorsBase/MatLayerCyl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class MatLayerCyl : public o2::gpu::FlatObject
107107
GPUd() int getZBinID(float z) const
108108
{
109109
int idz = int((z - getZMin()) * getDZInv()); // cannot be negative since before isZOutside is applied
110-
return idz < getNZBins() ? idz : getNZBins() - 1;
110+
return idz < getNZBins() ? (idz > 0 ? idz : 0) : getNZBins() - 1;
111111
}
112112

113113
// lower boundary of Z slice

Detectors/Base/include/DetectorsBase/Ray.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Ray
7979

8080
GPUd() float getPhi(float t) const
8181
{
82-
float p = o2::gpu::CAMath::ATan2(mP[1] + t * mD[1], mP[0] + t * mD[0]);
82+
float p = o2::math_utils::fastATan2(mP[1] + t * mD[1], mP[0] + t * mD[0]); // instead of float p = o2::gpu::CAMath::ATan2(mP[1] + t * mD[1], mP[0] + t * mD[0]);
8383
o2::math_utils::bringTo02Pi(p);
8484
return p;
8585
}

Detectors/Base/src/MatLayerCylSet.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,12 @@ GPUd() MatBudget MatLayerCylSet::getMatBudget(float x0, float y0, float z0, floa
348348
if (tEndPhi == Ray::InvalidT) {
349349
break; // ray parallel to radial line, abandon check for phi bin change
350350
}
351+
const auto tMarginPhi = 1.e-6f + 1.e-5f * (cross1 - cross2);
352+
// if (!(tEndPhi >= cross2 - tMarginPhi) | !(tEndPhi <= cross1 + tMarginPhi)) { // use non-short-circuit | to reject eventual NANs
353+
if (tEndPhi < cross2 - tMarginPhi || tEndPhi > cross1 + tMarginPhi) {
354+
tEndPhi = cross2;
355+
checkMorePhi = false;
356+
}
351357
}
352358
auto zID = lr.getZBinID(ray.getZ(tStartPhi));
353359
auto zIDLast = lr.getZBinID(ray.getZ(tEndPhi));

0 commit comments

Comments
 (0)