Skip to content

Commit 5b29fb4

Browse files
committed
[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.
1 parent 23fb5bd commit 5b29fb4

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎Detectors/GlobalTracking/src/MatchGlobalFwd.cxx‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// or submit itself to any jurisdiction.
1111

1212
#include "GlobalTracking/MatchGlobalFwd.h"
13+
#include "MathUtils/Utils.h"
1314
#include <queue>
1415

1516
using namespace o2::globaltracking;
@@ -889,6 +890,17 @@ o2::mch::TrackParam MatchGlobalFwd::FwdtoMCH(const o2::dataformats::GlobalFwdTra
889890
return o2::mch::TrackParam(convertedTrack);
890891
}
891892

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+
892904
//_________________________________________________________________________________________________
893905
MatchGlobalFwd::MatchGlobalFwd()
894906
{
@@ -926,6 +938,9 @@ MatchGlobalFwd::MatchGlobalFwd()
926938
// Update Parameters
927939
r_k_kminus1 = m_k - H_k * GlobalMuonTrackParameters; // Residuals of prediction
928940

941+
// Restrict the phi residual to the [-pi, pi] range
942+
o2::math_utils::bringToPMPiGend(r_k_kminus1[2]);
943+
929944
auto matchChi2Track = ROOT::Math::Similarity(r_k_kminus1, invResCov);
930945

931946
return matchChi2Track;
@@ -963,6 +978,9 @@ MatchGlobalFwd::MatchGlobalFwd()
963978
// Residuals of prediction
964979
r_k_kminus1 = m_k - H_k * GlobalMuonTrackParameters;
965980

981+
// Restrict the phi residual to the [-pi, pi] range
982+
o2::math_utils::bringToPMPiGend(r_k_kminus1[2]);
983+
966984
auto matchChi2Track = ROOT::Math::Similarity(r_k_kminus1, invResCov);
967985

968986
return matchChi2Track; };

0 commit comments

Comments
 (0)