1 #ifndef RecoTracker_LSTCore_src_alpaka_MiniDoublet_h 2 #define RecoTracker_LSTCore_src_alpaka_MiniDoublet_h 16 template <
typename TAcc>
21 unsigned int lowerHitIdx,
22 unsigned int upperHitIdx,
23 uint16_t lowerModuleIdx,
31 float noShiftedDPhiChange,
36 mds.moduleIndices()[
idx] = lowerModuleIdx;
37 unsigned int anchorHitIndex, outerHitIndex;
38 if (
modules.moduleType()[lowerModuleIdx] ==
PS and
modules.moduleLayerType()[lowerModuleIdx] == Strip) {
39 mds.anchorHitIndices()[
idx] = upperHitIdx;
40 mds.outerHitIndices()[
idx] = lowerHitIdx;
42 anchorHitIndex = upperHitIdx;
43 outerHitIndex = lowerHitIdx;
45 mds.anchorHitIndices()[
idx] = lowerHitIdx;
46 mds.outerHitIndices()[
idx] = upperHitIdx;
48 anchorHitIndex = lowerHitIdx;
49 outerHitIndex = upperHitIdx;
52 mds.dphichanges()[
idx] = dPhiChange;
54 mds.dphis()[
idx] = dPhi;
56 mds.shiftedXs()[
idx] = shiftedX;
57 mds.shiftedYs()[
idx] = shiftedY;
58 mds.shiftedZs()[
idx] = shiftedZ;
60 mds.noShiftedDphis()[
idx] = noShiftedDphi;
61 mds.noShiftedDphiChanges()[
idx] = noShiftedDPhiChange;
63 mds.anchorX()[
idx] =
hits.xs()[anchorHitIndex];
64 mds.anchorY()[
idx] =
hits.ys()[anchorHitIndex];
65 mds.anchorZ()[
idx] =
hits.zs()[anchorHitIndex];
66 mds.anchorRt()[
idx] =
hits.rts()[anchorHitIndex];
67 mds.anchorPhi()[
idx] =
hits.phis()[anchorHitIndex];
68 mds.anchorEta()[
idx] =
hits.etas()[anchorHitIndex];
69 mds.anchorHighEdgeX()[
idx] =
hits.highEdgeXs()[anchorHitIndex];
70 mds.anchorHighEdgeY()[
idx] =
hits.highEdgeYs()[anchorHitIndex];
71 mds.anchorLowEdgeX()[
idx] =
hits.lowEdgeXs()[anchorHitIndex];
72 mds.anchorLowEdgeY()[
idx] =
hits.lowEdgeYs()[anchorHitIndex];
76 mds.outerX()[
idx] =
hits.xs()[outerHitIndex];
77 mds.outerY()[
idx] =
hits.ys()[outerHitIndex];
78 mds.outerZ()[
idx] =
hits.zs()[outerHitIndex];
79 mds.outerRt()[
idx] =
hits.rts()[outerHitIndex];
80 mds.outerPhi()[
idx] =
hits.phis()[outerHitIndex];
81 mds.outerEta()[
idx] =
hits.etas()[outerHitIndex];
82 mds.outerHighEdgeX()[
idx] =
hits.highEdgeXs()[outerHitIndex];
83 mds.outerHighEdgeY()[
idx] =
hits.highEdgeYs()[outerHitIndex];
84 mds.outerLowEdgeX()[
idx] =
hits.lowEdgeXs()[outerHitIndex];
85 mds.outerLowEdgeY()[
idx] =
hits.lowEdgeYs()[outerHitIndex];
92 short subdet =
modules.subdets()[moduleIndex];
93 short layer =
modules.layers()[moduleIndex];
95 short rod =
modules.rods()[moduleIndex];
97 if (subdet == Barrel) {
100 (
side ==
PosZ and layer == 1 and rod < 4))
109 float miniDeltaTilted[3] = {0.26f, 0.26f, 0.26f};
110 float miniDeltaFlat[6] = {0.26f, 0.16f, 0.16f, 0.18f, 0.18f, 0.18f};
111 float miniDeltaLooseTilted[3] = {0.4f, 0.4f, 0.4f};
112 float miniDeltaEndcap[5][15];
114 for (
size_t i = 0;
i < 5;
i++) {
115 for (
size_t j = 0;
j < 15;
j++) {
116 if (
i == 0 ||
i == 1) {
118 miniDeltaEndcap[
i][
j] = 0.4f;
120 miniDeltaEndcap[
i][
j] = 0.18f;
122 }
else if (
i == 2 ||
i == 3) {
124 miniDeltaEndcap[
i][
j] = 0.4f;
126 miniDeltaEndcap[
i][
j] = 0.18f;
130 miniDeltaEndcap[
i][
j] = 0.4f;
132 miniDeltaEndcap[
i][
j] = 0.18f;
138 unsigned int iL =
modules.layers()[moduleIndex] - 1;
139 unsigned int iR =
modules.rings()[moduleIndex] - 1;
140 short subdet =
modules.subdets()[moduleIndex];
143 float moduleSeparation = 0;
146 moduleSeparation = miniDeltaFlat[iL];
148 moduleSeparation = miniDeltaTilted[iL];
149 }
else if (subdet ==
Endcap) {
150 moduleSeparation = miniDeltaEndcap[iL][iR];
153 moduleSeparation = miniDeltaLooseTilted[iL];
156 return moduleSeparation;
159 template <
typename TAcc>
171 unsigned int iL =
modules.layers()[moduleIndex] - 1;
173 const float rLayNominal =
175 const float miniPVoff = 0.1f / rLayNominal;
178 const bool isTilted =
modules.subdets()[moduleIndex] == Barrel and
modules.sides()[moduleIndex] !=
Center;
183 if (
modules.moduleType()[moduleIndex] ==
PS and
modules.moduleLayerType()[moduleIndex] == Strip) {
184 drdz =
modules.drdzs()[moduleIndex];
186 drdz =
modules.drdzs()[
modules.partnerModuleIndices()[moduleIndex]];
203 return miniSlope +
alpaka::math::sqrt(acc, miniMuls * miniMuls + miniPVoff * miniPVoff);
206 else if (
modules.subdets()[moduleIndex] == Barrel and
210 alpaka::math::sqrt(acc, miniMuls * miniMuls + miniPVoff * miniPVoff + miniTilt2 * miniSlope * miniSlope);
214 return miniSlope +
alpaka::math::sqrt(acc, miniMuls * miniMuls + miniPVoff * miniPVoff + miniLum * miniLum);
218 template <
typename TAcc>
221 uint16_t lowerModuleIndex,
222 uint16_t upperModuleIndex,
223 unsigned int lowerHitIndex,
224 unsigned int upperHitIndex,
225 float* shiftedCoords,
265 float moduleSeparation;
270 modules.dxdys()[lowerModuleIndex];
271 float absArctanSlope;
274 const float& drdz_ =
modules.drdzs()[lowerModuleIndex];
276 if (
modules.moduleType()[lowerModuleIndex] ==
PS) {
278 if (
modules.subdets()[lowerModuleIndex] == Barrel ?
modules.moduleLayerType()[lowerModuleIndex] != Pixel
279 :
modules.moduleLayerType()[lowerModuleIndex] == Pixel) {
312 : alpaka::math::atan(
319 if (
modules.moduleType()[lowerModuleIndex] ==
PS and
modules.moduleLayerType()[lowerModuleIndex] != Pixel) {
320 moduleSeparation *= -1;
329 if (xp > 0 and yp > 0) {
330 angleM = absArctanSlope;
331 }
else if (xp > 0 and yp < 0) {
332 angleM =
kPi - absArctanSlope;
333 }
else if (xp < 0 and yp < 0) {
334 angleM =
kPi + absArctanSlope;
337 angleM = 2.f *
kPi - absArctanSlope;
354 }
else if (
slope == 0) {
359 yn = (xn - xa) *
slope + ya;
371 if (
modules.moduleLayerType()[lowerModuleIndex] == Pixel) {
377 zn = abszn * ((zp > 0) ? 1 : -1);
379 shiftedCoords[0] = xn;
380 shiftedCoords[1] = yn;
381 shiftedCoords[2] = zn;
384 template <
typename TAcc>
387 uint16_t lowerModuleIndex,
388 uint16_t upperModuleIndex,
389 unsigned int lowerHitIndex,
390 unsigned int upperHitIndex,
397 float& noShiftedDphi,
398 float& noShiftedDphiChange,
407 dz = zLower - zUpper;
408 const float dzCut =
modules.moduleType()[lowerModuleIndex] ==
PS ? 2.f : 10.f;
409 const float sign = ((
dz > 0) - (
dz < 0)) * ((zLower > 0) - (zLower < 0));
417 miniCut =
modules.moduleLayerType()[lowerModuleIndex] == Pixel
423 float xn = 0.f, yn = 0.f;
428 float shiftedCoords[3];
444 xn = shiftedCoords[0];
445 yn = shiftedCoords[1];
448 if (
modules.moduleLayerType()[lowerModuleIndex] == Pixel) {
452 shiftedRt2 = xn * xn + yn * yn;
460 shiftedRt2 = xn * xn + yn * yn;
469 noShiftedDphi = dPhi;
480 if (
modules.moduleLayerType()[lowerModuleIndex] != Pixel) {
487 dPhiChange = (rtLower * rtLower < shiftedRt2) ?
deltaPhiChange(acc,
xLower, yLower, shiftedX, shiftedY)
497 dPhiChange = (shiftedRt2 < rtUpper * rtUpper) ?
deltaPhiChange(acc, shiftedX, shiftedY,
xUpper, yUpper)
505 noShiftedDphiChange = dPhiChange;
511 template <
typename TAcc>
514 uint16_t lowerModuleIndex,
515 uint16_t upperModuleIndex,
516 unsigned int lowerHitIndex,
517 unsigned int upperHitIndex,
524 float& noShiftedDphi,
525 float& noShiftedDphichange,
539 float dz = zLower - zUpper;
541 const float dzCut = 1.f;
547 const float drtCut =
modules.moduleType()[lowerModuleIndex] ==
PS ? 2.f : 10.f;
548 drt = rtLower - rtUpper;
552 float xn = 0, yn = 0, zn = 0;
554 float shiftedCoords[3];
571 xn = shiftedCoords[0];
572 yn = shiftedCoords[1];
573 zn = shiftedCoords[2];
575 if (
modules.moduleType()[lowerModuleIndex] ==
PS) {
577 if (
modules.moduleLayerType()[lowerModuleIndex] == Pixel) {
600 if (
modules.moduleType()[lowerModuleIndex] ==
PS) {
601 dz =
modules.moduleLayerType()[lowerModuleIndex] == Pixel ? zLower - zn : zUpper - zn;
605 miniCut =
modules.moduleLayerType()[lowerModuleIndex] == Pixel
616 dPhiChange = dPhi / dzFrac * (1.f + dzFrac);
617 noShiftedDphichange = noShiftedDphi / dzFrac * (1.f + dzFrac);
622 template <
typename TAcc>
625 uint16_t lowerModuleIndex,
626 uint16_t upperModuleIndex,
627 unsigned int lowerHitIndex,
628 unsigned int upperHitIndex,
635 float& noShiftedDphi,
636 float& noShiftedDphiChange,
645 if (
modules.subdets()[lowerModuleIndex] == Barrel) {
695 template <
typename TAcc>
703 auto const globalThreadIdx = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc);
704 auto const gridThreadExtent = alpaka::getWorkDiv<alpaka::Grid, alpaka::Threads>(acc);
706 for (uint16_t lowerModuleIndex = globalThreadIdx[1]; lowerModuleIndex <
modules.nLowerModules();
707 lowerModuleIndex += gridThreadExtent[1]) {
708 uint16_t upperModuleIndex =
modules.partnerModuleIndices()[lowerModuleIndex];
709 int nLowerHits = hitsRanges.hitRangesnLower()[lowerModuleIndex];
710 int nUpperHits = hitsRanges.hitRangesnUpper()[lowerModuleIndex];
711 if (hitsRanges.hitRangesLower()[lowerModuleIndex] == -1)
713 unsigned int upHitArrayIndex = hitsRanges.hitRangesUpper()[lowerModuleIndex];
714 unsigned int loHitArrayIndex = hitsRanges.hitRangesLower()[lowerModuleIndex];
715 int limit = nUpperHits * nLowerHits;
717 for (
int hitIndex = globalThreadIdx[2]; hitIndex <
limit; hitIndex += gridThreadExtent[2]) {
718 int lowerHitIndex = hitIndex / nUpperHits;
719 int upperHitIndex = hitIndex % nUpperHits;
720 if (upperHitIndex >= nUpperHits)
722 if (lowerHitIndex >= nLowerHits)
724 unsigned int lowerHitArrayIndex = loHitArrayIndex + lowerHitIndex;
726 float yLower =
hits.ys()[lowerHitArrayIndex];
727 float zLower =
hits.zs()[lowerHitArrayIndex];
728 float rtLower =
hits.rts()[lowerHitArrayIndex];
729 unsigned int upperHitArrayIndex = upHitArrayIndex + upperHitIndex;
731 float yUpper =
hits.ys()[upperHitArrayIndex];
732 float zUpper =
hits.zs()[upperHitArrayIndex];
733 float rtUpper =
hits.rts()[upperHitArrayIndex];
735 float dz, dphi, dphichange, shiftedX, shiftedY, shiftedZ, noShiftedDphi, noShiftedDphiChange;
760 acc, &mdsOccupancy.totOccupancyMDs()[lowerModuleIndex], 1u, alpaka::hierarchy::Threads{});
761 if (totOccupancyMDs >= (
ranges.miniDoubletModuleOccupancy()[lowerModuleIndex])) {
763 printf(
"Mini-doublet excess alert! Module index = %d\n", lowerModuleIndex);
767 alpaka::atomicAdd(acc, &mdsOccupancy.nMDs()[lowerModuleIndex], 1u, alpaka::hierarchy::Threads{});
768 unsigned int mdIndex =
ranges.miniDoubletModuleIndices()[lowerModuleIndex] + mdModuleIndex;
794 template <
typename TAcc>
797 static_assert(std::is_same_v<TAcc, ALPAKA_ACCELERATOR_NAMESPACE::Acc1D>,
"Should be Acc1D");
798 ALPAKA_ASSERT_ACC((alpaka::getWorkDiv<alpaka::Grid, alpaka::Blocks>(acc)[0] == 1));
800 auto const globalThreadIdx = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc);
801 auto const gridThreadExtent = alpaka::getWorkDiv<alpaka::Grid, alpaka::Threads>(acc);
804 int& nTotalMDs = alpaka::declareSharedVar<int, __COUNTER__>(acc);
808 alpaka::syncBlockThreads(acc);
810 for (uint16_t
i = globalThreadIdx[0];
i <
modules.nLowerModules();
i += gridThreadExtent[0]) {
821 else if (module_layers <= 2 && module_subdets == 4 && module_rings >= 11)
830 category_number = -1;
833 if (module_eta < 0.75
f)
835 else if (module_eta < 1.5
f)
837 else if (module_eta < 2.25
f)
839 else if (module_eta < 3.0
f)
845 if (category_number == 0 && eta_number == 0)
847 else if (category_number == 0 && eta_number == 1)
849 else if (category_number == 0 && eta_number == 2)
851 else if (category_number == 0 && eta_number == 3)
853 else if (category_number == 1)
855 else if (category_number == 2 && eta_number == 1)
857 else if (category_number == 2 && eta_number == 2)
859 else if (category_number == 3 && eta_number == 1)
861 else if (category_number == 3 && eta_number == 2)
863 else if (category_number == 3 && eta_number == 3)
868 printf(
"Unhandled case in createMDArrayRangesGPU! Module index = %i\n",
i);
872 unsigned int nTotMDs =
alpaka::atomicAdd(acc, &nTotalMDs, occupancy, alpaka::hierarchy::Threads{});
874 ranges.miniDoubletModuleIndices()[
i] = nTotMDs;
875 ranges.miniDoubletModuleOccupancy()[
i] = occupancy;
879 alpaka::syncBlockThreads(acc);
881 ranges.miniDoubletModuleIndices()[
modules.nLowerModules()] = nTotalMDs;
882 ranges.nTotalMDs() = nTotalMDs;
888 template <
typename TAcc>
895 static_assert(std::is_same_v<TAcc, ALPAKA_ACCELERATOR_NAMESPACE::Acc1D>,
"Should be Acc1D");
896 ALPAKA_ASSERT_ACC((alpaka::getWorkDiv<alpaka::Grid, alpaka::Blocks>(acc)[0] == 1));
898 auto const globalThreadIdx = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc);
899 auto const gridThreadExtent = alpaka::getWorkDiv<alpaka::Grid, alpaka::Threads>(acc);
901 for (uint16_t
i = globalThreadIdx[0];
i <
modules.nLowerModules();
i += gridThreadExtent[0]) {
902 if (mdsOccupancy.nMDs()[
i] == 0
or hitsRanges.hitRanges()[
i][0] == -1) {
907 ranges.mdRanges()[
i][1] =
ranges.miniDoubletModuleIndices()[
i] + mdsOccupancy.nMDs()[
i] - 1;
MiniDoubletsSoA::View MiniDoublets
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kMiniRminMeanEndcap[5]
ALPAKA_FN_ACC void operator()(TAcc const &acc, ModulesConst modules, ObjectRanges ranges) const
ALPAKA_FN_ACC bool runMiniDoubletDefaultAlgoBarrel(TAcc const &acc, ModulesConst modules, uint16_t lowerModuleIndex, uint16_t upperModuleIndex, unsigned int lowerHitIndex, unsigned int upperHitIndex, float &dz, float &dPhi, float &dPhiChange, float &shiftedX, float &shiftedY, float &shiftedZ, float &noShiftedDphi, float &noShiftedDphiChange, float xLower, float yLower, float zLower, float rtLower, float xUpper, float yUpper, float zUpper, float rtUpper)
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kMiniMulsPtScaleBarrel[6]
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float k2Rinv1GeVf
ObjectRangesSoA::View ObjectRanges
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kMiniMulsPtScaleEndcap[5]
static const double slope[3]
const std::vector< int > & module_rings()
Sin< T >::type sin(const T &t)
ALPAKA_FN_ACC void operator()(TAcc const &acc, ModulesConst modules, MiniDoubletsOccupancy mdsOccupancy, ObjectRanges ranges, HitsRangesConst hitsRanges) const
ALPAKA_FN_ACC int side(int ieta, int iphi)
ALPAKA_FN_ACC bool runMiniDoubletDefaultAlgoEndcap(TAcc const &acc, ModulesConst modules, uint16_t lowerModuleIndex, uint16_t upperModuleIndex, unsigned int lowerHitIndex, unsigned int upperHitIndex, float &drt, float &dPhi, float &dPhiChange, float &shiftedX, float &shiftedY, float &shiftedZ, float &noShiftedDphi, float &noShiftedDphichange, float xLower, float yLower, float zLower, float rtLower, float xUpper, float yUpper, float zUpper, float rtUpper)
ALPAKA_FN_ACC bool runMiniDoubletDefaultAlgo(TAcc const &acc, ModulesConst modules, uint16_t lowerModuleIndex, uint16_t upperModuleIndex, unsigned int lowerHitIndex, unsigned int upperHitIndex, float &dz, float &dPhi, float &dPhiChange, float &shiftedX, float &shiftedY, float &shiftedZ, float &noShiftedDphi, float &noShiftedDphiChange, float xLower, float yLower, float zLower, float rtLower, float xUpper, float yUpper, float zUpper, float rtUpper)
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kMiniRminMeanBarrel[6]
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kVerticalModuleSlope
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float ptCut
ALPAKA_FN_ACC ALPAKA_FN_INLINE void addMDToMemory(TAcc const &acc, MiniDoublets mds, HitsConst hits, ModulesConst modules, unsigned int lowerHitIdx, unsigned int upperHitIdx, uint16_t lowerModuleIdx, float dz, float dPhi, float dPhiChange, float shiftedX, float shiftedY, float shiftedZ, float noShiftedDphi, float noShiftedDPhiChange, unsigned int idx)
ALPAKA_FN_ACC ALPAKA_FN_INLINE float moduleGapSize(ModulesConst modules, uint16_t moduleIndex)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
HitsSoA::ConstView HitsConst
ModulesSoA::ConstView ModulesConst
HitsRangesSoA::ConstView HitsRangesConst
bool isEndcap(GeomDetEnumerators::SubDetector m)
ALPAKA_FN_INLINE ALPAKA_FN_ACC void shiftStripHits(TAcc const &acc, ModulesConst modules, uint16_t lowerModuleIndex, uint16_t upperModuleIndex, unsigned int lowerHitIndex, unsigned int upperHitIndex, float *shiftedCoords, float xLower, float yLower, float zLower, float rtLower, float xUpper, float yUpper, float zUpper, float rtUpper)
const std::vector< int > & module_layers()
MiniDoubletsOccupancySoA::View MiniDoubletsOccupancy
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kPixelPSZpitch
const std::vector< int > & module_subdets()
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kPi
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool isTighterTiltedModules(ModulesConst modules, uint16_t moduleIndex)
ObjectRangesSoA::ConstView ObjectRangesConst
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kSinAlphaMax
ALPAKA_FN_ACC ALPAKA_FN_INLINE float dPhiThreshold(TAcc const &acc, float rt, ModulesConst modules, uint16_t moduleIndex, float dPhi=0, float dz=0)
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kDeltaZLum
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE float deltaPhi(TAcc const &acc, float x1, float y1, float x2, float y2)
ALPAKA_ASSERT_ACC(offsets)
T1 atomicAdd(T1 *a, T2 b)
ALPAKA_FN_ACC void operator()(TAcc const &acc, ModulesConst modules, HitsConst hits, HitsRangesConst hitsRanges, MiniDoublets mds, MiniDoubletsOccupancy mdsOccupancy, ObjectRangesConst ranges) const
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE float deltaPhiChange(TAcc const &acc, float x1, float y1, float x2, float y2)
MPlex< T, D1, D2, N > atan2(const MPlex< T, D1, D2, N > &y, const MPlex< T, D1, D2, N > &x)