Skip to content
Merged
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
10 changes: 9 additions & 1 deletion DataFormats/Common/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,19 @@
</class>
<class name="edm::Wrapper<std::map<edm::ParameterSetID,edm::ParameterSetBlob>>"/>

<class name="edm::StdArray<uint8_t, 13>"/>

<class name="edm::StdArray<short, 4>"/>
<class name="edm::StdArray<unsigned short, 11>"/>

<class name="edm::StdArray<uint16_t, 11>"/>
<class name="edm::StdArray<uint16_t, 13>"/>

<class name="edm::StdArray<unsigned int, 2>"/>
<class name="edm::StdArray<unsigned int, 4>"/>
<class name="edm::StdArray<unsigned int, 14>"/>

<class name="edm::StdArray<edm::StdArray<unsigned int, 2>, 13>"/>

<class name="edm::PathStateToken" ClassVersion="3">
<version ClassVersion="3" checksum="2219165191"/>
</class>
Expand Down
31 changes: 9 additions & 22 deletions RecoTracker/LST/plugins/LSTOutputConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,28 +165,15 @@ void LSTOutputConverter::produce(edm::Event& iEvent, const edm::EventSetup& iSet
recHits.push_back(hit.clone());
}

// pixel-seeded TCs from LST always have 4 pixel hits
unsigned int const nPixelHits = (iType == lst::LSTObjType::T5 || iType == lst::LSTObjType::T4) ? 0 : 4;
unsigned int nHits = 0;
switch (iType) {
case lst::LSTObjType::T5:
nHits = lst::Params_T5::kHits;
break;
case lst::LSTObjType::pT3:
nHits = lst::Params_pT3::kHits;
break;
case lst::LSTObjType::pT5:
nHits = lst::Params_pT5::kHits;
break;
case lst::LSTObjType::pLS:
nHits = lst::Params_pLS::kHits;
break;
case lst::LSTObjType::T4:
nHits = lst::Params_T4::kHits;
break;
// The pixel hits are packed into first kPixelLayerSlots layer slots.
for (unsigned int layerSlot = lst::Params_TC::kPixelLayerSlots; layerSlot < lst::Params_TC::kLayers; ++layerSlot) {
for (unsigned int hitSlot = 0; hitSlot < lst::Params_TC::kHitsPerLayer; ++hitSlot) {
unsigned int hitIdx = lstOutput_view.hitIndices()[i][layerSlot][hitSlot];
if (hitIdx == lst::kTCEmptyHitIdx)
continue;
recHits.push_back(OTHits[hitIdx]->clone());
}
}
for (unsigned int j = nPixelHits; j < nHits; j++)
recHits.push_back(OTHits[lstOutput_view.hitIndices()[i][j]]->clone());

recHits.sort([](const auto& a, const auto& b) {
const auto asub = a.det()->subDetector();
Expand Down Expand Up @@ -215,7 +202,7 @@ void LSTOutputConverter::produce(edm::Event& iEvent, const edm::EventSetup& iSet
if (includeNonpLSTSs_ || (iType == lst::LSTObjType::T5 || iType == lst::LSTObjType::T4)) {
using Hit = SeedingHitSet::ConstRecHitPointer;
std::vector<Hit> hitsForSeed;
hitsForSeed.reserve(nHits);
hitsForSeed.reserve(recHits.size());
int n = 0;
unsigned int firstLayer;
for (auto const& hit : recHits) {
Expand Down
12 changes: 10 additions & 2 deletions RecoTracker/LSTCore/interface/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ namespace lst {

constexpr unsigned int size_superbins = 45000;

constexpr uint16_t kTCEmptyLowerModule = 0xFFFF; // Sentinel for empty lowerModule index
constexpr unsigned int kTCEmptyHitIdx = 0xFFFFFFFF; // Sentinel for empty hit slots

// Half precision wrapper functions.
#if defined(FP16_Base)
#define __F2H __float2half
Expand Down Expand Up @@ -94,10 +97,15 @@ namespace lst {
using ArrayUxHits = edm::StdArray<unsigned int, kHits>;
};
struct Params_TC {
static constexpr int kLayers = 7, kHits = 14;
static constexpr int kLayers = 13;
static constexpr int kHitsPerLayer = 2;
// Number of layers resevered for pixel hits.
static constexpr int kPixelLayerSlots = 2;
static constexpr int kHits = kLayers * kHitsPerLayer;
using ArrayU8xLayers = edm::StdArray<uint8_t, kLayers>;
using ArrayU16xLayers = edm::StdArray<uint16_t, kLayers>;
using ArrayUxHits = edm::StdArray<unsigned int, kHits>;
using ArrayUHitsPerLayer = edm::StdArray<unsigned int, kHitsPerLayer>;
using ArrayUxHits = edm::StdArray<ArrayUHitsPerLayer, kLayers>;
};

using ArrayIx2 = edm::StdArray<int, 2>;
Expand Down
1 change: 1 addition & 0 deletions RecoTracker/LSTCore/interface/QuintupletsSoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace lst {
SOA_COLUMN(float, rzChiSquared), // r-z only chi2
SOA_COLUMN(float, chiSquared),
SOA_COLUMN(float, nonAnchorChiSquared),
SOA_COLUMN(float, dnnScore),
SOA_COLUMN(float, dBeta1),
SOA_COLUMN(float, dBeta2));

Expand Down
1 change: 1 addition & 0 deletions RecoTracker/LSTCore/interface/alpaka/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
HOST_DEVICE_CONSTANT int kNTripletThreshold = 1000;
// To be updated with std::numeric_limits<float>::infinity() in the code and data files
HOST_DEVICE_CONSTANT float kVerticalModuleSlope = 123456789.0;
HOST_DEVICE_CONSTANT int kLogicalOTLayers = 11; // logical OT layers are 1..11

HOST_DEVICE_CONSTANT float kMiniDeltaTilted[3] = {0.26f, 0.26f, 0.26f};
HOST_DEVICE_CONSTANT float kMiniDeltaFlat[6] = {0.26f, 0.16f, 0.16f, 0.18f, 0.18f, 0.18f};
Expand Down
20 changes: 20 additions & 0 deletions RecoTracker/LSTCore/src/alpaka/LSTEvent.dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,26 @@ void LSTEvent::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets)
pixelSegmentsDC_->const_view(),
tc_pls_triplets);

// Get number of TCs to configure grid
auto nTrackCandidates_buf_h = cms::alpakatools::make_host_buffer<unsigned int>(queue_);
auto nTrackCandidates_buf_d =
cms::alpakatools::make_device_view(queue_, (*trackCandidatesBaseDC_)->nTrackCandidates());
alpaka::memcpy(queue_, nTrackCandidates_buf_h, nTrackCandidates_buf_d);
alpaka::wait(queue_);
unsigned int nTC = *nTrackCandidates_buf_h.data();

auto const wd = cms::alpakatools::make_workdiv<Acc1D>(nTC, 128);

alpaka::exec<Acc1D>(queue_,
wd,
ExtendTrackCandidatesFromDupT5{},
modules_.const_view<ModulesSoA>(),
rangesDC_->const_view(),
quintupletsDC_->const_view<QuintupletsSoA>(),
quintupletsDC_->const_view<QuintupletsOccupancySoA>(),
trackCandidatesBaseDC_->view(),
trackCandidatesExtendedDC_->view());

// Check if either n_max_pixel_track_candidates or n_max_nonpixel_track_candidates was reached
auto nTrackCanpT5Host_buf = cms::alpakatools::make_host_buffer<unsigned int>(queue_);
auto nTrackCanpT3Host_buf = cms::alpakatools::make_host_buffer<unsigned int>(queue_);
Expand Down
9 changes: 5 additions & 4 deletions RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
const unsigned int mdIndex5,
const float innerRadius,
const float outerRadius,
const float bridgeRadius) {
const float bridgeRadius,
float& dnnScore) {
// Constants
constexpr unsigned int kInputFeatures = 23;
constexpr unsigned int kHiddenFeatures = 32;
Expand Down Expand Up @@ -281,16 +282,16 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {

// Layer 3: Linear + Sigmoid
linear_layer<kHiddenFeatures, 1>(x_2, x_3, dnn::t5dnn::wgtT_output_layer, dnn::t5dnn::bias_output_layer);
float x_5 = sigmoid_activation(acc, x_3[0]);
dnnScore = sigmoid_activation(acc, x_3[0]);

// Get the bin index based on abs(eta) of first hit and t5_pt
float t5_pt = innerRadius * lst::k2Rinv1GeVf * 2;

uint8_t pt_index = (t5_pt > 5.0f);
uint8_t bin_index = (eta1 > 2.5f) ? (dnn::kEtaBins - 1) : static_cast<unsigned int>(eta1 / dnn::kEtaSize);

// Compare x_5 to the cut value for the relevant bin
return x_5 > dnn::t5dnn::kWp[pt_index][bin_index];
// Compare output to the cut value for the relevant bin
return dnnScore > dnn::t5dnn::kWp[pt_index][bin_index];
}
} // namespace t5dnn

Expand Down
25 changes: 18 additions & 7 deletions RecoTracker/LSTCore/src/alpaka/Quintuplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
uint8_t layer,
unsigned int quintupletIndex,
const float (&t5Embed)[Params_T5::kEmbed],
bool tightCutFlag) {
bool tightCutFlag,
float dnnScore) {
quintuplets.tripletIndices()[quintupletIndex][0] = innerTripletIndex;
quintuplets.tripletIndices()[quintupletIndex][1] = outerTripletIndex;

Expand Down Expand Up @@ -88,6 +89,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
quintuplets.nonAnchorChiSquared()[quintupletIndex] = nonAnchorChiSquared;
quintuplets.dBeta1()[quintupletIndex] = dBeta1;
quintuplets.dBeta2()[quintupletIndex] = dBeta2;
quintuplets.dnnScore()[quintupletIndex] = dnnScore;

CMS_UNROLL_LOOP
for (unsigned int i = 0; i < Params_T5::kEmbed; ++i) {
Expand Down Expand Up @@ -1491,6 +1493,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
float& nonAnchorChiSquared,
float& dBeta1,
float& dBeta2,
float& dnnScore,
bool& tightCutFlag,
float (&t5Embed)[Params_T5::kEmbed],
const float ptCut) {
Expand Down Expand Up @@ -1531,7 +1534,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
fifthMDIndex,
innerRadius,
outerRadius,
bridgeRadius);
bridgeRadius,
dnnScore);
tightCutFlag = tightCutFlag and inference; // T5-in-TC cut
if (!inference) // T5-building cut
return false;
Expand Down Expand Up @@ -1754,7 +1758,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
uint16_t lowerModule5 = triplets.lowerModuleIndices()[outerTripletIndex][2];

float innerRadius, outerRadius, bridgeRadius, regressionCenterX, regressionCenterY, regressionRadius,
rzChiSquared, chiSquared, nonAnchorChiSquared, dBeta1, dBeta2; //required for making distributions
rzChiSquared, chiSquared, nonAnchorChiSquared, dBeta1, dBeta2,
dnnScore; //required for making distributions

float t5Embed[Params_T5::kEmbed] = {0.f};

Expand Down Expand Up @@ -1783,6 +1788,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
nonAnchorChiSquared,
dBeta1,
dBeta2,
dnnScore,
tightCutFlag,
t5Embed,
ptCut);
Expand Down Expand Up @@ -1841,7 +1847,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
layer,
quintupletIndex,
t5Embed,
tightCutFlag);
tightCutFlag,
dnnScore);

