From 5b29fb4c0abcd8e7ae8936217ba57f44eea47c8c Mon Sep 17 00:00:00 2001 From: aferrero2707 Date: Mon, 21 Sep 2026 17:42:46 +0200 Subject: [PATCH 1/2] [MUON] fix computation of delta phi in MFT-MCH matching The value of delta phi between the MFT and MCH tracks at the matching plane is restricted to the [-pi, pi] range, to fix the cases of large angular differences when the MFT and MCH tracks are at the opposite side of the horizontal plane at negative X values. --- .../GlobalTracking/src/MatchGlobalFwd.cxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Detectors/GlobalTracking/src/MatchGlobalFwd.cxx b/Detectors/GlobalTracking/src/MatchGlobalFwd.cxx index 7ed50ce7400ae..7ada3f9c4b8f8 100644 --- a/Detectors/GlobalTracking/src/MatchGlobalFwd.cxx +++ b/Detectors/GlobalTracking/src/MatchGlobalFwd.cxx @@ -10,6 +10,7 @@ // or submit itself to any jurisdiction. #include "GlobalTracking/MatchGlobalFwd.h" +#include "MathUtils/Utils.h" #include using namespace o2::globaltracking; @@ -889,6 +890,17 @@ o2::mch::TrackParam MatchGlobalFwd::FwdtoMCH(const o2::dataformats::GlobalFwdTra return o2::mch::TrackParam(convertedTrack); } +/// Constrains angle to be within the [-pi, pi] range. +/// \note Inspired by TVector2::Phi_mpi_pi in ROOT. +/// \param angle angle +/// \return value of angle within [-pi, pi]. +static double constrainAngle(double angle) +{ + while (angle >= o2::constants::math::PI) angle -= o2::constants::math::TwoPI; + while (angle < -o2::constants::math::PI) angle += o2::constants::math::TwoPI; + return angle; +} + //_________________________________________________________________________________________________ MatchGlobalFwd::MatchGlobalFwd() { @@ -926,6 +938,9 @@ MatchGlobalFwd::MatchGlobalFwd() // Update Parameters r_k_kminus1 = m_k - H_k * GlobalMuonTrackParameters; // Residuals of prediction + // Restrict the phi residual to the [-pi, pi] range + o2::math_utils::bringToPMPiGend(r_k_kminus1[2]); + auto matchChi2Track = ROOT::Math::Similarity(r_k_kminus1, invResCov); return matchChi2Track; @@ -963,6 +978,9 @@ MatchGlobalFwd::MatchGlobalFwd() // Residuals of prediction r_k_kminus1 = m_k - H_k * GlobalMuonTrackParameters; + // Restrict the phi residual to the [-pi, pi] range + o2::math_utils::bringToPMPiGend(r_k_kminus1[2]); + auto matchChi2Track = ROOT::Math::Similarity(r_k_kminus1, invResCov); return matchChi2Track; }; From dc59d55e9bd0ba9376089f7a1b9741319398b1be Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Mon, 21 Sep 2026 15:44:02 +0000 Subject: [PATCH 2/2] Please consider the following formatting changes --- Detectors/GlobalTracking/src/MatchGlobalFwd.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Detectors/GlobalTracking/src/MatchGlobalFwd.cxx b/Detectors/GlobalTracking/src/MatchGlobalFwd.cxx index 7ada3f9c4b8f8..21ddaa2a4f794 100644 --- a/Detectors/GlobalTracking/src/MatchGlobalFwd.cxx +++ b/Detectors/GlobalTracking/src/MatchGlobalFwd.cxx @@ -896,8 +896,10 @@ o2::mch::TrackParam MatchGlobalFwd::FwdtoMCH(const o2::dataformats::GlobalFwdTra /// \return value of angle within [-pi, pi]. static double constrainAngle(double angle) { - while (angle >= o2::constants::math::PI) angle -= o2::constants::math::TwoPI; - while (angle < -o2::constants::math::PI) angle += o2::constants::math::TwoPI; + while (angle >= o2::constants::math::PI) + angle -= o2::constants::math::TwoPI; + while (angle < -o2::constants::math::PI) + angle += o2::constants::math::TwoPI; return angle; }