1 #ifndef RecoTracker_LSTCore_src_alpaka_Quintuplet_h 2 #define RecoTracker_LSTCore_src_alpaka_Quintuplet_h 25 return ((firstMin <= secondMin) && (secondMin < firstMax)) || ((secondMin < firstMin) && (firstMin < secondMax));
30 unsigned int innerTripletIndex,
31 unsigned int outerTripletIndex,
32 uint16_t lowerModule1,
33 uint16_t lowerModule2,
34 uint16_t lowerModule3,
35 uint16_t lowerModule4,
36 uint16_t lowerModule5,
42 float regressionRadius,
45 float nonAnchorChiSquared,
51 unsigned int quintupletIndex,
53 quintuplets.tripletIndices()[quintupletIndex][0] = innerTripletIndex;
54 quintuplets.tripletIndices()[quintupletIndex][1] = outerTripletIndex;
56 quintuplets.lowerModuleIndices()[quintupletIndex][0] = lowerModule1;
57 quintuplets.lowerModuleIndices()[quintupletIndex][1] = lowerModule2;
58 quintuplets.lowerModuleIndices()[quintupletIndex][2] = lowerModule3;
59 quintuplets.lowerModuleIndices()[quintupletIndex][3] = lowerModule4;
60 quintuplets.lowerModuleIndices()[quintupletIndex][4] = lowerModule5;
63 quintuplets.pt()[quintupletIndex] =
__F2H(
pt);
64 quintuplets.eta()[quintupletIndex] =
__F2H(
eta);
65 quintuplets.phi()[quintupletIndex] =
__F2H(
phi);
66 quintuplets.score_rphisum()[quintupletIndex] =
__F2H(scores);
67 quintuplets.isDup()[quintupletIndex] = 0;
68 quintuplets.tightCutFlag()[quintupletIndex] = tightCutFlag;
69 quintuplets.regressionRadius()[quintupletIndex] = regressionRadius;
70 quintuplets.regressionG()[quintupletIndex] = regressionG;
71 quintuplets.regressionF()[quintupletIndex] = regressionF;
72 quintuplets.logicalLayers()[quintupletIndex][0] = triplets.logicalLayers()[innerTripletIndex][0];
73 quintuplets.logicalLayers()[quintupletIndex][1] = triplets.logicalLayers()[innerTripletIndex][1];
74 quintuplets.logicalLayers()[quintupletIndex][2] = triplets.logicalLayers()[innerTripletIndex][2];
75 quintuplets.logicalLayers()[quintupletIndex][3] = triplets.logicalLayers()[outerTripletIndex][1];
76 quintuplets.logicalLayers()[quintupletIndex][4] = triplets.logicalLayers()[outerTripletIndex][2];
78 quintuplets.hitIndices()[quintupletIndex][0] = triplets.hitIndices()[innerTripletIndex][0];
79 quintuplets.hitIndices()[quintupletIndex][1] = triplets.hitIndices()[innerTripletIndex][1];
80 quintuplets.hitIndices()[quintupletIndex][2] = triplets.hitIndices()[innerTripletIndex][2];
81 quintuplets.hitIndices()[quintupletIndex][3] = triplets.hitIndices()[innerTripletIndex][3];
82 quintuplets.hitIndices()[quintupletIndex][4] = triplets.hitIndices()[innerTripletIndex][4];
83 quintuplets.hitIndices()[quintupletIndex][5] = triplets.hitIndices()[innerTripletIndex][5];
84 quintuplets.hitIndices()[quintupletIndex][6] = triplets.hitIndices()[outerTripletIndex][2];
85 quintuplets.hitIndices()[quintupletIndex][7] = triplets.hitIndices()[outerTripletIndex][3];
86 quintuplets.hitIndices()[quintupletIndex][8] = triplets.hitIndices()[outerTripletIndex][4];
87 quintuplets.hitIndices()[quintupletIndex][9] = triplets.hitIndices()[outerTripletIndex][5];
88 quintuplets.bridgeRadius()[quintupletIndex] = bridgeRadius;
89 quintuplets.rzChiSquared()[quintupletIndex] = rzChiSquared;
90 quintuplets.chiSquared()[quintupletIndex] = rPhiChiSquared;
91 quintuplets.nonAnchorChiSquared()[quintupletIndex] = nonAnchorChiSquared;
96 uint16_t lowerModuleIndex1,
97 uint16_t lowerModuleIndex2,
98 uint16_t lowerModuleIndex3,
99 uint16_t lowerModuleIndex4,
100 uint16_t lowerModuleIndex5,
103 const int layer1 =
modules.lstLayers()[lowerModuleIndex1];
104 const int layer2 =
modules.lstLayers()[lowerModuleIndex2];
105 const int layer3 =
modules.lstLayers()[lowerModuleIndex3];
106 const int layer4 =
modules.lstLayers()[lowerModuleIndex4];
107 const int layer5 =
modules.lstLayers()[lowerModuleIndex5];
109 if (layer1 == 7 and layer2 == 8 and layer3 == 9) {
110 if (layer4 == 10 and layer5 == 11) {
111 return chiSquared < 0.01788f;
112 }
else if (layer4 == 10 and layer5 == 16) {
113 return chiSquared < 0.04725f;
114 }
else if (layer4 == 15 and layer5 == 16) {
115 return chiSquared < 0.04725f;
117 }
else if (layer1 == 1 and layer2 == 7 and layer3 == 8) {
118 if (layer4 == 9 and layer5 == 10) {
119 return chiSquared < 0.01788f;
120 }
else if (layer4 == 9 and layer5 == 15) {
121 return chiSquared < 0.08234f;
123 }
else if (layer1 == 1 and layer2 == 2 and layer3 == 7) {
124 if (layer4 == 8 and layer5 == 9) {
125 return chiSquared < 0.02360f;
126 }
else if (layer4 == 8 and layer5 == 14) {
127 return chiSquared < 0.07167f;
128 }
else if (layer4 == 13 and layer5 == 14) {
129 return chiSquared < 0.08234f;
131 }
else if (layer1 == 1 and layer2 == 2 and layer3 == 3) {
132 if (layer4 == 7 and layer5 == 8) {
133 return chiSquared < 0.01026f;
134 }
else if (layer4 == 7 and layer5 == 13) {
135 return chiSquared < 0.06238f;
136 }
else if (layer4 == 12 and layer5 == 13) {
137 return chiSquared < 0.06238f;
139 }
else if (layer1 == 1 and layer2 == 2 and layer3 == 3 and layer4 == 4) {
141 return chiSquared < 0.04725f;
142 }
else if (layer5 == 12) {
143 return chiSquared < 0.09461f;
145 }
else if (layer1 == 2 and layer2 == 7 and layer3 == 8) {
146 if (layer4 == 9 and layer5 == 10) {
147 return chiSquared < 0.00512f;
149 if (layer4 == 9 and layer5 == 15) {
150 return chiSquared < 0.04112f;
151 }
else if (layer4 == 14 and layer5 == 15) {
152 return chiSquared < 0.06238f;
154 }
else if (layer1 == 2 and layer2 == 3 and layer3 == 7) {
155 if (layer4 == 8 and layer5 == 14) {
156 return chiSquared < 0.07167f;
157 }
else if (layer4 == 13 and layer5 == 14) {
158 return chiSquared < 0.06238f;
160 }
else if (layer1 == 2 and layer2 == 3 and layer3 == 4) {
161 if (layer4 == 5 and layer5 == 6) {
162 return chiSquared < 0.08234f;
163 }
else if (layer4 == 5 and layer5 == 12) {
164 return chiSquared < 0.10870f;
165 }
else if (layer4 == 12 and layer5 == 13) {
166 return chiSquared < 0.10870f;
168 }
else if (layer1 == 3 and layer2 == 7 and layer3 == 8 and layer4 == 14 and layer5 == 15) {
169 return chiSquared < 0.09461f;
170 }
else if (layer1 == 3 and layer2 == 4 and layer3 == 5 and layer4 == 12 and layer5 == 13) {
171 return chiSquared < 0.09461f;
178 template <
typename TAcc>
182 unsigned int firstMDIndex,
183 unsigned int secondMDIndex,
184 unsigned int thirdMDIndex,
185 unsigned int fourthMDIndex,
186 unsigned int fifthMDIndex,
187 uint16_t lowerModuleIndex1,
188 uint16_t lowerModuleIndex2,
189 uint16_t lowerModuleIndex3,
190 uint16_t lowerModuleIndex4,
191 uint16_t lowerModuleIndex5,
197 bool& tightCutFlag) {
199 const float rt1 = mds.anchorRt()[firstMDIndex] / 100;
200 const float rt2 = mds.anchorRt()[secondMDIndex] / 100;
201 const float rt3 = mds.anchorRt()[thirdMDIndex] / 100;
202 const float rt4 = mds.anchorRt()[fourthMDIndex] / 100;
203 const float rt5 = mds.anchorRt()[fifthMDIndex] / 100;
205 const float z1 = mds.anchorZ()[firstMDIndex] / 100;
206 const float z2 = mds.anchorZ()[secondMDIndex] / 100;
207 const float z3 = mds.anchorZ()[thirdMDIndex] / 100;
208 const float z4 = mds.anchorZ()[fourthMDIndex] / 100;
209 const float z5 = mds.anchorZ()[fifthMDIndex] / 100;
212 const int layer1 =
modules.lstLayers()[lowerModuleIndex1];
213 const int layer2 =
modules.lstLayers()[lowerModuleIndex2];
214 const int layer3 =
modules.lstLayers()[lowerModuleIndex3];
215 const int layer4 =
modules.lstLayers()[lowerModuleIndex4];
216 const int layer5 =
modules.lstLayers()[lowerModuleIndex5];
219 const int moduleType1 =
modules.moduleType()[lowerModuleIndex1];
220 const int moduleType2 =
modules.moduleType()[lowerModuleIndex2];
221 const int moduleType3 =
modules.moduleType()[lowerModuleIndex3];
222 const int moduleType4 =
modules.moduleType()[lowerModuleIndex4];
223 const int moduleType5 =
modules.moduleType()[lowerModuleIndex5];
225 const float x1 = mds.anchorX()[firstMDIndex] / 100;
226 const float x2 = mds.anchorX()[secondMDIndex] / 100;
227 const float x3 = mds.anchorX()[thirdMDIndex] / 100;
228 const float x4 = mds.anchorX()[fourthMDIndex] / 100;
229 const float y1 = mds.anchorY()[firstMDIndex] / 100;
230 const float y2 = mds.anchorY()[secondMDIndex] / 100;
231 const float y3 = mds.anchorY()[thirdMDIndex] / 100;
232 const float y4 = mds.anchorY()[fourthMDIndex] / 100;
236 float x_center =
g / 100, y_center =
f / 100;
237 float x_init = mds.anchorX()[thirdMDIndex] / 100;
238 float y_init = mds.anchorY()[thirdMDIndex] / 100;
239 float z_init = mds.anchorZ()[thirdMDIndex] / 100;
240 float rt_init = mds.anchorRt()[thirdMDIndex] / 100;
242 if (moduleType3 == 1)
244 x_init = mds.anchorX()[secondMDIndex] / 100;
245 y_init = mds.anchorY()[secondMDIndex] / 100;
246 z_init = mds.anchorZ()[secondMDIndex] / 100;
247 rt_init = mds.anchorRt()[secondMDIndex] / 100;
253 float slope3c = (y3 - y_center) / (x3 - x_center);
254 float slope1c = (
y1 - y_center) / (x1 - x_center);
256 if ((y3 - y_center) > 0 && (
y1 - y_center) > 0) {
257 if (slope1c > 0 && slope3c < 0)
259 else if (slope1c < 0 && slope3c > 0)
261 else if (slope3c > slope1c)
263 else if (slope3c < slope1c)
265 }
else if ((y3 - y_center) < 0 && (
y1 - y_center) < 0) {
266 if (slope1c < 0 && slope3c > 0)
268 else if (slope1c > 0 && slope3c < 0)
270 else if (slope3c > slope1c)
272 else if (slope3c < slope1c)
274 }
else if ((y3 - y_center) < 0 && (
y1 - y_center) > 0) {
275 if ((x3 - x_center) > 0 && (x1 - x_center) > 0)
277 else if ((x3 - x_center) < 0 && (x1 - x_center) < 0)
279 }
else if ((y3 - y_center) > 0 && (
y1 - y_center) < 0) {
280 if ((x3 - x_center) > 0 && (x1 - x_center) > 0)
282 else if ((x3 - x_center) < 0 && (x1 - x_center) < 0)
286 float pseudo_phi = alpaka::math::atan(
287 acc, (y_init - y_center) / (x_init - x_center));
293 if (x_init > x_center && y_init > y_center)
300 if (x_init < x_center && y_init > y_center)
307 if (x_init < x_center && y_init < y_center)
314 if (x_init > x_center && y_init < y_center)
323 if (moduleType3 == 0) {
324 if (x4 < x3 && x3 < x2)
326 else if (x4 > x3 && x3 > x2)
328 if (y4 < y3 && y3 <
y2)
330 else if (y4 > y3 && y3 >
y2)
332 }
else if (moduleType3 == 1)
334 if (x3 < x2 && x2 < x1)
336 else if (x3 > x2 && x2 > x1)
340 else if (y3 >
y2 &&
y2 >
y1)
345 float AO =
alpaka::math::sqrt(acc, (x1 - x_center) * (x1 - x_center) + (
y1 - y_center) * (
y1 - y_center));
347 alpaka::math::sqrt(acc, (x_init - x_center) * (x_init - x_center) + (y_init - y_center) * (y_init - y_center));
348 float AB2 = (x1 - x_init) * (x1 - x_init) + (
y1 - y_init) * (
y1 - y_init);
349 float dPhi = alpaka::math::acos(acc, (AO * AO + BO * BO - AB2) / (2 * AO * BO));
352 float Pz = (z_init -
z1) / ds * Pt;
358 int layeri, moduleTypei;
360 for (
size_t i = 2;
i < 6;
i++) {
365 moduleTypei = moduleType2;
370 moduleTypei = moduleType3;
375 moduleTypei = moduleType4;
380 moduleTypei = moduleType5;
383 if (moduleType3 == 0) {
392 float diffr = 0, diffz = 0;
396 float s = (zsi - z_init) *
p / Pz;
404 rt_init * rt_init + 2 * (Px * Px + Py * Py) / (
a *
a) + 2 * (y_init * Px - x_init * Py) /
a - rtsi * rtsi;
405 float paraB = 2 * (x_init * Px + y_init * Py) /
a;
406 float paraC = 2 * (y_init * Px - x_init * Py) /
a + 2 * (Px * Px + Py * Py) / (
a *
a);
407 float A = paraB * paraB + paraC * paraC;
408 float B = 2 * paraA * paraB;
409 float C = paraA * paraA - paraC * paraC;
412 float solz1 = alpaka::math::asin(acc, sol1) / rou * Pz /
p + z_init;
413 float solz2 = alpaka::math::asin(acc, sol2) / rou * Pz /
p + z_init;
414 float diffz1 = (solz1 - zsi) * 100;
415 float diffz2 = (solz2 - zsi) * 100;
424 residual = (layeri > 6) ? diffr : diffz;
427 if (moduleTypei == 0) {
447 if (
i == 2 ||
i == 3) {
448 residual = (layeri <= 6 && ((
side ==
Center)
or (drdz < 1))) ? diffz : diffr;
449 float projection_missing2 = 1.f;
451 projection_missing2 =
456 : (drdz * drdz) / (1 + drdz * drdz);
457 error2 = error2 * projection_missing2;
459 rzChiSquared += 12 * (residual * residual) / error2;
465 if (moduleType1 == 0 and moduleType2 == 0 and moduleType3 == 1)
469 slope = (z3 -
z1) / (rt3 - rt1);
471 float residual4_linear = (layer4 <= 6) ? ((z4 -
z1) -
slope * (rt4 - rt1)) : ((rt4 - rt1) - (z4 -
z1) /
slope);
472 float residual5_linear = (layer4 <= 6) ? ((z5 -
z1) -
slope * (rt5 - rt1)) : ((rt5 - rt1) - (z5 -
z1) /
slope);
478 residual4_linear = residual4_linear * 100;
479 residual5_linear = residual5_linear * 100;
481 rzChiSquared = 12 * (residual4_linear * residual4_linear + residual5_linear * residual5_linear);
482 return rzChiSquared < 4.677f;
486 tightCutFlag =
false;
489 if (layer1 == 7 and layer2 == 8 and layer3 == 9 and layer4 == 10 and layer5 == 11)
491 if (rzChiSquared < 94.470
f)
494 }
else if (layer1 == 7 and layer2 == 8 and layer3 == 9 and layer4 == 10 and layer5 == 16)
496 if (rzChiSquared < 22.099
f)
498 return rzChiSquared < 37.956f;
499 }
else if (layer1 == 7 and layer2 == 8 and layer3 == 9 and layer4 == 15 and layer5 == 16)
501 if (rzChiSquared < 7.992
f)
503 return rzChiSquared < 11.622f;
504 }
else if (layer1 == 1 and layer2 == 7 and layer3 == 8 and layer4 == 9) {
507 if (rzChiSquared < 111.390
f)
513 if (rzChiSquared < 18.351
f)
515 return rzChiSquared < 37.941f;
517 }
else if (layer1 == 1 and layer2 == 2 and layer3 == 7) {
518 if (layer4 == 8 and layer5 == 9)
520 if (rzChiSquared < 116.148
f)
524 if (layer4 == 8 and layer5 == 14)
526 if (rzChiSquared < 19.352
f)
528 return rzChiSquared < 52.561f;
529 }
else if (layer4 == 13 and layer5 == 14)
531 if (rzChiSquared < 10.392
f)
533 return rzChiSquared < 13.76f;
535 }
else if (layer1 == 1 and layer2 == 2 and layer3 == 3) {
536 if (layer4 == 7 and layer5 == 8)
538 if (rzChiSquared < 27.824
f)
540 return rzChiSquared < 44.247f;
541 }
else if (layer4 == 7 and layer5 == 13)
543 if (rzChiSquared < 18.145
f)
545 return rzChiSquared < 33.752f;
546 }
else if (layer4 == 12 and layer5 == 13)
548 if (rzChiSquared < 13.308
f)
550 return rzChiSquared < 21.213f;
551 }
else if (layer4 == 4 and layer5 == 5)
553 if (rzChiSquared < 15.627
f)
555 return rzChiSquared < 29.035f;
556 }
else if (layer4 == 4 and layer5 == 12)
558 if (rzChiSquared < 14.64
f)
560 return rzChiSquared < 23.037f;
562 }
else if (layer1 == 2 and layer2 == 7 and layer3 == 8) {
563 if (layer4 == 9 and layer5 == 15)
565 if (rzChiSquared < 24.662
f)
567 return rzChiSquared < 41.036f;
568 }
else if (layer4 == 14 and layer5 == 15)
570 if (rzChiSquared < 8.866
f)
572 return rzChiSquared < 14.092f;
574 }
else if (layer1 == 2 and layer2 == 3 and layer3 == 7) {
575 if (layer4 == 8 and layer5 == 14)
577 if (rzChiSquared < 23.730
f)
579 return rzChiSquared < 23.748f;
581 if (layer4 == 13 and layer5 == 14)
583 if (rzChiSquared < 10.772
f)
585 return rzChiSquared < 17.945f;
587 }
else if (layer1 == 2 and layer2 == 3 and layer3 == 4) {
588 if (layer4 == 5 and layer5 == 6)
590 if (rzChiSquared < 6.065
f)
592 return rzChiSquared < 8.803f;
593 }
else if (layer4 == 5 and layer5 == 12)
595 if (rzChiSquared < 5.693
f)
597 return rzChiSquared < 7.930f;
600 else if (layer4 == 12 and layer5 == 13)
602 if (rzChiSquared < 5.473
f)
604 return rzChiSquared < 7.626f;
610 template <
typename TAcc>
613 unsigned int innerTripletIndex,
614 unsigned int outerTripletIndex) {
615 unsigned int innerOuterSegmentIndex = triplets.segmentIndices()[innerTripletIndex][1];
616 unsigned int outerInnerSegmentIndex = triplets.segmentIndices()[outerTripletIndex][0];
617 unsigned int innerOuterOuterMiniDoubletIndex =
618 segments.mdIndices()[innerOuterSegmentIndex][1];
619 unsigned int outerInnerInnerMiniDoubletIndex =
620 segments.mdIndices()[outerInnerSegmentIndex][0];
622 return (innerOuterOuterMiniDoubletIndex == outerInnerInnerMiniDoubletIndex);
625 template <
typename TAcc>
633 float& minimumRadius,
634 float& maximumRadius) {
636 float candidateRadius;
640 for (
size_t i = 0;
i < 3;
i++) {
643 for (
size_t j = 0;
j < 3;
j++) {
646 for (
size_t k = 0;
k < 3;
k++) {
657 template <
typename TAcc>
662 float bridgeRadiusMin2S,
663 float bridgeRadiusMax2S) {
664 float innerInvRadiusMin, innerInvRadiusMax, bridgeInvRadiusMin, bridgeInvRadiusMax;
666 float innerInvRadiusErrorBound = 0.178f;
667 float bridgeInvRadiusErrorBound = 0.507f;
669 innerInvRadiusMax = (1.f + innerInvRadiusErrorBound) /
innerRadius;
672 bridgeInvRadiusMax = (1.f + bridgeInvRadiusErrorBound) / bridgeRadius;
673 bridgeInvRadiusMin =
alpaka::math::max(acc, 0.
f, (1.
f - bridgeInvRadiusErrorBound) / bridgeRadius);
682 template <
typename TAcc>
687 float innerInvRadiusMin, innerInvRadiusMax, bridgeInvRadiusMin, bridgeInvRadiusMax;
689 float innerInvRadiusErrorBound = 0.1512f;
690 float bridgeInvRadiusErrorBound = 0.1781f;
693 innerInvRadiusErrorBound = 0.4449f;
694 bridgeInvRadiusErrorBound = 0.4033f;
697 innerInvRadiusMax = (1.f + innerInvRadiusErrorBound) /
innerRadius;
700 bridgeInvRadiusMax = (1.f + bridgeInvRadiusErrorBound) / bridgeRadius;
701 bridgeInvRadiusMin =
alpaka::math::max(acc, 0.
f, (1.
f - bridgeInvRadiusErrorBound) / bridgeRadius);
703 return checkIntervalOverlap(innerInvRadiusMin, innerInvRadiusMax, bridgeInvRadiusMin, bridgeInvRadiusMax);
706 template <
typename TAcc>
711 float innerInvRadiusMin, innerInvRadiusMax, bridgeInvRadiusMin, bridgeInvRadiusMax;
713 float innerInvRadiusErrorBound = 0.1781f;
714 float bridgeInvRadiusErrorBound = 0.2167f;
717 innerInvRadiusErrorBound = 0.4750f;
718 bridgeInvRadiusErrorBound = 0.3903f;
721 innerInvRadiusMax = (1.f + innerInvRadiusErrorBound) /
innerRadius;
724 bridgeInvRadiusMax = (1.f + bridgeInvRadiusErrorBound) / bridgeRadius;
725 bridgeInvRadiusMin =
alpaka::math::max(acc, 0.
f, (1.
f - bridgeInvRadiusErrorBound) / bridgeRadius);
727 return checkIntervalOverlap(innerInvRadiusMin, innerInvRadiusMax, bridgeInvRadiusMin, bridgeInvRadiusMax);
730 template <
typename TAcc>
735 float bridgeRadiusMin2S,
736 float bridgeRadiusMax2S) {
737 float innerInvRadiusMin, innerInvRadiusMax, bridgeInvRadiusMin, bridgeInvRadiusMax;
739 float innerInvRadiusErrorBound = 0.2097f;
740 float bridgeInvRadiusErrorBound = 0.8557f;
742 innerInvRadiusMax = (1.f + innerInvRadiusErrorBound) /
innerRadius;
745 bridgeInvRadiusMax = (1.f + bridgeInvRadiusErrorBound) / bridgeRadius;
746 bridgeInvRadiusMin =
alpaka::math::max(acc, 0.
f, (1.
f - bridgeInvRadiusErrorBound) / bridgeRadius);
754 template <
typename TAcc>
759 float bridgeRadiusMin2S,
760 float bridgeRadiusMax2S) {
761 float innerInvRadiusMin, innerInvRadiusMax, bridgeInvRadiusMin, bridgeInvRadiusMax;
763 float innerInvRadiusErrorBound = 0.066f;
764 float bridgeInvRadiusErrorBound = 0.617f;
766 innerInvRadiusMax = (1.f + innerInvRadiusErrorBound) /
innerRadius;
769 bridgeInvRadiusMax = (1.f + bridgeInvRadiusErrorBound) / bridgeRadius;
770 bridgeInvRadiusMin =
alpaka::math::max(acc, 0.
f, (1.
f - bridgeInvRadiusErrorBound) / bridgeRadius);
778 template <
typename TAcc>
783 float bridgeRadiusMin2S,
784 float bridgeRadiusMax2S) {
785 float innerInvRadiusMin, innerInvRadiusMax, bridgeInvRadiusMin, bridgeInvRadiusMax;
787 float innerInvRadiusErrorBound = 0.6376f;
788 float bridgeInvRadiusErrorBound = 2.1381f;
792 innerInvRadiusErrorBound = 12.9173f;
793 bridgeInvRadiusErrorBound = 5.1700f;
796 innerInvRadiusMax = (1.f + innerInvRadiusErrorBound) /
innerRadius;
799 bridgeInvRadiusMax = (1.f + bridgeInvRadiusErrorBound) / bridgeRadius;
800 bridgeInvRadiusMin =
alpaka::math::max(acc, 0.
f, (1.
f - bridgeInvRadiusErrorBound) / bridgeRadius);
808 template <
typename TAcc>
813 float innerRadiusMin2S,
814 float innerRadiusMax2S,
815 float bridgeRadiusMin2S,
816 float bridgeRadiusMax2S) {
817 float innerInvRadiusMin, innerInvRadiusMax, bridgeInvRadiusMin, bridgeInvRadiusMax;
819 float innerInvRadiusErrorBound = 1.9382f;
820 float bridgeInvRadiusErrorBound = 3.7280f;
823 innerInvRadiusErrorBound = 23.2713f;
824 bridgeInvRadiusErrorBound = 21.7980f;
827 innerInvRadiusMax = (1.f + innerInvRadiusErrorBound) /
innerRadius;
830 bridgeInvRadiusMax = (1.f + bridgeInvRadiusErrorBound) / bridgeRadius;
831 bridgeInvRadiusMin =
alpaka::math::max(acc, 0.
f, (1.
f - bridgeInvRadiusErrorBound) / bridgeRadius);
839 template <
typename TAcc>
844 float innerRadiusMin2S,
845 float innerRadiusMax2S,
846 float bridgeRadiusMin2S,
847 float bridgeRadiusMax2S) {
848 float innerInvRadiusMin, innerInvRadiusMax, bridgeInvRadiusMin, bridgeInvRadiusMax;
850 float innerInvRadiusErrorBound = 1.9382f;
851 float bridgeInvRadiusErrorBound = 2.2091f;
854 innerInvRadiusErrorBound = 22.5226f;
855 bridgeInvRadiusErrorBound = 21.0966f;
858 innerInvRadiusMax = (1.f + innerInvRadiusErrorBound) /
innerRadius;
861 bridgeInvRadiusMax = (1.f + bridgeInvRadiusErrorBound) / bridgeRadius;
862 bridgeInvRadiusMin =
alpaka::math::max(acc, 0.
f, (1.
f - bridgeInvRadiusErrorBound) / bridgeRadius);
870 template <
typename TAcc>
873 const uint16_t* lowerModuleIndices,
878 unsigned int nPoints = 5,
879 bool anchorHits =
true) {
890 short moduleSubdet, moduleSide;
894 for (
size_t i = 0;
i < nPoints;
i++) {
895 moduleType =
modules.moduleType()[lowerModuleIndices[
i]];
896 moduleSubdet =
modules.subdets()[lowerModuleIndices[
i]];
897 moduleSide =
modules.sides()[lowerModuleIndices[
i]];
898 const float& drdz =
modules.drdzs()[lowerModuleIndices[
i]];
899 slopes[
i] =
modules.dxdys()[lowerModuleIndices[
i]];
901 if (moduleSubdet == Barrel and moduleType ==
PS and moduleSide ==
Center) {
908 else if (moduleSubdet == Barrel and moduleType ==
TwoS) {
915 else if (moduleSubdet == Barrel and moduleType ==
PS and moduleSide !=
Center) {
926 else if (moduleSubdet ==
Endcap and moduleType ==
PS) {
942 else if (moduleSubdet ==
Endcap and moduleType ==
TwoS) {
944 delta2[
i] = 500.f * inv1;
948 printf(
"ERROR!!!!! I SHOULDN'T BE HERE!!!! subdet = %d, type = %d, side = %d\n",
957 template <
typename TAcc>
959 unsigned int nPoints,
975 float sigmaX1Squared = 0.f;
976 float sigmaX2Squared = 0.f;
977 float sigmaX1X2 = 0.f;
978 float sigmaX1y = 0.f;
979 float sigmaX2y = 0.f;
983 float sigmaOne = 0.f;
985 float xPrime, yPrime, absArctanSlope, angleM;
986 for (
size_t i = 0;
i < nPoints;
i++) {
993 if (xs[
i] > 0 and ys[
i] > 0) {
994 angleM =
kPi / 2.f - absArctanSlope;
995 }
else if (xs[
i] < 0 and ys[
i] > 0) {
996 angleM = absArctanSlope +
kPi / 2.f;
997 }
else if (xs[
i] < 0 and ys[
i] < 0) {
998 angleM = -(absArctanSlope +
kPi / 2.f);
999 }
else if (xs[
i] > 0 and ys[
i] < 0) {
1000 angleM = -(
kPi / 2.f - absArctanSlope);
1005 if (not isFlat[
i]) {
1012 sigmas2[
i] = 4 * ((xPrime * delta1[
i]) * (xPrime * delta1[
i]) + (yPrime * delta2[
i]) * (yPrime * delta2[
i]));
1014 sigmaX1Squared += (xs[
i] * xs[
i]) / sigmas2[
i];
1015 sigmaX2Squared += (ys[
i] * ys[
i]) / sigmas2[
i];
1016 sigmaX1X2 += (xs[
i] * ys[
i]) / sigmas2[
i];
1017 sigmaX1y += (xs[
i] * (xs[
i] * xs[
i] + ys[
i] * ys[
i])) / sigmas2[
i];
1018 sigmaX2y += (ys[
i] * (xs[
i] * xs[
i] + ys[
i] * ys[
i])) / sigmas2[
i];
1019 sigmaY += (xs[
i] * xs[
i] + ys[
i] * ys[
i]) / sigmas2[
i];
1020 sigmaX1 += xs[
i] / sigmas2[
i];
1021 sigmaX2 += ys[
i] / sigmas2[
i];
1022 sigmaOne += 1.0f / sigmas2[
i];
1024 float denominator = (sigmaX1X2 - sigmaX1 * sigmaX2) * (sigmaX1X2 - sigmaX1 * sigmaX2) -
1025 (sigmaX1Squared - sigmaX1 * sigmaX1) * (sigmaX2Squared - sigmaX2 * sigmaX2);
1027 float twoG = ((sigmaX2y - sigmaX2 *
sigmaY) * (sigmaX1X2 - sigmaX1 * sigmaX2) -
1028 (sigmaX1y - sigmaX1 *
sigmaY) * (sigmaX2Squared - sigmaX2 * sigmaX2)) /
1030 float twoF = ((sigmaX1y - sigmaX1 *
sigmaY) * (sigmaX1X2 - sigmaX1 * sigmaX2) -
1031 (sigmaX2y - sigmaX2 *
sigmaY) * (sigmaX1Squared - sigmaX1 * sigmaX1)) /
1034 float c = -(
sigmaY - twoG * sigmaX1 - twoF * sigmaX2) / sigmaOne;
1037 if (
g *
g +
f *
f -
c < 0) {
1039 printf(
"FATAL! r^2 < 0!\n");
1048 for (
size_t i = 0;
i < nPoints;
i++) {
1049 chiSquared += (xs[
i] * xs[
i] + ys[
i] * ys[
i] - twoG * xs[
i] - twoF * ys[
i] +
c) *
1050 (xs[
i] * xs[
i] + ys[
i] * ys[
i] - twoG * xs[
i] - twoF * ys[
i] +
c) / sigmas2[
i];
1055 template <
typename TAcc>
1057 unsigned int nPoints,
1070 float chiSquared = 0.f;
1071 float absArctanSlope, angleM, xPrime, yPrime, sigma2;
1072 for (
size_t i = 0;
i < nPoints;
i++) {
1075 if (xs[
i] > 0 and ys[
i] > 0) {
1076 angleM =
kPi / 2.f - absArctanSlope;
1077 }
else if (xs[
i] < 0 and ys[
i] > 0) {
1078 angleM = absArctanSlope +
kPi / 2.f;
1079 }
else if (xs[
i] < 0 and ys[
i] < 0) {
1080 angleM = -(absArctanSlope +
kPi / 2.f);
1081 }
else if (xs[
i] > 0 and ys[
i] < 0) {
1082 angleM = -(
kPi / 2.f - absArctanSlope);
1087 if (not isFlat[
i]) {
1094 sigma2 = 4 * ((xPrime * delta1[
i]) * (xPrime * delta1[
i]) + (yPrime * delta2[
i]) * (yPrime * delta2[
i]));
1095 chiSquared += (xs[
i] * xs[
i] + ys[
i] * ys[
i] - 2 *
g * xs[
i] - 2 *
f * ys[
i] +
c) *
1096 (xs[
i] * xs[
i] + ys[
i] * ys[
i] - 2 *
g * xs[
i] - 2 *
f * ys[
i] +
c) / sigma2;
1101 template <
typename TAcc>
1112 betaOut += alpaka::math::copysign(
1120 if (betaIn * betaOut > 0.
f and
1125 const float betaInUpd =
1127 alpaka::math::copysign(
1132 const float betaOutUpd =
1134 alpaka::math::copysign(
1139 betaAv = 0.5f * (betaInUpd + betaOutUpd);
1142 const float pt_beta_inv =
1145 betaIn += alpaka::math::copysign(
1149 betaOut += alpaka::math::copysign(
1154 betaAv = 0.5f * (betaIn + betaOut);
1162 const float betaInUpd =
1164 alpaka::math::copysign(
1169 const float betaOutUpd =
1171 alpaka::math::copysign(
1178 ? (0.5
f * (betaInUpd + betaOutUpd))
1183 betaIn += alpaka::math::copysign(
1188 betaOut += alpaka::math::copysign(
1194 betaAv = 0.5f * (betaIn + betaOut);
1200 template <
typename TAcc>
1205 uint16_t innerInnerLowerModuleIndex,
1206 uint16_t innerOuterLowerModuleIndex,
1207 uint16_t outerInnerLowerModuleIndex,
1208 uint16_t outerOuterLowerModuleIndex,
1209 unsigned int innerSegmentIndex,
1210 unsigned int outerSegmentIndex,
1211 unsigned int firstMDIndex,
1212 unsigned int secondMDIndex,
1213 unsigned int thirdMDIndex,
1214 unsigned int fourthMDIndex) {
1215 bool isPS_InLo = (
modules.moduleType()[innerInnerLowerModuleIndex] ==
PS);
1216 bool isPS_OutLo = (
modules.moduleType()[outerInnerLowerModuleIndex] ==
PS);
1218 float rt_InLo = mds.anchorRt()[firstMDIndex];
1219 float rt_InOut = mds.anchorRt()[secondMDIndex];
1220 float rt_OutLo = mds.anchorRt()[thirdMDIndex];
1222 float z_InLo = mds.anchorZ()[firstMDIndex];
1223 float z_InOut = mds.anchorZ()[secondMDIndex];
1224 float z_OutLo = mds.anchorZ()[thirdMDIndex];
1226 float alpha1GeV_OutLo =
1229 float rtRatio_OutLoInLo = rt_OutLo / rt_InLo;
1235 float zHi = z_InLo + (z_InLo +
kDeltaZLum) * (rtRatio_OutLoInLo - 1.
f) * (z_InLo < 0.f ? 1.f : dzDrtScale) +
1236 (zpitch_InLo + zpitch_OutLo);
1237 float zLo = z_InLo + (z_InLo -
kDeltaZLum) * (rtRatio_OutLoInLo - 1.
f) * (z_InLo > 0.f ? 1.f : dzDrtScale) -
1238 (zpitch_InLo + zpitch_OutLo);
1241 if ((z_OutLo < zLo) || (z_OutLo > zHi))
1244 float drt_OutLo_InLo = (rt_OutLo - rt_InLo);
1246 float drt_InSeg = rt_InOut - rt_InLo;
1247 float dz_InSeg = z_InOut - z_InLo;
1251 float coshEta = dr3_InSeg / drt_InSeg;
1252 float dzErr = (zpitch_InLo + zpitch_OutLo) * (zpitch_InLo + zpitch_OutLo) * 2.f;
1254 float thetaMuls2 = (
kMulsInGeV *
kMulsInGeV) * (0.1
f + 0.2
f * (rt_OutLo - rt_InLo) / 50.f) * (r3_InLo / rt_InLo);
1255 float muls2 = thetaMuls2 * 9.f / (
ptCut *
ptCut) * 16.
f;
1256 dzErr += muls2 * drt_OutLo_InLo * drt_OutLo_InLo / 3.f * coshEta * coshEta;
1260 const float dzMean = dz_InSeg / drt_InSeg * drt_OutLo_InLo;
1261 const float zWindow =
1262 dzErr / drt_InSeg * drt_OutLo_InLo +
1263 (zpitch_InLo + zpitch_OutLo);
1264 float zLoPointed = z_InLo + dzMean * (z_InLo > 0.f ? 1.f : dzDrtScale) - zWindow;
1265 float zHiPointed = z_InLo + dzMean * (z_InLo < 0.f ? 1.f : dzDrtScale) + zWindow;
1268 if ((z_OutLo < zLoPointed) || (z_OutLo > zHiPointed))
1271 float pvOffset = 0.1f / rt_OutLo;
1272 float dPhiCut = alpha1GeV_OutLo +
alpaka::math::sqrt(acc, muls2 + pvOffset * pvOffset);
1274 float deltaPhiPos =
phi_mpi_pi(acc, mds.anchorPhi()[fourthMDIndex] - mds.anchorPhi()[secondMDIndex]);
1279 float midPointX = 0.5f * (mds.anchorX()[firstMDIndex] + mds.anchorX()[thirdMDIndex]);
1280 float midPointY = 0.5f * (mds.anchorY()[firstMDIndex] + mds.anchorY()[thirdMDIndex]);
1281 float diffX = mds.anchorX()[thirdMDIndex] - mds.anchorX()[firstMDIndex];
1282 float diffY = mds.anchorY()[thirdMDIndex] - mds.anchorY()[firstMDIndex];
1284 float dPhi =
deltaPhi(acc, midPointX, midPointY, diffX, diffY);
1291 float alpha_InLo =
__H2F(segments.dPhiChanges()[innerSegmentIndex]);
1292 float alpha_OutLo =
__H2F(segments.dPhiChanges()[outerSegmentIndex]);
1294 bool isEC_lastLayer =
modules.subdets()[outerOuterLowerModuleIndex] ==
Endcap and
1295 modules.moduleType()[outerOuterLowerModuleIndex] ==
TwoS;
1297 float alpha_OutUp, alpha_OutUp_highEdge, alpha_OutUp_lowEdge;
1301 mds.anchorX()[fourthMDIndex] - mds.anchorX()[thirdMDIndex],
1302 mds.anchorY()[fourthMDIndex] - mds.anchorY()[thirdMDIndex]) -
1303 mds.anchorPhi()[fourthMDIndex]);
1305 alpha_OutUp_highEdge = alpha_OutUp;
1306 alpha_OutUp_lowEdge = alpha_OutUp;
1308 float tl_axis_x = mds.anchorX()[fourthMDIndex] - mds.anchorX()[firstMDIndex];
1309 float tl_axis_y = mds.anchorY()[fourthMDIndex] - mds.anchorY()[firstMDIndex];
1310 float tl_axis_highEdge_x = tl_axis_x;
1311 float tl_axis_highEdge_y = tl_axis_y;
1312 float tl_axis_lowEdge_x = tl_axis_x;
1313 float tl_axis_lowEdge_y = tl_axis_y;
1315 float betaIn = alpha_InLo -
phi_mpi_pi(acc,
phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[firstMDIndex]);
1317 float betaInRHmin = betaIn;
1318 float betaInRHmax = betaIn;
1319 float betaOut = -alpha_OutUp +
phi_mpi_pi(acc,
phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[fourthMDIndex]);
1321 float betaOutRHmin = betaOut;
1322 float betaOutRHmax = betaOut;
1324 if (isEC_lastLayer) {
1327 mds.anchorHighEdgeX()[fourthMDIndex] - mds.anchorX()[thirdMDIndex],
1328 mds.anchorHighEdgeY()[fourthMDIndex] - mds.anchorY()[thirdMDIndex]) -
1329 mds.anchorHighEdgePhi()[fourthMDIndex]);
1332 mds.anchorLowEdgeX()[fourthMDIndex] - mds.anchorX()[thirdMDIndex],
1333 mds.anchorLowEdgeY()[fourthMDIndex] - mds.anchorY()[thirdMDIndex]) -
1334 mds.anchorLowEdgePhi()[fourthMDIndex]);
1336 tl_axis_highEdge_x = mds.anchorHighEdgeX()[fourthMDIndex] - mds.anchorX()[firstMDIndex];
1337 tl_axis_highEdge_y = mds.anchorHighEdgeY()[fourthMDIndex] - mds.anchorY()[firstMDIndex];
1338 tl_axis_lowEdge_x = mds.anchorLowEdgeX()[fourthMDIndex] - mds.anchorX()[firstMDIndex];
1339 tl_axis_lowEdge_y = mds.anchorLowEdgeY()[fourthMDIndex] - mds.anchorY()[firstMDIndex];
1342 -alpha_OutUp_highEdge +
1343 phi_mpi_pi(acc,
phi(acc, tl_axis_highEdge_x, tl_axis_highEdge_y) - mds.anchorHighEdgePhi()[fourthMDIndex]);
1345 -alpha_OutUp_lowEdge +
1346 phi_mpi_pi(acc,
phi(acc, tl_axis_lowEdge_x, tl_axis_lowEdge_y) - mds.anchorLowEdgePhi()[fourthMDIndex]);
1350 float drt_tl_axis =
alpaka::math::sqrt(acc, tl_axis_x * tl_axis_x + tl_axis_y * tl_axis_y);
1355 (mds.anchorX()[secondMDIndex] - mds.anchorX()[firstMDIndex]) *
1356 (mds.anchorX()[secondMDIndex] - mds.anchorX()[firstMDIndex]) +
1357 (mds.anchorY()[secondMDIndex] - mds.anchorY()[firstMDIndex]) *
1358 (mds.anchorY()[secondMDIndex] - mds.anchorY()[firstMDIndex]));
1362 (0.02f / drt_InSeg);
1368 float betaAv = 0.5f * (betaIn + betaOut);
1371 int lOut = isEC_lastLayer ? 11 : 5;
1373 (mds.anchorX()[fourthMDIndex] - mds.anchorX()[thirdMDIndex]) *
1374 (mds.anchorX()[fourthMDIndex] - mds.anchorX()[thirdMDIndex]) +
1375 (mds.anchorY()[fourthMDIndex] - mds.anchorY()[thirdMDIndex]) *
1376 (mds.anchorY()[fourthMDIndex] - mds.anchorY()[thirdMDIndex]));
1377 float sdOut_d = mds.anchorRt()[fourthMDIndex] - mds.anchorRt()[thirdMDIndex];
1381 const float betaInMMSF = (
alpaka::math::abs(acc, betaInRHmin + betaInRHmax) > 0)
1384 const float betaOutMMSF = (
alpaka::math::abs(acc, betaOutRHmin + betaOutRHmax) > 0)
1387 betaInRHmin *= betaInMMSF;
1388 betaInRHmax *= betaInMMSF;
1389 betaOutRHmin *= betaOutMMSF;
1390 betaOutRHmax *= betaOutMMSF;
1394 const float dBetaMuls2 = thetaMuls2 * 16.f / (min_ptBeta_maxPtBeta * min_ptBeta_maxPtBeta);
1396 const float alphaInAbsReg =
1400 const float alphaOutAbsReg =
1406 const float dBetaLum2 = (dBetaInLum + dBetaOutLum) * (dBetaInLum + dBetaOutLum);
1409 const float dBetaRIn2 = 0;
1410 float dBetaROut = 0;
1411 if (isEC_lastLayer) {
1413 mds.anchorHighEdgeX()[fourthMDIndex] * mds.anchorHighEdgeX()[fourthMDIndex] +
1414 mds.anchorHighEdgeY()[fourthMDIndex] * mds.anchorHighEdgeY()[fourthMDIndex]) -
1416 mds.anchorLowEdgeX()[fourthMDIndex] * mds.anchorLowEdgeX()[fourthMDIndex] +
1417 mds.anchorLowEdgeY()[fourthMDIndex] * mds.anchorLowEdgeY()[fourthMDIndex])) *
1418 sinDPhi / drt_tl_axis;
1421 const float dBetaROut2 = dBetaROut * dBetaROut;
1433 (dBetaRes * dBetaRes * 2.0f + dBetaMuls2 + dBetaLum2 + dBetaRIn2 + dBetaROut2 +
1438 float dBeta = betaIn - betaOut;
1439 return dBeta * dBeta <= dBetaCut2;
1442 template <
typename TAcc>
1447 uint16_t innerInnerLowerModuleIndex,
1448 uint16_t innerOuterLowerModuleIndex,
1449 uint16_t outerInnerLowerModuleIndex,
1450 uint16_t outerOuterLowerModuleIndex,
1451 unsigned int innerSegmentIndex,
1452 unsigned int outerSegmentIndex,
1453 unsigned int firstMDIndex,
1454 unsigned int secondMDIndex,
1455 unsigned int thirdMDIndex,
1456 unsigned int fourthMDIndex) {
1457 bool isPS_InLo = (
modules.moduleType()[innerInnerLowerModuleIndex] ==
PS);
1458 bool isPS_OutLo = (
modules.moduleType()[outerInnerLowerModuleIndex] ==
PS);
1460 float rt_InLo = mds.anchorRt()[firstMDIndex];
1461 float rt_InOut = mds.anchorRt()[secondMDIndex];
1462 float rt_OutLo = mds.anchorRt()[thirdMDIndex];
1464 float z_InLo = mds.anchorZ()[firstMDIndex];
1465 float z_InOut = mds.anchorZ()[secondMDIndex];
1466 float z_OutLo = mds.anchorZ()[thirdMDIndex];
1468 float alpha1GeV_OutLo =
1475 float zGeom = zpitch_InLo + zpitch_OutLo;
1478 if (z_InLo * z_OutLo <= 0)
1481 float dLum = alpaka::math::copysign(acc,
kDeltaZLum, z_InLo);
1482 bool isOutSgInnerMDPS =
modules.moduleType()[outerInnerLowerModuleIndex] ==
PS;
1484 float zGeom1 = alpaka::math::copysign(acc, zGeom, z_InLo);
1485 float rtLo = rt_InLo * (1.f + (z_OutLo - z_InLo - zGeom1) / (z_InLo + zGeom1 + dLum) / dzDrtScale) -
1487 float rtOut = rt_OutLo;
1493 float zInForHi = z_InLo - zGeom1 - dLum;
1494 if (zInForHi * z_InLo < 0) {
1495 zInForHi = alpaka::math::copysign(acc, 0.1
f, z_InLo);
1497 float rtHi = rt_InLo * (1.f + (z_OutLo - z_InLo + zGeom1) / zInForHi) + rtGeom1;
1500 if ((rt_OutLo < rtLo) || (rt_OutLo > rtHi))
1504 const float drtSDIn = rt_InOut - rt_InLo;
1505 const float dzSDIn = z_InOut - z_InLo;
1506 const float dr3SDIn =
alpaka::math::sqrt(acc, rt_InOut * rt_InOut + z_InOut * z_InOut) -
1509 const float coshEta = dr3SDIn / drtSDIn;
1511 const float multDzDr = dzOutInAbs * coshEta / (coshEta * coshEta - 1.f);
1513 float kZ = (z_OutLo - z_InLo) / dzSDIn;
1515 zGeom1_another * zGeom1_another * drtSDIn * drtSDIn / dzSDIn / dzSDIn * (1.f - 2.f * kZ + 2.f * kZ * kZ);
1516 const float thetaMuls2 = (
kMulsInGeV *
kMulsInGeV) * (0.1
f + 0.2
f * (rt_OutLo - rt_InLo) / 50.f) * (rIn / rt_InLo);
1517 const float muls2 = thetaMuls2 * 9.f / (
ptCut *
ptCut) * 16.
f;
1518 drtErr += muls2 * multDzDr * multDzDr / 3.f * coshEta * coshEta;
1522 if ((kZ < 0) || (rtOut < rtLo) || (rtOut > rtHi))
1525 const float pvOffset = 0.1f / rt_OutLo;
1526 float dPhiCut = alpha1GeV_OutLo +
alpaka::math::sqrt(acc, muls2 + pvOffset * pvOffset);
1528 float deltaPhiPos =
phi_mpi_pi(acc, mds.anchorPhi()[fourthMDIndex] - mds.anchorPhi()[secondMDIndex]);
1534 float midPointX = 0.5f * (mds.anchorX()[firstMDIndex] + mds.anchorX()[thirdMDIndex]);
1535 float midPointY = 0.5f * (mds.anchorY()[firstMDIndex] + mds.anchorY()[thirdMDIndex]);
1536 float diffX = mds.anchorX()[thirdMDIndex] - mds.anchorX()[firstMDIndex];
1537 float diffY = mds.anchorY()[thirdMDIndex] - mds.anchorY()[firstMDIndex];
1539 float dPhi =
deltaPhi(acc, midPointX, midPointY, diffX, diffY);
1544 float sdIn_alpha =
__H2F(segments.dPhiChanges()[innerSegmentIndex]);
1545 float sdIn_alpha_min =
__H2F(segments.dPhiChangeMins()[innerSegmentIndex]);
1546 float sdIn_alpha_max =
__H2F(segments.dPhiChangeMaxs()[innerSegmentIndex]);
1547 float sdOut_alpha = sdIn_alpha;
1551 mds.anchorX()[fourthMDIndex] - mds.anchorX()[thirdMDIndex],
1552 mds.anchorY()[fourthMDIndex] - mds.anchorY()[thirdMDIndex]) -
1553 mds.anchorPhi()[fourthMDIndex]);
1556 acc,
__H2F(segments.dPhiChangeMins()[outerSegmentIndex]) -
__H2F(segments.dPhiMins()[outerSegmentIndex]));
1558 acc,
__H2F(segments.dPhiChangeMaxs()[outerSegmentIndex]) -
__H2F(segments.dPhiMaxs()[outerSegmentIndex]));
1560 float tl_axis_x = mds.anchorX()[fourthMDIndex] - mds.anchorX()[firstMDIndex];
1561 float tl_axis_y = mds.anchorY()[fourthMDIndex] - mds.anchorY()[firstMDIndex];
1563 float betaIn = sdIn_alpha -
phi_mpi_pi(acc,
phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[firstMDIndex]);
1565 float betaInRHmin = betaIn;
1566 float betaInRHmax = betaIn;
1567 float betaOut = -sdOut_alphaOut +
phi_mpi_pi(acc,
phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[fourthMDIndex]);
1569 float betaOutRHmin = betaOut;
1570 float betaOutRHmax = betaOut;
1572 bool isEC_secondLayer = (
modules.subdets()[innerOuterLowerModuleIndex] ==
Endcap) and
1573 (
modules.moduleType()[innerOuterLowerModuleIndex] ==
TwoS);
1575 if (isEC_secondLayer) {
1576 betaInRHmin = betaIn - sdIn_alpha_min + sdIn_alpha;
1577 betaInRHmax = betaIn - sdIn_alpha_max + sdIn_alpha;
1580 betaOutRHmin = betaOut - sdOut_alphaOut_min + sdOut_alphaOut;
1581 betaOutRHmax = betaOut - sdOut_alphaOut_max + sdOut_alphaOut;
1585 swapTemp = betaOutRHmin;
1586 betaOutRHmin = betaOutRHmax;
1587 betaOutRHmax = swapTemp;
1591 swapTemp = betaInRHmin;
1592 betaInRHmin = betaInRHmax;
1593 betaInRHmax = swapTemp;
1597 (mds.anchorX()[secondMDIndex] - mds.anchorX()[firstMDIndex]) *
1598 (mds.anchorX()[secondMDIndex] - mds.anchorX()[firstMDIndex]) +
1599 (mds.anchorY()[secondMDIndex] - mds.anchorY()[firstMDIndex]) *
1600 (mds.anchorY()[secondMDIndex] - mds.anchorY()[firstMDIndex]));
1601 float sdIn_d = rt_InOut - rt_InLo;
1604 const float corrF = 1.f;
1613 float betaAv = 0.5f * (betaIn + betaOut);
1620 (mds.anchorX()[fourthMDIndex] - mds.anchorX()[thirdMDIndex]) *
1621 (mds.anchorX()[fourthMDIndex] - mds.anchorX()[thirdMDIndex]) +
1622 (mds.anchorY()[fourthMDIndex] - mds.anchorY()[thirdMDIndex]) *
1623 (mds.anchorY()[fourthMDIndex] - mds.anchorY()[thirdMDIndex]));
1624 float sdOut_d = mds.anchorRt()[fourthMDIndex] - mds.anchorRt()[thirdMDIndex];
1628 const float betaInMMSF = (
alpaka::math::abs(acc, betaInRHmin + betaInRHmax) > 0)
1631 const float betaOutMMSF = (
alpaka::math::abs(acc, betaOutRHmin + betaOutRHmax) > 0)
1634 betaInRHmin *= betaInMMSF;
1635 betaInRHmax *= betaInMMSF;
1636 betaOutRHmin *= betaOutMMSF;
1637 betaOutRHmax *= betaOutMMSF;
1641 const float dBetaMuls2 = thetaMuls2 * 16.f / (min_ptBeta_maxPtBeta * min_ptBeta_maxPtBeta);
1643 const float alphaInAbsReg =
1647 const float alphaOutAbsReg =
1653 const float dBetaLum2 = (dBetaInLum + dBetaOutLum) * (dBetaInLum + dBetaOutLum);
1656 const float dBetaRIn2 = 0;
1657 float dBetaROut = 0;
1658 if (
modules.moduleType()[outerOuterLowerModuleIndex] ==
TwoS) {
1660 mds.anchorHighEdgeX()[fourthMDIndex] * mds.anchorHighEdgeX()[fourthMDIndex] +
1661 mds.anchorHighEdgeY()[fourthMDIndex] * mds.anchorHighEdgeY()[fourthMDIndex]) -
1663 mds.anchorLowEdgeX()[fourthMDIndex] * mds.anchorLowEdgeX()[fourthMDIndex] +
1664 mds.anchorLowEdgeY()[fourthMDIndex] * mds.anchorLowEdgeY()[fourthMDIndex])) *
1668 const float dBetaROut2 = dBetaROut * dBetaROut;
1678 (dBetaRes * dBetaRes * 2.0f + dBetaMuls2 + dBetaLum2 + dBetaRIn2 + dBetaROut2 +
1682 float dBeta = betaIn - betaOut;
1684 return dBeta * dBeta <= dBetaCut2;
1687 template <
typename TAcc>
1692 uint16_t innerInnerLowerModuleIndex,
1693 uint16_t innerOuterLowerModuleIndex,
1694 uint16_t outerInnerLowerModuleIndex,
1695 uint16_t outerOuterLowerModuleIndex,
1696 unsigned int innerSegmentIndex,
1697 unsigned int outerSegmentIndex,
1698 unsigned int firstMDIndex,
1699 unsigned int secondMDIndex,
1700 unsigned int thirdMDIndex,
1701 unsigned int fourthMDIndex) {
1702 float rt_InLo = mds.anchorRt()[firstMDIndex];
1703 float rt_InOut = mds.anchorRt()[secondMDIndex];
1704 float rt_OutLo = mds.anchorRt()[thirdMDIndex];
1706 float z_InLo = mds.anchorZ()[firstMDIndex];
1707 float z_InOut = mds.anchorZ()[secondMDIndex];
1708 float z_OutLo = mds.anchorZ()[thirdMDIndex];
1710 float alpha1GeV_OutLo =
1717 if ((z_InLo * z_OutLo) <= 0)
1720 float dLum = alpaka::math::copysign(acc,
kDeltaZLum, z_InLo);
1721 bool isOutSgInnerMDPS =
modules.moduleType()[outerInnerLowerModuleIndex] ==
PS;
1722 bool isInSgInnerMDPS =
modules.moduleType()[innerInnerLowerModuleIndex] ==
PS;
1724 float rtGeom = (isInSgInnerMDPS and isOutSgInnerMDPS) ? 2.
f *
kPixelPSZpitch 1728 float dz = z_OutLo - z_InLo;
1729 float rtLo = rt_InLo * (1.f +
dz / (z_InLo + dLum) / dzDrtScale) - rtGeom;
1731 float rtOut = rt_OutLo;
1735 float rtHi = rt_InLo * (1.f +
dz / (z_InLo - dLum)) + rtGeom;
1737 if ((rtOut < rtLo) || (rtOut > rtHi))
1740 bool isInSgOuterMDPS =
modules.moduleType()[innerOuterLowerModuleIndex] ==
PS;
1742 const float drtSDIn = rt_InOut - rt_InLo;
1743 const float dzSDIn = z_InOut - z_InLo;
1744 const float dr3SDIn =
alpaka::math::sqrt(acc, rt_InOut * rt_InOut + z_InOut * z_InOut) -
1746 float coshEta = dr3SDIn / drtSDIn;
1748 float multDzDr = dzOutInAbs * coshEta / (coshEta * coshEta - 1.f);
1750 float kZ = (z_OutLo - z_InLo) / dzSDIn;
1753 float muls2 = thetaMuls2 * 9.f / (
ptCut *
ptCut) * 16.
f;
1758 muls2 * multDzDr * multDzDr / 3.
f * coshEta * coshEta);
1761 float rtWindow = drtErr + rtGeom;
1762 float rtLo_point = rt_InLo + drtMean / dzDrtScale - rtWindow;
1763 float rtHi_point = rt_InLo + drtMean + rtWindow;
1768 if (isInSgInnerMDPS and isInSgOuterMDPS)
1770 if (kZ < 0 || rtOut < rtLo_point || rtOut > rtHi_point)
1774 float pvOffset = 0.1f / rtOut;
1775 float dPhiCut = alpha1GeV_OutLo +
alpaka::math::sqrt(acc, muls2 + pvOffset * pvOffset);
1777 float deltaPhiPos =
phi_mpi_pi(acc, mds.anchorPhi()[fourthMDIndex] - mds.anchorPhi()[secondMDIndex]);
1782 float midPointX = 0.5f * (mds.anchorX()[firstMDIndex] + mds.anchorX()[thirdMDIndex]);
1783 float midPointY = 0.5f * (mds.anchorY()[firstMDIndex] + mds.anchorY()[thirdMDIndex]);
1784 float diffX = mds.anchorX()[thirdMDIndex] - mds.anchorX()[firstMDIndex];
1785 float diffY = mds.anchorY()[thirdMDIndex] - mds.anchorY()[firstMDIndex];
1787 float dPhi =
deltaPhi(acc, midPointX, midPointY, diffX, diffY);
1793 float sdIn_alpha =
__H2F(segments.dPhiChanges()[innerSegmentIndex]);
1794 float sdOut_alpha = sdIn_alpha;
1795 float sdOut_dPhiPos =
phi_mpi_pi(acc, mds.anchorPhi()[fourthMDIndex] - mds.anchorPhi()[thirdMDIndex]);
1797 float sdOut_dPhiChange =
__H2F(segments.dPhiChanges()[outerSegmentIndex]);
1798 float sdOut_dPhiChange_min =
__H2F(segments.dPhiChangeMins()[outerSegmentIndex]);
1799 float sdOut_dPhiChange_max =
__H2F(segments.dPhiChangeMaxs()[outerSegmentIndex]);
1801 float sdOut_alphaOutRHmin =
phi_mpi_pi(acc, sdOut_dPhiChange_min - sdOut_dPhiPos);
1802 float sdOut_alphaOutRHmax =
phi_mpi_pi(acc, sdOut_dPhiChange_max - sdOut_dPhiPos);
1803 float sdOut_alphaOut =
phi_mpi_pi(acc, sdOut_dPhiChange - sdOut_dPhiPos);
1805 float tl_axis_x = mds.anchorX()[fourthMDIndex] - mds.anchorX()[firstMDIndex];
1806 float tl_axis_y = mds.anchorY()[fourthMDIndex] - mds.anchorY()[firstMDIndex];
1808 float betaIn = sdIn_alpha -
phi_mpi_pi(acc,
phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[firstMDIndex]);
1810 float sdIn_alphaRHmin =
__H2F(segments.dPhiChangeMins()[innerSegmentIndex]);
1811 float sdIn_alphaRHmax =
__H2F(segments.dPhiChangeMaxs()[innerSegmentIndex]);
1812 float betaInRHmin = betaIn + sdIn_alphaRHmin - sdIn_alpha;
1813 float betaInRHmax = betaIn + sdIn_alphaRHmax - sdIn_alpha;
1815 float betaOut = -sdOut_alphaOut +
phi_mpi_pi(acc,
phi(acc, tl_axis_x, tl_axis_y) - mds.anchorPhi()[fourthMDIndex]);
1817 float betaOutRHmin = betaOut - sdOut_alphaOutRHmin + sdOut_alphaOut;
1818 float betaOutRHmax = betaOut - sdOut_alphaOutRHmax + sdOut_alphaOut;
1822 swapTemp = betaOutRHmin;
1823 betaOutRHmin = betaOutRHmax;
1824 betaOutRHmax = swapTemp;
1828 swapTemp = betaInRHmin;
1829 betaInRHmin = betaInRHmax;
1830 betaInRHmax = swapTemp;
1833 (mds.anchorX()[secondMDIndex] - mds.anchorX()[firstMDIndex]) *
1834 (mds.anchorX()[secondMDIndex] - mds.anchorX()[firstMDIndex]) +
1835 (mds.anchorY()[secondMDIndex] - mds.anchorY()[firstMDIndex]) *
1836 (mds.anchorY()[secondMDIndex] - mds.anchorY()[firstMDIndex]));
1837 float sdIn_d = rt_InOut - rt_InLo;
1840 const float corrF = 1.f;
1849 float betaAv = 0.5f * (betaIn + betaOut);
1856 (mds.anchorX()[fourthMDIndex] - mds.anchorX()[thirdMDIndex]) *
1857 (mds.anchorX()[fourthMDIndex] - mds.anchorX()[thirdMDIndex]) +
1858 (mds.anchorY()[fourthMDIndex] - mds.anchorY()[thirdMDIndex]) *
1859 (mds.anchorY()[fourthMDIndex] - mds.anchorY()[thirdMDIndex]));
1860 float sdOut_d = mds.anchorRt()[fourthMDIndex] - mds.anchorRt()[thirdMDIndex];
1864 const float betaInMMSF = (
alpaka::math::abs(acc, betaInRHmin + betaInRHmax) > 0)
1867 const float betaOutMMSF = (
alpaka::math::abs(acc, betaOutRHmin + betaOutRHmax) > 0)
1870 betaInRHmin *= betaInMMSF;
1871 betaInRHmax *= betaInMMSF;
1872 betaOutRHmin *= betaOutMMSF;
1873 betaOutRHmax *= betaOutMMSF;
1877 const float dBetaMuls2 = thetaMuls2 * 16.f / (min_ptBeta_maxPtBeta * min_ptBeta_maxPtBeta);
1879 const float alphaInAbsReg =
1883 const float alphaOutAbsReg =
1889 const float dBetaLum2 = (dBetaInLum + dBetaOutLum) * (dBetaInLum + dBetaOutLum);
1891 const float dBetaRIn2 = 0;
1893 float dBetaROut2 = 0;
1903 (dBetaRes * dBetaRes * 2.0f + dBetaMuls2 + dBetaLum2 + dBetaRIn2 + dBetaROut2 +
1907 float dBeta = betaIn - betaOut;
1909 return dBeta * dBeta <= dBetaCut2;
1912 template <
typename TAcc>
1917 uint16_t innerInnerLowerModuleIndex,
1918 uint16_t innerOuterLowerModuleIndex,
1919 uint16_t outerInnerLowerModuleIndex,
1920 uint16_t outerOuterLowerModuleIndex,
1921 unsigned int innerSegmentIndex,
1922 unsigned int outerSegmentIndex,
1923 unsigned int firstMDIndex,
1924 unsigned int secondMDIndex,
1925 unsigned int thirdMDIndex,
1926 unsigned int fourthMDIndex) {
1927 short innerInnerLowerModuleSubdet =
modules.subdets()[innerInnerLowerModuleIndex];
1928 short innerOuterLowerModuleSubdet =
modules.subdets()[innerOuterLowerModuleIndex];
1929 short outerInnerLowerModuleSubdet =
modules.subdets()[outerInnerLowerModuleIndex];
1930 short outerOuterLowerModuleSubdet =
modules.subdets()[outerOuterLowerModuleIndex];
1932 if (innerInnerLowerModuleSubdet == Barrel and innerOuterLowerModuleSubdet == Barrel and
1933 outerInnerLowerModuleSubdet == Barrel and outerOuterLowerModuleSubdet == Barrel) {
1938 innerInnerLowerModuleIndex,
1939 innerOuterLowerModuleIndex,
1940 outerInnerLowerModuleIndex,
1941 outerOuterLowerModuleIndex,
1948 }
else if (innerInnerLowerModuleSubdet == Barrel and innerOuterLowerModuleSubdet == Barrel and
1949 outerInnerLowerModuleSubdet ==
Endcap and outerOuterLowerModuleSubdet ==
Endcap) {
1954 innerInnerLowerModuleIndex,
1955 innerOuterLowerModuleIndex,
1956 outerInnerLowerModuleIndex,
1957 outerOuterLowerModuleIndex,
1964 }
else if (innerInnerLowerModuleSubdet == Barrel and innerOuterLowerModuleSubdet == Barrel and
1965 outerInnerLowerModuleSubdet == Barrel and outerOuterLowerModuleSubdet ==
Endcap) {
1970 innerInnerLowerModuleIndex,
1971 innerOuterLowerModuleIndex,
1972 outerInnerLowerModuleIndex,
1973 outerOuterLowerModuleIndex,
1980 }
else if (innerInnerLowerModuleSubdet == Barrel and innerOuterLowerModuleSubdet ==
Endcap and
1981 outerInnerLowerModuleSubdet ==
Endcap and outerOuterLowerModuleSubdet ==
Endcap) {
1986 innerInnerLowerModuleIndex,
1987 innerOuterLowerModuleIndex,
1988 outerInnerLowerModuleIndex,
1989 outerOuterLowerModuleIndex,
1996 }
else if (innerInnerLowerModuleSubdet ==
Endcap and innerOuterLowerModuleSubdet ==
Endcap and
1997 outerInnerLowerModuleSubdet ==
Endcap and outerOuterLowerModuleSubdet ==
Endcap) {
2002 innerInnerLowerModuleIndex,
2003 innerOuterLowerModuleIndex,
2004 outerInnerLowerModuleIndex,
2005 outerOuterLowerModuleIndex,
2017 template <
typename TAcc>
2023 uint16_t lowerModuleIndex1,
2024 uint16_t lowerModuleIndex2,
2025 uint16_t lowerModuleIndex3,
2026 uint16_t lowerModuleIndex4,
2027 uint16_t lowerModuleIndex5,
2028 unsigned int innerTripletIndex,
2029 unsigned int outerTripletIndex,
2032 float& bridgeRadius,
2035 float& regressionRadius,
2036 float& rzChiSquared,
2038 float& nonAnchorChiSquared,
2039 bool& tightCutFlag) {
2040 unsigned int firstSegmentIndex = triplets.segmentIndices()[innerTripletIndex][0];
2041 unsigned int secondSegmentIndex = triplets.segmentIndices()[innerTripletIndex][1];
2042 unsigned int thirdSegmentIndex = triplets.segmentIndices()[outerTripletIndex][0];
2043 unsigned int fourthSegmentIndex = triplets.segmentIndices()[outerTripletIndex][1];
2045 unsigned int innerOuterOuterMiniDoubletIndex =
2046 segments.mdIndices()[secondSegmentIndex][1];
2047 unsigned int outerInnerInnerMiniDoubletIndex =
2048 segments.mdIndices()[thirdSegmentIndex][0];
2051 if (innerOuterOuterMiniDoubletIndex != outerInnerInnerMiniDoubletIndex)
2054 unsigned int firstMDIndex = segments.mdIndices()[firstSegmentIndex][0];
2055 unsigned int secondMDIndex = segments.mdIndices()[secondSegmentIndex][0];
2056 unsigned int thirdMDIndex = segments.mdIndices()[secondSegmentIndex][1];
2057 unsigned int fourthMDIndex = segments.mdIndices()[thirdSegmentIndex][1];
2058 unsigned int fifthMDIndex = segments.mdIndices()[fourthSegmentIndex][1];
2092 float x1 = mds.anchorX()[firstMDIndex];
2093 float x2 = mds.anchorX()[secondMDIndex];
2094 float x3 = mds.anchorX()[thirdMDIndex];
2095 float x4 = mds.anchorX()[fourthMDIndex];
2096 float x5 = mds.anchorX()[fifthMDIndex];
2098 float y1 = mds.anchorY()[firstMDIndex];
2099 float y2 = mds.anchorY()[secondMDIndex];
2100 float y3 = mds.anchorY()[thirdMDIndex];
2101 float y4 = mds.anchorY()[fourthMDIndex];
2102 float y5 = mds.anchorY()[fifthMDIndex];
2105 float x1Vec[] = {x1, x1, x1};
2106 float y1Vec[] = {
y1,
y1,
y1};
2107 float x2Vec[] = {x2, x2, x2};
2108 float y2Vec[] = {
y2,
y2,
y2};
2109 float x3Vec[] = {x3, x3, x3};
2110 float y3Vec[] = {y3, y3, y3};
2113 x1Vec[1] = mds.anchorLowEdgeX()[firstMDIndex];
2114 x1Vec[2] = mds.anchorHighEdgeX()[firstMDIndex];
2116 y1Vec[1] = mds.anchorLowEdgeY()[firstMDIndex];
2117 y1Vec[2] = mds.anchorHighEdgeY()[firstMDIndex];
2120 x2Vec[1] = mds.anchorLowEdgeX()[secondMDIndex];
2121 x2Vec[2] = mds.anchorHighEdgeX()[secondMDIndex];
2123 y2Vec[1] = mds.anchorLowEdgeY()[secondMDIndex];
2124 y2Vec[2] = mds.anchorHighEdgeY()[secondMDIndex];
2127 x3Vec[1] = mds.anchorLowEdgeX()[thirdMDIndex];
2128 x3Vec[2] = mds.anchorHighEdgeX()[thirdMDIndex];
2130 y3Vec[1] = mds.anchorLowEdgeY()[thirdMDIndex];
2131 y3Vec[2] = mds.anchorHighEdgeY()[thirdMDIndex];
2134 float innerRadiusMin2S, innerRadiusMax2S;
2135 computeErrorInRadius(acc, x1Vec, y1Vec, x2Vec, y2Vec, x3Vec, y3Vec, innerRadiusMin2S, innerRadiusMax2S);
2137 for (
int i = 0;
i < 3;
i++) {
2142 x1Vec[1] = mds.anchorLowEdgeX()[fourthMDIndex];
2143 x1Vec[2] = mds.anchorHighEdgeX()[fourthMDIndex];
2145 y1Vec[1] = mds.anchorLowEdgeY()[fourthMDIndex];
2146 y1Vec[2] = mds.anchorHighEdgeY()[fourthMDIndex];
2149 float bridgeRadiusMin2S, bridgeRadiusMax2S;
2150 computeErrorInRadius(acc, x2Vec, y2Vec, x3Vec, y3Vec, x1Vec, y1Vec, bridgeRadiusMin2S, bridgeRadiusMax2S);
2152 for (
int i = 0;
i < 3;
i++) {
2157 x2Vec[1] = mds.anchorLowEdgeX()[fifthMDIndex];
2158 x2Vec[2] = mds.anchorHighEdgeX()[fifthMDIndex];
2160 y2Vec[1] = mds.anchorLowEdgeY()[fifthMDIndex];
2161 y2Vec[2] = mds.anchorHighEdgeY()[fifthMDIndex];
2164 float outerRadiusMin2S, outerRadiusMax2S;
2165 computeErrorInRadius(acc, x3Vec, y3Vec, x1Vec, y1Vec, x2Vec, y2Vec, outerRadiusMin2S, outerRadiusMax2S);
2168 outerRadius = triplets.radius()[outerTripletIndex];
2170 innerRadius = triplets.radius()[innerTripletIndex];
2171 g = triplets.centerX()[innerTripletIndex];
2172 f = triplets.centerY()[innerTripletIndex];
2202 if (
modules.subdets()[lowerModuleIndex1] == Barrel and
modules.subdets()[lowerModuleIndex2] == Barrel and
2203 modules.subdets()[lowerModuleIndex3] == Barrel and
modules.subdets()[lowerModuleIndex4] == Barrel and
2204 modules.subdets()[lowerModuleIndex5] == Barrel) {
2206 }
else if (
modules.subdets()[lowerModuleIndex1] == Barrel and
modules.subdets()[lowerModuleIndex2] == Barrel and
2207 modules.subdets()[lowerModuleIndex3] == Barrel and
modules.subdets()[lowerModuleIndex4] == Barrel and
2210 }
else if (
modules.subdets()[lowerModuleIndex1] == Barrel and
modules.subdets()[lowerModuleIndex2] == Barrel and
2211 modules.subdets()[lowerModuleIndex3] == Barrel and
modules.subdets()[lowerModuleIndex4] ==
Endcap and
2213 if (
modules.layers()[lowerModuleIndex1] == 1) {
2216 }
else if (
modules.layers()[lowerModuleIndex1] == 2) {
2225 else if (
modules.subdets()[lowerModuleIndex1] == Barrel and
modules.subdets()[lowerModuleIndex2] == Barrel and
2229 }
else if (
modules.subdets()[lowerModuleIndex1] == Barrel and
modules.subdets()[lowerModuleIndex2] ==
Endcap and
2252 if (not matchedRadii)
2255 float xVec[] = {x1, x2, x3, x4, x5};
2256 float yVec[] = {
y1,
y2, y3, y4, y5};
2257 const uint16_t lowerModuleIndices[] = {
2258 lowerModuleIndex1, lowerModuleIndex2, lowerModuleIndex3, lowerModuleIndex4, lowerModuleIndex5};
2261 float sigmas2[5], delta1[5], delta2[5], slopes[5];
2278 unsigned int mdIndices[] = {firstMDIndex, secondMDIndex, thirdMDIndex, fourthMDIndex, fifthMDIndex};
2299 float nonAnchorDelta1[Params_T5::kLayers], nonAnchorDelta2[Params_T5::kLayers], nonAnchorSlopes[Params_T5::kLayers];
2300 float nonAnchorxs[] = {mds.outerX()[firstMDIndex],
2301 mds.outerX()[secondMDIndex],
2302 mds.outerX()[thirdMDIndex],
2303 mds.outerX()[fourthMDIndex],
2304 mds.outerX()[fifthMDIndex]};
2305 float nonAnchorys[] = {mds.outerY()[firstMDIndex],
2306 mds.outerY()[secondMDIndex],
2307 mds.outerY()[thirdMDIndex],
2308 mds.outerY()[fourthMDIndex],
2309 mds.outerY()[fifthMDIndex]};
2335 template <
typename TAcc>
2345 uint16_t nEligibleT5Modules)
const {
2346 auto const globalThreadIdx = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc);
2347 auto const gridThreadExtent = alpaka::getWorkDiv<alpaka::Grid, alpaka::Threads>(acc);
2349 for (
int iter = globalThreadIdx[0]; iter < nEligibleT5Modules; iter += gridThreadExtent[0]) {
2350 uint16_t lowerModule1 =
ranges.indicesOfEligibleT5Modules()[iter];
2351 short layer2_adjustment;
2352 int layer =
modules.layers()[lowerModule1];
2354 layer2_adjustment = 1;
2356 else if (layer == 2) {
2357 layer2_adjustment = 0;
2362 unsigned int nInnerTriplets = tripletsOccupancy.nTriplets()[lowerModule1];
2363 for (
unsigned int innerTripletArrayIndex = globalThreadIdx[1]; innerTripletArrayIndex < nInnerTriplets;
2364 innerTripletArrayIndex += gridThreadExtent[1]) {
2365 unsigned int innerTripletIndex =
ranges.tripletModuleIndices()[lowerModule1] + innerTripletArrayIndex;
2366 uint16_t lowerModule2 = triplets.lowerModuleIndices()[innerTripletIndex][1];
2367 uint16_t lowerModule3 = triplets.lowerModuleIndices()[innerTripletIndex][2];
2368 unsigned int nOuterTriplets = tripletsOccupancy.nTriplets()[lowerModule3];
2369 for (
unsigned int outerTripletArrayIndex = globalThreadIdx[2]; outerTripletArrayIndex < nOuterTriplets;
2370 outerTripletArrayIndex += gridThreadExtent[2]) {
2371 unsigned int outerTripletIndex =
ranges.tripletModuleIndices()[lowerModule3] + outerTripletArrayIndex;
2372 uint16_t lowerModule4 = triplets.lowerModuleIndices()[outerTripletIndex][1];
2373 uint16_t lowerModule5 = triplets.lowerModuleIndices()[outerTripletIndex][2];
2376 chiSquared, nonAnchorChiSquared;
2378 bool tightCutFlag =
false;
2399 nonAnchorChiSquared,
2404 acc, &quintupletsOccupancy.totOccupancyQuintuplets()[lowerModule1], 1u, alpaka::hierarchy::Threads{});
2405 if (totOccupancyQuintuplets >=
ranges.quintupletModuleOccupancy()[lowerModule1]) {
2407 printf(
"Quintuplet excess alert! Module index = %d\n", lowerModule1);
2411 acc, &quintupletsOccupancy.nQuintuplets()[lowerModule1], 1u, alpaka::hierarchy::Threads{});
2413 if (
ranges.quintupletModuleIndices()[lowerModule1] == -1) {
2415 printf(
"Quintuplets : no memory for module at module index = %d\n", lowerModule1);
2418 unsigned int quintupletIndex =
ranges.quintupletModuleIndices()[lowerModule1] + quintupletModuleIndex;
2419 float phi = mds.anchorPhi()[segments.mdIndices()[triplets.segmentIndices()[innerTripletIndex][0]]
2420 [layer2_adjustment]];
2421 float eta = mds.anchorEta()[segments.mdIndices()[triplets.segmentIndices()[innerTripletIndex][0]]
2422 [layer2_adjustment]];
2424 float scores = chiSquared + nonAnchorChiSquared;
2442 nonAnchorChiSquared,
2451 triplets.partOfT5()[quintuplets.tripletIndices()[quintupletIndex][0]] =
true;
2452 triplets.partOfT5()[quintuplets.tripletIndices()[quintupletIndex][1]] =
true;
2463 template <
typename TAcc>
2469 static_assert(std::is_same_v<TAcc, ALPAKA_ACCELERATOR_NAMESPACE::Acc1D>,
"Should be Acc1D");
2470 ALPAKA_ASSERT_ACC((alpaka::getWorkDiv<alpaka::Grid, alpaka::Blocks>(acc)[0] == 1));
2472 auto const globalThreadIdx = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc);
2473 auto const gridThreadExtent = alpaka::getWorkDiv<alpaka::Grid, alpaka::Threads>(acc);
2476 int& nEligibleT5Modulesx = alpaka::declareSharedVar<int, __COUNTER__>(acc);
2477 int& nTotalQuintupletsx = alpaka::declareSharedVar<int, __COUNTER__>(acc);
2479 nTotalQuintupletsx = 0;
2480 nEligibleT5Modulesx = 0;
2482 alpaka::syncBlockThreads(acc);
2484 for (
int i = globalThreadIdx[0];
i <
modules.nLowerModules();
i += gridThreadExtent[0]) {
2492 if (tripletsOccupancy.nTriplets()[
i] == 0)
2499 int nEligibleT5Modules =
alpaka::atomicAdd(acc, &nEligibleT5Modulesx, 1, alpaka::hierarchy::Threads{});
2501 int category_number;
2503 category_number = 0;
2505 category_number = 1;
2506 else if (module_layers <= 2 && module_subdets == 4 && module_rings >= 11)
2507 category_number = 2;
2509 category_number = 2;
2511 category_number = 3;
2513 category_number = 3;
2515 category_number = -1;
2518 if (module_eta < 0.75
f)
2520 else if (module_eta < 1.5
f)
2522 else if (module_eta < 2.25
f)
2524 else if (module_eta < 3.0
f)
2530 if (category_number == 0 && eta_number == 0)
2532 else if (category_number == 0 && eta_number == 1)
2534 else if (category_number == 0 && eta_number == 2)
2536 else if (category_number == 0 && eta_number == 3)
2538 else if (category_number == 3 && eta_number == 1)
2540 else if (category_number == 3 && eta_number == 2)
2542 else if (category_number == 3 && eta_number == 3)
2547 printf(
"Unhandled case in createEligibleModulesListForQuintupletsGPU! Module index = %i\n",
i);
2551 int nTotQ =
alpaka::atomicAdd(acc, &nTotalQuintupletsx, occupancy, alpaka::hierarchy::Threads{});
2552 ranges.quintupletModuleIndices()[
i] = nTotQ;
2553 ranges.indicesOfEligibleT5Modules()[nEligibleT5Modules] =
i;
2554 ranges.quintupletModuleOccupancy()[
i] = occupancy;
2558 alpaka::syncBlockThreads(acc);
2560 ranges.nEligibleT5Modules() =
static_cast<uint16_t
>(nEligibleT5Modulesx);
2561 ranges.nTotalQuints() =
static_cast<unsigned int>(nTotalQuintupletsx);
2567 template <
typename TAcc>
2573 static_assert(std::is_same_v<TAcc, ALPAKA_ACCELERATOR_NAMESPACE::Acc1D>,
"Should be Acc1D");
2574 ALPAKA_ASSERT_ACC((alpaka::getWorkDiv<alpaka::Grid, alpaka::Blocks>(acc)[0] == 1));
2576 auto const globalThreadIdx = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc);
2577 auto const gridThreadExtent = alpaka::getWorkDiv<alpaka::Grid, alpaka::Threads>(acc);
2579 for (uint16_t
i = globalThreadIdx[0];
i <
modules.nLowerModules();
i += gridThreadExtent[0]) {
2580 if (quintupletsOccupancy.nQuintuplets()[
i] == 0
or ranges.quintupletModuleIndices()[
i] == -1) {
2581 ranges.quintupletRanges()[
i][0] = -1;
2582 ranges.quintupletRanges()[
i][1] = -1;
2584 ranges.quintupletRanges()[
i][0] =
ranges.quintupletModuleIndices()[
i];
2585 ranges.quintupletRanges()[
i][1] =
2586 ranges.quintupletModuleIndices()[
i] + quintupletsOccupancy.nQuintuplets()[
i] - 1;
ALPAKA_FN_ACC ALPAKA_FN_INLINE float runInference(TAcc const &acc, ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, TripletsConst triplets, const float *xVec, const float *yVec, const unsigned int *mdIndices, const uint16_t *lowerModuleIndices, unsigned int innerTripletIndex, unsigned int outerTripletIndex, float innerRadius, float outerRadius, float bridgeRadius)
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runQuintupletAlgoSelector(TAcc const &acc, ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, 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)
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passChiSquaredConstraint(ModulesConst modules, uint16_t lowerModuleIndex1, uint16_t lowerModuleIndex2, uint16_t lowerModuleIndex3, uint16_t lowerModuleIndex4, uint16_t lowerModuleIndex5, float chiSquared)
ALPAKA_FN_ACC ALPAKA_FN_INLINE void computeSigmasForRegression(TAcc const &acc, ModulesConst modules, const uint16_t *lowerModuleIndices, float *delta1, float *delta2, float *slopes, bool *isFlat, unsigned int nPoints=5, bool anchorHits=true)
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool checkIntervalOverlap(float firstMin, float firstMax, float secondMin, float secondMax)
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float k2Rinv1GeVf
ObjectRangesSoA::View ObjectRanges
static const double slope[3]
const std::vector< int > & module_rings()
Sin< T >::type sin(const T &t)
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runQuintupletDefaultAlgo(TAcc const &acc, ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, TripletsConst triplets, uint16_t lowerModuleIndex1, uint16_t lowerModuleIndex2, uint16_t lowerModuleIndex3, uint16_t lowerModuleIndex4, uint16_t lowerModuleIndex5, unsigned int innerTripletIndex, unsigned int outerTripletIndex, float &innerRadius, float &outerRadius, float &bridgeRadius, float ®ressionG, float ®ressionF, float ®ressionRadius, float &rzChiSquared, float &chiSquared, float &nonAnchorChiSquared, bool &tightCutFlag)
ALPAKA_FN_ACC int side(int ieta, int iphi)
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kWidthPS
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)
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kWidth2S
ALPAKA_FN_ACC void operator()(TAcc const &acc, ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, Triplets triplets, TripletsOccupancyConst tripletsOccupancy, Quintuplets quintuplets, QuintupletsOccupancy quintupletsOccupancy, ObjectRangesConst ranges, uint16_t nEligibleT5Modules) const
ALPAKA_FN_ACC ALPAKA_FN_INLINE float computeChiSquared(TAcc const &acc, unsigned int nPoints, float *xs, float *ys, float *delta1, float *delta2, float *slopes, bool *isFlat, float g, float f, float radius)
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool T5HasCommonMiniDoublet(TripletsConst triplets, SegmentsConst segments, unsigned int innerTripletIndex, unsigned int outerTripletIndex)
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kVerticalModuleSlope
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 g
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float ptCut
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool matchRadiiBBBBE(TAcc const &acc, float innerRadius, float bridgeRadius, float outerRadius)
QuintupletsSoA::View Quintuplets
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool matchRadiiBBBEE12378(TAcc const &acc, float innerRadius, float bridgeRadius, float outerRadius, float bridgeRadiusMin2S, float bridgeRadiusMax2S)
TripletsSoA::ConstView TripletsConst
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE float phi_mpi_pi(TAcc const &acc, float x)
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runQuintupletDefaultAlgoEEEE(TAcc const &acc, ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, 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)
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE float phi(TAcc const &acc, float x, float y)
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)
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
ALPAKA_FN_ACC ALPAKA_FN_INLINE void runDeltaBetaIterationsT5(TAcc const &acc, float &betaIn, float &betaOut, float betaAv, float &pt_beta, float sdIn_dr, float sdOut_dr, float dr, float lIn)
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kLSTWp2
MiniDoubletsSoA::ConstView MiniDoubletsConst
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runQuintupletDefaultAlgoBBBB(TAcc const &acc, ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, 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)
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool matchRadiiBBEEE(TAcc const &acc, float innerRadius, float bridgeRadius, float outerRadius, float bridgeRadiusMin2S, float bridgeRadiusMax2S)
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool matchRadiiBBBEE23478(TAcc const &acc, float innerRadius, float bridgeRadius, float outerRadius, float bridgeRadiusMin2S, float bridgeRadiusMax2S)
ModulesSoA::ConstView ModulesConst
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passT5RZConstraint(TAcc const &acc, ModulesConst modules, MiniDoubletsConst mds, unsigned int firstMDIndex, unsigned int secondMDIndex, unsigned int thirdMDIndex, unsigned int fourthMDIndex, unsigned int fifthMDIndex, uint16_t lowerModuleIndex1, uint16_t lowerModuleIndex2, uint16_t lowerModuleIndex3, uint16_t lowerModuleIndex4, uint16_t lowerModuleIndex5, float &rzChiSquared, float inner_pt, float innerRadius, float g, float f, bool &tightCutFlag)
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool matchRadiiBBBBB(TAcc const &acc, float innerRadius, float bridgeRadius, float outerRadius)
const std::vector< int > & module_layers()
QuintupletsOccupancySoA::View QuintupletsOccupancy
ALPAKA_FN_ACC ALPAKA_FN_INLINE void computeErrorInRadius(TAcc const &acc, float *x1Vec, float *y1Vec, float *x2Vec, float *y2Vec, float *x3Vec, float *y3Vec, float &minimumRadius, float &maximumRadius)
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kMulsInGeV
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kPixelPSZpitch
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool matchRadiiEEEEE(TAcc const &acc, float innerRadius, float bridgeRadius, float outerRadius, float innerRadiusMin2S, float innerRadiusMax2S, float bridgeRadiusMin2S, float bridgeRadiusMax2S)
const std::vector< int > & module_subdets()
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kStripPSZpitch
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kPt_betaMax
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kPi
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runQuintupletDefaultAlgoBBEE(TAcc const &acc, ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, 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)
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kStrip2SZpitch
TripletsSoA::View Triplets
ALPAKA_FN_ACC void operator()(TAcc const &acc, ModulesConst modules, TripletsOccupancyConst tripletsOccupancy, ObjectRanges ranges) const
ALPAKA_FN_ACC void operator()(TAcc const &acc, ModulesConst modules, QuintupletsOccupancyConst quintupletsOccupancy, ObjectRanges ranges) const
TripletsOccupancySoA::ConstView TripletsOccupancyConst
ObjectRangesSoA::ConstView ObjectRangesConst
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kSinAlphaMax
SegmentsSoA::ConstView SegmentsConst
QuintupletsOccupancySoA::ConstView QuintupletsOccupancyConst
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool matchRadiiBEEEE(TAcc const &acc, float innerRadius, float bridgeRadius, float outerRadius, float innerRadiusMin2S, float innerRadiusMax2S, float bridgeRadiusMin2S, float bridgeRadiusMax2S)
ALPAKA_FN_ACC ALPAKA_FN_INLINE void addQuintupletToMemory(TripletsConst triplets, Quintuplets quintuplets, unsigned int innerTripletIndex, unsigned int outerTripletIndex, uint16_t lowerModule1, uint16_t lowerModule2, uint16_t lowerModule3, uint16_t lowerModule4, uint16_t lowerModule5, float innerRadius, float bridgeRadius, float outerRadius, float regressionG, float regressionF, float regressionRadius, float rzChiSquared, float rPhiChiSquared, float nonAnchorChiSquared, float pt, float eta, float phi, float scores, uint8_t layer, unsigned int quintupletIndex, bool tightCutFlag)
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)
static const std::string subdets[7]
T1 atomicAdd(T1 *a, T2 b)
ALPAKA_FN_ACC ALPAKA_FN_INLINE float computeRadiusUsingRegression(TAcc const &acc, unsigned int nPoints, float *xs, float *ys, float *delta1, float *delta2, float *slopes, bool *isFlat, float &g, float &f, float *sigmas2, float &chiSquared)
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool matchRadiiBBBEE34578(TAcc const &acc, float innerRadius, float bridgeRadius, float outerRadius, float bridgeRadiusMin2S, float bridgeRadiusMax2S)
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE float eta(TAcc const &acc, float x, float y, float z)