Skip to content

Commit 678aac3

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 678aac3

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Detectors/GlobalTracking/src/MatchGlobalFwd.cxx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,17 @@ o2::mch::TrackParam MatchGlobalFwd::FwdtoMCH(const o2::dataformats::GlobalFwdTra
889889
return o2::mch::TrackParam(convertedTrack);
890890
}
891891

892+
/// Constrains angle to be within the [-pi, pi] range.
893+
/// \note Inspired by TVector2::Phi_mpi_pi in ROOT.
894+
/// \param angle angle
895+
/// \return value of angle within [-pi, pi].
896+
static double constrainAngle(double angle)
897+
{
898+
while (angle >= o2::constants::math::PI) angle -= o2::constants::math::TwoPI;
899+
while (angle < -o2::constants::math::PI) angle += o2::constants::math::TwoPI;
900+
return angle;
901+
}
902+
892903
//_________________________________________________________________________________________________
893904
MatchGlobalFwd::MatchGlobalFwd()
894905
{
@@ -926,6 +937,9 @@ MatchGlobalFwd::MatchGlobalFwd()
926937
// Update Parameters
927938
r_k_kminus1 = m_k - H_k * GlobalMuonTrackParameters; // Residuals of prediction
928939

940+
// Restrict the phi residual to the [-pi, pi] range
941+
r_k_kminus1[2] = constrainAngle(r_k_kminus1[2]);
942+
929943
auto matchChi2Track = ROOT::Math::Similarity(r_k_kminus1, invResCov);
930944

931945
return matchChi2Track;
@@ -963,6 +977,9 @@ MatchGlobalFwd::MatchGlobalFwd()
963977
// Residuals of prediction
964978
r_k_kminus1 = m_k - H_k * GlobalMuonTrackParameters;
965979

980+
// Restrict the phi residual to the [-pi, pi] range
981+
r_k_kminus1[2] = constrainAngle(r_k_kminus1[2]);
982+
966983
auto matchChi2Track = ROOT::Math::Similarity(r_k_kminus1, invResCov);
967984

968985
return matchChi2Track; };

0 commit comments

Comments
 (0)