From 681eb351288454e7ec7e995222b6b244d4de508d Mon Sep 17 00:00:00 2001 From: YonsiG Date: Mon, 22 Apr 2024 10:34:40 -0700 Subject: [PATCH 01/29] atrimBBBBB for runTriplet --- SDL/Triplet.h | 256 +------------------------------------------------- 1 file changed, 2 insertions(+), 254 deletions(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index 7bb937c6..58165cea 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -766,152 +766,15 @@ namespace SDL { float& betaOutCut, float& deltaBetaCut) { bool pass = true; - - bool isPS_InLo = (modulesInGPU.moduleType[innerInnerLowerModuleIndex] == SDL::PS); - bool isPS_OutLo = (modulesInGPU.moduleType[outerInnerLowerModuleIndex] == SDL::PS); - float rt_InLo = mdsInGPU.anchorRt[firstMDIndex]; float rt_InOut = mdsInGPU.anchorRt[secondMDIndex]; - float rt_OutLo = mdsInGPU.anchorRt[thirdMDIndex]; - - float z_InLo = mdsInGPU.anchorZ[firstMDIndex]; - float z_InOut = mdsInGPU.anchorZ[secondMDIndex]; - float z_OutLo = mdsInGPU.anchorZ[thirdMDIndex]; - - float alpha1GeV_OutLo = - alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)); - float rtRatio_OutLoInLo = rt_OutLo / rt_InLo; // Outer segment beginning rt divided by inner segment beginning rt; - float dzDrtScale = - alpaka::math::tan(acc, alpha1GeV_OutLo) / alpha1GeV_OutLo; // The track can bend in r-z plane slightly - float zpitch_InLo = (isPS_InLo ? SDL::pixelPSZpitch : SDL::strip2SZpitch); - float zpitch_OutLo = (isPS_OutLo ? SDL::pixelPSZpitch : SDL::strip2SZpitch); - - zHi = z_InLo + (z_InLo + SDL::deltaZLum) * (rtRatio_OutLoInLo - 1.f) * (z_InLo < 0.f ? 1.f : dzDrtScale) + - (zpitch_InLo + zpitch_OutLo); - zLo = z_InLo + (z_InLo - SDL::deltaZLum) * (rtRatio_OutLoInLo - 1.f) * (z_InLo > 0.f ? 1.f : dzDrtScale) - - (zpitch_InLo + zpitch_OutLo); - - //Cut 1 - z compatibility - zOut = z_OutLo; - rtOut = rt_OutLo; - pass = pass and ((z_OutLo >= zLo) && (z_OutLo <= zHi)); - if (not pass) - return pass; - - float drt_OutLo_InLo = (rt_OutLo - rt_InLo); - float r3_InLo = alpaka::math::sqrt(acc, z_InLo * z_InLo + rt_InLo * rt_InLo); float drt_InSeg = rt_InOut - rt_InLo; - float dz_InSeg = z_InOut - z_InLo; - float dr3_InSeg = alpaka::math::sqrt(acc, rt_InOut * rt_InOut + z_InOut * z_InOut) - - alpaka::math::sqrt(acc, rt_InLo * rt_InLo + z_InLo * z_InLo); - - float coshEta = dr3_InSeg / drt_InSeg; - float dzErr = (zpitch_InLo + zpitch_OutLo) * (zpitch_InLo + zpitch_OutLo) * 2.f; - - float sdlThetaMulsF = 0.015f * alpaka::math::sqrt(acc, 0.1f + 0.2f * (rt_OutLo - rt_InLo) / 50.f) * - alpaka::math::sqrt(acc, r3_InLo / rt_InLo); - float sdlMuls = sdlThetaMulsF * 3.f / SDL::ptCut * 4.f; // will need a better guess than x4? - dzErr += sdlMuls * sdlMuls * drt_OutLo_InLo * drt_OutLo_InLo / 3.f * coshEta * coshEta; //sloppy - dzErr = alpaka::math::sqrt(acc, dzErr); - - // Constructing upper and lower bound - const float dzMean = dz_InSeg / drt_InSeg * drt_OutLo_InLo; - const float zWindow = - dzErr / drt_InSeg * drt_OutLo_InLo + - (zpitch_InLo + zpitch_OutLo); //FIXME for SDL::ptCut lower than ~0.8 need to add curv path correction - zLoPointed = z_InLo + dzMean * (z_InLo > 0.f ? 1.f : dzDrtScale) - zWindow; - zHiPointed = z_InLo + dzMean * (z_InLo < 0.f ? 1.f : dzDrtScale) + zWindow; - - // Cut #2: Pointed Z (Inner segment two MD points to outer segment inner MD) - pass = pass and ((z_OutLo >= zLoPointed) && (z_OutLo <= zHiPointed)); - if (not pass) - return pass; - - float sdlPVoff = 0.1f / rt_OutLo; - sdlCut = alpha1GeV_OutLo + alpaka::math::sqrt(acc, sdlMuls * sdlMuls + sdlPVoff * sdlPVoff); - - deltaPhiPos = SDL::phi_mpi_pi(acc, mdsInGPU.anchorPhi[fourthMDIndex] - mdsInGPU.anchorPhi[secondMDIndex]); - // Cut #3: FIXME:deltaPhiPos can be tighter - pass = pass and (alpaka::math::abs(acc, deltaPhiPos) <= sdlCut); - if (not pass) - return pass; - - float midPointX = 0.5f * (mdsInGPU.anchorX[firstMDIndex] + mdsInGPU.anchorX[thirdMDIndex]); - float midPointY = 0.5f * (mdsInGPU.anchorY[firstMDIndex] + mdsInGPU.anchorY[thirdMDIndex]); - float diffX = mdsInGPU.anchorX[thirdMDIndex] - mdsInGPU.anchorX[firstMDIndex]; - float diffY = mdsInGPU.anchorY[thirdMDIndex] - mdsInGPU.anchorY[firstMDIndex]; - - dPhi = SDL::deltaPhi(acc, midPointX, midPointY, diffX, diffY); - - // Cut #4: deltaPhiChange - pass = pass and (alpaka::math::abs(acc, dPhi) <= sdlCut); - //lots of array accesses below. Cut here! - if (not pass) - return pass; - // 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(segmentsInGPU.dPhiChanges[innerSegmentIndex]); - float alpha_OutLo = __H2F(segmentsInGPU.dPhiChanges[outerSegmentIndex]); - - bool isEC_lastLayer = modulesInGPU.subdets[outerOuterLowerModuleIndex] == SDL::Endcap and - modulesInGPU.moduleType[outerOuterLowerModuleIndex] == SDL::TwoS; - - float alpha_OutUp, alpha_OutUp_highEdge, alpha_OutUp_lowEdge; - - alpha_OutUp = SDL::phi_mpi_pi(acc, - SDL::phi(acc, - mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex], - mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex]) - - mdsInGPU.anchorPhi[fourthMDIndex]); - - alpha_OutUp_highEdge = alpha_OutUp; - alpha_OutUp_lowEdge = alpha_OutUp; - float tl_axis_x = mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[firstMDIndex]; float tl_axis_y = mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex]; - float tl_axis_highEdge_x = tl_axis_x; - float tl_axis_highEdge_y = tl_axis_y; - float tl_axis_lowEdge_x = tl_axis_x; - float tl_axis_lowEdge_y = tl_axis_y; - - betaIn = alpha_InLo - SDL::phi_mpi_pi(acc, SDL::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[firstMDIndex]); - - float betaInRHmin = betaIn; - float betaInRHmax = betaIn; - betaOut = - -alpha_OutUp + SDL::phi_mpi_pi(acc, SDL::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[fourthMDIndex]); - - float betaOutRHmin = betaOut; - float betaOutRHmax = betaOut; - - if (isEC_lastLayer) { - alpha_OutUp_highEdge = - SDL::phi_mpi_pi(acc, - SDL::phi(acc, - mdsInGPU.anchorHighEdgeX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex], - mdsInGPU.anchorHighEdgeY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex]) - - mdsInGPU.anchorHighEdgePhi[fourthMDIndex]); - alpha_OutUp_lowEdge = - SDL::phi_mpi_pi(acc, - SDL::phi(acc, - mdsInGPU.anchorLowEdgeX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex], - mdsInGPU.anchorLowEdgeY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex]) - - mdsInGPU.anchorLowEdgePhi[fourthMDIndex]); - - tl_axis_highEdge_x = mdsInGPU.anchorHighEdgeX[fourthMDIndex] - mdsInGPU.anchorX[firstMDIndex]; - tl_axis_highEdge_y = mdsInGPU.anchorHighEdgeY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex]; - tl_axis_lowEdge_x = mdsInGPU.anchorLowEdgeX[fourthMDIndex] - mdsInGPU.anchorX[firstMDIndex]; - tl_axis_lowEdge_y = mdsInGPU.anchorLowEdgeY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex]; - - betaOutRHmin = -alpha_OutUp_highEdge + SDL::phi_mpi_pi(acc, - SDL::phi(acc, tl_axis_highEdge_x, tl_axis_highEdge_y) - - mdsInGPU.anchorHighEdgePhi[fourthMDIndex]); - betaOutRHmax = -alpha_OutUp_lowEdge + SDL::phi_mpi_pi(acc, - SDL::phi(acc, tl_axis_lowEdge_x, tl_axis_lowEdge_y) - - mdsInGPU.anchorLowEdgePhi[fourthMDIndex]); - } + float betaInRHmin = alpha_InLo - SDL::phi_mpi_pi(acc, SDL::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[firstMDIndex]); //beta computation float drt_tl_axis = alpaka::math::sqrt(acc, tl_axis_x * tl_axis_x + tl_axis_y * tl_axis_y); @@ -931,90 +794,8 @@ namespace SDL { (0.02f / drt_InSeg); //Cut #5: first beta cut + //-5 pass = pass and (alpaka::math::abs(acc, betaInRHmin) < betaInCut); - if (not pass) - return pass; - - float betaAv = 0.5f * (betaIn + betaOut); - pt_beta = drt_tl_axis * SDL::k2Rinv1GeVf / alpaka::math::sin(acc, betaAv); - int lIn = 5; - int lOut = isEC_lastLayer ? 11 : 5; - float sdOut_dr = alpaka::math::sqrt(acc, - (mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex]) * - (mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex]) + - (mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex]) * - (mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex])); - float sdOut_d = mdsInGPU.anchorRt[fourthMDIndex] - mdsInGPU.anchorRt[thirdMDIndex]; - - runDeltaBetaIterationsT3(acc, betaIn, betaOut, betaAv, pt_beta, rt_InSeg, sdOut_dr, drt_tl_axis, lIn); - - const float betaInMMSF = (alpaka::math::abs(acc, betaInRHmin + betaInRHmax) > 0) - ? (2.f * betaIn / alpaka::math::abs(acc, betaInRHmin + betaInRHmax)) - : 0.f; //mean value of min,max is the old betaIn - const float betaOutMMSF = (alpaka::math::abs(acc, betaOutRHmin + betaOutRHmax) > 0) - ? (2.f * betaOut / alpaka::math::abs(acc, betaOutRHmin + betaOutRHmax)) - : 0.f; - betaInRHmin *= betaInMMSF; - betaInRHmax *= betaInMMSF; - betaOutRHmin *= betaOutMMSF; - betaOutRHmax *= betaOutMMSF; - - const float dBetaMuls = - sdlThetaMulsF * 4.f / - alpaka::math::min( - acc, alpaka::math::abs(acc, pt_beta), SDL::pt_betaMax); //need to confirm the range-out value of 7 GeV - - const float alphaInAbsReg = alpaka::math::max( - acc, - alpaka::math::abs(acc, alpha_InLo), - alpaka::math::asin(acc, alpaka::math::min(acc, rt_InLo * SDL::k2Rinv1GeVf / 3.0f, SDL::sinAlphaMax))); - const float alphaOutAbsReg = alpaka::math::max( - acc, - alpaka::math::abs(acc, alpha_OutLo), - alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * SDL::k2Rinv1GeVf / 3.0f, SDL::sinAlphaMax))); - const float dBetaInLum = lIn < 11 ? 0.0f : alpaka::math::abs(acc, alphaInAbsReg * SDL::deltaZLum / z_InLo); - const float dBetaOutLum = lOut < 11 ? 0.0f : alpaka::math::abs(acc, alphaOutAbsReg * SDL::deltaZLum / z_OutLo); - const float dBetaLum2 = (dBetaInLum + dBetaOutLum) * (dBetaInLum + dBetaOutLum); - const float sinDPhi = alpaka::math::sin(acc, dPhi); - - const float dBetaRIn2 = 0; // TODO-RH - // const float dBetaROut2 = 0; // TODO-RH - float dBetaROut = 0; - if (isEC_lastLayer) { - dBetaROut = - (alpaka::math::sqrt(acc, - mdsInGPU.anchorHighEdgeX[fourthMDIndex] * mdsInGPU.anchorHighEdgeX[fourthMDIndex] + - mdsInGPU.anchorHighEdgeY[fourthMDIndex] * mdsInGPU.anchorHighEdgeY[fourthMDIndex]) - - alpaka::math::sqrt(acc, - mdsInGPU.anchorLowEdgeX[fourthMDIndex] * mdsInGPU.anchorLowEdgeX[fourthMDIndex] + - mdsInGPU.anchorLowEdgeY[fourthMDIndex] * mdsInGPU.anchorLowEdgeY[fourthMDIndex])) * - sinDPhi / drt_tl_axis; - } - - const float dBetaROut2 = dBetaROut * dBetaROut; - - betaOutCut = alpaka::math::asin(acc, - alpaka::math::min(acc, - drt_tl_axis * SDL::k2Rinv1GeVf / SDL::ptCut, - SDL::sinAlphaMax)) //FIXME: need faster version - + (0.02f / sdOut_d) + alpaka::math::sqrt(acc, dBetaLum2 + dBetaMuls * dBetaMuls); - - //Cut #6: The real beta cut - pass = pass and ((alpaka::math::abs(acc, betaOut) < betaOutCut)); - if (not pass) - return pass; - - float dBetaRes = 0.02f / alpaka::math::min(acc, sdOut_d, drt_InSeg); - float dBetaCut2 = - (dBetaRes * dBetaRes * 2.0f + dBetaMuls * dBetaMuls + dBetaLum2 + dBetaRIn2 + dBetaROut2 + - 0.25f * - (alpaka::math::abs(acc, betaInRHmin - betaInRHmax) + alpaka::math::abs(acc, betaOutRHmin - betaOutRHmax)) * - (alpaka::math::abs(acc, betaInRHmin - betaInRHmax) + alpaka::math::abs(acc, betaOutRHmin - betaOutRHmax))); - - float dBeta = betaIn - betaOut; - deltaBetaCut = alpaka::math::sqrt(acc, dBetaCut2); - pass = pass and (dBeta * dBeta <= dBetaCut2); - return pass; }; @@ -1656,39 +1437,6 @@ namespace SDL { deltaBetaCut); } - else if (innerInnerLowerModuleSubdet == SDL::Barrel and innerOuterLowerModuleSubdet == SDL::Barrel and - outerInnerLowerModuleSubdet == SDL::Endcap and outerOuterLowerModuleSubdet == SDL::Endcap) { - return runTripletDefaultAlgoBBEE(acc, - modulesInGPU, - mdsInGPU, - segmentsInGPU, - innerInnerLowerModuleIndex, - innerOuterLowerModuleIndex, - outerInnerLowerModuleIndex, - outerOuterLowerModuleIndex, - innerSegmentIndex, - outerSegmentIndex, - firstMDIndex, - secondMDIndex, - thirdMDIndex, - fourthMDIndex, - zOut, - rtOut, - deltaPhiPos, - deltaPhi, - betaIn, - betaOut, - pt_beta, - zLo, - rtLo, - rtHi, - sdlCut, - betaInCut, - betaOutCut, - deltaBetaCut, - kZ); - } - else if (innerInnerLowerModuleSubdet == SDL::Barrel and innerOuterLowerModuleSubdet == SDL::Barrel and outerInnerLowerModuleSubdet == SDL::Barrel and outerOuterLowerModuleSubdet == SDL::Endcap) { return runTripletDefaultAlgoBBBB(acc, From 4cc041725b1a99515120855df6ec205135e7cea2 Mon Sep 17 00:00:00 2001 From: YonsiG Date: Tue, 23 Apr 2024 07:05:09 -0700 Subject: [PATCH 02/29] trim triplet BBEE geometry cuts --- SDL/Triplet.h | 86 --------------------------------------------------- 1 file changed, 86 deletions(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index 58165cea..66c2a78c 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -830,104 +830,18 @@ namespace SDL { float& deltaBetaCut, float& kZ) { bool pass = true; - bool isPS_InLo = (modulesInGPU.moduleType[innerInnerLowerModuleIndex] == SDL::PS); - bool isPS_OutLo = (modulesInGPU.moduleType[outerInnerLowerModuleIndex] == SDL::PS); float rt_InLo = mdsInGPU.anchorRt[firstMDIndex]; float rt_InOut = mdsInGPU.anchorRt[secondMDIndex]; float rt_OutLo = mdsInGPU.anchorRt[thirdMDIndex]; float z_InLo = mdsInGPU.anchorZ[firstMDIndex]; - float z_InOut = mdsInGPU.anchorZ[secondMDIndex]; float z_OutLo = mdsInGPU.anchorZ[thirdMDIndex]; - float alpha1GeV_OutLo = - alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)); - - float rtRatio_OutLoInLo = rt_OutLo / rt_InLo; // Outer segment beginning rt divided by inner segment beginning rt; - float dzDrtScale = - alpaka::math::tan(acc, alpha1GeV_OutLo) / alpha1GeV_OutLo; // The track can bend in r-z plane slightly - float zpitch_InLo = (isPS_InLo ? SDL::pixelPSZpitch : SDL::strip2SZpitch); - float zpitch_OutLo = (isPS_OutLo ? SDL::pixelPSZpitch : SDL::strip2SZpitch); - float zGeom = zpitch_InLo + zpitch_OutLo; - - zLo = z_InLo + (z_InLo - SDL::deltaZLum) * (rtRatio_OutLoInLo - 1.f) * (z_InLo > 0.f ? 1.f : dzDrtScale) - zGeom; - - // Cut #0: Preliminary (Only here in endcap case) - pass = pass and (z_InLo * z_OutLo > 0); - if (not pass) - return pass; - - float dLum = SDL::copysignf(SDL::deltaZLum, z_InLo); - bool isOutSgInnerMDPS = modulesInGPU.moduleType[outerInnerLowerModuleIndex] == SDL::PS; - float rtGeom1 = isOutSgInnerMDPS ? SDL::pixelPSZpitch : SDL::strip2SZpitch; - float zGeom1 = SDL::copysignf(zGeom, z_InLo); - rtLo = rt_InLo * (1.f + (z_OutLo - z_InLo - zGeom1) / (z_InLo + zGeom1 + dLum) / dzDrtScale) - - rtGeom1; //slope correction only on the lower end - zOut = z_OutLo; - rtOut = rt_OutLo; - - //Cut #1: rt condition - pass = pass and (rtOut >= rtLo); - if (not pass) - return pass; - - float zInForHi = z_InLo - zGeom1 - dLum; - if (zInForHi * z_InLo < 0) { - zInForHi = SDL::copysignf(0.1f, z_InLo); - } - rtHi = rt_InLo * (1.f + (z_OutLo - z_InLo + zGeom1) / zInForHi) + rtGeom1; - - //Cut #2: rt condition - pass = pass and ((rt_OutLo >= rtLo) && (rt_OutLo <= rtHi)); - if (not pass) - return pass; - float rIn = alpaka::math::sqrt(acc, z_InLo * z_InLo + rt_InLo * rt_InLo); - const float drtSDIn = rt_InOut - rt_InLo; - const float dzSDIn = z_InOut - z_InLo; - const float dr3SDIn = alpaka::math::sqrt(acc, rt_InOut * rt_InOut + z_InOut * z_InOut) - - alpaka::math::sqrt(acc, rt_InLo * rt_InLo + z_InLo * z_InLo); - - const float coshEta = dr3SDIn / drtSDIn; //direction estimate - const float dzOutInAbs = alpaka::math::abs(acc, z_OutLo - z_InLo); - const float multDzDr = dzOutInAbs * coshEta / (coshEta * coshEta - 1.f); - const float zGeom1_another = SDL::pixelPSZpitch; - kZ = (z_OutLo - z_InLo) / dzSDIn; - float drtErr = - zGeom1_another * zGeom1_another * drtSDIn * drtSDIn / dzSDIn / dzSDIn * (1.f - 2.f * kZ + 2.f * kZ * kZ); const float sdlThetaMulsF = 0.015f * alpaka::math::sqrt(acc, 0.1f + 0.2f * (rt_OutLo - rt_InLo) / 50.f) * alpaka::math::sqrt(acc, rIn / rt_InLo); - const float sdlMuls = sdlThetaMulsF * 3.f / SDL::ptCut * 4.f; //will need a better guess than x4? - drtErr += - sdlMuls * sdlMuls * multDzDr * multDzDr / 3.f * coshEta * coshEta; //sloppy: relative muls is 1/3 of total muls - drtErr = alpaka::math::sqrt(acc, drtErr); - - //Cut #3: rt-z pointed - pass = pass and ((kZ >= 0) && (rtOut >= rtLo) && (rtOut <= rtHi)); - if (not pass) - return pass; - const float sdlPVoff = 0.1f / rt_OutLo; - sdlCut = alpha1GeV_OutLo + alpaka::math::sqrt(acc, sdlMuls * sdlMuls + sdlPVoff * sdlPVoff); - - deltaPhiPos = SDL::phi_mpi_pi(acc, mdsInGPU.anchorPhi[fourthMDIndex] - mdsInGPU.anchorPhi[secondMDIndex]); - - //Cut #4: deltaPhiPos can be tighter - pass = pass and (alpaka::math::abs(acc, deltaPhiPos) <= sdlCut); - if (not pass) - return pass; - - float midPointX = 0.5f * (mdsInGPU.anchorX[firstMDIndex] + mdsInGPU.anchorX[thirdMDIndex]); - float midPointY = 0.5f * (mdsInGPU.anchorY[firstMDIndex] + mdsInGPU.anchorY[thirdMDIndex]); - float diffX = mdsInGPU.anchorX[thirdMDIndex] - mdsInGPU.anchorX[firstMDIndex]; - float diffY = mdsInGPU.anchorY[thirdMDIndex] - mdsInGPU.anchorY[firstMDIndex]; - - dPhi = SDL::deltaPhi(acc, midPointX, midPointY, diffX, diffY); - // Cut #5: deltaPhiChange - pass = pass and (alpaka::math::abs(acc, dPhi) <= sdlCut); - if (not pass) - return pass; float sdIn_alpha = __H2F(segmentsInGPU.dPhiChanges[innerSegmentIndex]); float sdIn_alpha_min = __H2F(segmentsInGPU.dPhiChangeMins[innerSegmentIndex]); From 494a288b20a4576c9de40bb168a8fb54d243f820 Mon Sep 17 00:00:00 2001 From: YonsiG Date: Tue, 23 Apr 2024 07:19:31 -0700 Subject: [PATCH 03/29] trim BBEE triplet --- SDL/Triplet.h | 67 ++++++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index 66c2a78c..af4aeee9 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -957,23 +957,8 @@ namespace SDL { const float dBetaInLum = lIn < 11 ? 0.0f : alpaka::math::abs(acc, alphaInAbsReg * SDL::deltaZLum / z_InLo); const float dBetaOutLum = lOut < 11 ? 0.0f : alpaka::math::abs(acc, alphaOutAbsReg * SDL::deltaZLum / z_OutLo); const float dBetaLum2 = (dBetaInLum + dBetaOutLum) * (dBetaInLum + dBetaOutLum); - const float sinDPhi = alpaka::math::sin(acc, dPhi); - const float dBetaRIn2 = 0; // TODO-RH - // const float dBetaROut2 = 0; // TODO-RH - float dBetaROut = 0; - if (modulesInGPU.moduleType[outerOuterLowerModuleIndex] == SDL::TwoS) { - dBetaROut = - (alpaka::math::sqrt(acc, - mdsInGPU.anchorHighEdgeX[fourthMDIndex] * mdsInGPU.anchorHighEdgeX[fourthMDIndex] + - mdsInGPU.anchorHighEdgeY[fourthMDIndex] * mdsInGPU.anchorHighEdgeY[fourthMDIndex]) - - alpaka::math::sqrt(acc, - mdsInGPU.anchorLowEdgeX[fourthMDIndex] * mdsInGPU.anchorLowEdgeX[fourthMDIndex] + - mdsInGPU.anchorLowEdgeY[fourthMDIndex] * mdsInGPU.anchorLowEdgeY[fourthMDIndex])) * - sinDPhi / dr; - } - - const float dBetaROut2 = dBetaROut * dBetaROut; +// const float dBetaROut2 = dBetaROut * dBetaROut; betaOutCut = alpaka::math::asin( acc, @@ -981,20 +966,7 @@ namespace SDL { + (0.02f / sdOut_d) + alpaka::math::sqrt(acc, dBetaLum2 + dBetaMuls * dBetaMuls); //Cut #6: The real beta cut - pass = pass and (alpaka::math::abs(acc, betaOut) < betaOutCut); - if (not pass) - return pass; - - float dBetaRes = 0.02f / alpaka::math::min(acc, sdOut_d, sdIn_d); - float dBetaCut2 = - (dBetaRes * dBetaRes * 2.0f + dBetaMuls * dBetaMuls + dBetaLum2 + dBetaRIn2 + dBetaROut2 + - 0.25f * - (alpaka::math::abs(acc, betaInRHmin - betaInRHmax) + alpaka::math::abs(acc, betaOutRHmin - betaOutRHmax)) * - (alpaka::math::abs(acc, betaInRHmin - betaInRHmax) + alpaka::math::abs(acc, betaOutRHmin - betaOutRHmax))); - float dBeta = betaIn - betaOut; - deltaBetaCut = alpaka::math::sqrt(acc, dBetaCut2); - //Cut #7: Cut on dBet - pass = pass and (dBeta * dBeta <= dBetaCut2); +// pass = pass and (alpaka::math::abs(acc, betaOut) < betaOutCut); return pass; }; @@ -1269,6 +1241,41 @@ namespace SDL { return pass; }; + template + ALPAKA_FN_ACC ALPAKA_FN_INLINE float computeRadiusFromThreeAnchorHits( + TAcc const& acc, float x1, float y1, float x2, float y2, float x3, float y3, float& g, float& f) { + float radius = 0.f; + + //writing manual code for computing radius, which obviously sucks + //TODO:Use fancy inbuilt libraries like cuBLAS or cuSOLVE for this! + //(g,f) -> center + //first anchor hit - (x1,y1), second anchor hit - (x2,y2), third anchor hit - (x3, y3) + + float denomInv = 1.0f / ((y1 - y3) * (x2 - x3) - (x1 - x3) * (y2 - y3)); + + float xy1sqr = x1 * x1 + y1 * y1; + + float xy2sqr = x2 * x2 + y2 * y2; + + float xy3sqr = x3 * x3 + y3 * y3; + + g = 0.5f * ((y3 - y2) * xy1sqr + (y1 - y3) * xy2sqr + (y2 - y1) * xy3sqr) * denomInv; + + f = 0.5f * ((x2 - x3) * xy1sqr + (x3 - x1) * xy2sqr + (x1 - x2) * xy3sqr) * denomInv; + + float c = ((x2 * y3 - x3 * y2) * xy1sqr + (x3 * y1 - x1 * y3) * xy2sqr + (x1 * y2 - x2 * y1) * xy3sqr) * denomInv; + + if (((y1 - y3) * (x2 - x3) - (x1 - x3) * (y2 - y3) == 0) || (g * g + f * f - c < 0)) { +#ifdef Warnings + printf("three collinear points or FATAL! r^2 < 0!\n"); +#endif + radius = -1.f; + } else + radius = alpaka::math::sqrt(acc, g * g + f * f - c); + + return radius; + }; + template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runTripletDefaultAlgo(TAcc const& acc, struct SDL::modules& modulesInGPU, From b39bc53c8ed1d583644c23335f31ac0e3c91b2d6 Mon Sep 17 00:00:00 2001 From: YonsiG Date: Tue, 23 Apr 2024 07:35:29 -0700 Subject: [PATCH 04/29] trim BBEE only with first beta cuts --- SDL/Triplet.h | 56 --------------------------------------------------- 1 file changed, 56 deletions(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index af4aeee9..c3067f78 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -912,62 +912,6 @@ namespace SDL { //Cut #6: first beta cut pass = pass and (alpaka::math::abs(acc, betaInRHmin) < betaInCut); - if (not pass) - return pass; - - float betaAv = 0.5f * (betaIn + betaOut); - pt_beta = dr * SDL::k2Rinv1GeVf / alpaka::math::sin(acc, betaAv); - - float lIn = 5; - float lOut = 11; - - float sdOut_dr = alpaka::math::sqrt(acc, - (mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex]) * - (mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex]) + - (mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex]) * - (mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex])); - float sdOut_d = mdsInGPU.anchorRt[fourthMDIndex] - mdsInGPU.anchorRt[thirdMDIndex]; - - runDeltaBetaIterationsT3(acc, betaIn, betaOut, betaAv, pt_beta, sdIn_dr, sdOut_dr, dr, lIn); - - const float betaInMMSF = (alpaka::math::abs(acc, betaInRHmin + betaInRHmax) > 0) - ? (2.f * betaIn / alpaka::math::abs(acc, betaInRHmin + betaInRHmax)) - : 0.; //mean value of min,max is the old betaIn - const float betaOutMMSF = (alpaka::math::abs(acc, betaOutRHmin + betaOutRHmax) > 0) - ? (2.f * betaOut / alpaka::math::abs(acc, betaOutRHmin + betaOutRHmax)) - : 0.; - betaInRHmin *= betaInMMSF; - betaInRHmax *= betaInMMSF; - betaOutRHmin *= betaOutMMSF; - betaOutRHmax *= betaOutMMSF; - - const float dBetaMuls = - sdlThetaMulsF * 4.f / - alpaka::math::min( - acc, alpaka::math::abs(acc, pt_beta), SDL::pt_betaMax); //need to confirm the range-out value of 7 GeV - - const float alphaInAbsReg = alpaka::math::max( - acc, - alpaka::math::abs(acc, sdIn_alpha), - alpaka::math::asin(acc, alpaka::math::min(acc, rt_InLo * SDL::k2Rinv1GeVf / 3.0f, SDL::sinAlphaMax))); - const float alphaOutAbsReg = alpaka::math::max( - acc, - alpaka::math::abs(acc, sdOut_alpha), - alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * SDL::k2Rinv1GeVf / 3.0f, SDL::sinAlphaMax))); - const float dBetaInLum = lIn < 11 ? 0.0f : alpaka::math::abs(acc, alphaInAbsReg * SDL::deltaZLum / z_InLo); - const float dBetaOutLum = lOut < 11 ? 0.0f : alpaka::math::abs(acc, alphaOutAbsReg * SDL::deltaZLum / z_OutLo); - const float dBetaLum2 = (dBetaInLum + dBetaOutLum) * (dBetaInLum + dBetaOutLum); - -// const float dBetaROut2 = dBetaROut * dBetaROut; - betaOutCut = - alpaka::math::asin( - acc, - alpaka::math::min(acc, dr * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)) //FIXME: need faster version - + (0.02f / sdOut_d) + alpaka::math::sqrt(acc, dBetaLum2 + dBetaMuls * dBetaMuls); - - //Cut #6: The real beta cut -// pass = pass and (alpaka::math::abs(acc, betaOut) < betaOutCut); - return pass; }; From 3bb68fa31b080b4cf60c7c76d9f11328b8345d3b Mon Sep 17 00:00:00 2001 From: YonsiG Date: Tue, 23 Apr 2024 08:24:40 -0700 Subject: [PATCH 05/29] move radius calculation from T5 to T3 --- SDL/Quintuplet.h | 41 ++++-------------------------------- SDL/Triplet.h | 55 +++++++++++++++++++++++++++++++++++++----------- 2 files changed, 47 insertions(+), 49 deletions(-) diff --git a/SDL/Quintuplet.h b/SDL/Quintuplet.h index a4259c39..93d301df 100644 --- a/SDL/Quintuplet.h +++ b/SDL/Quintuplet.h @@ -743,41 +743,6 @@ namespace SDL { return (innerOuterOuterMiniDoubletIndex == outerInnerInnerMiniDoubletIndex); }; - template - ALPAKA_FN_ACC ALPAKA_FN_INLINE float computeRadiusFromThreeAnchorHits( - TAcc const& acc, float x1, float y1, float x2, float y2, float x3, float y3, float& g, float& f) { - float radius = 0.f; - - //writing manual code for computing radius, which obviously sucks - //TODO:Use fancy inbuilt libraries like cuBLAS or cuSOLVE for this! - //(g,f) -> center - //first anchor hit - (x1,y1), second anchor hit - (x2,y2), third anchor hit - (x3, y3) - - float denomInv = 1.0f / ((y1 - y3) * (x2 - x3) - (x1 - x3) * (y2 - y3)); - - float xy1sqr = x1 * x1 + y1 * y1; - - float xy2sqr = x2 * x2 + y2 * y2; - - float xy3sqr = x3 * x3 + y3 * y3; - - g = 0.5f * ((y3 - y2) * xy1sqr + (y1 - y3) * xy2sqr + (y2 - y1) * xy3sqr) * denomInv; - - f = 0.5f * ((x2 - x3) * xy1sqr + (x3 - x1) * xy2sqr + (x1 - x2) * xy3sqr) * denomInv; - - float c = ((x2 * y3 - x3 * y2) * xy1sqr + (x3 * y1 - x1 * y3) * xy2sqr + (x1 * y2 - x2 * y1) * xy3sqr) * denomInv; - - if (((y1 - y3) * (x2 - x3) - (x1 - x3) * (y2 - y3) == 0) || (g * g + f * f - c < 0)) { -#ifdef Warnings - printf("three collinear points or FATAL! r^2 < 0!\n"); -#endif - radius = -1.f; - } else - radius = alpaka::math::sqrt(acc, g * g + f * f - c); - - return radius; - }; - template ALPAKA_FN_ACC ALPAKA_FN_INLINE void computeErrorInRadius(TAcc const& acc, float* x1Vec, @@ -2732,9 +2697,11 @@ namespace SDL { computeErrorInRadius(acc, x3Vec, y3Vec, x1Vec, y1Vec, x2Vec, y2Vec, outerRadiusMin2S, outerRadiusMax2S); float g, f; - outerRadius = computeRadiusFromThreeAnchorHits(acc, x3, y3, x4, y4, x5, y5, g, f); + outerRadius = tripletsInGPU.Circle_Radius[outerTripletIndex]; bridgeRadius = computeRadiusFromThreeAnchorHits(acc, x2, y2, x3, y3, x4, y4, g, f); - innerRadius = computeRadiusFromThreeAnchorHits(acc, x1, y1, x2, y2, x3, y3, g, f); + innerRadius = tripletsInGPU.Circle_Radius[innerTripletIndex]; + g = tripletsInGPU.Circle_CenterX[innerTripletIndex]; + f = tripletsInGPU.Circle_CenterY[innerTripletIndex]; #ifdef USE_RZCHI2 float inner_pt = 2 * k2Rinv1GeVf * innerRadius; diff --git a/SDL/Triplet.h b/SDL/Triplet.h index c3067f78..69f6957d 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -20,6 +20,9 @@ namespace SDL { FPX* betaIn; FPX* betaOut; FPX* pt_beta; + FPX* Circle_Radius; + FPX* Circle_CenterX; + FPX* Circle_CenterY; bool* partOfPT5; bool* partOfT5; bool* partOfPT3; @@ -54,6 +57,9 @@ namespace SDL { betaIn = alpaka::getPtrNative(tripletsbuf.betaIn_buf); betaOut = alpaka::getPtrNative(tripletsbuf.betaOut_buf); pt_beta = alpaka::getPtrNative(tripletsbuf.pt_beta_buf); + Circle_Radius = alpaka::getPtrNative(tripletsbuf.Circle_Radius_buf); + Circle_CenterX = alpaka::getPtrNative(tripletsbuf.Circle_CenterX_buf); + Circle_CenterY = alpaka::getPtrNative(tripletsbuf.Circle_CenterY_buf); partOfPT5 = alpaka::getPtrNative(tripletsbuf.partOfPT5_buf); partOfT5 = alpaka::getPtrNative(tripletsbuf.partOfT5_buf); partOfPT3 = alpaka::getPtrNative(tripletsbuf.partOfPT3_buf); @@ -89,6 +95,9 @@ namespace SDL { Buf betaIn_buf; Buf betaOut_buf; Buf pt_beta_buf; + Buf Circle_Radius_buf; + Buf Circle_CenterX_buf; + Buf Circle_CenterY_buf; Buf partOfPT5_buf; Buf partOfT5_buf; Buf partOfPT3_buf; @@ -123,6 +132,9 @@ namespace SDL { betaIn_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), betaOut_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), pt_beta_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), + Circle_Radius_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), + Circle_CenterX_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), + Circle_CenterY_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), partOfPT5_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), partOfT5_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), partOfPT3_buf(allocBufWrapper(devAccIn, maxTriplets, queue)) @@ -170,6 +182,9 @@ namespace SDL { float& betaIn, float& betaOut, float& pt_beta, + float& Circle_Radius, + float& Circle_CenterX, + float& Circle_CenterY, float& zLo, float& zHi, float& rtLo, @@ -195,6 +210,9 @@ namespace SDL { float& betaIn, float& betaOut, float& pt_beta, + float& Circle_Radius, + float& Circle_CenterX, + float& Circle_CenterY, unsigned int& tripletIndex) #endif { @@ -207,7 +225,9 @@ namespace SDL { tripletsInGPU.betaIn[tripletIndex] = __F2H(betaIn); tripletsInGPU.betaOut[tripletIndex] = __F2H(betaOut); tripletsInGPU.pt_beta[tripletIndex] = __F2H(pt_beta); - + tripletsInGPU.Circle_Radius[tripletIndex] = __F2H(Circle_Radius); + tripletsInGPU.Circle_CenterX[tripletIndex] = __F2H(Circle_CenterX); + tripletsInGPU.Circle_CenterY[tripletIndex] = __F2H(Circle_CenterY); tripletsInGPU.logicalLayers[tripletIndex * 3] = modulesInGPU.layers[innerInnerLowerModuleIndex] + (modulesInGPU.subdets[innerInnerLowerModuleIndex] == 4) * 6; tripletsInGPU.logicalLayers[tripletIndex * 3 + 1] = @@ -833,20 +853,10 @@ namespace SDL { float rt_InLo = mdsInGPU.anchorRt[firstMDIndex]; float rt_InOut = mdsInGPU.anchorRt[secondMDIndex]; - float rt_OutLo = mdsInGPU.anchorRt[thirdMDIndex]; - - float z_InLo = mdsInGPU.anchorZ[firstMDIndex]; - float z_OutLo = mdsInGPU.anchorZ[thirdMDIndex]; - - float rIn = alpaka::math::sqrt(acc, z_InLo * z_InLo + rt_InLo * rt_InLo); - const float sdlThetaMulsF = 0.015f * alpaka::math::sqrt(acc, 0.1f + 0.2f * (rt_OutLo - rt_InLo) / 50.f) * - alpaka::math::sqrt(acc, rIn / rt_InLo); - float sdIn_alpha = __H2F(segmentsInGPU.dPhiChanges[innerSegmentIndex]); float sdIn_alpha_min = __H2F(segmentsInGPU.dPhiChangeMins[innerSegmentIndex]); float sdIn_alpha_max = __H2F(segmentsInGPU.dPhiChangeMaxs[innerSegmentIndex]); - float sdOut_alpha = sdIn_alpha; //weird float sdOut_alphaOut = SDL::phi_mpi_pi(acc, SDL::phi(acc, @@ -1423,6 +1433,9 @@ namespace SDL { float& betaIn, float& betaOut, float& pt_beta, + float& Circle_Radius, + float& Circle_CenterX, + float& Circle_CenterY, float& zLo, float& zHi, float& rtLo, @@ -1503,6 +1516,15 @@ namespace SDL { deltaBetaCut, kZ)); + float x1 = mdsInGPU.anchorX[firstMDIndex]; + float x2 = mdsInGPU.anchorX[secondMDIndex]; + float x3 = mdsInGPU.anchorX[thirdMDIndex]; + float y1 = mdsInGPU.anchorY[firstMDIndex]; + float y2 = mdsInGPU.anchorY[secondMDIndex]; + float y3 = mdsInGPU.anchorY[thirdMDIndex]; + + Circle_Radius = computeRadiusFromThreeAnchorHits(acc, x1, y1, x2, y2, x3, y3, Circle_CenterX, Circle_CenterY); + pt_beta = Circle_Radius * SDL::k2Rinv1GeVf * 2; return pass; }; @@ -1546,7 +1568,7 @@ namespace SDL { uint16_t outerOuterLowerModuleIndex = segmentsInGPU.outerLowerModuleIndices[outerSegmentIndex]; - float zOut, rtOut, deltaPhiPos, deltaPhi, betaIn, betaOut, pt_beta; + float zOut, rtOut, deltaPhiPos, deltaPhi, betaIn, betaOut, pt_beta, Circle_Radius, Circle_CenterX, Circle_CenterY; float zLo, zHi, rtLo, rtHi, zLoPointed, zHiPointed, sdlCut, betaInCut, betaOutCut, deltaBetaCut, kZ; bool success = runTripletConstraintsAndAlgo(acc, @@ -1565,6 +1587,9 @@ namespace SDL { betaIn, betaOut, pt_beta, + Circle_Radius, + Circle_CenterX, + Circle_CenterY, zLo, zHi, rtLo, @@ -1607,6 +1632,9 @@ namespace SDL { betaIn, betaOut, pt_beta, + Circle_Radius, + Circle_CenterX, + Circle_CenterY, zLo, zHi, rtLo, @@ -1632,6 +1660,9 @@ namespace SDL { betaIn, betaOut, pt_beta, + Circle_Radius, + Circle_CenterX, + Circle_CenterY, tripletIndex); #endif } From 6c86f052a9d871124e6345b079709a12726e7dbc Mon Sep 17 00:00:00 2001 From: YonsiG Date: Tue, 23 Apr 2024 09:08:51 -0700 Subject: [PATCH 06/29] trim EEEE function except beta cuts --- SDL/Triplet.h | 98 --------------------------------------------------- 1 file changed, 98 deletions(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index 69f6957d..79a3f5f1 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -957,113 +957,15 @@ namespace SDL { float& kZ) { bool pass = true; - bool isPS_InLo = (modulesInGPU.moduleType[innerInnerLowerModuleIndex] == SDL::PS); - bool isPS_OutLo = (modulesInGPU.moduleType[outerInnerLowerModuleIndex] == SDL::PS); - float rt_InLo = mdsInGPU.anchorRt[firstMDIndex]; float rt_InOut = mdsInGPU.anchorRt[secondMDIndex]; float rt_OutLo = mdsInGPU.anchorRt[thirdMDIndex]; float z_InLo = mdsInGPU.anchorZ[firstMDIndex]; - float z_InOut = mdsInGPU.anchorZ[secondMDIndex]; float z_OutLo = mdsInGPU.anchorZ[thirdMDIndex]; - float alpha1GeV_OutLo = - alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)); - - float rtRatio_OutLoInLo = rt_OutLo / rt_InLo; // Outer segment beginning rt divided by inner segment beginning rt; - float dzDrtScale = - alpaka::math::tan(acc, alpha1GeV_OutLo) / alpha1GeV_OutLo; // The track can bend in r-z plane slightly - float zpitch_InLo = (isPS_InLo ? SDL::pixelPSZpitch : SDL::strip2SZpitch); - float zpitch_OutLo = (isPS_OutLo ? SDL::pixelPSZpitch : SDL::strip2SZpitch); - float zGeom = zpitch_InLo + zpitch_OutLo; - - zLo = z_InLo + (z_InLo - SDL::deltaZLum) * (rtRatio_OutLoInLo - 1.f) * (z_InLo > 0.f ? 1.f : dzDrtScale) - - zGeom; //slope-correction only on outer end - - // Cut #0: Preliminary (Only here in endcap case) - pass = pass and ((z_InLo * z_OutLo) > 0); - if (not pass) - return pass; - - float dLum = SDL::copysignf(SDL::deltaZLum, z_InLo); - bool isOutSgInnerMDPS = modulesInGPU.moduleType[outerInnerLowerModuleIndex] == SDL::PS; - bool isInSgInnerMDPS = modulesInGPU.moduleType[innerInnerLowerModuleIndex] == SDL::PS; - - float rtGeom = (isInSgInnerMDPS and isOutSgInnerMDPS) ? 2.f * SDL::pixelPSZpitch - : (isInSgInnerMDPS or isOutSgInnerMDPS) ? SDL::pixelPSZpitch + SDL::strip2SZpitch - : 2.f * SDL::strip2SZpitch; - - float dz = z_OutLo - z_InLo; - rtLo = rt_InLo * (1.f + dz / (z_InLo + dLum) / dzDrtScale) - rtGeom; //slope correction only on the lower end - - zOut = z_OutLo; - rtOut = rt_OutLo; - - //Cut #1: rt condition - - rtHi = rt_InLo * (1.f + dz / (z_InLo - dLum)) + rtGeom; - - pass = pass and ((rtOut >= rtLo) && (rtOut <= rtHi)); - if (not pass) - return pass; - - bool isInSgOuterMDPS = modulesInGPU.moduleType[innerOuterLowerModuleIndex] == SDL::PS; - - const float drtSDIn = rt_InOut - rt_InLo; - const float dzSDIn = z_InOut - z_InLo; - const float dr3SDIn = alpaka::math::sqrt(acc, rt_InOut * rt_InOut + z_InOut * z_InOut) - - alpaka::math::sqrt(acc, rt_InLo * rt_InLo + z_InLo * z_InLo); - float coshEta = dr3SDIn / drtSDIn; //direction estimate - float dzOutInAbs = alpaka::math::abs(acc, z_OutLo - z_InLo); - float multDzDr = dzOutInAbs * coshEta / (coshEta * coshEta - 1.f); - - kZ = (z_OutLo - z_InLo) / dzSDIn; float sdlThetaMulsF = 0.015f * alpaka::math::sqrt(acc, 0.1f + 0.2f * (rt_OutLo - rt_InLo) / 50.f); - float sdlMuls = sdlThetaMulsF * 3.f / SDL::ptCut * 4.f; //will need a better guess than x4? - - float drtErr = alpaka::math::sqrt( - acc, - SDL::pixelPSZpitch * SDL::pixelPSZpitch * 2.f / (dzSDIn * dzSDIn) * (dzOutInAbs * dzOutInAbs) + - sdlMuls * sdlMuls * multDzDr * multDzDr / 3.f * coshEta * coshEta); - - float drtMean = drtSDIn * dzOutInAbs / alpaka::math::abs(acc, dzSDIn); - float rtWindow = drtErr + rtGeom; - float rtLo_point = rt_InLo + drtMean / dzDrtScale - rtWindow; - float rtHi_point = rt_InLo + drtMean + rtWindow; - - // Cut #3: rt-z pointed - // https://github.com/slava77/cms-tkph2-ntuple/blob/superDoubletLinked-91X-noMock/doubletAnalysis.C#L3765 - - if (isInSgInnerMDPS and isInSgOuterMDPS) // If both PS then we can point - { - pass = pass and (kZ >= 0 and rtOut >= rtLo_point and rtOut <= rtHi_point); - if (not pass) - return pass; - } - - float sdlPVoff = 0.1f / rtOut; - sdlCut = alpha1GeV_OutLo + alpaka::math::sqrt(acc, sdlMuls * sdlMuls + sdlPVoff * sdlPVoff); - - deltaPhiPos = SDL::phi_mpi_pi(acc, mdsInGPU.anchorPhi[fourthMDIndex] - mdsInGPU.anchorPhi[secondMDIndex]); - - pass = pass and (alpaka::math::abs(acc, deltaPhiPos) <= sdlCut); - if (not pass) - return pass; - - float midPointX = 0.5f * (mdsInGPU.anchorX[firstMDIndex] + mdsInGPU.anchorX[thirdMDIndex]); - float midPointY = 0.5f * (mdsInGPU.anchorY[firstMDIndex] + mdsInGPU.anchorY[thirdMDIndex]); - float diffX = mdsInGPU.anchorX[thirdMDIndex] - mdsInGPU.anchorX[firstMDIndex]; - float diffY = mdsInGPU.anchorY[thirdMDIndex] - mdsInGPU.anchorY[firstMDIndex]; - - dPhi = SDL::deltaPhi(acc, midPointX, midPointY, diffX, diffY); - - // Cut #5: deltaPhiChange - pass = pass and ((alpaka::math::abs(acc, dPhi) <= sdlCut)); - if (not pass) - return pass; - float sdIn_alpha = __H2F(segmentsInGPU.dPhiChanges[innerSegmentIndex]); float sdOut_alpha = sdIn_alpha; //weird float sdOut_dPhiPos = SDL::phi_mpi_pi(acc, mdsInGPU.anchorPhi[fourthMDIndex] - mdsInGPU.anchorPhi[thirdMDIndex]); From e1e687bd7a2e471875f70937c773dbf862c605c9 Mon Sep 17 00:00:00 2001 From: YonsiG Date: Mon, 29 Apr 2024 06:22:56 -0700 Subject: [PATCH 07/29] disable T3 EEEE cuts --- SDL/Triplet.h | 81 +-------------------------------------------------- 1 file changed, 1 insertion(+), 80 deletions(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index 79a3f5f1..174dc266 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -959,15 +959,7 @@ namespace SDL { float rt_InLo = mdsInGPU.anchorRt[firstMDIndex]; float rt_InOut = mdsInGPU.anchorRt[secondMDIndex]; - float rt_OutLo = mdsInGPU.anchorRt[thirdMDIndex]; - - float z_InLo = mdsInGPU.anchorZ[firstMDIndex]; - float z_OutLo = mdsInGPU.anchorZ[thirdMDIndex]; - - float sdlThetaMulsF = 0.015f * alpaka::math::sqrt(acc, 0.1f + 0.2f * (rt_OutLo - rt_InLo) / 50.f); - float sdIn_alpha = __H2F(segmentsInGPU.dPhiChanges[innerSegmentIndex]); - float sdOut_alpha = sdIn_alpha; //weird float sdOut_dPhiPos = SDL::phi_mpi_pi(acc, mdsInGPU.anchorPhi[fourthMDIndex] - mdsInGPU.anchorPhi[thirdMDIndex]); float sdOut_dPhiChange = __H2F(segmentsInGPU.dPhiChanges[outerSegmentIndex]); @@ -1022,79 +1014,8 @@ namespace SDL { //Cut #6: first beta cut pass = pass and (alpaka::math::abs(acc, betaInRHmin) < betaInCut); - if (not pass) - return pass; - - float betaAv = 0.5f * (betaIn + betaOut); - pt_beta = dr * SDL::k2Rinv1GeVf / alpaka::math::sin(acc, betaAv); - - int lIn = 11; //endcap - int lOut = 13; //endcap - - float sdOut_dr = alpaka::math::sqrt(acc, - (mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex]) * - (mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex]) + - (mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex]) * - (mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex])); - float sdOut_d = mdsInGPU.anchorRt[fourthMDIndex] - mdsInGPU.anchorRt[thirdMDIndex]; - - runDeltaBetaIterationsT3(acc, betaIn, betaOut, betaAv, pt_beta, sdIn_dr, sdOut_dr, dr, lIn); - - const float betaInMMSF = (alpaka::math::abs(acc, betaInRHmin + betaInRHmax) > 0) - ? (2.f * betaIn / alpaka::math::abs(acc, betaInRHmin + betaInRHmax)) - : 0.; //mean value of min,max is the old betaIn - const float betaOutMMSF = (alpaka::math::abs(acc, betaOutRHmin + betaOutRHmax) > 0) - ? (2.f * betaOut / alpaka::math::abs(acc, betaOutRHmin + betaOutRHmax)) - : 0.; - betaInRHmin *= betaInMMSF; - betaInRHmax *= betaInMMSF; - betaOutRHmin *= betaOutMMSF; - betaOutRHmax *= betaOutMMSF; - - const float dBetaMuls = - sdlThetaMulsF * 4.f / - alpaka::math::min( - acc, alpaka::math::abs(acc, pt_beta), SDL::pt_betaMax); //need to confirm the range-out value of 7 GeV - - const float alphaInAbsReg = alpaka::math::max( - acc, - alpaka::math::abs(acc, sdIn_alpha), - alpaka::math::asin(acc, alpaka::math::min(acc, rt_InLo * SDL::k2Rinv1GeVf / 3.0f, SDL::sinAlphaMax))); - const float alphaOutAbsReg = alpaka::math::max( - acc, - alpaka::math::abs(acc, sdOut_alpha), - alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * SDL::k2Rinv1GeVf / 3.0f, SDL::sinAlphaMax))); - const float dBetaInLum = lIn < 11 ? 0.0f : alpaka::math::abs(acc, alphaInAbsReg * SDL::deltaZLum / z_InLo); - const float dBetaOutLum = lOut < 11 ? 0.0f : alpaka::math::abs(acc, alphaOutAbsReg * SDL::deltaZLum / z_OutLo); - const float dBetaLum2 = (dBetaInLum + dBetaOutLum) * (dBetaInLum + dBetaOutLum); - - const float dBetaRIn2 = 0; // TODO-RH - // const float dBetaROut2 = 0; // TODO-RH - float dBetaROut2 = 0; //TODO-RH - betaOutCut = - alpaka::math::asin( - acc, - alpaka::math::min(acc, dr * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)) //FIXME: need faster version - + (0.02f / sdOut_d) + alpaka::math::sqrt(acc, dBetaLum2 + dBetaMuls * dBetaMuls); - - //Cut #6: The real beta cut - pass = pass and (alpaka::math::abs(acc, betaOut) < betaOutCut); - if (not pass) - return pass; - - float dBetaRes = 0.02f / alpaka::math::min(acc, sdOut_d, sdIn_d); - float dBetaCut2 = - (dBetaRes * dBetaRes * 2.0f + dBetaMuls * dBetaMuls + dBetaLum2 + dBetaRIn2 + dBetaROut2 + - 0.25f * - (alpaka::math::abs(acc, betaInRHmin - betaInRHmax) + alpaka::math::abs(acc, betaOutRHmin - betaOutRHmax)) * - (alpaka::math::abs(acc, betaInRHmin - betaInRHmax) + alpaka::math::abs(acc, betaOutRHmin - betaOutRHmax))); - float dBeta = betaIn - betaOut; - //Cut #7: Cut on dBeta - deltaBetaCut = alpaka::math::sqrt(acc, dBetaCut2); - - pass = pass and (dBeta * dBeta <= dBetaCut2); - return pass; + }; template From edfa6fa959ec7fc3cb1573ca843364fdb99dd558 Mon Sep 17 00:00:00 2001 From: YonsiG Date: Mon, 29 Apr 2024 06:44:53 -0700 Subject: [PATCH 08/29] remove triplet radius calculation in pT3 --- SDL/PixelTriplet.h | 38 +++-------------------------------- code/core/write_sdl_ntuple.cc | 27 ------------------------- 2 files changed, 3 insertions(+), 62 deletions(-) diff --git a/SDL/PixelTriplet.h b/SDL/PixelTriplet.h index 087762ee..e7a76fca 100644 --- a/SDL/PixelTriplet.h +++ b/SDL/PixelTriplet.h @@ -196,40 +196,6 @@ namespace SDL { pixelTripletsInGPU.rzChiSquared[pixelTripletIndex] = rzChiSquared; }; - template - ALPAKA_FN_ACC ALPAKA_FN_INLINE float computeRadiusFromThreeAnchorHitspT3( - TAcc const& acc, const float* xs, const float* ys, float& g, float& f) { - float radius = 0; - - //writing manual code for computing radius, which obviously sucks - //TODO:Use fancy inbuilt libraries like cuBLAS or cuSOLVE for this! - //(g,f) -> center - //first anchor hit - (x1,y1), second anchor hit - (x2,y2), third anchor hit - (x3, y3) - - float denomInv = 1.f / ((ys[0] - ys[2]) * (xs[1] - xs[2]) - (xs[0] - xs[2]) * (ys[1] - ys[2])); - - float xy1sqr = xs[0] * xs[0] + ys[0] * ys[0]; - float xy2sqr = xs[1] * xs[1] + ys[1] * ys[1]; - float xy3sqr = xs[2] * xs[2] + ys[2] * ys[2]; - - g = 0.5f * ((ys[2] - ys[1]) * xy1sqr + (ys[0] - ys[2]) * xy2sqr + (ys[1] - ys[0]) * xy3sqr) * denomInv; - f = 0.5f * ((xs[1] - xs[2]) * xy1sqr + (xs[2] - xs[0]) * xy2sqr + (xs[0] - xs[1]) * xy3sqr) * denomInv; - - float c = ((xs[1] * ys[2] - xs[2] * ys[1]) * xy1sqr + (xs[2] * ys[0] - xs[0] * ys[2]) * xy2sqr + - (xs[0] * ys[1] - xs[1] * ys[0]) * xy3sqr) * - denomInv; - - if (((ys[0] - ys[2]) * (xs[1] - xs[2]) - (xs[0] - xs[2]) * (ys[1] - ys[2]) == 0) || (g * g + f * f - c < 0)) { -#ifdef Warnings - printf("three collinear points or FATAL! r^2 < 0!\n"); -#endif - radius = -1; - } else - radius = alpaka::math::sqrt(acc, g * g + f * f - c); - - return radius; - }; - template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runPixelTrackletDefaultAlgopT3(TAcc const& acc, struct SDL::modules& modulesInGPU, @@ -976,7 +942,9 @@ namespace SDL { float ys[3] = {mdsInGPU.anchorY[firstMDIndex], mdsInGPU.anchorY[secondMDIndex], mdsInGPU.anchorY[thirdMDIndex]}; float g, f; - tripletRadius = computeRadiusFromThreeAnchorHitspT3(acc, xs, ys, g, f); + tripletRadius = tripletsInGPU.Circle_Radius[tripletIndex]; + g = tripletsInGPU.Circle_CenterX[tripletIndex]; + f = tripletsInGPU.Circle_CenterY[tripletIndex]; pass = pass and passRadiusCriterion(acc, modulesInGPU, diff --git a/code/core/write_sdl_ntuple.cc b/code/core/write_sdl_ntuple.cc index 1ca4c242..327a5995 100644 --- a/code/core/write_sdl_ntuple.cc +++ b/code/core/write_sdl_ntuple.cc @@ -994,33 +994,6 @@ std::tuple, vector> pars return {pt, eta, phi, hit_idx, hit_type}; } -//________________________________________________________________________________________________________________________________ -float computeRadiusFromThreeAnchorHits(float x1, float y1, float x2, float y2, float x3, float y3, float& g, float& f) -{ - float radius = 0; - if ((y1 - y3) * (x2 - x3) - (x1 - x3) * (y2 - y3) == 0) - { - return -1; // WTF man three collinear points! - } - - float denom = ((y1 - y3) * (x2 - x3) - (x1 - x3) * (y2 - y3)); - - g = 0.5 * ((y3 - y2) * (x1 * x1 + y1 * y1) + (y1 - y3) * (x2 * x2 + y2 * y2) + (y2 - y1) * (x3 * x3 + y3 * y3)) / denom; - - f = 0.5 * ((x2 - x3) * (x1 * x1 + y1 * y1) + (x3 - x1) * (x2 * x2 + y2 * y2) + (x1 - x2) * (x3 * x3 + y3 * y3)) / denom; - - float c = ((x2 * y3 - x3 * y2) * (x1 * x1 + y1 * y1) + (x3 * y1 - x1 * y3) * (x2 * x2 + y2 * y2) + (x1 * y2 - x2 * y1) * (x3 * x3 + y3 * y3)) / denom; - - if (g * g + f * f - c < 0) - { - std::cout << "FATAL! r^2 < 0!" << std::endl; - return -1; - } - - radius = sqrtf(g * g + f * f - c); - return radius; -} - //________________________________________________________________________________________________________________________________ void printHitMultiplicities(SDL::Event* event) { From dbe19c30f61053c3bf3bdc102258021765490dc0 Mon Sep 17 00:00:00 2001 From: YonsiG Date: Mon, 29 Apr 2024 07:44:44 -0700 Subject: [PATCH 09/29] remove the betaOut and betaIteration variables --- SDL/Event.cc | 4 - SDL/PixelTriplet.h | 6 +- SDL/Quintuplet.h | 8 +- SDL/Triplet.h | 258 +++++++-------------------------------------- 4 files changed, 48 insertions(+), 228 deletions(-) diff --git a/SDL/Event.cc b/SDL/Event.cc index 7372d7b6..8a1800fe 100644 --- a/SDL/Event.cc +++ b/SDL/Event.cc @@ -1668,8 +1668,6 @@ SDL::tripletsBuffer* SDL::Event::getTriplets() { alpaka::memcpy(queue, tripletsInCPU->zHiPointed_buf, tripletsBuffers->zHiPointed_buf, nMemHost); alpaka::memcpy(queue, tripletsInCPU->sdlCut_buf, tripletsBuffers->sdlCut_buf, nMemHost); alpaka::memcpy(queue, tripletsInCPU->betaInCut_buf, tripletsBuffers->betaInCut_buf, nMemHost); - alpaka::memcpy(queue, tripletsInCPU->betaOutCut_buf, tripletsBuffers->betaOutCut_buf, nMemHost); - alpaka::memcpy(queue, tripletsInCPU->deltaBetaCut_buf, tripletsBuffers->deltaBetaCut_buf, nMemHost); alpaka::memcpy(queue, tripletsInCPU->rtLo_buf, tripletsBuffers->rtLo_buf, nMemHost); alpaka::memcpy(queue, tripletsInCPU->rtHi_buf, tripletsBuffers->rtHi_buf, nMemHost); alpaka::memcpy(queue, tripletsInCPU->kZ_buf, tripletsBuffers->kZ_buf, nMemHost); @@ -1678,8 +1676,6 @@ SDL::tripletsBuffer* SDL::Event::getTriplets() { alpaka::memcpy(queue, tripletsInCPU->logicalLayers_buf, tripletsBuffers->logicalLayers_buf, 3 * nMemHost); alpaka::memcpy(queue, tripletsInCPU->segmentIndices_buf, tripletsBuffers->segmentIndices_buf, 2 * nMemHost); alpaka::memcpy(queue, tripletsInCPU->betaIn_buf, tripletsBuffers->betaIn_buf, nMemHost); - alpaka::memcpy(queue, tripletsInCPU->betaOut_buf, tripletsBuffers->betaOut_buf, nMemHost); - alpaka::memcpy(queue, tripletsInCPU->pt_beta_buf, tripletsBuffers->pt_beta_buf, nMemHost); alpaka::memcpy(queue, tripletsInCPU->nTriplets_buf, tripletsBuffers->nTriplets_buf); alpaka::memcpy(queue, tripletsInCPU->totOccupancyTriplets_buf, tripletsBuffers->totOccupancyTriplets_buf); alpaka::wait(queue); diff --git a/SDL/PixelTriplet.h b/SDL/PixelTriplet.h index e7a76fca..42c3afee 100644 --- a/SDL/PixelTriplet.h +++ b/SDL/PixelTriplet.h @@ -942,9 +942,9 @@ namespace SDL { float ys[3] = {mdsInGPU.anchorY[firstMDIndex], mdsInGPU.anchorY[secondMDIndex], mdsInGPU.anchorY[thirdMDIndex]}; float g, f; - tripletRadius = tripletsInGPU.Circle_Radius[tripletIndex]; - g = tripletsInGPU.Circle_CenterX[tripletIndex]; - f = tripletsInGPU.Circle_CenterY[tripletIndex]; + tripletRadius = tripletsInGPU.circleRadius[tripletIndex]; + g = tripletsInGPU.circleCenterX[tripletIndex]; + f = tripletsInGPU.circleCenterY[tripletIndex]; pass = pass and passRadiusCriterion(acc, modulesInGPU, diff --git a/SDL/Quintuplet.h b/SDL/Quintuplet.h index 93d301df..b9aef5b1 100644 --- a/SDL/Quintuplet.h +++ b/SDL/Quintuplet.h @@ -2697,11 +2697,11 @@ namespace SDL { computeErrorInRadius(acc, x3Vec, y3Vec, x1Vec, y1Vec, x2Vec, y2Vec, outerRadiusMin2S, outerRadiusMax2S); float g, f; - outerRadius = tripletsInGPU.Circle_Radius[outerTripletIndex]; + outerRadius = tripletsInGPU.circleRadius[outerTripletIndex]; bridgeRadius = computeRadiusFromThreeAnchorHits(acc, x2, y2, x3, y3, x4, y4, g, f); - innerRadius = tripletsInGPU.Circle_Radius[innerTripletIndex]; - g = tripletsInGPU.Circle_CenterX[innerTripletIndex]; - f = tripletsInGPU.Circle_CenterY[innerTripletIndex]; + innerRadius = tripletsInGPU.circleRadius[innerTripletIndex]; + g = tripletsInGPU.circleCenterX[innerTripletIndex]; + f = tripletsInGPU.circleCenterY[innerTripletIndex]; #ifdef USE_RZCHI2 float inner_pt = 2 * k2Rinv1GeVf * innerRadius; diff --git a/SDL/Triplet.h b/SDL/Triplet.h index 174dc266..c6f45af7 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -16,13 +16,10 @@ namespace SDL { unsigned int* nMemoryLocations; uint8_t* logicalLayers; unsigned int* hitIndices; - //delta beta = betaIn - betaOut FPX* betaIn; - FPX* betaOut; - FPX* pt_beta; - FPX* Circle_Radius; - FPX* Circle_CenterX; - FPX* Circle_CenterY; + FPX* circleRadius; + FPX* circleCenterX; + FPX* circleCenterY; bool* partOfPT5; bool* partOfT5; bool* partOfPT3; @@ -39,8 +36,6 @@ namespace SDL { float* zHiPointed; float* sdlCut; float* betaInCut; - float* betaOutCut; - float* deltaBetaCut; float* rtLo; float* rtHi; float* kZ; @@ -55,11 +50,9 @@ namespace SDL { logicalLayers = alpaka::getPtrNative(tripletsbuf.logicalLayers_buf); hitIndices = alpaka::getPtrNative(tripletsbuf.hitIndices_buf); betaIn = alpaka::getPtrNative(tripletsbuf.betaIn_buf); - betaOut = alpaka::getPtrNative(tripletsbuf.betaOut_buf); - pt_beta = alpaka::getPtrNative(tripletsbuf.pt_beta_buf); - Circle_Radius = alpaka::getPtrNative(tripletsbuf.Circle_Radius_buf); - Circle_CenterX = alpaka::getPtrNative(tripletsbuf.Circle_CenterX_buf); - Circle_CenterY = alpaka::getPtrNative(tripletsbuf.Circle_CenterY_buf); + circleRadius = alpaka::getPtrNative(tripletsbuf.circleRadius_buf); + circleCenterX = alpaka::getPtrNative(tripletsbuf.circleCenterX_buf); + circleCenterY = alpaka::getPtrNative(tripletsbuf.circleCenterY_buf); partOfPT5 = alpaka::getPtrNative(tripletsbuf.partOfPT5_buf); partOfT5 = alpaka::getPtrNative(tripletsbuf.partOfT5_buf); partOfPT3 = alpaka::getPtrNative(tripletsbuf.partOfPT3_buf); @@ -74,8 +67,6 @@ namespace SDL { zHiPointed = alpaka::getPtrNative(tripletsbuf.zHiPointed_buf); sdlCut = alpaka::getPtrNative(tripletsbuf.sdlCut_buf); betaInCut = alpaka::getPtrNative(tripletsbuf.betaInCut_buf); - betaOutCut = alpaka::getPtrNative(tripletsbuf.betaOutCut_buf); - deltaBetaCut = alpaka::getPtrNative(tripletsbuf.deltaBetaCut_buf); rtLo = alpaka::getPtrNative(tripletsbuf.rtLo_buf); rtHi = alpaka::getPtrNative(tripletsbuf.rtHi_buf); kZ = alpaka::getPtrNative(tripletsbuf.kZ_buf); @@ -93,11 +84,9 @@ namespace SDL { Buf logicalLayers_buf; Buf hitIndices_buf; Buf betaIn_buf; - Buf betaOut_buf; - Buf pt_beta_buf; - Buf Circle_Radius_buf; - Buf Circle_CenterX_buf; - Buf Circle_CenterY_buf; + Buf circleRadius_buf; + Buf circleCenterX_buf; + Buf circleCenterY_buf; Buf partOfPT5_buf; Buf partOfT5_buf; Buf partOfPT3_buf; @@ -113,8 +102,6 @@ namespace SDL { Buf zHiPointed_buf; Buf sdlCut_buf; Buf betaInCut_buf; - Buf betaOutCut_buf; - Buf deltaBetaCut_buf; Buf rtLo_buf; Buf rtHi_buf; Buf kZ_buf; @@ -130,11 +117,9 @@ namespace SDL { logicalLayers_buf(allocBufWrapper(devAccIn, maxTriplets * 3, queue)), hitIndices_buf(allocBufWrapper(devAccIn, maxTriplets * 6, queue)), betaIn_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - betaOut_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - pt_beta_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - Circle_Radius_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - Circle_CenterX_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - Circle_CenterY_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), + circleRadius_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), + circleCenterX_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), + circleCenterY_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), partOfPT5_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), partOfT5_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), partOfPT3_buf(allocBufWrapper(devAccIn, maxTriplets, queue)) @@ -150,8 +135,6 @@ namespace SDL { zHiPointed_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), sdlCut_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), betaInCut_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - betaOutCut_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - deltaBetaCut_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), rtLo_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), rtHi_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), kZ_buf(allocBufWrapper(devAccIn, maxTriplets, queue)) @@ -180,11 +163,9 @@ namespace SDL { float& deltaPhiPos, float& deltaPhi, float& betaIn, - float& betaOut, - float& pt_beta, - float& Circle_Radius, - float& Circle_CenterX, - float& Circle_CenterY, + float& circleRadius, + float& circleCenterX, + float& circleCenterY, float& zLo, float& zHi, float& rtLo, @@ -193,8 +174,6 @@ namespace SDL { float& zHiPointed, float& sdlCut, float& betaInCut, - float& betaOutCut, - float& deltaBetaCut, float& kZ, unsigned int& tripletIndex) #else @@ -208,11 +187,9 @@ namespace SDL { uint16_t& middleLowerModuleIndex, uint16_t& outerOuterLowerModuleIndex, float& betaIn, - float& betaOut, - float& pt_beta, - float& Circle_Radius, - float& Circle_CenterX, - float& Circle_CenterY, + float& circleRadius, + float& circleCenterX, + float& circleCenterY, unsigned int& tripletIndex) #endif { @@ -223,11 +200,9 @@ namespace SDL { tripletsInGPU.lowerModuleIndices[tripletIndex * 3 + 2] = outerOuterLowerModuleIndex; tripletsInGPU.betaIn[tripletIndex] = __F2H(betaIn); - tripletsInGPU.betaOut[tripletIndex] = __F2H(betaOut); - tripletsInGPU.pt_beta[tripletIndex] = __F2H(pt_beta); - tripletsInGPU.Circle_Radius[tripletIndex] = __F2H(Circle_Radius); - tripletsInGPU.Circle_CenterX[tripletIndex] = __F2H(Circle_CenterX); - tripletsInGPU.Circle_CenterY[tripletIndex] = __F2H(Circle_CenterY); + tripletsInGPU.circleRadius[tripletIndex] = __F2H(circleRadius); + tripletsInGPU.circleCenterX[tripletIndex] = __F2H(circleCenterX); + tripletsInGPU.circleCenterY[tripletIndex] = __F2H(circleCenterY); tripletsInGPU.logicalLayers[tripletIndex * 3] = modulesInGPU.layers[innerInnerLowerModuleIndex] + (modulesInGPU.subdets[innerInnerLowerModuleIndex] == 4) * 6; tripletsInGPU.logicalLayers[tripletIndex * 3 + 1] = @@ -258,8 +233,6 @@ namespace SDL { tripletsInGPU.zHiPointed[tripletIndex] = zHiPointed; tripletsInGPU.sdlCut[tripletIndex] = sdlCut; tripletsInGPU.betaInCut[tripletIndex] = betaInCut; - tripletsInGPU.betaOutCut[tripletIndex] = betaOutCut; - tripletsInGPU.deltaBetaCut[tripletIndex] = deltaBetaCut; tripletsInGPU.kZ[tripletIndex] = kZ; #endif }; @@ -657,104 +630,6 @@ namespace SDL { return false; // failsafe }; - template - ALPAKA_FN_ACC ALPAKA_FN_INLINE void runDeltaBetaIterationsT3(TAcc const& acc, - float& betaIn, - float& betaOut, - float& betaAv, - float& pt_beta, - float sdIn_dr, - float sdOut_dr, - float dr, - float lIn) { - if (lIn == 0) { - betaOut += copysign( - alpaka::math::asin( - acc, - alpaka::math::min(acc, sdOut_dr * SDL::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), SDL::sinAlphaMax)), - betaOut); - return; - } - - if (betaIn * betaOut > 0.f and - (alpaka::math::abs(acc, pt_beta) < 4.f * SDL::pt_betaMax or - (lIn >= 11 and alpaka::math::abs(acc, pt_beta) < - 8.f * SDL::pt_betaMax))) //and the pt_beta is well-defined; less strict for endcap-endcap - { - const float betaInUpd = - betaIn + - SDL::copysignf(alpaka::math::asin( - acc, - alpaka::math::min( - acc, sdIn_dr * SDL::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), SDL::sinAlphaMax)), - betaIn); //FIXME: need a faster version - const float betaOutUpd = - betaOut + - SDL::copysignf(alpaka::math::asin( - acc, - alpaka::math::min( - acc, sdOut_dr * SDL::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), SDL::sinAlphaMax)), - betaOut); //FIXME: need a faster version - betaAv = 0.5f * (betaInUpd + betaOutUpd); - - //1st update - //pt_beta = dr * k2Rinv1GeVf / alpaka::math::sin(acc, betaAv); //get a better pt estimate - const float pt_beta_inv = - 1.f / alpaka::math::abs(acc, dr * k2Rinv1GeVf / alpaka::math::sin(acc, betaAv)); //get a better pt estimate - - betaIn += SDL::copysignf( - alpaka::math::asin(acc, alpaka::math::min(acc, sdIn_dr * SDL::k2Rinv1GeVf * pt_beta_inv, SDL::sinAlphaMax)), - betaIn); //FIXME: need a faster version - betaOut += SDL::copysignf( - alpaka::math::asin(acc, alpaka::math::min(acc, sdOut_dr * SDL::k2Rinv1GeVf * pt_beta_inv, SDL::sinAlphaMax)), - betaOut); //FIXME: need a faster version - //update the av and pt - betaAv = 0.5f * (betaIn + betaOut); - //2nd update - pt_beta = dr * SDL::k2Rinv1GeVf / alpaka::math::sin(acc, betaAv); //get a better pt estimate - } else if (lIn < 11 && alpaka::math::abs(acc, betaOut) < 0.2f * alpaka::math::abs(acc, betaIn) && - alpaka::math::abs(acc, pt_beta) < 12.f * SDL::pt_betaMax) //use betaIn sign as ref - { - const float pt_betaIn = dr * k2Rinv1GeVf / alpaka::math::sin(acc, betaIn); - - const float betaInUpd = - betaIn + SDL::copysignf( - alpaka::math::asin( - acc, - alpaka::math::min( - acc, sdIn_dr * SDL::k2Rinv1GeVf / alpaka::math::abs(acc, pt_betaIn), SDL::sinAlphaMax)), - betaIn); //FIXME: need a faster version - const float betaOutUpd = - betaOut + - SDL::copysignf( - alpaka::math::asin( - acc, - alpaka::math::min( - acc, sdOut_dr * SDL::k2Rinv1GeVf / alpaka::math::abs(acc, pt_betaIn), SDL::sinAlphaMax)), - betaIn); //FIXME: need a faster version - betaAv = (alpaka::math::abs(acc, betaOut) > 0.2f * alpaka::math::abs(acc, betaIn)) - ? (0.5f * (betaInUpd + betaOutUpd)) - : betaInUpd; - - //1st update - pt_beta = dr * SDL::k2Rinv1GeVf / alpaka::math::sin(acc, betaAv); //get a better pt estimate - betaIn += SDL::copysignf( - alpaka::math::asin( - acc, - alpaka::math::min(acc, sdIn_dr * SDL::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), SDL::sinAlphaMax)), - betaIn); //FIXME: need a faster version - betaOut += SDL::copysignf( - alpaka::math::asin( - acc, - alpaka::math::min(acc, sdOut_dr * SDL::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), SDL::sinAlphaMax)), - betaIn); //FIXME: need a faster version - //update the av and pt - betaAv = 0.5f * (betaIn + betaOut); - //2nd update - pt_beta = dr * SDL::k2Rinv1GeVf / alpaka::math::sin(acc, betaAv); //get a better pt estimate - } - }; - template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runTripletDefaultAlgoBBBB(TAcc const& acc, struct SDL::modules& modulesInGPU, @@ -775,16 +650,12 @@ namespace SDL { float& deltaPhiPos, float& dPhi, float& betaIn, - float& betaOut, - float& pt_beta, float& zLo, float& zHi, float& zLoPointed, float& zHiPointed, float& sdlCut, - float& betaInCut, - float& betaOutCut, - float& deltaBetaCut) { + float& betaInCut) { bool pass = true; float rt_InLo = mdsInGPU.anchorRt[firstMDIndex]; float rt_InOut = mdsInGPU.anchorRt[secondMDIndex]; @@ -839,15 +710,11 @@ namespace SDL { float& deltaPhiPos, float& dPhi, float& betaIn, - float& betaOut, - float& pt_beta, float& zLo, float& rtLo, float& rtHi, float& sdlCut, float& betaInCut, - float& betaOutCut, - float& deltaBetaCut, float& kZ) { bool pass = true; @@ -876,7 +743,7 @@ namespace SDL { float betaInRHmin = betaIn; float betaInRHmax = betaIn; - betaOut = + float betaOut = -sdOut_alphaOut + SDL::phi_mpi_pi(acc, SDL::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[fourthMDIndex]); float betaOutRHmin = betaOut; @@ -945,15 +812,11 @@ namespace SDL { float& deltaPhiPos, float& dPhi, float& betaIn, - float& betaOut, - float& pt_beta, float& zLo, float& rtLo, float& rtHi, float& sdlCut, float& betaInCut, - float& betaOutCut, - float& deltaBetaCut, float& kZ) { bool pass = true; @@ -980,7 +843,7 @@ namespace SDL { float betaInRHmin = betaIn + sdIn_alphaRHmin - sdIn_alpha; float betaInRHmax = betaIn + sdIn_alphaRHmax - sdIn_alpha; - betaOut = + float betaOut = -sdOut_alphaOut + SDL::phi_mpi_pi(acc, SDL::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[fourthMDIndex]); float betaOutRHmin = betaOut - sdOut_alphaOutRHmin + sdOut_alphaOut; @@ -1073,8 +936,6 @@ namespace SDL { float& deltaPhiPos, float& deltaPhi, float& betaIn, - float& betaOut, - float& pt_beta, float& zLo, float& zHi, float& rtLo, @@ -1083,8 +944,6 @@ namespace SDL { float& zHiPointed, float& sdlCut, float& betaInCut, - float& betaOutCut, - float& deltaBetaCut, float& kZ) { bool pass = false; @@ -1123,16 +982,12 @@ namespace SDL { deltaPhiPos, deltaPhi, betaIn, - betaOut, - pt_beta, zLo, zHi, zLoPointed, zHiPointed, sdlCut, - betaInCut, - betaOutCut, - deltaBetaCut); + betaInCut); } else if (innerInnerLowerModuleSubdet == SDL::Barrel and innerOuterLowerModuleSubdet == SDL::Barrel and @@ -1156,16 +1011,12 @@ namespace SDL { deltaPhiPos, deltaPhi, betaIn, - betaOut, - pt_beta, zLo, zHi, zLoPointed, zHiPointed, sdlCut, - betaInCut, - betaOutCut, - deltaBetaCut); + betaInCut); } @@ -1190,15 +1041,11 @@ namespace SDL { deltaPhiPos, deltaPhi, betaIn, - betaOut, - pt_beta, zLo, rtLo, rtHi, sdlCut, betaInCut, - betaOutCut, - deltaBetaCut, kZ); } @@ -1224,15 +1071,11 @@ namespace SDL { deltaPhiPos, deltaPhi, betaIn, - betaOut, - pt_beta, zLo, rtLo, rtHi, sdlCut, betaInCut, - betaOutCut, - deltaBetaCut, kZ); } @@ -1254,11 +1097,9 @@ namespace SDL { float& deltaPhiPos, float& deltaPhi, float& betaIn, - float& betaOut, - float& pt_beta, - float& Circle_Radius, - float& Circle_CenterX, - float& Circle_CenterY, + float& circleRadius, + float& circleCenterX, + float& circleCenterY, float& zLo, float& zHi, float& rtLo, @@ -1267,8 +1108,6 @@ namespace SDL { float& zHiPointed, float& sdlCut, float& betaInCut, - float& betaOutCut, - float& deltaBetaCut, float& kZ) { bool pass = true; @@ -1325,8 +1164,6 @@ namespace SDL { deltaPhiPos, deltaPhi, betaIn, - betaOut, - pt_beta, zLo, zHi, rtLo, @@ -1335,8 +1172,6 @@ namespace SDL { zHiPointed, sdlCut, betaInCut, - betaOutCut, - deltaBetaCut, kZ)); float x1 = mdsInGPU.anchorX[firstMDIndex]; @@ -1346,8 +1181,7 @@ namespace SDL { float y2 = mdsInGPU.anchorY[secondMDIndex]; float y3 = mdsInGPU.anchorY[thirdMDIndex]; - Circle_Radius = computeRadiusFromThreeAnchorHits(acc, x1, y1, x2, y2, x3, y3, Circle_CenterX, Circle_CenterY); - pt_beta = Circle_Radius * SDL::k2Rinv1GeVf * 2; + circleRadius = computeRadiusFromThreeAnchorHits(acc, x1, y1, x2, y2, x3, y3, circleCenterX, circleCenterY); return pass; }; @@ -1391,8 +1225,8 @@ namespace SDL { uint16_t outerOuterLowerModuleIndex = segmentsInGPU.outerLowerModuleIndices[outerSegmentIndex]; - float zOut, rtOut, deltaPhiPos, deltaPhi, betaIn, betaOut, pt_beta, Circle_Radius, Circle_CenterX, Circle_CenterY; - float zLo, zHi, rtLo, rtHi, zLoPointed, zHiPointed, sdlCut, betaInCut, betaOutCut, deltaBetaCut, kZ; + float zOut, rtOut, deltaPhiPos, deltaPhi, betaIn, circleRadius, circleCenterX, circleCenterY; + float zLo, zHi, rtLo, rtHi, zLoPointed, zHiPointed, sdlCut, betaInCut, kZ; bool success = runTripletConstraintsAndAlgo(acc, modulesInGPU, @@ -1408,11 +1242,9 @@ namespace SDL { deltaPhiPos, deltaPhi, betaIn, - betaOut, - pt_beta, - Circle_Radius, - Circle_CenterX, - Circle_CenterY, + circleRadius, + circleCenterX, + circleCenterY, zLo, zHi, rtLo, @@ -1421,8 +1253,6 @@ namespace SDL { zHiPointed, sdlCut, betaInCut, - betaOutCut, - deltaBetaCut, kZ); if (success) { @@ -1453,11 +1283,9 @@ namespace SDL { deltaPhiPos, deltaPhi, betaIn, - betaOut, - pt_beta, - Circle_Radius, - Circle_CenterX, - Circle_CenterY, + circleRadius, + circleCenterX, + circleCenterY, zLo, zHi, rtLo, @@ -1466,8 +1294,6 @@ namespace SDL { zHiPointed, sdlCut, betaInCut, - betaOutCut, - deltaBetaCut, kZ, tripletIndex); #else @@ -1481,11 +1307,9 @@ namespace SDL { middleLowerModuleIndex, outerOuterLowerModuleIndex, betaIn, - betaOut, - pt_beta, - Circle_Radius, - Circle_CenterX, - Circle_CenterY, + circleRadius, + circleCenterX, + circleCenterY, tripletIndex); #endif } From aaf5f82f145c143c0f70b4144c9a373edc352f6a Mon Sep 17 00:00:00 2001 From: YonsiG Date: Mon, 29 Apr 2024 09:30:06 -0700 Subject: [PATCH 10/29] formatting --- SDL/Event.h | 4 +--- SDL/Triplet.h | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/SDL/Event.h b/SDL/Event.h index 408ffc2e..80521b6a 100644 --- a/SDL/Event.h +++ b/SDL/Event.h @@ -179,9 +179,7 @@ namespace SDL { modulesBuffer* getModules(bool isFull = false); //read from file and init - static void initModules(QueueAcc& queue, - const MapPLStoLayer& pLStoLayer, - const char* moduleMetaDataFilePath); + static void initModules(QueueAcc& queue, const MapPLStoLayer& pLStoLayer, const char* moduleMetaDataFilePath); }; } // namespace SDL diff --git a/SDL/Triplet.h b/SDL/Triplet.h index c6f45af7..4c5c84ad 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -665,7 +665,8 @@ namespace SDL { float alpha_InLo = __H2F(segmentsInGPU.dPhiChanges[innerSegmentIndex]); float tl_axis_x = mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[firstMDIndex]; float tl_axis_y = mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex]; - float betaInRHmin = alpha_InLo - SDL::phi_mpi_pi(acc, SDL::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[firstMDIndex]); + float betaInRHmin = + alpha_InLo - SDL::phi_mpi_pi(acc, SDL::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[firstMDIndex]); //beta computation float drt_tl_axis = alpaka::math::sqrt(acc, tl_axis_x * tl_axis_x + tl_axis_y * tl_axis_y); @@ -878,7 +879,6 @@ namespace SDL { //Cut #6: first beta cut pass = pass and (alpaka::math::abs(acc, betaInRHmin) < betaInCut); return pass; - }; template From 78a2add22478b1ac218268602bd5d92affec1f13 Mon Sep 17 00:00:00 2001 From: YonsiG Date: Mon, 29 Apr 2024 12:41:50 -0700 Subject: [PATCH 11/29] move BBBB into passPointing Constraint --- SDL/Triplet.h | 162 ++++++++++++++------------------------------------ 1 file changed, 46 insertions(+), 116 deletions(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index 4c5c84ad..2d047361 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -309,7 +309,10 @@ namespace SDL { unsigned int& secondMDIndex, unsigned int& thirdMDIndex, float& zOut, - float& rtOut) { + float& rtOut, + unsigned int& innerSegmentIndex, + float& betaIn, + float& betaInCut) { bool pass = true; bool isPSIn = (modulesInGPU.moduleType[innerInnerLowerModuleIndex] == SDL::PS); bool isPSOut = (modulesInGPU.moduleType[outerOuterLowerModuleIndex] == SDL::PS); @@ -370,6 +373,34 @@ namespace SDL { // Cut #2: Pointed Z (Inner segment two MD points to outer segment inner MD) pass = pass and ((zOut >= zLoPointed) && (zOut <= zHiPointed)); + // 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(segmentsInGPU.dPhiChanges[innerSegmentIndex]); + float tl_axis_x = mdsInGPU.anchorX[thirdMDIndex] - mdsInGPU.anchorX[firstMDIndex]; + float tl_axis_y = mdsInGPU.anchorY[thirdMDIndex] - mdsInGPU.anchorY[firstMDIndex]; + float betaInRHmin = + alpha_InLo - SDL::phi_mpi_pi(acc, SDL::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[firstMDIndex]); + + //beta computation + float drt_tl_axis = alpaka::math::sqrt(acc, tl_axis_x * tl_axis_x + tl_axis_y * tl_axis_y); + + float corrF = 1.f; + //innerOuterAnchor - innerInnerAnchor + const float rt_InSeg = + alpaka::math::sqrt(acc, + (mdsInGPU.anchorX[secondMDIndex] - mdsInGPU.anchorX[firstMDIndex]) * + (mdsInGPU.anchorX[secondMDIndex] - mdsInGPU.anchorX[firstMDIndex]) + + (mdsInGPU.anchorY[secondMDIndex] - mdsInGPU.anchorY[firstMDIndex]) * + (mdsInGPU.anchorY[secondMDIndex] - mdsInGPU.anchorY[firstMDIndex])); + betaInCut = alpaka::math::asin( + acc, + alpaka::math::min( + acc, (-rt_InSeg * corrF + drt_tl_axis) * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)) + + (0.02f / drt_InSeg); + + //Cut #5: first beta cut + //-5 + pass = pass and (alpaka::math::abs(acc, betaInRHmin) < betaInCut); + return pass; }; @@ -562,7 +593,10 @@ namespace SDL { unsigned int& secondMDIndex, unsigned int& thirdMDIndex, float& zOut, - float& rtOut) { + float& rtOut, + unsigned int& innerSegmentIndex, + float& betaIn, + float& betaInCut) { short innerInnerLowerModuleSubdet = modulesInGPU.subdets[innerInnerLowerModuleIndex]; short middleLowerModuleSubdet = modulesInGPU.subdets[middleLowerModuleIndex]; short outerOuterLowerModuleSubdet = modulesInGPU.subdets[outerOuterLowerModuleIndex]; @@ -580,7 +614,10 @@ namespace SDL { secondMDIndex, thirdMDIndex, zOut, - rtOut); + rtOut, + innerSegmentIndex, + betaIn, + betaInCut); } else if (innerInnerLowerModuleSubdet == SDL::Barrel and middleLowerModuleSubdet == SDL::Barrel and outerOuterLowerModuleSubdet == SDL::Endcap) { return passPointingConstraintBBE(acc, @@ -630,67 +667,6 @@ namespace SDL { return false; // failsafe }; - template - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runTripletDefaultAlgoBBBB(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, - uint16_t& innerInnerLowerModuleIndex, - uint16_t& innerOuterLowerModuleIndex, - uint16_t& outerInnerLowerModuleIndex, - uint16_t& outerOuterLowerModuleIndex, - unsigned int& innerSegmentIndex, - unsigned int& outerSegmentIndex, - unsigned int& firstMDIndex, - unsigned int& secondMDIndex, - unsigned int& thirdMDIndex, - unsigned int& fourthMDIndex, - float& zOut, - float& rtOut, - float& deltaPhiPos, - float& dPhi, - float& betaIn, - float& zLo, - float& zHi, - float& zLoPointed, - float& zHiPointed, - float& sdlCut, - float& betaInCut) { - bool pass = true; - float rt_InLo = mdsInGPU.anchorRt[firstMDIndex]; - float rt_InOut = mdsInGPU.anchorRt[secondMDIndex]; - - float drt_InSeg = rt_InOut - rt_InLo; - // 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(segmentsInGPU.dPhiChanges[innerSegmentIndex]); - float tl_axis_x = mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[firstMDIndex]; - float tl_axis_y = mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex]; - float betaInRHmin = - alpha_InLo - SDL::phi_mpi_pi(acc, SDL::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[firstMDIndex]); - - //beta computation - float drt_tl_axis = alpaka::math::sqrt(acc, tl_axis_x * tl_axis_x + tl_axis_y * tl_axis_y); - - float corrF = 1.f; - //innerOuterAnchor - innerInnerAnchor - const float rt_InSeg = - alpaka::math::sqrt(acc, - (mdsInGPU.anchorX[secondMDIndex] - mdsInGPU.anchorX[firstMDIndex]) * - (mdsInGPU.anchorX[secondMDIndex] - mdsInGPU.anchorX[firstMDIndex]) + - (mdsInGPU.anchorY[secondMDIndex] - mdsInGPU.anchorY[firstMDIndex]) * - (mdsInGPU.anchorY[secondMDIndex] - mdsInGPU.anchorY[firstMDIndex])); - betaInCut = alpaka::math::asin( - acc, - alpaka::math::min( - acc, (-rt_InSeg * corrF + drt_tl_axis) * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)) + - (0.02f / drt_InSeg); - - //Cut #5: first beta cut - //-5 - pass = pass and (alpaka::math::abs(acc, betaInRHmin) < betaInCut); - return pass; - }; - template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runTripletDefaultAlgoBBEE(TAcc const& acc, struct SDL::modules& modulesInGPU, @@ -963,61 +939,12 @@ namespace SDL { if (innerInnerLowerModuleSubdet == SDL::Barrel and innerOuterLowerModuleSubdet == SDL::Barrel and outerInnerLowerModuleSubdet == SDL::Barrel and outerOuterLowerModuleSubdet == SDL::Barrel) { - return runTripletDefaultAlgoBBBB(acc, - modulesInGPU, - mdsInGPU, - segmentsInGPU, - innerInnerLowerModuleIndex, - innerOuterLowerModuleIndex, - outerInnerLowerModuleIndex, - outerOuterLowerModuleIndex, - innerSegmentIndex, - outerSegmentIndex, - firstMDIndex, - secondMDIndex, - thirdMDIndex, - fourthMDIndex, - zOut, - rtOut, - deltaPhiPos, - deltaPhi, - betaIn, - zLo, - zHi, - zLoPointed, - zHiPointed, - sdlCut, - betaInCut); + return true; } else if (innerInnerLowerModuleSubdet == SDL::Barrel and innerOuterLowerModuleSubdet == SDL::Barrel and outerInnerLowerModuleSubdet == SDL::Barrel and outerOuterLowerModuleSubdet == SDL::Endcap) { - return runTripletDefaultAlgoBBBB(acc, - modulesInGPU, - mdsInGPU, - segmentsInGPU, - innerInnerLowerModuleIndex, - innerOuterLowerModuleIndex, - outerInnerLowerModuleIndex, - outerOuterLowerModuleIndex, - innerSegmentIndex, - outerSegmentIndex, - firstMDIndex, - secondMDIndex, - thirdMDIndex, - fourthMDIndex, - zOut, - rtOut, - deltaPhiPos, - deltaPhi, - betaIn, - zLo, - zHi, - zLoPointed, - zHiPointed, - sdlCut, - betaInCut); - + return true; } else if (innerInnerLowerModuleSubdet == SDL::Barrel and innerOuterLowerModuleSubdet == SDL::Endcap and @@ -1142,7 +1069,10 @@ namespace SDL { secondMDIndex, thirdMDIndex, zOut, - rtOut)); + rtOut, + innerSegmentIndex, + betaIn, + betaInCut)); if (not pass) return pass; pass = pass and (runTripletDefaultAlgo(acc, From 6785d6788aabb7ba896ed5e88627ae71da1848b3 Mon Sep 17 00:00:00 2001 From: YonsiG Date: Mon, 29 Apr 2024 13:26:23 -0700 Subject: [PATCH 12/29] remove runTripletDefaultAlgo completely --- SDL/Triplet.h | 502 ++++++++++++++++---------------------------------- 1 file changed, 161 insertions(+), 341 deletions(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index 2d047361..401c7621 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -416,9 +416,13 @@ namespace SDL { unsigned int& secondMDIndex, unsigned int& thirdMDIndex, float& zOut, - float& rtOut) { + float& rtOut, + uint16_t& innerOuterLowerModuleIndex, + unsigned int& innerSegmentIndex, + unsigned int& outerSegmentIndex, + float& betaIn, + float& betaInCut) { bool pass = true; - //unsigned int outerInnerLowerModuleIndex = middleLowerModuleIndex; bool isPSIn = (modulesInGPU.moduleType[innerInnerLowerModuleIndex] == SDL::PS); bool isPSOut = (modulesInGPU.moduleType[outerOuterLowerModuleIndex] == SDL::PS); @@ -490,6 +494,78 @@ namespace SDL { //Cut #3: rt-z pointed pass = pass and (kZ >= 0) && (rtOut >= rtLo) && (rtOut <= rtHi); + + float rt_InLo = mdsInGPU.anchorRt[firstMDIndex]; + float rt_InOut = mdsInGPU.anchorRt[secondMDIndex]; + + float sdIn_alpha = __H2F(segmentsInGPU.dPhiChanges[innerSegmentIndex]); + float sdIn_alpha_min = __H2F(segmentsInGPU.dPhiChangeMins[innerSegmentIndex]); + float sdIn_alpha_max = __H2F(segmentsInGPU.dPhiChangeMaxs[innerSegmentIndex]); + + float sdOut_alphaOut = SDL::phi_mpi_pi(acc, + SDL::phi(acc, + mdsInGPU.anchorX[thirdMDIndex] - mdsInGPU.anchorX[secondMDIndex], + mdsInGPU.anchorY[thirdMDIndex] - mdsInGPU.anchorY[secondMDIndex]) - + mdsInGPU.anchorPhi[thirdMDIndex]); + + float sdOut_alphaOut_min = SDL::phi_mpi_pi( + acc, __H2F(segmentsInGPU.dPhiChangeMins[outerSegmentIndex]) - __H2F(segmentsInGPU.dPhiMins[outerSegmentIndex])); + float sdOut_alphaOut_max = SDL::phi_mpi_pi( + acc, __H2F(segmentsInGPU.dPhiChangeMaxs[outerSegmentIndex]) - __H2F(segmentsInGPU.dPhiMaxs[outerSegmentIndex])); + + float tl_axis_x = mdsInGPU.anchorX[thirdMDIndex] - mdsInGPU.anchorX[firstMDIndex]; + float tl_axis_y = mdsInGPU.anchorY[thirdMDIndex] - mdsInGPU.anchorY[firstMDIndex]; + + betaIn = sdIn_alpha - SDL::phi_mpi_pi(acc, SDL::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[firstMDIndex]); + + float betaInRHmin = betaIn; + float betaInRHmax = betaIn; + float betaOut = + -sdOut_alphaOut + SDL::phi_mpi_pi(acc, SDL::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[thirdMDIndex]); + + float betaOutRHmin = betaOut; + float betaOutRHmax = betaOut; + + bool isEC_secondLayer = (modulesInGPU.subdets[innerOuterLowerModuleIndex] == SDL::Endcap) and + (modulesInGPU.moduleType[innerOuterLowerModuleIndex] == SDL::TwoS); + + if (isEC_secondLayer) { + betaInRHmin = betaIn - sdIn_alpha_min + sdIn_alpha; + betaInRHmax = betaIn - sdIn_alpha_max + sdIn_alpha; + } + + betaOutRHmin = betaOut - sdOut_alphaOut_min + sdOut_alphaOut; + betaOutRHmax = betaOut - sdOut_alphaOut_max + sdOut_alphaOut; + + float swapTemp; + if (alpaka::math::abs(acc, betaOutRHmin) > alpaka::math::abs(acc, betaOutRHmax)) { + swapTemp = betaOutRHmin; + betaOutRHmin = betaOutRHmax; + betaOutRHmax = swapTemp; + } + + if (alpaka::math::abs(acc, betaInRHmin) > alpaka::math::abs(acc, betaInRHmax)) { + swapTemp = betaInRHmin; + betaInRHmin = betaInRHmax; + betaInRHmax = swapTemp; + } + + float sdIn_dr = alpaka::math::sqrt(acc, + (mdsInGPU.anchorX[secondMDIndex] - mdsInGPU.anchorX[firstMDIndex]) * + (mdsInGPU.anchorX[secondMDIndex] - mdsInGPU.anchorX[firstMDIndex]) + + (mdsInGPU.anchorY[secondMDIndex] - mdsInGPU.anchorY[firstMDIndex]) * + (mdsInGPU.anchorY[secondMDIndex] - mdsInGPU.anchorY[firstMDIndex])); + float sdIn_d = rt_InOut - rt_InLo; + + float dr = alpaka::math::sqrt(acc, tl_axis_x * tl_axis_x + tl_axis_y * tl_axis_y); + const float corrF = 1.f; + betaInCut = + alpaka::math::asin( + acc, alpaka::math::min(acc, (-sdIn_dr * corrF + dr) * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)) + + (0.02f / sdIn_d); + + //Cut #6: first beta cut + pass = pass and (alpaka::math::abs(acc, betaInRHmin) < betaInCut); return pass; }; @@ -505,7 +581,11 @@ namespace SDL { unsigned int& secondMDIndex, unsigned int& thirdMDIndex, float& zOut, - float& rtOut) { + float& rtOut, + unsigned int& innerSegmentIndex, + unsigned int& outerSegmentIndex, + float& betaIn, + float& betaInCut) { bool pass = true; float rtIn = mdsInGPU.anchorRt[firstMDIndex]; @@ -578,6 +658,63 @@ namespace SDL { pass = pass and ((kZ >= 0) && (rtOut >= rtLo_point) && (rtOut <= rtHi_point)); } + float rt_InLo = mdsInGPU.anchorRt[firstMDIndex]; + float rt_InOut = mdsInGPU.anchorRt[secondMDIndex]; + float sdIn_alpha = __H2F(segmentsInGPU.dPhiChanges[innerSegmentIndex]); + float sdOut_dPhiPos = SDL::phi_mpi_pi(acc, mdsInGPU.anchorPhi[thirdMDIndex] - mdsInGPU.anchorPhi[secondMDIndex]); + + float sdOut_dPhiChange = __H2F(segmentsInGPU.dPhiChanges[outerSegmentIndex]); + float sdOut_dPhiChange_min = __H2F(segmentsInGPU.dPhiChangeMins[outerSegmentIndex]); + float sdOut_dPhiChange_max = __H2F(segmentsInGPU.dPhiChangeMaxs[outerSegmentIndex]); + + float sdOut_alphaOutRHmin = SDL::phi_mpi_pi(acc, sdOut_dPhiChange_min - sdOut_dPhiPos); + float sdOut_alphaOutRHmax = SDL::phi_mpi_pi(acc, sdOut_dPhiChange_max - sdOut_dPhiPos); + float sdOut_alphaOut = SDL::phi_mpi_pi(acc, sdOut_dPhiChange - sdOut_dPhiPos); + + float tl_axis_x = mdsInGPU.anchorX[thirdMDIndex] - mdsInGPU.anchorX[firstMDIndex]; + float tl_axis_y = mdsInGPU.anchorY[thirdMDIndex] - mdsInGPU.anchorY[firstMDIndex]; + + betaIn = sdIn_alpha - SDL::phi_mpi_pi(acc, SDL::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[firstMDIndex]); + + float sdIn_alphaRHmin = __H2F(segmentsInGPU.dPhiChangeMins[innerSegmentIndex]); + float sdIn_alphaRHmax = __H2F(segmentsInGPU.dPhiChangeMaxs[innerSegmentIndex]); + float betaInRHmin = betaIn + sdIn_alphaRHmin - sdIn_alpha; + float betaInRHmax = betaIn + sdIn_alphaRHmax - sdIn_alpha; + + float betaOut = + -sdOut_alphaOut + SDL::phi_mpi_pi(acc, SDL::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[thirdMDIndex]); + + float betaOutRHmin = betaOut - sdOut_alphaOutRHmin + sdOut_alphaOut; + float betaOutRHmax = betaOut - sdOut_alphaOutRHmax + sdOut_alphaOut; + + float swapTemp; + if (alpaka::math::abs(acc, betaOutRHmin) > alpaka::math::abs(acc, betaOutRHmax)) { + swapTemp = betaOutRHmin; + betaOutRHmin = betaOutRHmax; + betaOutRHmax = swapTemp; + } + + if (alpaka::math::abs(acc, betaInRHmin) > alpaka::math::abs(acc, betaInRHmax)) { + swapTemp = betaInRHmin; + betaInRHmin = betaInRHmax; + betaInRHmax = swapTemp; + } + float sdIn_dr = alpaka::math::sqrt(acc, + (mdsInGPU.anchorX[secondMDIndex] - mdsInGPU.anchorX[firstMDIndex]) * + (mdsInGPU.anchorX[secondMDIndex] - mdsInGPU.anchorX[firstMDIndex]) + + (mdsInGPU.anchorY[secondMDIndex] - mdsInGPU.anchorY[firstMDIndex]) * + (mdsInGPU.anchorY[secondMDIndex] - mdsInGPU.anchorY[firstMDIndex])); + float sdIn_d = rt_InOut - rt_InLo; + + float dr = alpaka::math::sqrt(acc, tl_axis_x * tl_axis_x + tl_axis_y * tl_axis_y); + const float corrF = 1.f; + betaInCut = + alpaka::math::asin( + acc, alpaka::math::min(acc, (-sdIn_dr * corrF + dr) * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)) + + (0.02f / sdIn_d); + + //Cut #6: first beta cut + pass = pass and (alpaka::math::abs(acc, betaInRHmin) < betaInCut); return pass; }; @@ -594,7 +731,9 @@ namespace SDL { unsigned int& thirdMDIndex, float& zOut, float& rtOut, + uint16_t& innerOuterLowerModuleIndex, unsigned int& innerSegmentIndex, + unsigned int& outerSegmentIndex, float& betaIn, float& betaInCut) { short innerInnerLowerModuleSubdet = modulesInGPU.subdets[innerInnerLowerModuleIndex]; @@ -631,7 +770,12 @@ namespace SDL { secondMDIndex, thirdMDIndex, zOut, - rtOut); + rtOut, + innerOuterLowerModuleIndex, + innerSegmentIndex, + outerSegmentIndex, + betaIn, + betaInCut); } else if (innerInnerLowerModuleSubdet == SDL::Barrel and middleLowerModuleSubdet == SDL::Endcap and outerOuterLowerModuleSubdet == SDL::Endcap) { return passPointingConstraintBBE(acc, @@ -645,7 +789,12 @@ namespace SDL { secondMDIndex, thirdMDIndex, zOut, - rtOut); + rtOut, + innerOuterLowerModuleIndex, + innerSegmentIndex, + outerSegmentIndex, + betaIn, + betaInCut); } @@ -662,201 +811,15 @@ namespace SDL { secondMDIndex, thirdMDIndex, zOut, - rtOut); + rtOut, + innerSegmentIndex, + outerSegmentIndex, + betaIn, + betaInCut); } return false; // failsafe }; - template - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runTripletDefaultAlgoBBEE(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, - uint16_t& innerInnerLowerModuleIndex, - uint16_t& innerOuterLowerModuleIndex, - uint16_t& outerInnerLowerModuleIndex, - uint16_t& outerOuterLowerModuleIndex, - unsigned int& innerSegmentIndex, - unsigned int& outerSegmentIndex, - unsigned int& firstMDIndex, - unsigned int& secondMDIndex, - unsigned int& thirdMDIndex, - unsigned int& fourthMDIndex, - float& zOut, - float& rtOut, - float& deltaPhiPos, - float& dPhi, - float& betaIn, - float& zLo, - float& rtLo, - float& rtHi, - float& sdlCut, - float& betaInCut, - float& kZ) { - bool pass = true; - - float rt_InLo = mdsInGPU.anchorRt[firstMDIndex]; - float rt_InOut = mdsInGPU.anchorRt[secondMDIndex]; - - float sdIn_alpha = __H2F(segmentsInGPU.dPhiChanges[innerSegmentIndex]); - float sdIn_alpha_min = __H2F(segmentsInGPU.dPhiChangeMins[innerSegmentIndex]); - float sdIn_alpha_max = __H2F(segmentsInGPU.dPhiChangeMaxs[innerSegmentIndex]); - - float sdOut_alphaOut = SDL::phi_mpi_pi(acc, - SDL::phi(acc, - mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex], - mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex]) - - mdsInGPU.anchorPhi[fourthMDIndex]); - - float sdOut_alphaOut_min = SDL::phi_mpi_pi( - acc, __H2F(segmentsInGPU.dPhiChangeMins[outerSegmentIndex]) - __H2F(segmentsInGPU.dPhiMins[outerSegmentIndex])); - float sdOut_alphaOut_max = SDL::phi_mpi_pi( - acc, __H2F(segmentsInGPU.dPhiChangeMaxs[outerSegmentIndex]) - __H2F(segmentsInGPU.dPhiMaxs[outerSegmentIndex])); - - float tl_axis_x = mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[firstMDIndex]; - float tl_axis_y = mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex]; - - betaIn = sdIn_alpha - SDL::phi_mpi_pi(acc, SDL::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[firstMDIndex]); - - float betaInRHmin = betaIn; - float betaInRHmax = betaIn; - float betaOut = - -sdOut_alphaOut + SDL::phi_mpi_pi(acc, SDL::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[fourthMDIndex]); - - float betaOutRHmin = betaOut; - float betaOutRHmax = betaOut; - - bool isEC_secondLayer = (modulesInGPU.subdets[innerOuterLowerModuleIndex] == SDL::Endcap) and - (modulesInGPU.moduleType[innerOuterLowerModuleIndex] == SDL::TwoS); - - if (isEC_secondLayer) { - betaInRHmin = betaIn - sdIn_alpha_min + sdIn_alpha; - betaInRHmax = betaIn - sdIn_alpha_max + sdIn_alpha; - } - - betaOutRHmin = betaOut - sdOut_alphaOut_min + sdOut_alphaOut; - betaOutRHmax = betaOut - sdOut_alphaOut_max + sdOut_alphaOut; - - float swapTemp; - if (alpaka::math::abs(acc, betaOutRHmin) > alpaka::math::abs(acc, betaOutRHmax)) { - swapTemp = betaOutRHmin; - betaOutRHmin = betaOutRHmax; - betaOutRHmax = swapTemp; - } - - if (alpaka::math::abs(acc, betaInRHmin) > alpaka::math::abs(acc, betaInRHmax)) { - swapTemp = betaInRHmin; - betaInRHmin = betaInRHmax; - betaInRHmax = swapTemp; - } - - float sdIn_dr = alpaka::math::sqrt(acc, - (mdsInGPU.anchorX[secondMDIndex] - mdsInGPU.anchorX[firstMDIndex]) * - (mdsInGPU.anchorX[secondMDIndex] - mdsInGPU.anchorX[firstMDIndex]) + - (mdsInGPU.anchorY[secondMDIndex] - mdsInGPU.anchorY[firstMDIndex]) * - (mdsInGPU.anchorY[secondMDIndex] - mdsInGPU.anchorY[firstMDIndex])); - float sdIn_d = rt_InOut - rt_InLo; - - float dr = alpaka::math::sqrt(acc, tl_axis_x * tl_axis_x + tl_axis_y * tl_axis_y); - const float corrF = 1.f; - betaInCut = - alpaka::math::asin( - acc, alpaka::math::min(acc, (-sdIn_dr * corrF + dr) * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)) + - (0.02f / sdIn_d); - - //Cut #6: first beta cut - pass = pass and (alpaka::math::abs(acc, betaInRHmin) < betaInCut); - return pass; - }; - - template - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runTripletDefaultAlgoEEEE(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, - uint16_t& innerInnerLowerModuleIndex, - uint16_t& innerOuterLowerModuleIndex, - uint16_t& outerInnerLowerModuleIndex, - uint16_t& outerOuterLowerModuleIndex, - unsigned int& innerSegmentIndex, - unsigned int& outerSegmentIndex, - unsigned int& firstMDIndex, - unsigned int& secondMDIndex, - unsigned int& thirdMDIndex, - unsigned int& fourthMDIndex, - float& zOut, - float& rtOut, - float& deltaPhiPos, - float& dPhi, - float& betaIn, - float& zLo, - float& rtLo, - float& rtHi, - float& sdlCut, - float& betaInCut, - float& kZ) { - bool pass = true; - - float rt_InLo = mdsInGPU.anchorRt[firstMDIndex]; - float rt_InOut = mdsInGPU.anchorRt[secondMDIndex]; - float sdIn_alpha = __H2F(segmentsInGPU.dPhiChanges[innerSegmentIndex]); - float sdOut_dPhiPos = SDL::phi_mpi_pi(acc, mdsInGPU.anchorPhi[fourthMDIndex] - mdsInGPU.anchorPhi[thirdMDIndex]); - - float sdOut_dPhiChange = __H2F(segmentsInGPU.dPhiChanges[outerSegmentIndex]); - float sdOut_dPhiChange_min = __H2F(segmentsInGPU.dPhiChangeMins[outerSegmentIndex]); - float sdOut_dPhiChange_max = __H2F(segmentsInGPU.dPhiChangeMaxs[outerSegmentIndex]); - - float sdOut_alphaOutRHmin = SDL::phi_mpi_pi(acc, sdOut_dPhiChange_min - sdOut_dPhiPos); - float sdOut_alphaOutRHmax = SDL::phi_mpi_pi(acc, sdOut_dPhiChange_max - sdOut_dPhiPos); - float sdOut_alphaOut = SDL::phi_mpi_pi(acc, sdOut_dPhiChange - sdOut_dPhiPos); - - float tl_axis_x = mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[firstMDIndex]; - float tl_axis_y = mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex]; - - betaIn = sdIn_alpha - SDL::phi_mpi_pi(acc, SDL::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[firstMDIndex]); - - float sdIn_alphaRHmin = __H2F(segmentsInGPU.dPhiChangeMins[innerSegmentIndex]); - float sdIn_alphaRHmax = __H2F(segmentsInGPU.dPhiChangeMaxs[innerSegmentIndex]); - float betaInRHmin = betaIn + sdIn_alphaRHmin - sdIn_alpha; - float betaInRHmax = betaIn + sdIn_alphaRHmax - sdIn_alpha; - - float betaOut = - -sdOut_alphaOut + SDL::phi_mpi_pi(acc, SDL::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[fourthMDIndex]); - - float betaOutRHmin = betaOut - sdOut_alphaOutRHmin + sdOut_alphaOut; - float betaOutRHmax = betaOut - sdOut_alphaOutRHmax + sdOut_alphaOut; - - float swapTemp; - if (alpaka::math::abs(acc, betaOutRHmin) > alpaka::math::abs(acc, betaOutRHmax)) { - swapTemp = betaOutRHmin; - betaOutRHmin = betaOutRHmax; - betaOutRHmax = swapTemp; - } - - if (alpaka::math::abs(acc, betaInRHmin) > alpaka::math::abs(acc, betaInRHmax)) { - swapTemp = betaInRHmin; - betaInRHmin = betaInRHmax; - betaInRHmax = swapTemp; - } - float sdIn_dr = alpaka::math::sqrt(acc, - (mdsInGPU.anchorX[secondMDIndex] - mdsInGPU.anchorX[firstMDIndex]) * - (mdsInGPU.anchorX[secondMDIndex] - mdsInGPU.anchorX[firstMDIndex]) + - (mdsInGPU.anchorY[secondMDIndex] - mdsInGPU.anchorY[firstMDIndex]) * - (mdsInGPU.anchorY[secondMDIndex] - mdsInGPU.anchorY[firstMDIndex])); - float sdIn_d = rt_InOut - rt_InLo; - - float dr = alpaka::math::sqrt(acc, tl_axis_x * tl_axis_x + tl_axis_y * tl_axis_y); - const float corrF = 1.f; - betaInCut = - alpaka::math::asin( - acc, alpaka::math::min(acc, (-sdIn_dr * corrF + dr) * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)) + - (0.02f / sdIn_d); - - //Cut #6: first beta cut - pass = pass and (alpaka::math::abs(acc, betaInRHmin) < betaInCut); - return pass; - }; - template ALPAKA_FN_ACC ALPAKA_FN_INLINE float computeRadiusFromThreeAnchorHits( TAcc const& acc, float x1, float y1, float x2, float y2, float x3, float y3, float& g, float& f) { @@ -892,123 +855,6 @@ namespace SDL { return radius; }; - template - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runTripletDefaultAlgo(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, - uint16_t& innerInnerLowerModuleIndex, - uint16_t& innerOuterLowerModuleIndex, - uint16_t& outerInnerLowerModuleIndex, - uint16_t& outerOuterLowerModuleIndex, - unsigned int& innerSegmentIndex, - unsigned int& outerSegmentIndex, - unsigned int& firstMDIndex, - unsigned int& secondMDIndex, - unsigned int& thirdMDIndex, - unsigned int& fourthMDIndex, - float& zOut, - float& rtOut, - float& deltaPhiPos, - float& deltaPhi, - float& betaIn, - float& zLo, - float& zHi, - float& rtLo, - float& rtHi, - float& zLoPointed, - float& zHiPointed, - float& sdlCut, - float& betaInCut, - float& kZ) { - bool pass = false; - - zLo = -999; - zHi = -999; - rtLo = -999; - rtHi = -999; - zLoPointed = -999; - zHiPointed = -999; - kZ = -999; - betaInCut = -999; - - short innerInnerLowerModuleSubdet = modulesInGPU.subdets[innerInnerLowerModuleIndex]; - short innerOuterLowerModuleSubdet = modulesInGPU.subdets[innerOuterLowerModuleIndex]; - short outerInnerLowerModuleSubdet = modulesInGPU.subdets[outerInnerLowerModuleIndex]; - short outerOuterLowerModuleSubdet = modulesInGPU.subdets[outerOuterLowerModuleIndex]; - - if (innerInnerLowerModuleSubdet == SDL::Barrel and innerOuterLowerModuleSubdet == SDL::Barrel and - outerInnerLowerModuleSubdet == SDL::Barrel and outerOuterLowerModuleSubdet == SDL::Barrel) { - return true; - } - - else if (innerInnerLowerModuleSubdet == SDL::Barrel and innerOuterLowerModuleSubdet == SDL::Barrel and - outerInnerLowerModuleSubdet == SDL::Barrel and outerOuterLowerModuleSubdet == SDL::Endcap) { - return true; - } - - else if (innerInnerLowerModuleSubdet == SDL::Barrel and innerOuterLowerModuleSubdet == SDL::Endcap and - outerInnerLowerModuleSubdet == SDL::Endcap and outerOuterLowerModuleSubdet == SDL::Endcap) { - return runTripletDefaultAlgoBBEE(acc, - modulesInGPU, - mdsInGPU, - segmentsInGPU, - innerInnerLowerModuleIndex, - innerOuterLowerModuleIndex, - outerInnerLowerModuleIndex, - outerOuterLowerModuleIndex, - innerSegmentIndex, - outerSegmentIndex, - firstMDIndex, - secondMDIndex, - thirdMDIndex, - fourthMDIndex, - zOut, - rtOut, - deltaPhiPos, - deltaPhi, - betaIn, - zLo, - rtLo, - rtHi, - sdlCut, - betaInCut, - kZ); - - } - - else if (innerInnerLowerModuleSubdet == SDL::Endcap and innerOuterLowerModuleSubdet == SDL::Endcap and - outerInnerLowerModuleSubdet == SDL::Endcap and outerOuterLowerModuleSubdet == SDL::Endcap) { - return runTripletDefaultAlgoEEEE(acc, - modulesInGPU, - mdsInGPU, - segmentsInGPU, - innerInnerLowerModuleIndex, - innerOuterLowerModuleIndex, - outerInnerLowerModuleIndex, - outerOuterLowerModuleIndex, - innerSegmentIndex, - outerSegmentIndex, - firstMDIndex, - secondMDIndex, - thirdMDIndex, - fourthMDIndex, - zOut, - rtOut, - deltaPhiPos, - deltaPhi, - betaIn, - zLo, - rtLo, - rtHi, - sdlCut, - betaInCut, - kZ); - } - - return pass; - }; - template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runTripletConstraintsAndAlgo(TAcc const& acc, struct SDL::modules& modulesInGPU, @@ -1070,39 +916,13 @@ namespace SDL { thirdMDIndex, zOut, rtOut, + middleLowerModuleIndex, innerSegmentIndex, + outerSegmentIndex, betaIn, betaInCut)); if (not pass) return pass; - pass = pass and (runTripletDefaultAlgo(acc, - modulesInGPU, - mdsInGPU, - segmentsInGPU, - innerInnerLowerModuleIndex, - middleLowerModuleIndex, - middleLowerModuleIndex, - outerOuterLowerModuleIndex, - innerSegmentIndex, - outerSegmentIndex, - firstMDIndex, - secondMDIndex, - secondMDIndex, - thirdMDIndex, - zOut, - rtOut, - deltaPhiPos, - deltaPhi, - betaIn, - zLo, - zHi, - rtLo, - rtHi, - zLoPointed, - zHiPointed, - sdlCut, - betaInCut, - kZ)); float x1 = mdsInGPU.anchorX[firstMDIndex]; float x2 = mdsInGPU.anchorX[secondMDIndex]; From 1481611449ff3ba335c55fc7b1684978fb482387 Mon Sep 17 00:00:00 2001 From: YonsiG Date: Mon, 29 Apr 2024 13:30:53 -0700 Subject: [PATCH 13/29] format and delete unallocated variable --- SDL/Triplet.h | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index 401c7621..41de709e 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -38,7 +38,6 @@ namespace SDL { float* betaInCut; float* rtLo; float* rtHi; - float* kZ; #endif template void setData(TBuff& tripletsbuf) { @@ -69,7 +68,6 @@ namespace SDL { betaInCut = alpaka::getPtrNative(tripletsbuf.betaInCut_buf); rtLo = alpaka::getPtrNative(tripletsbuf.rtLo_buf); rtHi = alpaka::getPtrNative(tripletsbuf.rtHi_buf); - kZ = alpaka::getPtrNative(tripletsbuf.kZ_buf); #endif } }; @@ -104,7 +102,6 @@ namespace SDL { Buf betaInCut_buf; Buf rtLo_buf; Buf rtHi_buf; - Buf kZ_buf; #endif template @@ -136,8 +133,7 @@ namespace SDL { sdlCut_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), betaInCut_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), rtLo_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - rtHi_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - kZ_buf(allocBufWrapper(devAccIn, maxTriplets, queue)) + rtHi_buf(allocBufWrapper(devAccIn, maxTriplets, queue)) #endif { alpaka::memset(queue, nTriplets_buf, 0u); @@ -173,9 +169,7 @@ namespace SDL { float& zLoPointed, float& zHiPointed, float& sdlCut, - float& betaInCut, - float& kZ, - unsigned int& tripletIndex) + float& betaInCut unsigned int& tripletIndex) #else ALPAKA_FN_ACC ALPAKA_FN_INLINE void addTripletToMemory(struct SDL::modules& modulesInGPU, struct SDL::miniDoublets& mdsInGPU, @@ -233,7 +227,6 @@ namespace SDL { tripletsInGPU.zHiPointed[tripletIndex] = zHiPointed; tripletsInGPU.sdlCut[tripletIndex] = sdlCut; tripletsInGPU.betaInCut[tripletIndex] = betaInCut; - tripletsInGPU.kZ[tripletIndex] = kZ; #endif }; @@ -976,7 +969,7 @@ namespace SDL { uint16_t outerOuterLowerModuleIndex = segmentsInGPU.outerLowerModuleIndices[outerSegmentIndex]; float zOut, rtOut, deltaPhiPos, deltaPhi, betaIn, circleRadius, circleCenterX, circleCenterY; - float zLo, zHi, rtLo, rtHi, zLoPointed, zHiPointed, sdlCut, betaInCut, kZ; + float zLo, zHi, rtLo, rtHi, zLoPointed, zHiPointed, sdlCut, betaInCut; bool success = runTripletConstraintsAndAlgo(acc, modulesInGPU, @@ -1002,8 +995,7 @@ namespace SDL { zLoPointed, zHiPointed, sdlCut, - betaInCut, - kZ); + betaInCut); if (success) { unsigned int totOccupancyTriplets = alpaka::atomicOp( @@ -1044,7 +1036,6 @@ namespace SDL { zHiPointed, sdlCut, betaInCut, - kZ, tripletIndex); #else addTripletToMemory(modulesInGPU, From f89b3332c4786f0473098eb01aeb3b6bb5ead352 Mon Sep 17 00:00:00 2001 From: YonsiG Date: Mon, 29 Apr 2024 13:35:34 -0700 Subject: [PATCH 14/29] remove kZ --- SDL/Event.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/SDL/Event.cc b/SDL/Event.cc index 8a1800fe..54aea9b3 100644 --- a/SDL/Event.cc +++ b/SDL/Event.cc @@ -1670,7 +1670,6 @@ SDL::tripletsBuffer* SDL::Event::getTriplets() { alpaka::memcpy(queue, tripletsInCPU->betaInCut_buf, tripletsBuffers->betaInCut_buf, nMemHost); alpaka::memcpy(queue, tripletsInCPU->rtLo_buf, tripletsBuffers->rtLo_buf, nMemHost); alpaka::memcpy(queue, tripletsInCPU->rtHi_buf, tripletsBuffers->rtHi_buf, nMemHost); - alpaka::memcpy(queue, tripletsInCPU->kZ_buf, tripletsBuffers->kZ_buf, nMemHost); #endif alpaka::memcpy(queue, tripletsInCPU->hitIndices_buf, tripletsBuffers->hitIndices_buf, 6 * nMemHost); alpaka::memcpy(queue, tripletsInCPU->logicalLayers_buf, tripletsBuffers->logicalLayers_buf, 3 * nMemHost); From 3f5a86b058ba7f87d149d4b7618da5229b18267e Mon Sep 17 00:00:00 2001 From: YonsiG Date: Mon, 29 Apr 2024 13:43:00 -0700 Subject: [PATCH 15/29] bug fix --- SDL/Triplet.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index 41de709e..afa5df8b 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -873,8 +873,7 @@ namespace SDL { float& zLoPointed, float& zHiPointed, float& sdlCut, - float& betaInCut, - float& kZ) { + float& betaInCut) { bool pass = true; //this cut reduces the number of candidates by a factor of 4, i.e., 3 out of 4 warps can end right here! From 87d4bfcdd58ab1d4a4ce493d113e3a61168f7caf Mon Sep 17 00:00:00 2001 From: YonsiG Date: Tue, 30 Apr 2024 11:27:36 -0700 Subject: [PATCH 16/29] remove tthe betaOut variable --- SDL/Triplet.h | 54 --------------------------------------------------- 1 file changed, 54 deletions(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index afa5df8b..b09f0611 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -492,19 +492,6 @@ namespace SDL { float rt_InOut = mdsInGPU.anchorRt[secondMDIndex]; float sdIn_alpha = __H2F(segmentsInGPU.dPhiChanges[innerSegmentIndex]); - float sdIn_alpha_min = __H2F(segmentsInGPU.dPhiChangeMins[innerSegmentIndex]); - float sdIn_alpha_max = __H2F(segmentsInGPU.dPhiChangeMaxs[innerSegmentIndex]); - - float sdOut_alphaOut = SDL::phi_mpi_pi(acc, - SDL::phi(acc, - mdsInGPU.anchorX[thirdMDIndex] - mdsInGPU.anchorX[secondMDIndex], - mdsInGPU.anchorY[thirdMDIndex] - mdsInGPU.anchorY[secondMDIndex]) - - mdsInGPU.anchorPhi[thirdMDIndex]); - - float sdOut_alphaOut_min = SDL::phi_mpi_pi( - acc, __H2F(segmentsInGPU.dPhiChangeMins[outerSegmentIndex]) - __H2F(segmentsInGPU.dPhiMins[outerSegmentIndex])); - float sdOut_alphaOut_max = SDL::phi_mpi_pi( - acc, __H2F(segmentsInGPU.dPhiChangeMaxs[outerSegmentIndex]) - __H2F(segmentsInGPU.dPhiMaxs[outerSegmentIndex])); float tl_axis_x = mdsInGPU.anchorX[thirdMDIndex] - mdsInGPU.anchorX[firstMDIndex]; float tl_axis_y = mdsInGPU.anchorY[thirdMDIndex] - mdsInGPU.anchorY[firstMDIndex]; @@ -513,29 +500,8 @@ namespace SDL { float betaInRHmin = betaIn; float betaInRHmax = betaIn; - float betaOut = - -sdOut_alphaOut + SDL::phi_mpi_pi(acc, SDL::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[thirdMDIndex]); - - float betaOutRHmin = betaOut; - float betaOutRHmax = betaOut; - - bool isEC_secondLayer = (modulesInGPU.subdets[innerOuterLowerModuleIndex] == SDL::Endcap) and - (modulesInGPU.moduleType[innerOuterLowerModuleIndex] == SDL::TwoS); - - if (isEC_secondLayer) { - betaInRHmin = betaIn - sdIn_alpha_min + sdIn_alpha; - betaInRHmax = betaIn - sdIn_alpha_max + sdIn_alpha; - } - - betaOutRHmin = betaOut - sdOut_alphaOut_min + sdOut_alphaOut; - betaOutRHmax = betaOut - sdOut_alphaOut_max + sdOut_alphaOut; float swapTemp; - if (alpaka::math::abs(acc, betaOutRHmin) > alpaka::math::abs(acc, betaOutRHmax)) { - swapTemp = betaOutRHmin; - betaOutRHmin = betaOutRHmax; - betaOutRHmax = swapTemp; - } if (alpaka::math::abs(acc, betaInRHmin) > alpaka::math::abs(acc, betaInRHmax)) { swapTemp = betaInRHmin; @@ -654,15 +620,6 @@ namespace SDL { float rt_InLo = mdsInGPU.anchorRt[firstMDIndex]; float rt_InOut = mdsInGPU.anchorRt[secondMDIndex]; float sdIn_alpha = __H2F(segmentsInGPU.dPhiChanges[innerSegmentIndex]); - float sdOut_dPhiPos = SDL::phi_mpi_pi(acc, mdsInGPU.anchorPhi[thirdMDIndex] - mdsInGPU.anchorPhi[secondMDIndex]); - - float sdOut_dPhiChange = __H2F(segmentsInGPU.dPhiChanges[outerSegmentIndex]); - float sdOut_dPhiChange_min = __H2F(segmentsInGPU.dPhiChangeMins[outerSegmentIndex]); - float sdOut_dPhiChange_max = __H2F(segmentsInGPU.dPhiChangeMaxs[outerSegmentIndex]); - - float sdOut_alphaOutRHmin = SDL::phi_mpi_pi(acc, sdOut_dPhiChange_min - sdOut_dPhiPos); - float sdOut_alphaOutRHmax = SDL::phi_mpi_pi(acc, sdOut_dPhiChange_max - sdOut_dPhiPos); - float sdOut_alphaOut = SDL::phi_mpi_pi(acc, sdOut_dPhiChange - sdOut_dPhiPos); float tl_axis_x = mdsInGPU.anchorX[thirdMDIndex] - mdsInGPU.anchorX[firstMDIndex]; float tl_axis_y = mdsInGPU.anchorY[thirdMDIndex] - mdsInGPU.anchorY[firstMDIndex]; @@ -674,18 +631,7 @@ namespace SDL { float betaInRHmin = betaIn + sdIn_alphaRHmin - sdIn_alpha; float betaInRHmax = betaIn + sdIn_alphaRHmax - sdIn_alpha; - float betaOut = - -sdOut_alphaOut + SDL::phi_mpi_pi(acc, SDL::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[thirdMDIndex]); - - float betaOutRHmin = betaOut - sdOut_alphaOutRHmin + sdOut_alphaOut; - float betaOutRHmax = betaOut - sdOut_alphaOutRHmax + sdOut_alphaOut; - float swapTemp; - if (alpaka::math::abs(acc, betaOutRHmin) > alpaka::math::abs(acc, betaOutRHmax)) { - swapTemp = betaOutRHmin; - betaOutRHmin = betaOutRHmax; - betaOutRHmax = swapTemp; - } if (alpaka::math::abs(acc, betaInRHmin) > alpaka::math::abs(acc, betaInRHmax)) { swapTemp = betaInRHmin; From d25355eac094fe0e91ebcb9d6e2c590845331c37 Mon Sep 17 00:00:00 2001 From: YonsiG <48876687+YonsiG@users.noreply.github.com> Date: Fri, 3 May 2024 16:09:59 +0200 Subject: [PATCH 17/29] Update SDL/Triplet.h Co-authored-by: Slava Krutelyov --- SDL/Triplet.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index b09f0611..86747270 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -390,8 +390,7 @@ namespace SDL { acc, (-rt_InSeg * corrF + drt_tl_axis) * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)) + (0.02f / drt_InSeg); - //Cut #5: first beta cut - //-5 + //Cut #3: first beta cut pass = pass and (alpaka::math::abs(acc, betaInRHmin) < betaInCut); return pass; From a1c3a6d1e2c9f63ad9280f0c5717d742452bc448 Mon Sep 17 00:00:00 2001 From: YonsiG <48876687+YonsiG@users.noreply.github.com> Date: Fri, 3 May 2024 16:10:32 +0200 Subject: [PATCH 18/29] Update SDL/Triplet.h Co-authored-by: Slava Krutelyov --- SDL/Triplet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index 86747270..9976c63c 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -522,7 +522,7 @@ namespace SDL { acc, alpaka::math::min(acc, (-sdIn_dr * corrF + dr) * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)) + (0.02f / sdIn_d); - //Cut #6: first beta cut + //Cut #4: first beta cut pass = pass and (alpaka::math::abs(acc, betaInRHmin) < betaInCut); return pass; }; From b0317482f91c70f044551a067fbc69fc4eb58610 Mon Sep 17 00:00:00 2001 From: YonsiG Date: Fri, 3 May 2024 07:15:18 -0700 Subject: [PATCH 19/29] resolve debug compile --- SDL/Triplet.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index 9976c63c..3cd88fdd 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -169,7 +169,8 @@ namespace SDL { float& zLoPointed, float& zHiPointed, float& sdlCut, - float& betaInCut unsigned int& tripletIndex) + float& betaInCut, + unsigned int& tripletIndex) #else ALPAKA_FN_ACC ALPAKA_FN_INLINE void addTripletToMemory(struct SDL::modules& modulesInGPU, struct SDL::miniDoublets& mdsInGPU, From 7e8311c8c86d51d0184027f48d56cccd6e7e2d93 Mon Sep 17 00:00:00 2001 From: YonsiG Date: Fri, 3 May 2024 07:19:08 -0700 Subject: [PATCH 20/29] remove corrF --- SDL/Triplet.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index 3cd88fdd..9661d0c2 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -377,7 +377,6 @@ namespace SDL { //beta computation float drt_tl_axis = alpaka::math::sqrt(acc, tl_axis_x * tl_axis_x + tl_axis_y * tl_axis_y); - float corrF = 1.f; //innerOuterAnchor - innerInnerAnchor const float rt_InSeg = alpaka::math::sqrt(acc, @@ -388,7 +387,7 @@ namespace SDL { betaInCut = alpaka::math::asin( acc, alpaka::math::min( - acc, (-rt_InSeg * corrF + drt_tl_axis) * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)) + + acc, (-rt_InSeg + drt_tl_axis) * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)) + (0.02f / drt_InSeg); //Cut #3: first beta cut From 626ff62549d67ce3bc8c11da5e631f869abe8731 Mon Sep 17 00:00:00 2001 From: YonsiG <48876687+YonsiG@users.noreply.github.com> Date: Fri, 3 May 2024 16:20:26 +0200 Subject: [PATCH 21/29] Update SDL/Triplet.h Co-authored-by: Slava Krutelyov --- SDL/Triplet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index 9661d0c2..7d11eb97 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -367,7 +367,7 @@ namespace SDL { // Cut #2: Pointed Z (Inner segment two MD points to outer segment inner MD) pass = pass and ((zOut >= zLoPointed) && (zOut <= zHiPointed)); - // First obtaining the raw betaIn and betaOut values without any correction and just purely based on the mini-doublet hit positions + // raw betaIn value without any correction, based on the mini-doublet hit positions float alpha_InLo = __H2F(segmentsInGPU.dPhiChanges[innerSegmentIndex]); float tl_axis_x = mdsInGPU.anchorX[thirdMDIndex] - mdsInGPU.anchorX[firstMDIndex]; float tl_axis_y = mdsInGPU.anchorY[thirdMDIndex] - mdsInGPU.anchorY[firstMDIndex]; From 9f9d62630bf71d00d1d3e1d6fcfa6c0d744cf2e6 Mon Sep 17 00:00:00 2001 From: YonsiG Date: Fri, 3 May 2024 07:24:01 -0700 Subject: [PATCH 22/29] remove corrF --- SDL/Triplet.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index 7d11eb97..a54f0806 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -516,10 +516,9 @@ namespace SDL { float sdIn_d = rt_InOut - rt_InLo; float dr = alpaka::math::sqrt(acc, tl_axis_x * tl_axis_x + tl_axis_y * tl_axis_y); - const float corrF = 1.f; betaInCut = alpaka::math::asin( - acc, alpaka::math::min(acc, (-sdIn_dr * corrF + dr) * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)) + + acc, alpaka::math::min(acc, (-sdIn_dr + dr) * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)) + (0.02f / sdIn_d); //Cut #4: first beta cut From c49dc6f213adad5ea4fc41bad890423b02c91a2a Mon Sep 17 00:00:00 2001 From: YonsiG <48876687+YonsiG@users.noreply.github.com> Date: Fri, 3 May 2024 16:26:13 +0200 Subject: [PATCH 23/29] Update SDL/Triplet.h Co-authored-by: Slava Krutelyov --- SDL/Triplet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index a54f0806..0f1da327 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -650,7 +650,7 @@ namespace SDL { acc, alpaka::math::min(acc, (-sdIn_dr * corrF + dr) * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)) + (0.02f / sdIn_d); - //Cut #6: first beta cut + //Cut #4: first beta cut pass = pass and (alpaka::math::abs(acc, betaInRHmin) < betaInCut); return pass; }; From 48e1be2cbae84866227d0f6989059a37f1ba3f4e Mon Sep 17 00:00:00 2001 From: YonsiG Date: Fri, 3 May 2024 07:28:18 -0700 Subject: [PATCH 24/29] remove corrF --- SDL/Triplet.h | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index 0f1da327..e205abc8 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -384,11 +384,10 @@ namespace SDL { (mdsInGPU.anchorX[secondMDIndex] - mdsInGPU.anchorX[firstMDIndex]) + (mdsInGPU.anchorY[secondMDIndex] - mdsInGPU.anchorY[firstMDIndex]) * (mdsInGPU.anchorY[secondMDIndex] - mdsInGPU.anchorY[firstMDIndex])); - betaInCut = alpaka::math::asin( - acc, - alpaka::math::min( - acc, (-rt_InSeg + drt_tl_axis) * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)) + - (0.02f / drt_InSeg); + betaInCut = + alpaka::math::asin( + acc, alpaka::math::min(acc, (-rt_InSeg + drt_tl_axis) * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)) + + (0.02f / drt_InSeg); //Cut #3: first beta cut pass = pass and (alpaka::math::abs(acc, betaInRHmin) < betaInCut); @@ -516,10 +515,9 @@ namespace SDL { float sdIn_d = rt_InOut - rt_InLo; float dr = alpaka::math::sqrt(acc, tl_axis_x * tl_axis_x + tl_axis_y * tl_axis_y); - betaInCut = - alpaka::math::asin( - acc, alpaka::math::min(acc, (-sdIn_dr + dr) * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)) + - (0.02f / sdIn_d); + betaInCut = alpaka::math::asin( + acc, alpaka::math::min(acc, (-sdIn_dr + dr) * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)) + + (0.02f / sdIn_d); //Cut #4: first beta cut pass = pass and (alpaka::math::abs(acc, betaInRHmin) < betaInCut); @@ -644,11 +642,9 @@ namespace SDL { float sdIn_d = rt_InOut - rt_InLo; float dr = alpaka::math::sqrt(acc, tl_axis_x * tl_axis_x + tl_axis_y * tl_axis_y); - const float corrF = 1.f; - betaInCut = - alpaka::math::asin( - acc, alpaka::math::min(acc, (-sdIn_dr * corrF + dr) * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)) + - (0.02f / sdIn_d); + betaInCut = alpaka::math::asin( + acc, alpaka::math::min(acc, (-sdIn_dr + dr) * SDL::k2Rinv1GeVf / SDL::ptCut, SDL::sinAlphaMax)) + + (0.02f / sdIn_d); //Cut #4: first beta cut pass = pass and (alpaka::math::abs(acc, betaInRHmin) < betaInCut); From 413ff9311d175d31693e5e89ff81a146e7551cab Mon Sep 17 00:00:00 2001 From: YonsiG Date: Fri, 3 May 2024 07:47:04 -0700 Subject: [PATCH 25/29] change half precision into float --- SDL/Triplet.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index e205abc8..8532cce7 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -16,10 +16,10 @@ namespace SDL { unsigned int* nMemoryLocations; uint8_t* logicalLayers; unsigned int* hitIndices; - FPX* betaIn; - FPX* circleRadius; - FPX* circleCenterX; - FPX* circleCenterY; + float* betaIn; + float* circleRadius; + float* circleCenterX; + float* circleCenterY; bool* partOfPT5; bool* partOfT5; bool* partOfPT3; @@ -81,10 +81,10 @@ namespace SDL { Buf nMemoryLocations_buf; Buf logicalLayers_buf; Buf hitIndices_buf; - Buf betaIn_buf; - Buf circleRadius_buf; - Buf circleCenterX_buf; - Buf circleCenterY_buf; + Buf betaIn_buf; + Buf circleRadius_buf; + Buf circleCenterX_buf; + Buf circleCenterY_buf; Buf partOfPT5_buf; Buf partOfT5_buf; Buf partOfPT3_buf; @@ -113,10 +113,10 @@ namespace SDL { nMemoryLocations_buf(allocBufWrapper(devAccIn, 1, queue)), logicalLayers_buf(allocBufWrapper(devAccIn, maxTriplets * 3, queue)), hitIndices_buf(allocBufWrapper(devAccIn, maxTriplets * 6, queue)), - betaIn_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - circleRadius_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - circleCenterX_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - circleCenterY_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), + betaIn_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), + circleRadius_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), + circleCenterX_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), + circleCenterY_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), partOfPT5_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), partOfT5_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), partOfPT3_buf(allocBufWrapper(devAccIn, maxTriplets, queue)) From 7c97fceeebf86f0424b37905cce67e5f9490d000 Mon Sep 17 00:00:00 2001 From: YonsiG <48876687+YonsiG@users.noreply.github.com> Date: Mon, 6 May 2024 16:56:38 +0200 Subject: [PATCH 26/29] Update SDL/Triplet.h Co-authored-by: Slava Krutelyov --- SDL/Triplet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index 8532cce7..9e830864 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -16,7 +16,7 @@ namespace SDL { unsigned int* nMemoryLocations; uint8_t* logicalLayers; unsigned int* hitIndices; - float* betaIn; + FPX* betaIn; float* circleRadius; float* circleCenterX; float* circleCenterY; From 7e492c33f4b04d94cc68713a5205930095bd4914 Mon Sep 17 00:00:00 2001 From: YonsiG Date: Mon, 6 May 2024 08:01:02 -0700 Subject: [PATCH 27/29] change the half precision --- SDL/Triplet.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index 9e830864..a84bdc9b 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -195,9 +195,9 @@ namespace SDL { tripletsInGPU.lowerModuleIndices[tripletIndex * 3 + 2] = outerOuterLowerModuleIndex; tripletsInGPU.betaIn[tripletIndex] = __F2H(betaIn); - tripletsInGPU.circleRadius[tripletIndex] = __F2H(circleRadius); - tripletsInGPU.circleCenterX[tripletIndex] = __F2H(circleCenterX); - tripletsInGPU.circleCenterY[tripletIndex] = __F2H(circleCenterY); + tripletsInGPU.circleRadius[tripletIndex] = circleRadius; + tripletsInGPU.circleCenterX[tripletIndex] = circleCenterX; + tripletsInGPU.circleCenterY[tripletIndex] = circleCenterY; tripletsInGPU.logicalLayers[tripletIndex * 3] = modulesInGPU.layers[innerInnerLowerModuleIndex] + (modulesInGPU.subdets[innerInnerLowerModuleIndex] == 4) * 6; tripletsInGPU.logicalLayers[tripletIndex * 3 + 1] = From 7858f1c894426ed80e9af917f827e76aaac9185a Mon Sep 17 00:00:00 2001 From: YonsiG <48876687+YonsiG@users.noreply.github.com> Date: Tue, 7 May 2024 20:14:28 +0200 Subject: [PATCH 28/29] Update SDL/Triplet.h Co-authored-by: Slava Krutelyov --- SDL/Triplet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index a84bdc9b..24fbe161 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -81,7 +81,7 @@ namespace SDL { Buf nMemoryLocations_buf; Buf logicalLayers_buf; Buf hitIndices_buf; - Buf betaIn_buf; + Buf betaIn_buf; Buf circleRadius_buf; Buf circleCenterX_buf; Buf circleCenterY_buf; From cf39c3a458b124d056027edcb1805965033c4740 Mon Sep 17 00:00:00 2001 From: YonsiG <48876687+YonsiG@users.noreply.github.com> Date: Tue, 7 May 2024 20:14:42 +0200 Subject: [PATCH 29/29] Update SDL/Triplet.h Co-authored-by: Slava Krutelyov --- SDL/Triplet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDL/Triplet.h b/SDL/Triplet.h index 24fbe161..e37c17a0 100644 --- a/SDL/Triplet.h +++ b/SDL/Triplet.h @@ -113,7 +113,7 @@ namespace SDL { nMemoryLocations_buf(allocBufWrapper(devAccIn, 1, queue)), logicalLayers_buf(allocBufWrapper(devAccIn, maxTriplets * 3, queue)), hitIndices_buf(allocBufWrapper(devAccIn, maxTriplets * 6, queue)), - betaIn_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), + betaIn_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), circleRadius_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), circleCenterX_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), circleCenterY_buf(allocBufWrapper(devAccIn, maxTriplets, queue)),