Skip to content

Commit 51ba1d6

Browse files
committed
Replace pT3 Rphi with DNN.
1 parent a115465 commit 51ba1d6

File tree

10 files changed

+717
-776
lines changed

10 files changed

+717
-776
lines changed

RecoTracker/LSTCore/interface/alpaka/Common.h

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,27 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
9494

9595
namespace pt3dnn {
9696
HOST_DEVICE_CONSTANT float kEta_norm = 2.5f;
97-
HOST_DEVICE_CONSTANT float kWp[kEtaBins] = {
98-
0.189f, 0.1805f, 0.2267f, 0.3104f, 0.4719f, 0.3159f, 0.1372f, 0.1571f, 0.3198f, 0.186f};
99-
HOST_DEVICE_CONSTANT float kWpHigh = 0.0473f;
97+
98+
// 95% sig-efficiency for abs(eta) <= 1.25, 84% for abs(eta) > 1.25
99+
HOST_DEVICE_CONSTANT float kWp_pT3[kEtaBins] = {
100+
0.6288f, 0.8014f, 0.7218f, 0.743f, 0.7519f, 0.8633f, 0.6934f, 0.6983f, 0.6502f, 0.7037f};
101+
// 95% sig-efficiency for high pT bin
102+
HOST_DEVICE_CONSTANT float kWpHigh_pT3 = 0.657f;
103+
// 99.5% sig-efficiency for abs(eta) <= 1.25, 99% for abs(eta) > 1.25
104+
HOST_DEVICE_CONSTANT float kWp_pT5[kEtaBins] = {
105+
0.1227f, 0.1901f, 0.218f, 0.3438f, 0.1011f, 0.1502f, 0.0391f, 0.0471f, 0.1444f, 0.1007f};
106+
// 99.5% signal efficiency for high pT bin
107+
HOST_DEVICE_CONSTANT float kWpHigh_pT5 = 0.1498f;
108+
109+
// kWp's must be defined with inline static in the structs to compile.
110+
struct pT3WP {
111+
ALPAKA_FN_ACC static inline float wp(unsigned i) { return kWp_pT3[i]; }
112+
ALPAKA_FN_ACC static inline float wpHigh() { return kWpHigh_pT3; }
113+
};
114+
struct pT5WP {
115+
ALPAKA_FN_ACC static inline float wp(unsigned i) { return kWp_pT5[i]; }
116+
ALPAKA_FN_ACC static inline float wpHigh() { return kWpHigh_pT5; }
117+
};
100118
} // namespace pt3dnn
101119

102120
} // namespace dnn

RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,25 +140,29 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
140140

141141
namespace pt3dnn {
142142

143-
template <typename TAcc>
143+
template <typename WP, typename TAcc>
144144
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runInference(TAcc const& acc,
145145
const float rPhiChiSquared,
146146
const float tripletRadius,
147147
const float pixelRadius,
148148
const float pixRadiusError,
149149
const float rzChiSquared,
150150
const float pixelEta,
151-
const float pixelPt) {
152-
constexpr unsigned int kInputFeatures = 6;
151+
const float pixelPt,
152+
const int moduleType3) {
153+
constexpr unsigned int kInputFeatures = 7;
153154
constexpr unsigned int kHiddenFeatures = 32;
154155
constexpr unsigned int kOutputFeatures = 1;
155156

156-
float x[kInputFeatures] = {alpaka::math::log10(acc, rPhiChiSquared),
157-
alpaka::math::log10(acc, tripletRadius),
158-
alpaka::math::log10(acc, pixelRadius),
159-
alpaka::math::log10(acc, pixRadiusError),
160-
alpaka::math::log10(acc, rzChiSquared),
161-
alpaka::math::abs(acc, pixelEta) / dnn::pt3dnn::kEta_norm};
157+
float x[kInputFeatures] = {
158+
alpaka::math::log10(acc, rPhiChiSquared),
159+
alpaka::math::log10(acc, tripletRadius),
160+
alpaka::math::log10(acc, pixelRadius),
161+
alpaka::math::log10(acc, pixRadiusError),
162+
alpaka::math::log10(acc, rzChiSquared),
163+
alpaka::math::abs(acc, pixelEta) / dnn::pt3dnn::kEta_norm,
164+
static_cast<float>(moduleType3),
165+
};
162166

163167
float x1[kHiddenFeatures];
164168
float x2[kHiddenFeatures];
@@ -179,9 +183,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
179183
: static_cast<unsigned int>(alpaka::math::abs(acc, pixelEta) / dnn::kEtaSize);
180184

181185
if (pixelPt > 5.0f)
182-
return output > dnn::pt3dnn::kWpHigh;
186+
return output > WP::wpHigh();
183187

184-
return output > dnn::pt3dnn::kWp[bin_index];
188+
return output > WP::wp(bin_index);
185189
}
186190

187191
} // namespace pt3dnn

RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -491,27 +491,27 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
491491
float pixelRadiusTemp, tripletRadius, rPhiChiSquaredTemp, rzChiSquaredTemp, rPhiChiSquaredInwardsTemp, centerXTemp,
492492
centerYTemp, pixelRadiusErrorTemp;
493493

494-
if (not runPixelTripletDefaultAlgo(acc,
495-
modules,
496-
ranges,
497-
mds,
498-
segments,
499-
pixelSeeds,
500-
pixelSegments,
501-
triplets,
502-
pixelSegmentIndex,
503-
t5InnerT3Index,
504-
pixelRadiusTemp,
505-
tripletRadius,
506-
centerXTemp,
507-
centerYTemp,
508-
rzChiSquaredTemp,
509-
rPhiChiSquaredTemp,
510-
rPhiChiSquaredInwardsTemp,
511-
pixelRadiusErrorTemp,
512-
ptCut,
513-
true,
514-
false))
494+
if (not runPixelTripletDefaultAlgo<dnn::pt3dnn::pT5WP>(acc,
495+
modules,
496+
ranges,
497+
mds,
498+
segments,
499+
pixelSeeds,
500+
pixelSegments,
501+
triplets,
502+
pixelSegmentIndex,
503+
t5InnerT3Index,
504+
pixelRadiusTemp,
505+
tripletRadius,
506+
centerXTemp,
507+
centerYTemp,
508+
rzChiSquaredTemp,
509+
rPhiChiSquaredTemp,
510+
rPhiChiSquaredInwardsTemp,
511+
pixelRadiusErrorTemp,
512+
ptCut,
513+
true,
514+
false))
515515
return false;
516516

517517
unsigned int firstSegmentIndex = triplets.segmentIndices()[t5InnerT3Index][0];

RecoTracker/LSTCore/src/alpaka/PixelTriplet.h

Lines changed: 13 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -312,107 +312,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
312312
return chiSquared;
313313
}
314314