triplets.partOfT5()[quintuplets.tripletIndices()[quintupletIndex][0]] = true;
triplets.partOfT5()[quintuplets.tripletIndices()[quintupletIndex][1]] = true;
Expand Down Expand Up @@ -1890,7 +1897,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
uint16_t lowerModule5 = triplets.lowerModuleIndices()[outerTripletIndex][2];

float innerRadius, outerRadius, bridgeRadius, regressionCenterX, regressionCenterY, regressionRadius,
rzChiSquared, chiSquared, nonAnchorChiSquared, dBeta1, dBeta2; //required for making distributions
rzChiSquared, chiSquared, nonAnchorChiSquared, dBeta1, dBeta2,
dnnScore; //required for making distributions

float t5Embed[Params_T5::kEmbed] = {0.f};

Expand Down Expand Up @@ -1919,6 +1927,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
nonAnchorChiSquared,
dBeta1,
dBeta2,
dnnScore,
tightCutFlag,
t5Embed,
ptCut);
Expand Down Expand Up @@ -1974,7 +1983,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
layer,
quintupletIndex,
t5Embed,
tightCutFlag);
tightCutFlag,
dnnScore);

triplets.partOfT5()[quintuplets.tripletIndices()[quintupletIndex][0]] = true;
triplets.partOfT5()[quintuplets.tripletIndices()[quintupletIndex][1]] = true;
Expand Down Expand Up @@ -2045,7 +2055,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {

float innerRadius, outerRadius, bridgeRadius;
float regCx, regCy, regR;
float rzChi2, chi2, nonAnchorChi2, dBeta1, dBeta2;
float rzChi2, chi2, nonAnchorChi2, dBeta1, dBeta2, dnnScore;
float t5Embed[Params_T5::kEmbed] = {0.f};
bool tightFlag = false;

Expand All @@ -2072,6 +2082,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
nonAnchorChi2,
dBeta1,
dBeta2,
dnnScore,
tightFlag,
t5Embed,
ptCut);
Expand Down
Loading