Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNN Indexing Bug Fix + Normalization Improvements #100

Open
wants to merge 5 commits into
base: CMSSW_14_1_0_pre3_LST_X_LSTCore_realfiles_batch1_devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions RecoTracker/LSTCore/interface/alpaka/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,13 @@ namespace lst {
namespace t5dnn {
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kZ_max = 267.2349854f;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kR_max = 110.1099396f;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kEta_norm = 2.5f;
// pt, eta binned
constexpr unsigned int kPtBins = 2;
constexpr unsigned int kEtaBins = 10;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kWp[kPtBins][kEtaBins] = {
{0.4301, 0.4419, 0.4762, 0.5147, 0.347, 0.3538, 0.4061, 0.5284, 0.7186, 0.7806},
{0.2504, 0.3244, 0.3069, 0.4128, 0.2115, 0.2105, 0.2568, 0.2435, 0.3587, 0.2614}};
{0.2747, 0.2954, 0.3673, 0.4729, 0.419, 0.464, 0.4843, 0.5571, 0.6796, 0.6885},
{0.1696, 0.255, 0.2716, 0.3713, 0.1902, 0.1597, 0.1446, 0.095, 0.1797, 0.1104}};
} // namespace t5dnn

} //namespace lst
Expand Down
58 changes: 21 additions & 37 deletions RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,58 +70,42 @@ namespace lst::t5dnn {
unsigned int mdIndex3 = mdIndices[2];
unsigned int mdIndex4 = mdIndices[3];
unsigned int mdIndex5 = mdIndices[4];
// Unpack module indices
uint16_t lowerModuleIndex1 = lowerModuleIndices[0];
uint16_t lowerModuleIndex2 = lowerModuleIndices[1];
uint16_t lowerModuleIndex3 = lowerModuleIndices[2];
uint16_t lowerModuleIndex4 = lowerModuleIndices[3];
uint16_t lowerModuleIndex5 = lowerModuleIndices[4];

// Compute some convenience variables
short layer2_adjustment = 0;
if (modulesInGPU.layers[lowerModuleIndex1] == 1) {
if (modulesInGPU.layers[lowerModuleIndices[0]] == 1) {
layer2_adjustment = 1; // get upper segment to be in second layer
}
unsigned int md_idx_for_t5_eta_phi =
segmentsInGPU.mdIndices[2 * tripletsInGPU.segmentIndices[2 * innerTripletIndex + layer2_adjustment]];
bool is_endcap1 = (modulesInGPU.subdets[lowerModuleIndex1] == 4); // true if anchor hit 1 is in the endcap
bool is_endcap2 = (modulesInGPU.subdets[lowerModuleIndex2] == 4); // true if anchor hit 2 is in the endcap
bool is_endcap3 = (modulesInGPU.subdets[lowerModuleIndex3] == 4); // true if anchor hit 3 is in the endcap
bool is_endcap4 = (modulesInGPU.subdets[lowerModuleIndex4] == 4); // true if anchor hit 4 is in the endcap
bool is_endcap5 = (modulesInGPU.subdets[lowerModuleIndex5] == 4); // true if anchor hit 5 is in the endcap

float t5_eta = mdsInGPU.anchorEta[md_idx_for_t5_eta_phi];

// Constants
constexpr unsigned int kinputFeatures = 24;
constexpr unsigned int kinputFeatures = 18;
constexpr unsigned int khiddenFeatures = 32;

// Build DNN input vector (corresponding output N-tuple branch noted in parenthetical in comment)
float x[kinputFeatures] = {
mdsInGPU.anchorEta[mdIndex1], // inner T3 anchor hit 1 eta (t3_0_eta)
mdsInGPU.anchorZ[mdIndex1] / kZ_max, // inner T3 anchor hit 1 z (t3_0_z)
alpaka::math::sqrt(acc, x1 * x1 + y1 * y1) / kR_max, // inner T3 anchor hit 1 r (t3_0_r)
float(modulesInGPU.layers[lowerModuleIndex1] + 6 * is_endcap1), // inner T3 anchor hit 1 layer (t3_0_layer)
mdsInGPU.anchorEta[mdIndex2], // inner T3 anchor hit 2 eta (t3_2_eta)
mdsInGPU.anchorZ[mdIndex2] / kZ_max, // inner T3 anchor hit 2 z (t3_2_z)
alpaka::math::sqrt(acc, x2 * x2 + y2 * y2) / kR_max, // inner T3 anchor hit 2 r (t3_2_r)
float(modulesInGPU.layers[lowerModuleIndex2] + 6 * is_endcap2), // inner T3 anchor hit 2 layer (t3_2_layer)
mdsInGPU.anchorEta[mdIndex3], // inner T3 anchor hit 3 eta (t3_4_eta)
mdsInGPU.anchorZ[mdIndex3] / kZ_max, // inner T3 anchor hit 3 z (t3_4_z)
alpaka::math::sqrt(acc, x3 * x3 + y3 * y3) / kR_max, // inner T3 anchor hit 3 r (t3_4_r)
float(modulesInGPU.layers[lowerModuleIndex3] + 6 * is_endcap3), // inner T3 anchor hit 3 layer (t3_4_layer)
mdsInGPU.anchorEta[mdIndex4], // outer T3 anchor hit 4 eta (t3_2_eta)
mdsInGPU.anchorZ[mdIndex4] / kZ_max, // outer T3 anchor hit 4 z (t3_2_z)
alpaka::math::sqrt(acc, x4 * x4 + y4 * y4) / kR_max, // outer T3 anchor hit 4 r (t3_2_r)
float(modulesInGPU.layers[lowerModuleIndex4] + 6 * is_endcap4), // outer T3 anchor hit 4 layer (t3_2_layer)
mdsInGPU.anchorEta[mdIndex5], // outer T3 anchor hit 5 eta (t3_4_eta)
mdsInGPU.anchorZ[mdIndex5] / kZ_max, // outer T3 anchor hit 5 z (t3_4_z)
alpaka::math::sqrt(acc, x5 * x5 + y5 * y5) / kR_max, // outer T3 anchor hit 5 r (t3_4_r)
float(modulesInGPU.layers[lowerModuleIndex5] + 6 * is_endcap5), // outer T3 anchor hit 5 layer (t3_4_layer)
GNiendorf marked this conversation as resolved.
Show resolved Hide resolved
t5_eta, // T5 eta (t5_eta)
alpaka::math::log10(acc, innerRadius), // T5 inner radius (t5_innerRadius)
alpaka::math::log10(acc, bridgeRadius), // T5 bridge radius (t5_bridgeRadius)
alpaka::math::log10(acc, outerRadius) // T5 outer radius (t5_outerRadius)
alpaka::math::abs(acc, mdsInGPU.anchorEta[mdIndex1]) / kEta_norm, // inner T3 anchor hit 1 eta (t3_0_eta)
alpaka::math::abs(acc, mdsInGPU.anchorZ[mdIndex1]) / kZ_max, // inner T3 anchor hit 1 z (t3_0_z)
alpaka::math::sqrt(acc, x1 * x1 + y1 * y1) / kR_max, // inner T3 anchor hit 1 r (t3_0_r)
alpaka::math::abs(acc, mdsInGPU.anchorEta[mdIndex2]) / kEta_norm, // inner T3 anchor hit 2 eta (t3_2_eta)
alpaka::math::abs(acc, mdsInGPU.anchorZ[mdIndex2]) / kZ_max, // inner T3 anchor hit 2 z (t3_2_z)
alpaka::math::sqrt(acc, x2 * x2 + y2 * y2) / kR_max, // inner T3 anchor hit 2 r (t3_2_r)
alpaka::math::abs(acc, mdsInGPU.anchorEta[mdIndex3]) / kEta_norm, // inner T3 anchor hit 3 eta (t3_4_eta)
alpaka::math::abs(acc, mdsInGPU.anchorZ[mdIndex3]) / kZ_max, // inner T3 anchor hit 3 z (t3_4_z)
alpaka::math::sqrt(acc, x3 * x3 + y3 * y3) / kR_max, // inner T3 anchor hit 3 r (t3_4_r)
alpaka::math::abs(acc, mdsInGPU.anchorEta[mdIndex4]) / kEta_norm, // outer T3 anchor hit 4 eta (t3_2_eta)
alpaka::math::abs(acc, mdsInGPU.anchorZ[mdIndex4]) / kZ_max, // outer T3 anchor hit 4 z (t3_2_z)
alpaka::math::sqrt(acc, x4 * x4 + y4 * y4) / kR_max, // outer T3 anchor hit 4 r (t3_2_r)
alpaka::math::abs(acc, mdsInGPU.anchorEta[mdIndex5]) / kEta_norm, // outer T3 anchor hit 5 eta (t3_4_eta)
alpaka::math::abs(acc, mdsInGPU.anchorZ[mdIndex5]) / kZ_max, // outer T3 anchor hit 5 z (t3_4_z)
alpaka::math::sqrt(acc, x5 * x5 + y5 * y5) / kR_max, // outer T3 anchor hit 5 r (t3_4_r)

alpaka::math::log10(acc, innerRadius), // T5 inner radius (t5_innerRadius)
alpaka::math::log10(acc, bridgeRadius), // T5 bridge radius (t5_bridgeRadius)
alpaka::math::log10(acc, outerRadius) // T5 outer radius (t5_outerRadius)
};

// Layer 1: Linear
Expand Down
Loading