From eec20cb881a6d78d6fc5b68ba10346edb417ea1c Mon Sep 17 00:00:00 2001 From: Manos Vourliotis Date: Mon, 20 Jan 2025 14:59:15 -0800 Subject: [PATCH] Use central phi functions instead LST ones --- RecoTracker/LSTCore/src/alpaka/Hit.h | 50 +--------- RecoTracker/LSTCore/src/alpaka/Kernels.h | 6 +- RecoTracker/LSTCore/src/alpaka/MiniDoublet.h | 22 ++--- RecoTracker/LSTCore/src/alpaka/PixelTriplet.h | 98 +++++++++---------- RecoTracker/LSTCore/src/alpaka/Quintuplet.h | 93 +++++++++++------- RecoTracker/LSTCore/src/alpaka/Segment.h | 13 ++- .../LSTCore/src/alpaka/TrackCandidate.h | 10 +- RecoTracker/LSTCore/src/alpaka/Triplet.h | 9 +- 8 files changed, 142 insertions(+), 159 deletions(-) diff --git a/RecoTracker/LSTCore/src/alpaka/Hit.h b/RecoTracker/LSTCore/src/alpaka/Hit.h index e5d3eb4226abc..d1af0501ceaa4 100644 --- a/RecoTracker/LSTCore/src/alpaka/Hit.h +++ b/RecoTracker/LSTCore/src/alpaka/Hit.h @@ -1,59 +1,17 @@ #ifndef RecoTracker_LSTCore_src_alpaka_Hit_h #define RecoTracker_LSTCore_src_alpaka_Hit_h +#include "DataFormats/Math/interface/deltaPhi.h" +#include "HeterogeneousCore/AlpakaMath/interface/deltaPhi.h" #include "RecoTracker/LSTCore/interface/alpaka/Common.h" #include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/alpaka/HitsDeviceCollection.h" namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { - template - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE float eta(TAcc const& acc, float x, float y, float z) { - float r3 = alpaka::math::sqrt(acc, x * x + y * y + z * z); - float rt = alpaka::math::sqrt(acc, x * x + y * y); - float eta = ((z > 0) - (z < 0)) * alpaka::math::acosh(acc, r3 / rt); - return eta; - } - - template - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE float phi_mpi_pi(TAcc const& acc, float x) { - if (alpaka::math::abs(acc, x) <= kPi) - return x; - - constexpr float o2pi = 1.f / (2.f * kPi); - float n = alpaka::math::round(acc, x * o2pi); - return x - n * float(2.f * kPi); - } - - template - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE float phi(TAcc const& acc, float x, float y) { - return phi_mpi_pi(acc, kPi + alpaka::math::atan2(acc, -y, -x)); - } - - template - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE float deltaPhi(TAcc const& acc, float x1, float y1, float x2, float y2) { - float phi1 = phi(acc, x1, y1); - float phi2 = phi(acc, x2, y2); - return phi_mpi_pi(acc, (phi2 - phi1)); - } - template ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE float deltaPhiChange(TAcc const& acc, float x1, float y1, float x2, float y2) { - return deltaPhi(acc, x1, y1, x2 - x1, y2 - y1); - } - - ALPAKA_FN_ACC ALPAKA_FN_INLINE float calculate_dPhi(float phi1, float phi2) { - // Calculate dPhi - float dPhi = phi1 - phi2; - - // Normalize dPhi to be between -pi and pi - if (dPhi > kPi) { - dPhi -= 2 * kPi; - } else if (dPhi < -kPi) { - dPhi += 2 * kPi; - } - - return dPhi; + return cms::alpakatools::deltaPhi(acc, x1, y1, x2 - x1, y2 - y1); } struct ModuleRangesKernel { @@ -103,7 +61,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { int iDetId = hits.detid()[ihit]; hits.rts()[ihit] = alpaka::math::sqrt(acc, ihit_x * ihit_x + ihit_y * ihit_y); - hits.phis()[ihit] = phi(acc, ihit_x, ihit_y); + hits.phis()[ihit] = cms::alpakatools::phi(acc, ihit_x, ihit_y); hits.etas()[ihit] = ((ihit_z > 0) - (ihit_z < 0)) * alpaka::math::acosh( diff --git a/RecoTracker/LSTCore/src/alpaka/Kernels.h b/RecoTracker/LSTCore/src/alpaka/Kernels.h index 13d0d2b0e1202..74a619a0f2894 100644 --- a/RecoTracker/LSTCore/src/alpaka/Kernels.h +++ b/RecoTracker/LSTCore/src/alpaka/Kernels.h @@ -164,7 +164,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float eta2 = __H2F(quintuplets.eta()[jx]); float phi2 = __H2F(quintuplets.phi()[jx]); float dEta = alpaka::math::abs(acc, eta1 - eta2); - float dPhi = calculate_dPhi(phi1, phi2); + float dPhi = reco::deltaPhi(phi1, phi2); float score_rphisum2 = __H2F(quintuplets.score_rphisum()[jx]); if (dEta > 0.1f) @@ -244,7 +244,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float score_rphisum2 = __H2F(quintuplets.score_rphisum()[jx]); float dEta = alpaka::math::abs(acc, eta1 - eta2); - float dPhi = calculate_dPhi(phi1, phi2); + float dPhi = reco::deltaPhi(phi1, phi2); if (dEta > 0.1f) continue; @@ -413,7 +413,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } if (secondpass) { float dEta = alpaka::math::abs(acc, eta_pix1 - eta_pix2); - float dPhi = calculate_dPhi(phi_pix1, phi_pix2); + float dPhi = reco::deltaPhi(phi_pix1, phi_pix2); float dR2 = dEta * dEta + dPhi * dPhi; if ((npMatched >= 1) || (dR2 < 1e-5f)) { diff --git a/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h b/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h index 4255d651dbce2..99e87ab551783 100644 --- a/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h +++ b/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h @@ -428,22 +428,22 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { shiftedZ = zUpper; shiftedRt2 = xn * xn + yn * yn; - dPhi = deltaPhi(acc, xLower, yLower, shiftedX, shiftedY); //function from Hit.cc - noShiftedDphi = deltaPhi(acc, xLower, yLower, xUpper, yUpper); + dPhi = cms::alpakatools::deltaPhi(acc, xLower, yLower, shiftedX, shiftedY); //function from Hit.cc + noShiftedDphi = cms::alpakatools::deltaPhi(acc, xLower, yLower, xUpper, yUpper); } else { shiftedX = xn; shiftedY = yn; shiftedZ = zLower; shiftedRt2 = xn * xn + yn * yn; - dPhi = deltaPhi(acc, shiftedX, shiftedY, xUpper, yUpper); - noShiftedDphi = deltaPhi(acc, xLower, yLower, xUpper, yUpper); + dPhi = cms::alpakatools::deltaPhi(acc, shiftedX, shiftedY, xUpper, yUpper); + noShiftedDphi = cms::alpakatools::deltaPhi(acc, xLower, yLower, xUpper, yUpper); } } else { shiftedX = 0.f; shiftedY = 0.f; shiftedZ = 0.f; shiftedRt2 = 0.f; - dPhi = deltaPhi(acc, xLower, yLower, xUpper, yUpper); + dPhi = cms::alpakatools::deltaPhi(acc, xLower, yLower, xUpper, yUpper); noShiftedDphi = dPhi; } @@ -556,21 +556,21 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { shiftedX = xn; shiftedY = yn; shiftedZ = zUpper; - dPhi = deltaPhi(acc, xLower, yLower, shiftedX, shiftedY); - noShiftedDphi = deltaPhi(acc, xLower, yLower, xUpper, yUpper); + dPhi = cms::alpakatools::deltaPhi(acc, xLower, yLower, shiftedX, shiftedY); + noShiftedDphi = cms::alpakatools::deltaPhi(acc, xLower, yLower, xUpper, yUpper); } else { shiftedX = xn; shiftedY = yn; shiftedZ = zLower; - dPhi = deltaPhi(acc, shiftedX, shiftedY, xUpper, yUpper); - noShiftedDphi = deltaPhi(acc, xLower, yLower, xUpper, yUpper); + dPhi = cms::alpakatools::deltaPhi(acc, shiftedX, shiftedY, xUpper, yUpper); + noShiftedDphi = cms::alpakatools::deltaPhi(acc, xLower, yLower, xUpper, yUpper); } } else { shiftedX = xn; shiftedY = yn; shiftedZ = zUpper; - dPhi = deltaPhi(acc, xLower, yLower, xn, yn); - noShiftedDphi = deltaPhi(acc, xLower, yLower, xUpper, yUpper); + dPhi = cms::alpakatools::deltaPhi(acc, xLower, yLower, xn, yn); + noShiftedDphi = cms::alpakatools::deltaPhi(acc, xLower, yLower, xUpper, yUpper); } // dz needs to change if it is a PS module where the strip hits are shifted in order to properly account for the case when a tilted module falls under "endcap logic" diff --git a/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h b/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h index cfd1b3d9b5a5c..57518bc1beaae 100644 --- a/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h +++ b/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h @@ -969,7 +969,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float rt_InOut = rt_InUp; - if (alpaka::math::abs(acc, deltaPhi(acc, x_InUp, y_InUp, x_OutLo, y_OutLo)) > kPi / 2.f) + if (alpaka::math::abs(acc, cms::alpakatools::deltaPhi(acc, x_InUp, y_InUp, x_OutLo, y_OutLo)) > kPi / 2.f) return false; unsigned int pixelSegmentArrayIndex = innerSegmentIndex - ranges.segmentModuleIndices()[pixelModuleIndex]; @@ -1043,7 +1043,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float diffX = x_OutLo - x_InLo; float diffY = y_OutLo - y_InLo; - dPhi = deltaPhi(acc, midPointX, midPointY, diffX, diffY); + dPhi = cms::alpakatools::deltaPhi(acc, midPointX, midPointY, diffX, diffY); if (alpaka::math::abs(acc, dPhi) > dPhiCut) return false; @@ -1057,7 +1057,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { modules.moduleType()[outerOuterLowerModuleIndex] == TwoS; float alpha_OutUp, alpha_OutUp_highEdge, alpha_OutUp_lowEdge; - alpha_OutUp = deltaPhi(acc, x_OutUp, y_OutUp, x_OutUp - x_OutLo, y_OutUp - y_OutLo); + alpha_OutUp = cms::alpakatools::deltaPhi(acc, x_OutUp, y_OutUp, x_OutUp - x_OutLo, y_OutUp - y_OutLo); alpha_OutUp_highEdge = alpha_OutUp; alpha_OutUp_lowEdge = alpha_OutUp; @@ -1071,42 +1071,42 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float tl_axis_lowEdge_x = tl_axis_x; float tl_axis_lowEdge_y = tl_axis_y; - betaIn = -deltaPhi(acc, px, py, tl_axis_x, tl_axis_y); + betaIn = -cms::alpakatools::deltaPhi(acc, px, py, tl_axis_x, tl_axis_y); float betaInRHmin = betaIn; float betaInRHmax = betaIn; - betaOut = -alpha_OutUp + deltaPhi(acc, x_OutUp, y_OutUp, tl_axis_x, tl_axis_y); + betaOut = -alpha_OutUp + cms::alpakatools::deltaPhi(acc, x_OutUp, y_OutUp, tl_axis_x, tl_axis_y); float betaOutRHmin = betaOut; float betaOutRHmax = betaOut; if (isEC_lastLayer) { - alpha_OutUp_highEdge = deltaPhi(acc, - mds.anchorHighEdgeX()[fourthMDIndex], - mds.anchorHighEdgeY()[fourthMDIndex], - mds.anchorHighEdgeX()[fourthMDIndex] - x_OutLo, - mds.anchorHighEdgeY()[fourthMDIndex] - y_OutLo); - alpha_OutUp_lowEdge = deltaPhi(acc, - mds.anchorLowEdgeX()[fourthMDIndex], - mds.anchorLowEdgeY()[fourthMDIndex], - mds.anchorLowEdgeX()[fourthMDIndex] - x_OutLo, - mds.anchorLowEdgeY()[fourthMDIndex] - y_OutLo); + alpha_OutUp_highEdge = cms::alpakatools::deltaPhi(acc, + mds.anchorHighEdgeX()[fourthMDIndex], + mds.anchorHighEdgeY()[fourthMDIndex], + mds.anchorHighEdgeX()[fourthMDIndex] - x_OutLo, + mds.anchorHighEdgeY()[fourthMDIndex] - y_OutLo); + alpha_OutUp_lowEdge = cms::alpakatools::deltaPhi(acc, + mds.anchorLowEdgeX()[fourthMDIndex], + mds.anchorLowEdgeY()[fourthMDIndex], + mds.anchorLowEdgeX()[fourthMDIndex] - x_OutLo, + mds.anchorLowEdgeY()[fourthMDIndex] - y_OutLo); tl_axis_highEdge_x = mds.anchorHighEdgeX()[fourthMDIndex] - x_InUp; tl_axis_highEdge_y = mds.anchorHighEdgeY()[fourthMDIndex] - y_InUp; tl_axis_lowEdge_x = mds.anchorLowEdgeX()[fourthMDIndex] - x_InUp; tl_axis_lowEdge_y = mds.anchorLowEdgeY()[fourthMDIndex] - y_InUp; - betaOutRHmin = -alpha_OutUp_highEdge + deltaPhi(acc, - mds.anchorHighEdgeX()[fourthMDIndex], - mds.anchorHighEdgeY()[fourthMDIndex], - tl_axis_highEdge_x, - tl_axis_highEdge_y); - betaOutRHmax = -alpha_OutUp_lowEdge + deltaPhi(acc, - mds.anchorLowEdgeX()[fourthMDIndex], - mds.anchorLowEdgeY()[fourthMDIndex], - tl_axis_lowEdge_x, - tl_axis_lowEdge_y); + betaOutRHmin = -alpha_OutUp_highEdge + cms::alpakatools::deltaPhi(acc, + mds.anchorHighEdgeX()[fourthMDIndex], + mds.anchorHighEdgeY()[fourthMDIndex], + tl_axis_highEdge_x, + tl_axis_highEdge_y); + betaOutRHmax = -alpha_OutUp_lowEdge + cms::alpakatools::deltaPhi(acc, + mds.anchorLowEdgeX()[fourthMDIndex], + mds.anchorLowEdgeY()[fourthMDIndex], + tl_axis_lowEdge_x, + tl_axis_lowEdge_y); } //beta computation @@ -1307,7 +1307,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float diffX = x_OutLo - x_InLo; float diffY = y_OutLo - y_InLo; - dPhi = deltaPhi(acc, midPointX, midPointY, diffX, diffY); + dPhi = cms::alpakatools::deltaPhi(acc, midPointX, midPointY, diffX, diffY); // Cut #5: deltaPhiChange if (alpaka::math::abs(acc, dPhi) > dPhiCut) @@ -1321,7 +1321,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float alpha_OutUp, alpha_OutUp_highEdge, alpha_OutUp_lowEdge; - alpha_OutUp = deltaPhi(acc, x_OutUp, y_OutUp, x_OutUp - x_OutLo, y_OutUp - y_OutLo); + alpha_OutUp = cms::alpakatools::deltaPhi(acc, x_OutUp, y_OutUp, x_OutUp - x_OutLo, y_OutUp - y_OutLo); alpha_OutUp_highEdge = alpha_OutUp; alpha_OutUp_lowEdge = alpha_OutUp; @@ -1334,41 +1334,41 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float tl_axis_lowEdge_x = tl_axis_x; float tl_axis_lowEdge_y = tl_axis_y; - betaIn = -deltaPhi(acc, px, py, tl_axis_x, tl_axis_y); + betaIn = -cms::alpakatools::deltaPhi(acc, px, py, tl_axis_x, tl_axis_y); float betaInRHmin = betaIn; float betaInRHmax = betaIn; - betaOut = -alpha_OutUp + deltaPhi(acc, x_OutUp, y_OutUp, tl_axis_x, tl_axis_y); + betaOut = -alpha_OutUp + cms::alpakatools::deltaPhi(acc, x_OutUp, y_OutUp, tl_axis_x, tl_axis_y); float betaOutRHmin = betaOut; float betaOutRHmax = betaOut; if (isEC_lastLayer) { - alpha_OutUp_highEdge = deltaPhi(acc, - mds.anchorHighEdgeX()[fourthMDIndex], - mds.anchorHighEdgeY()[fourthMDIndex], - mds.anchorHighEdgeX()[fourthMDIndex] - x_OutLo, - mds.anchorHighEdgeY()[fourthMDIndex] - y_OutLo); - alpha_OutUp_lowEdge = deltaPhi(acc, - mds.anchorLowEdgeX()[fourthMDIndex], - mds.anchorLowEdgeY()[fourthMDIndex], - mds.anchorLowEdgeX()[fourthMDIndex] - x_OutLo, - mds.anchorLowEdgeY()[fourthMDIndex] - y_OutLo); + alpha_OutUp_highEdge = cms::alpakatools::deltaPhi(acc, + mds.anchorHighEdgeX()[fourthMDIndex], + mds.anchorHighEdgeY()[fourthMDIndex], + mds.anchorHighEdgeX()[fourthMDIndex] - x_OutLo, + mds.anchorHighEdgeY()[fourthMDIndex] - y_OutLo); + alpha_OutUp_lowEdge = cms::alpakatools::deltaPhi(acc, + mds.anchorLowEdgeX()[fourthMDIndex], + mds.anchorLowEdgeY()[fourthMDIndex], + mds.anchorLowEdgeX()[fourthMDIndex] - x_OutLo, + mds.anchorLowEdgeY()[fourthMDIndex] - y_OutLo); tl_axis_highEdge_x = mds.anchorHighEdgeX()[fourthMDIndex] - x_InUp; tl_axis_highEdge_y = mds.anchorHighEdgeY()[fourthMDIndex] - y_InUp; tl_axis_lowEdge_x = mds.anchorLowEdgeX()[fourthMDIndex] - x_InUp; tl_axis_lowEdge_y = mds.anchorLowEdgeY()[fourthMDIndex] - y_InUp; - betaOutRHmin = -alpha_OutUp_highEdge + deltaPhi(acc, - mds.anchorHighEdgeX()[fourthMDIndex], - mds.anchorHighEdgeY()[fourthMDIndex], - tl_axis_highEdge_x, - tl_axis_highEdge_y); - betaOutRHmax = -alpha_OutUp_lowEdge + deltaPhi(acc, - mds.anchorLowEdgeX()[fourthMDIndex], - mds.anchorLowEdgeY()[fourthMDIndex], - tl_axis_lowEdge_x, - tl_axis_lowEdge_y); + betaOutRHmin = -alpha_OutUp_highEdge + cms::alpakatools::deltaPhi(acc, + mds.anchorHighEdgeX()[fourthMDIndex], + mds.anchorHighEdgeY()[fourthMDIndex], + tl_axis_highEdge_x, + tl_axis_highEdge_y); + betaOutRHmax = -alpha_OutUp_lowEdge + cms::alpakatools::deltaPhi(acc, + mds.anchorLowEdgeX()[fourthMDIndex], + mds.anchorLowEdgeY()[fourthMDIndex], + tl_axis_lowEdge_x, + tl_axis_lowEdge_y); } //beta computation diff --git a/RecoTracker/LSTCore/src/alpaka/Quintuplet.h b/RecoTracker/LSTCore/src/alpaka/Quintuplet.h index 8bb9a16a5a38b..102897f530f00 100644 --- a/RecoTracker/LSTCore/src/alpaka/Quintuplet.h +++ b/RecoTracker/LSTCore/src/alpaka/Quintuplet.h @@ -901,7 +901,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float diffX = mds.anchorX()[thirdMDIndex] - mds.anchorX()[firstMDIndex]; float diffY = mds.anchorY()[thirdMDIndex] - mds.anchorY()[firstMDIndex]; - float dPhi = deltaPhi(acc, midPointX, midPointY, diffX, diffY); + float dPhi = cms::alpakatools::deltaPhi(acc, midPointX, midPointY, diffX, diffY); // First obtaining the raw betaIn and betaOut values without any correction and just purely based on the mini-doublet hit positions float alpha_InLo = __H2F(segments.dPhiChanges()[innerSegmentIndex]); @@ -912,11 +912,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float alpha_OutUp, alpha_OutUp_highEdge, alpha_OutUp_lowEdge; - alpha_OutUp = phi_mpi_pi(acc, - phi(acc, - mds.anchorX()[fourthMDIndex] - mds.anchorX()[thirdMDIndex], - mds.anchorY()[fourthMDIndex] - mds.anchorY()[thirdMDIndex]) - - mds.anchorPhi()[fourthMDIndex]); + alpha_OutUp = cms::alpakatools::reducePhiRange( + acc, + cms::alpakatools::phi(acc, + mds.anchorX()[fourthMDIndex] - mds.anchorX()[thirdMDIndex], + mds.anchorY()[fourthMDIndex] - mds.anchorY()[thirdMDIndex]) - + mds.anchorPhi()[fourthMDIndex]); alpha_OutUp_highEdge = alpha_OutUp; alpha_OutUp_lowEdge = alpha_OutUp; @@ -928,38 +929,46 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float tl_axis_lowEdge_x = tl_axis_x; float tl_axis_lowEdge_y = tl_axis_y; - float betaIn = alpha_InLo - phi_mpi_pi(acc, phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[firstMDIndex]); + float betaIn = + alpha_InLo - cms::alpakatools::reducePhiRange( + acc, cms::alpakatools::phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[firstMDIndex]); float betaInRHmin = betaIn; float betaInRHmax = betaIn; - float betaOut = -alpha_OutUp + phi_mpi_pi(acc, phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[fourthMDIndex]); + float betaOut = + -alpha_OutUp + cms::alpakatools::reducePhiRange( + acc, cms::alpakatools::phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[fourthMDIndex]); float betaOutRHmin = betaOut; float betaOutRHmax = betaOut; if (isEC_lastLayer) { - alpha_OutUp_highEdge = phi_mpi_pi(acc, - phi(acc, - mds.anchorHighEdgeX()[fourthMDIndex] - mds.anchorX()[thirdMDIndex], - mds.anchorHighEdgeY()[fourthMDIndex] - mds.anchorY()[thirdMDIndex]) - - mds.anchorHighEdgePhi()[fourthMDIndex]); - alpha_OutUp_lowEdge = phi_mpi_pi(acc, - phi(acc, - mds.anchorLowEdgeX()[fourthMDIndex] - mds.anchorX()[thirdMDIndex], - mds.anchorLowEdgeY()[fourthMDIndex] - mds.anchorY()[thirdMDIndex]) - - mds.anchorLowEdgePhi()[fourthMDIndex]); + alpha_OutUp_highEdge = cms::alpakatools::reducePhiRange( + acc, + cms::alpakatools::phi(acc, + mds.anchorHighEdgeX()[fourthMDIndex] - mds.anchorX()[thirdMDIndex], + mds.anchorHighEdgeY()[fourthMDIndex] - mds.anchorY()[thirdMDIndex]) - + mds.anchorHighEdgePhi()[fourthMDIndex]); + alpha_OutUp_lowEdge = cms::alpakatools::reducePhiRange( + acc, + cms::alpakatools::phi(acc, + mds.anchorLowEdgeX()[fourthMDIndex] - mds.anchorX()[thirdMDIndex], + mds.anchorLowEdgeY()[fourthMDIndex] - mds.anchorY()[thirdMDIndex]) - + mds.anchorLowEdgePhi()[fourthMDIndex]); tl_axis_highEdge_x = mds.anchorHighEdgeX()[fourthMDIndex] - mds.anchorX()[firstMDIndex]; tl_axis_highEdge_y = mds.anchorHighEdgeY()[fourthMDIndex] - mds.anchorY()[firstMDIndex]; tl_axis_lowEdge_x = mds.anchorLowEdgeX()[fourthMDIndex] - mds.anchorX()[firstMDIndex]; tl_axis_lowEdge_y = mds.anchorLowEdgeY()[fourthMDIndex] - mds.anchorY()[firstMDIndex]; - betaOutRHmin = - -alpha_OutUp_highEdge + - phi_mpi_pi(acc, phi(acc, tl_axis_highEdge_x, tl_axis_highEdge_y) - mds.anchorHighEdgePhi()[fourthMDIndex]); - betaOutRHmax = - -alpha_OutUp_lowEdge + - phi_mpi_pi(acc, phi(acc, tl_axis_lowEdge_x, tl_axis_lowEdge_y) - mds.anchorLowEdgePhi()[fourthMDIndex]); + betaOutRHmin = -alpha_OutUp_highEdge + cms::alpakatools::reducePhiRange( + acc, + cms::alpakatools::phi(acc, tl_axis_highEdge_x, tl_axis_highEdge_y) - + mds.anchorHighEdgePhi()[fourthMDIndex]); + betaOutRHmax = -alpha_OutUp_lowEdge + + cms::alpakatools::reducePhiRange(acc, + cms::alpakatools::phi(acc, tl_axis_lowEdge_x, tl_axis_lowEdge_y) - + mds.anchorLowEdgePhi()[fourthMDIndex]); } //beta computation @@ -1069,31 +1078,36 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float diffX = mds.anchorX()[thirdMDIndex] - mds.anchorX()[firstMDIndex]; float diffY = mds.anchorY()[thirdMDIndex] - mds.anchorY()[firstMDIndex]; - float dPhi = deltaPhi(acc, midPointX, midPointY, diffX, diffY); + float dPhi = cms::alpakatools::deltaPhi(acc, midPointX, midPointY, diffX, diffY); float sdIn_alpha = __H2F(segments.dPhiChanges()[innerSegmentIndex]); float sdIn_alpha_min = __H2F(segments.dPhiChangeMins()[innerSegmentIndex]); float sdIn_alpha_max = __H2F(segments.dPhiChangeMaxs()[innerSegmentIndex]); float sdOut_alpha = sdIn_alpha; - float sdOut_dPhiPos = phi_mpi_pi(acc, mds.anchorPhi()[fourthMDIndex] - mds.anchorPhi()[thirdMDIndex]); + float sdOut_dPhiPos = + cms::alpakatools::reducePhiRange(acc, mds.anchorPhi()[fourthMDIndex] - mds.anchorPhi()[thirdMDIndex]); float sdOut_dPhiChange = __H2F(segments.dPhiChanges()[outerSegmentIndex]); float sdOut_dPhiChange_min = __H2F(segments.dPhiChangeMins()[outerSegmentIndex]); float sdOut_dPhiChange_max = __H2F(segments.dPhiChangeMaxs()[outerSegmentIndex]); - float sdOut_alphaOutRHmin = phi_mpi_pi(acc, sdOut_dPhiChange_min - sdOut_dPhiPos); - float sdOut_alphaOutRHmax = phi_mpi_pi(acc, sdOut_dPhiChange_max - sdOut_dPhiPos); - float sdOut_alphaOut = phi_mpi_pi(acc, sdOut_dPhiChange - sdOut_dPhiPos); + float sdOut_alphaOutRHmin = cms::alpakatools::reducePhiRange(acc, sdOut_dPhiChange_min - sdOut_dPhiPos); + float sdOut_alphaOutRHmax = cms::alpakatools::reducePhiRange(acc, sdOut_dPhiChange_max - sdOut_dPhiPos); + float sdOut_alphaOut = cms::alpakatools::reducePhiRange(acc, sdOut_dPhiChange - sdOut_dPhiPos); float tl_axis_x = mds.anchorX()[fourthMDIndex] - mds.anchorX()[firstMDIndex]; float tl_axis_y = mds.anchorY()[fourthMDIndex] - mds.anchorY()[firstMDIndex]; - float betaIn = sdIn_alpha - phi_mpi_pi(acc, phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[firstMDIndex]); + float betaIn = + sdIn_alpha - cms::alpakatools::reducePhiRange( + acc, cms::alpakatools::phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[firstMDIndex]); float betaInRHmin = betaIn; float betaInRHmax = betaIn; - float betaOut = -sdOut_alphaOut + phi_mpi_pi(acc, phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[fourthMDIndex]); + float betaOut = + -sdOut_alphaOut + cms::alpakatools::reducePhiRange( + acc, cms::alpakatools::phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[fourthMDIndex]); float betaOutRHmin = betaOut; float betaOutRHmax = betaOut; @@ -1225,27 +1239,32 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float thetaMuls2 = (kMulsInGeV * kMulsInGeV) * (0.1f + 0.2f * (rt_OutLo - rt_InLo) / 50.f); float sdIn_alpha = __H2F(segments.dPhiChanges()[innerSegmentIndex]); float sdOut_alpha = sdIn_alpha; //weird - float sdOut_dPhiPos = phi_mpi_pi(acc, mds.anchorPhi()[fourthMDIndex] - mds.anchorPhi()[thirdMDIndex]); + float sdOut_dPhiPos = + cms::alpakatools::reducePhiRange(acc, mds.anchorPhi()[fourthMDIndex] - mds.anchorPhi()[thirdMDIndex]); float sdOut_dPhiChange = __H2F(segments.dPhiChanges()[outerSegmentIndex]); float sdOut_dPhiChange_min = __H2F(segments.dPhiChangeMins()[outerSegmentIndex]); float sdOut_dPhiChange_max = __H2F(segments.dPhiChangeMaxs()[outerSegmentIndex]); - float sdOut_alphaOutRHmin = phi_mpi_pi(acc, sdOut_dPhiChange_min - sdOut_dPhiPos); - float sdOut_alphaOutRHmax = phi_mpi_pi(acc, sdOut_dPhiChange_max - sdOut_dPhiPos); - float sdOut_alphaOut = phi_mpi_pi(acc, sdOut_dPhiChange - sdOut_dPhiPos); + float sdOut_alphaOutRHmin = cms::alpakatools::reducePhiRange(acc, sdOut_dPhiChange_min - sdOut_dPhiPos); + float sdOut_alphaOutRHmax = cms::alpakatools::reducePhiRange(acc, sdOut_dPhiChange_max - sdOut_dPhiPos); + float sdOut_alphaOut = cms::alpakatools::reducePhiRange(acc, sdOut_dPhiChange - sdOut_dPhiPos); float tl_axis_x = mds.anchorX()[fourthMDIndex] - mds.anchorX()[firstMDIndex]; float tl_axis_y = mds.anchorY()[fourthMDIndex] - mds.anchorY()[firstMDIndex]; - float betaIn = sdIn_alpha - phi_mpi_pi(acc, phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[firstMDIndex]); + float betaIn = + sdIn_alpha - cms::alpakatools::reducePhiRange( + acc, cms::alpakatools::phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[firstMDIndex]); float sdIn_alphaRHmin = __H2F(segments.dPhiChangeMins()[innerSegmentIndex]); float sdIn_alphaRHmax = __H2F(segments.dPhiChangeMaxs()[innerSegmentIndex]); float betaInRHmin = betaIn + sdIn_alphaRHmin - sdIn_alpha; float betaInRHmax = betaIn + sdIn_alphaRHmax - sdIn_alpha; - float betaOut = -sdOut_alphaOut + phi_mpi_pi(acc, phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[fourthMDIndex]); + float betaOut = + -sdOut_alphaOut + cms::alpakatools::reducePhiRange( + acc, cms::alpakatools::phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[fourthMDIndex]); float betaOutRHmin = betaOut - sdOut_alphaOutRHmin + sdOut_alphaOut; float betaOutRHmax = betaOut - sdOut_alphaOutRHmax + sdOut_alphaOut; diff --git a/RecoTracker/LSTCore/src/alpaka/Segment.h b/RecoTracker/LSTCore/src/alpaka/Segment.h index 911119bf67ff8..a206242e6162c 100644 --- a/RecoTracker/LSTCore/src/alpaka/Segment.h +++ b/RecoTracker/LSTCore/src/alpaka/Segment.h @@ -313,12 +313,13 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float sdCut = sdSlope + alpaka::math::sqrt(acc, sdMuls * sdMuls + sdPVoff * sdPVoff); - dPhi = phi_mpi_pi(acc, mds.anchorPhi()[outerMDIndex] - mds.anchorPhi()[innerMDIndex]); + dPhi = cms::alpakatools::reducePhiRange(acc, mds.anchorPhi()[outerMDIndex] - mds.anchorPhi()[innerMDIndex]); if (alpaka::math::abs(acc, dPhi) > sdCut) return false; - dPhiChange = phi_mpi_pi(acc, phi(acc, xOut - xIn, yOut - yIn) - mds.anchorPhi()[innerMDIndex]); + dPhiChange = cms::alpakatools::reducePhiRange( + acc, cms::alpakatools::phi(acc, xOut - xIn, yOut - yIn) - mds.anchorPhi()[innerMDIndex]); if (alpaka::math::abs(acc, dPhiChange) > sdCut) return false; @@ -414,12 +415,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { if ((rtOut < rtLo) || (rtOut > rtHi)) return false; - dPhi = phi_mpi_pi(acc, mds.anchorPhi()[outerMDIndex] - mds.anchorPhi()[innerMDIndex]); + dPhi = cms::alpakatools::reducePhiRange(acc, mds.anchorPhi()[outerMDIndex] - mds.anchorPhi()[innerMDIndex]); float sdCut = sdSlope; if (outerLayerEndcapTwoS) { - float dPhiPos_high = phi_mpi_pi(acc, mds.anchorHighEdgePhi()[outerMDIndex] - mds.anchorPhi()[innerMDIndex]); - float dPhiPos_low = phi_mpi_pi(acc, mds.anchorLowEdgePhi()[outerMDIndex] - mds.anchorPhi()[innerMDIndex]); + float dPhiPos_high = + cms::alpakatools::reducePhiRange(acc, mds.anchorHighEdgePhi()[outerMDIndex] - mds.anchorPhi()[innerMDIndex]); + float dPhiPos_low = + cms::alpakatools::reducePhiRange(acc, mds.anchorLowEdgePhi()[outerMDIndex] - mds.anchorPhi()[innerMDIndex]); dPhiMax = alpaka::math::abs(acc, dPhiPos_high) > alpaka::math::abs(acc, dPhiPos_low) ? dPhiPos_high : dPhiPos_low; dPhiMin = alpaka::math::abs(acc, dPhiPos_high) > alpaka::math::abs(acc, dPhiPos_low) ? dPhiPos_low : dPhiPos_high; diff --git a/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h b/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h index 315263919aa87..a0f295eadd446 100644 --- a/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h +++ b/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h @@ -136,7 +136,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float eta2 = segmentsPixel.eta()[pLS_jx - prefix]; float phi2 = segmentsPixel.phi()[pLS_jx - prefix]; float dEta = alpaka::math::abs(acc, (eta1 - eta2)); - float dPhi = calculate_dPhi(phi1, phi2); + float dPhi = reco::deltaPhi(phi1, phi2); float dR2 = dEta * dEta + dPhi * dPhi; if (dR2 < 1e-5f) @@ -189,7 +189,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } float dEta = alpaka::math::abs(acc, eta1 - eta2); - float dPhi = calculate_dPhi(phi1, phi2); + float dPhi = reco::deltaPhi(phi1, phi2); float dR2 = dEta * dEta + dPhi * dPhi; if (dR2 < 1e-3f) @@ -237,7 +237,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float eta2 = __H2F(quintuplets.eta()[quintupletIndex]); float phi2 = __H2F(quintuplets.phi()[quintupletIndex]); float dEta = alpaka::math::abs(acc, eta1 - eta2); - float dPhi = calculate_dPhi(phi1, phi2); + float dPhi = reco::deltaPhi(phi1, phi2); float dR2 = dEta * dEta + dPhi * dPhi; if (dR2 < 1e-3f) @@ -253,7 +253,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float eta2 = __H2F(pixelTriplets.eta_pix()[pT3Index]); float phi2 = __H2F(pixelTriplets.phi_pix()[pT3Index]); float dEta = alpaka::math::abs(acc, eta1 - eta2); - float dPhi = calculate_dPhi(phi1, phi2); + float dPhi = reco::deltaPhi(phi1, phi2); float dR2 = dEta * dEta + dPhi * dPhi; if (dR2 < 0.000001f) @@ -269,7 +269,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float eta2 = segmentsPixel.eta()[pLSIndex - prefix]; float phi2 = segmentsPixel.phi()[pLSIndex - prefix]; float dEta = alpaka::math::abs(acc, eta1 - eta2); - float dPhi = calculate_dPhi(phi1, phi2); + float dPhi = reco::deltaPhi(phi1, phi2); float dR2 = dEta * dEta + dPhi * dPhi; if (dR2 < 0.000001f) diff --git a/RecoTracker/LSTCore/src/alpaka/Triplet.h b/RecoTracker/LSTCore/src/alpaka/Triplet.h index ae2faecb080a6..13f4c262ce440 100644 --- a/RecoTracker/LSTCore/src/alpaka/Triplet.h +++ b/RecoTracker/LSTCore/src/alpaka/Triplet.h @@ -393,7 +393,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float alpha_InLo = __H2F(segments.dPhiChanges()[innerSegmentIndex]); float tl_axis_x = mds.anchorX()[thirdMDIndex] - mds.anchorX()[firstMDIndex]; float tl_axis_y = mds.anchorY()[thirdMDIndex] - mds.anchorY()[firstMDIndex]; - betaIn = alpha_InLo - phi_mpi_pi(acc, phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[firstMDIndex]); + betaIn = alpha_InLo - cms::alpakatools::reducePhiRange( + acc, cms::alpakatools::phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[firstMDIndex]); //beta computation float drt_tl_axis = alpaka::math::sqrt(acc, tl_axis_x * tl_axis_x + tl_axis_y * tl_axis_y); @@ -439,7 +440,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float tl_axis_x = mds.anchorX()[thirdMDIndex] - mds.anchorX()[firstMDIndex]; float tl_axis_y = mds.anchorY()[thirdMDIndex] - mds.anchorY()[firstMDIndex]; - betaIn = sdIn_alpha - phi_mpi_pi(acc, phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[firstMDIndex]); + betaIn = sdIn_alpha - cms::alpakatools::reducePhiRange( + acc, cms::alpakatools::phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[firstMDIndex]); float betaInRHmin = betaIn; float betaInRHmax = betaIn; @@ -492,7 +494,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float tl_axis_x = mds.anchorX()[thirdMDIndex] - mds.anchorX()[firstMDIndex]; float tl_axis_y = mds.anchorY()[thirdMDIndex] - mds.anchorY()[firstMDIndex]; - betaIn = sdIn_alpha - phi_mpi_pi(acc, phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[firstMDIndex]); + betaIn = sdIn_alpha - cms::alpakatools::reducePhiRange( + acc, cms::alpakatools::phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[firstMDIndex]); float sdIn_alphaRHmin = __H2F(segments.dPhiChangeMins()[innerSegmentIndex]); float sdIn_alphaRHmax = __H2F(segments.dPhiChangeMaxs()[innerSegmentIndex]);