|
10 | 10 | // or submit itself to any jurisdiction. |
11 | 11 |
|
12 | 12 | #include "GlobalTracking/MatchGlobalFwd.h" |
| 13 | +#include "MathUtils/Utils.h" |
13 | 14 | #include <queue> |
14 | 15 |
|
15 | 16 | using namespace o2::globaltracking; |
@@ -889,6 +890,17 @@ o2::mch::TrackParam MatchGlobalFwd::FwdtoMCH(const o2::dataformats::GlobalFwdTra |
889 | 890 | return o2::mch::TrackParam(convertedTrack); |
890 | 891 | } |
891 | 892 |
|
| 893 | +/// Constrains angle to be within the [-pi, pi] range. |
| 894 | +/// \note Inspired by TVector2::Phi_mpi_pi in ROOT. |
| 895 | +/// \param angle angle |
| 896 | +/// \return value of angle within [-pi, pi]. |
| 897 | +static double constrainAngle(double angle) |
| 898 | +{ |
| 899 | + while (angle >= o2::constants::math::PI) angle -= o2::constants::math::TwoPI; |
| 900 | + while (angle < -o2::constants::math::PI) angle += o2::constants::math::TwoPI; |
| 901 | + return angle; |
| 902 | +} |
| 903 | + |
892 | 904 | //_________________________________________________________________________________________________ |
893 | 905 | MatchGlobalFwd::MatchGlobalFwd() |
894 | 906 | { |
@@ -926,6 +938,9 @@ MatchGlobalFwd::MatchGlobalFwd() |
926 | 938 | // Update Parameters |
927 | 939 | r_k_kminus1 = m_k - H_k * GlobalMuonTrackParameters; // Residuals of prediction |
928 | 940 |
|
| 941 | + // Restrict the phi residual to the [-pi, pi] range |
| 942 | + o2::math_utils::bringToPMPiGend(r_k_kminus1[2]); |
| 943 | + |
929 | 944 | auto matchChi2Track = ROOT::Math::Similarity(r_k_kminus1, invResCov); |
930 | 945 |
|
931 | 946 | return matchChi2Track; |
@@ -963,6 +978,9 @@ MatchGlobalFwd::MatchGlobalFwd() |
963 | 978 | // Residuals of prediction |
964 | 979 | r_k_kminus1 = m_k - H_k * GlobalMuonTrackParameters; |
965 | 980 |
|
| 981 | + // Restrict the phi residual to the [-pi, pi] range |
| 982 | + o2::math_utils::bringToPMPiGend(r_k_kminus1[2]); |
| 983 | + |
966 | 984 | auto matchChi2Track = ROOT::Math::Similarity(r_k_kminus1, invResCov); |
967 | 985 |
|
968 | 986 | return matchChi2Track; }; |
|
0 commit comments