Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Detectors/GlobalTracking/src/MatchGlobalFwd.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,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()
{
Expand Down Expand Up @@ -926,6 +937,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
r_k_kminus1[2] = constrainAngle(r_k_kminus1[2]);

auto matchChi2Track = ROOT::Math::Similarity(r_k_kminus1, invResCov);

return matchChi2Track;
Expand Down Expand Up @@ -963,6 +977,9 @@ MatchGlobalFwd::MatchGlobalFwd()
// Residuals of prediction
r_k_kminus1 = m_k - H_k * GlobalMuonTrackParameters;

// Restrict the phi residual to the [-pi, pi] range
r_k_kminus1[2] = constrainAngle(r_k_kminus1[2]);

Comment on lines 892 to +982

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you not just use the o2::math_utils::bringToPMPiGen(...) function?

Suggested change
@@ -926,6 +937,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::bringToPMPiGen(r_k_kminus1[2]);
auto matchChi2Track = ROOT::Math::Similarity(r_k_kminus1, invResCov);
return matchChi2Track;
@@ -963,6 +977,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::bringToPMPiGen(r_k_kminus1[2]);

auto matchChi2Track = ROOT::Math::Similarity(r_k_kminus1, invResCov);

return matchChi2Track; };
Expand Down