315-
//90pc threshold
316-
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RPhiChiSquaredCuts(ModulesConst modules,
317-
uint16_t lowerModuleIndex1,
318-
uint16_t lowerModuleIndex2,
319-
uint16_t lowerModuleIndex3,
320-
float chiSquared) {
321-
const int layer1 =
322-
modules.layers()[lowerModuleIndex1] + 6 * (modules.subdets()[lowerModuleIndex1] == Endcap) +
323-
5 * (modules.subdets()[lowerModuleIndex1] == Endcap and modules.moduleType()[lowerModuleIndex1] == TwoS);
324-
const int layer2 =
325-
modules.layers()[lowerModuleIndex2] + 6 * (modules.subdets()[lowerModuleIndex2] == Endcap) +
326-
5 * (modules.subdets()[lowerModuleIndex2] == Endcap and modules.moduleType()[lowerModuleIndex2] == TwoS);
327-
const int layer3 =
328-
modules.layers()[lowerModuleIndex3] + 6 * (modules.subdets()[lowerModuleIndex3] == Endcap) +
329-
5 * (modules.subdets()[lowerModuleIndex3] == Endcap and modules.moduleType()[lowerModuleIndex3] == TwoS);
330-
331-
if (layer1 == 8 and layer2 == 9 and layer3 == 10) {
332-
return chiSquared < 7.003f;
333-
} else if (layer1 == 8 and layer2 == 9 and layer3 == 15) {
334-
return chiSquared < 0.5f;
335-
} else if (layer1 == 7 and layer2 == 8 and layer3 == 9) {
336-
return chiSquared < 8.046f;
337-
} else if (layer1 == 7 and layer2 == 8 and layer3 == 14) {
338-
return chiSquared < 0.575f;
339-
} else if (layer1 == 1 and layer2 == 2 and layer3 == 7) {
340-
return chiSquared < 5.304f;
341-
} else if (layer1 == 1 and layer2 == 2 and layer3 == 3) {
342-
return chiSquared < 10.6211f;
343-
} else if (layer1 == 1 and layer2 == 7 and layer3 == 8) {
344-
return chiSquared < 4.617f;
345-
} else if (layer1 == 2 and layer2 == 7 and layer3 == 8) {
346-
return chiSquared < 8.046f;
347-
} else if (layer1 == 2 and layer2 == 7 and layer3 == 13) {
348-
return chiSquared < 0.435f;
349-
} else if (layer1 == 2 and layer2 == 3 and layer3 == 7) {
350-
return chiSquared < 9.244f;
351-
} else if (layer1 == 2 and layer2 == 3 and layer3 == 12) {
352-
return chiSquared < 0.287f;
353-
} else if (layer1 == 2 and layer2 == 3 and layer3 == 4) {
354-
return chiSquared < 18.509f;
355-
}
356-
357-
return true;
358-
}
359-
360-
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RPhiChiSquaredInwardsCuts(ModulesConst modules,
361-
uint16_t lowerModuleIndex1,
362-
uint16_t lowerModuleIndex2,
363-
uint16_t lowerModuleIndex3,
364-
float chiSquared) {
365-
const int layer1 =
366-
modules.layers()[lowerModuleIndex1] + 6 * (modules.subdets()[lowerModuleIndex1] == Endcap) +
367-
5 * (modules.subdets()[lowerModuleIndex1] == Endcap and modules.moduleType()[lowerModuleIndex1] == TwoS);
368-
const int layer2 =
369-
modules.layers()[lowerModuleIndex2] + 6 * (modules.subdets()[lowerModuleIndex2] == Endcap) +
370-
5 * (modules.subdets()[lowerModuleIndex2] == Endcap and modules.moduleType()[lowerModuleIndex2] == TwoS);
371-
const int layer3 =
372-
modules.layers()[lowerModuleIndex3] + 6 * (modules.subdets()[lowerModuleIndex3] == Endcap) +
373-
5 * (modules.subdets()[lowerModuleIndex3] == Endcap and modules.moduleType()[lowerModuleIndex3] == TwoS);
374-
375-
if (layer1 == 7 and layer2 == 8 and layer3 == 9) // endcap layer 1,2,3, ps
376-
{
377-
return chiSquared < 22016.8055f;
378-
} else if (layer1 == 7 and layer2 == 8 and layer3 == 14) // endcap layer 1,2,3 layer3->2s
379-
{
380-
return chiSquared < 935179.56807f;
381-
} else if (layer1 == 8 and layer2 == 9 and layer3 == 10) // endcap layer 2,3,4
382-
{
383-
return chiSquared < 29064.12959f;
384-
} else if (layer1 == 8 and layer2 == 9 and layer3 == 15) // endcap layer 2,3,4, layer3->2s
385-
{
386-
return chiSquared < 935179.5681f;
387-
} else if (layer1 == 1 and layer2 == 2 and layer3 == 3) // barrel 1,2,3
388-
{
389-
return chiSquared < 1370.0113195101474f;
390-
} else if (layer1 == 1 and layer2 == 2 and layer3 == 7) // barrel 1,2 endcap 1
391-
{
392-
return chiSquared < 5492.110048314815f;
393-
} else if (layer1 == 2 and layer2 == 3 and layer3 == 4) // barrel 2,3,4
394-
{
395-
return chiSquared < 4160.410806470067f;
396-
} else if (layer1 == 1 and layer2 == 7 and layer3 == 8) // barrel 1, endcap 1,2
397-
{
398-
return chiSquared < 29064.129591225726f;
399-
} else if (layer1 == 2 and layer2 == 3 and layer3 == 7) // barrel 2,3 endcap 1
400-
{
401-
return chiSquared < 12634.215376250893f;
402-
} else if (layer1 == 2 and layer2 == 3 and layer3 == 12) // barrel 2,3, endcap 1->2s
403-
{
404-
return chiSquared < 353821.69361145404f;
405-
} else if (layer1 == 2 and layer2 == 7 and layer3 == 8) // barrel2, endcap 1,2
406-
{
407-
return chiSquared < 33393.26076341235f;
408-
} else if (layer1 == 2 and layer2 == 7 and layer3 == 13) //barrel 2, endcap 1, endcap2->2s
409-
{
410-
return chiSquared < 935179.5680742573f;
411-
}
412-
413-
return true;
414-
}
415-
416315
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool checkIntervalOverlappT3(float firstMin,
417316
float firstMax,
418317
float secondMin,
@@ -630,7 +529,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
630529
return RMSE;
631530
}
632531

