Skip to content

Commit da933b8

Browse files
committed
TrackPar fix: redefine alpha conv. to have track valid
I the constructor with Cartesian params input is used with request to take alpha = track positon angle but angular difference between the track transverse direction and position angles exceeds pi/2, the track model will break down (track cos(phi) becomes negative). In this case the alpha will be redefined to track direction angle to save track validity
1 parent b8974ea commit da933b8

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

DataFormats/Reconstruction/src/TrackParametrization.cxx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ GPUd() TrackParametrization<value_T>::TrackParametrization(const dim3_t& xyz, co
6767
//
6868
value_t sn, cs;
6969
math_utils::detail::sincos(alp, sn, cs);
70+
// protection against cosp<0
71+
if (cs * pxpypz[0] + sn * pxpypz[1] < 0) {
72+
LOG(WARNING) << "alpha from phiPos() will invalidate this track parameters, overriding to alpha from phi()";
73+
alp = gpu::CAMath::ATan2(pxpypz[1], pxpypz[0]);
74+
if (sectorAlpha) {
75+
alp = math_utils::detail::angle2Alpha<value_t>(alp);
76+
}
77+
math_utils::detail::sincos(alp, sn, cs);
78+
}
79+
7080
// protection: avoid alpha being too close to 0 or +-pi/2
7181
if (gpu::CAMath::Abs(sn) < 2 * kSafe) {
7282
if (alp > 0) {

DataFormats/Reconstruction/src/TrackParametrizationWithError.cxx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,15 @@ GPUd() TrackParametrizationWithError<value_T>::TrackParametrizationWithError(con
286286
//
287287
value_t sn, cs;
288288
math_utils::detail::sincos(alp, sn, cs);
289+
// protection against cosp<0
290+
if (cs * pxpypz[0] + sn * pxpypz[1] < 0) {
291+
LOG(WARNING) << "alpha from phiPos() will invalidate this track parameters, overriding to alpha from phi()";
292+
alp = gpu::CAMath::ATan2(pxpypz[1], pxpypz[0]);
293+
if (sectorAlpha) {
294+
alp = math_utils::detail::angle2Alpha<value_t>(alp);
295+
}
296+
math_utils::detail::sincos(alp, sn, cs);
297+
}
289298
// protection: avoid alpha being too close to 0 or +-pi/2
290299
if (gpu::CAMath::Abs(sn) < 2.f * kSafe) {
291300
if (alp > 0) {

0 commit comments

Comments
 (0)