633-
template <typename TAcc>
532+
template <typename WP = dnn::pt3dnn::pT3WP, typename TAcc>
634533
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runPixelTripletDefaultAlgo(TAcc const& acc,
635534
ModulesConst modules,
636535
ObjectRangesConst ranges,
@@ -771,30 +670,25 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
771670

772671
rPhiChiSquared =
773672
computePT3RPhiChiSquared(acc, modules, lowerModuleIndices, pixelG, pixelF, pixelRadiusPCA, xs, ys);
774-
if (runChiSquaredCuts && pixelSegmentPt < 5.0f) {
775-
if (!passPT3RPhiChiSquaredCuts(modules, lowerModuleIndex, middleModuleIndex, upperModuleIndex, rPhiChiSquared))
776-
return false;
777-
}
778673

779674
rPhiChiSquaredInwards = computePT3RPhiChiSquaredInwards(g, f, tripletRadius, xPix, yPix);
780-
if (runChiSquaredCuts && pixelSegmentPt < 5.0f) {
781-
if (!passPT3RPhiChiSquaredInwardsCuts(
782-
modules, lowerModuleIndex, middleModuleIndex, upperModuleIndex, rPhiChiSquaredInwards))
783-
return false;
784-
}
785675
}
786676

787677
centerX = 0;
788678
centerY = 0;
789679

790-
if (runDNN and !lst::pt3dnn::runInference(acc,
791-
rPhiChiSquared,
792-
tripletRadius,
793-
pixelRadius,
794-
pixelRadiusError,
795-
rzChiSquared,
796-
pixelSeeds.eta()[pixelSegmentArrayIndex],
797-
pixelSegmentPt)) {
680+
// Module type of last anchor hit for the T3.
681+
const int module_type_3 = modules.moduleType()[upperModuleIndex];
682+
683+
if (runDNN and !lst::pt3dnn::runInference<WP>(acc,
684+
rPhiChiSquared,
685+
tripletRadius,
686+
pixelRadius,
687+
pixelRadiusError,
688+
rzChiSquared,
689+
pixelSeeds.eta()[pixelSegmentArrayIndex],
690+
pixelSegmentPt,
691+
module_type_3)) {
798692
return false;
799693
}
800694

0 commit comments

Comments
 (0)