From 043dfe04a6049ef40315bf5736931ed839d498cc Mon Sep 17 00:00:00 2001 From: Andres Rios Tascon Date: Fri, 25 Oct 2024 11:35:59 -0700 Subject: [PATCH] migrate modules to SoATemplate --- .../plugins/alpaka/LSTModulesDevESProducer.cc | 1 - RecoTracker/LSTCore/interface/Constants.h | 3 + RecoTracker/LSTCore/interface/LSTESData.h | 29 ++- RecoTracker/LSTCore/interface/Module.h | 227 ------------------ RecoTracker/LSTCore/interface/ModulesSoA.h | 57 +++++ .../alpaka/ModulesDeviceCollection.h | 12 + RecoTracker/LSTCore/src/ModuleMethods.h | 197 +++++++++------ RecoTracker/LSTCore/src/alpaka/Event.dev.cc | 113 +++++---- RecoTracker/LSTCore/src/alpaka/Event.h | 12 +- RecoTracker/LSTCore/src/alpaka/Hit.h | 14 +- RecoTracker/LSTCore/src/alpaka/Kernels.h | 11 +- RecoTracker/LSTCore/src/alpaka/MiniDoublet.h | 150 ++++++------ .../LSTCore/src/alpaka/NeuralNetwork.h | 80 +++--- .../LSTCore/src/alpaka/PixelQuintuplet.h | 126 +++++----- RecoTracker/LSTCore/src/alpaka/PixelTriplet.h | 152 ++++++------ RecoTracker/LSTCore/src/alpaka/Quintuplet.h | 200 ++++++++------- RecoTracker/LSTCore/src/alpaka/Segment.h | 123 +++++----- .../LSTCore/src/alpaka/TrackCandidate.h | 14 +- RecoTracker/LSTCore/src/alpaka/Triplet.h | 92 +++---- .../standalone/code/core/AccessHelper.cc | 12 +- .../standalone/code/core/write_lst_ntuple.cc | 52 ++-- 21 files changed, 802 insertions(+), 875 deletions(-) delete mode 100644 RecoTracker/LSTCore/interface/Module.h create mode 100644 RecoTracker/LSTCore/interface/ModulesSoA.h create mode 100644 RecoTracker/LSTCore/interface/alpaka/ModulesDeviceCollection.h diff --git a/RecoTracker/LST/plugins/alpaka/LSTModulesDevESProducer.cc b/RecoTracker/LST/plugins/alpaka/LSTModulesDevESProducer.cc index 0f0c53344de18..d0e103b1e315b 100644 --- a/RecoTracker/LST/plugins/alpaka/LSTModulesDevESProducer.cc +++ b/RecoTracker/LST/plugins/alpaka/LSTModulesDevESProducer.cc @@ -1,5 +1,4 @@ // LST includes -#include "RecoTracker/LSTCore/interface/Module.h" #include "RecoTracker/LSTCore/interface/alpaka/LST.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" diff --git a/RecoTracker/LSTCore/interface/Constants.h b/RecoTracker/LSTCore/interface/Constants.h index 6280ea8670540..55675adaa918a 100644 --- a/RecoTracker/LSTCore/interface/Constants.h +++ b/RecoTracker/LSTCore/interface/Constants.h @@ -88,6 +88,9 @@ namespace lst { // Defining the constant host device variables right up here // Currently pixel tracks treated as LSs with 2 double layers (IT layers 1+2 and 3+4) and 4 hits. To be potentially handled better in the future. + struct Params_Modules { + using ArrayU16xMaxConnected = edm::StdArray; + }; struct Params_pLS { static constexpr int kLayers = 2, kHits = 4; }; diff --git a/RecoTracker/LSTCore/interface/LSTESData.h b/RecoTracker/LSTCore/interface/LSTESData.h index c70a93a45fe78..1b4dffe712aa3 100644 --- a/RecoTracker/LSTCore/interface/LSTESData.h +++ b/RecoTracker/LSTCore/interface/LSTESData.h @@ -3,7 +3,7 @@ #include "RecoTracker/LSTCore/interface/Constants.h" #include "RecoTracker/LSTCore/interface/EndcapGeometryDevSoA.h" -#include "RecoTracker/LSTCore/interface/Module.h" +#include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/PixelMap.h" #include "HeterogeneousCore/AlpakaInterface/interface/CopyToDevice.h" @@ -19,7 +19,7 @@ namespace lst { uint16_t nLowerModules; unsigned int nPixels; unsigned int nEndCapMap; - ModulesBuffer modulesBuffers; + std::unique_ptr> modules; std::unique_ptr> endcapGeometry; std::shared_ptr pixelMapping; @@ -27,14 +27,14 @@ namespace lst { uint16_t const& nLowerModulesIn, unsigned int const& nPixelsIn, unsigned int const& nEndCapMapIn, - ModulesBuffer const& modulesBuffersIn, + std::unique_ptr> modulesIn, std::unique_ptr> endcapGeometryIn, std::shared_ptr const& pixelMappingIn) : nModules(nModulesIn), nLowerModules(nLowerModulesIn), nPixels(nPixelsIn), nEndCapMap(nEndCapMapIn), - modulesBuffers(modulesBuffersIn), + modules(std::move(modulesIn)), endcapGeometry(std::move(endcapGeometryIn)), pixelMapping(pixelMappingIn) {} }; @@ -57,14 +57,27 @@ namespace cms::alpakatools { } }; + template <> + struct CopyToDevice> { + template + static auto copyAsync(TQueue& queue, + PortableHostMultiCollection const& srcData) { + using TDevice = typename alpaka::trait::DevType::type; + PortableMultiCollection dstData(srcData.sizes(), queue); + alpaka::memcpy(queue, dstData.buffer(), srcData.buffer()); + return dstData; + } + }; + template <> struct CopyToDevice> { template static lst::LSTESData> copyAsync(TQueue& queue, lst::LSTESData const& srcData) { - auto deviceModulesBuffers = - lst::ModulesBuffer>(alpaka::getDev(queue), srcData.nModules, srcData.nPixels); - deviceModulesBuffers.copyFromSrc(queue, srcData.modulesBuffers); + auto deviceModules = + std::make_unique, lst::ModulesSoA, lst::ModulesPixelSoA>>( + CopyToDevice>::copyAsync( + queue, *srcData.modules)); auto deviceEndcapGeometry = std::make_unique>>( CopyToDevice>::copyAsync(queue, *srcData.endcapGeometry)); @@ -72,7 +85,7 @@ namespace cms::alpakatools { srcData.nLowerModules, srcData.nPixels, srcData.nEndCapMap, - std::move(deviceModulesBuffers), + std::move(deviceModules), std::move(deviceEndcapGeometry), srcData.pixelMapping); } diff --git a/RecoTracker/LSTCore/interface/Module.h b/RecoTracker/LSTCore/interface/Module.h deleted file mode 100644 index 7266ebd7bc49b..0000000000000 --- a/RecoTracker/LSTCore/interface/Module.h +++ /dev/null @@ -1,227 +0,0 @@ -#ifndef RecoTracker_LSTCore_interface_Module_h -#define RecoTracker_LSTCore_interface_Module_h - -#include "RecoTracker/LSTCore/interface/Constants.h" - -namespace lst { - enum SubDet { InnerPixel = 0, Barrel = 5, Endcap = 4 }; - - enum Side { NegZ = 1, PosZ = 2, Center = 3 }; - - enum ModuleType { PS, TwoS, PixelModule }; - - enum ModuleLayerType { Pixel, Strip, InnerPixelLayer }; - - struct Modules { - const unsigned int* detIds; - const uint16_t* moduleMap; - const unsigned int* mapdetId; - const uint16_t* mapIdx; - const uint16_t* nConnectedModules; - const float* drdzs; - const float* dxdys; - const uint16_t* nModules; - const uint16_t* nLowerModules; - const uint16_t* partnerModuleIndices; - - const short* layers; - const short* rings; - const short* modules; - const short* rods; - const short* subdets; - const short* sides; - const float* eta; - const float* r; - const bool* isInverted; - const bool* isLower; - const bool* isAnchor; - const ModuleType* moduleType; - const ModuleLayerType* moduleLayerType; - const int* lstLayers; - const unsigned int* connectedPixels; - - static bool parseIsInverted(short subdet, short side, short module, short layer) { - if (subdet == Endcap) { - if (side == NegZ) { - return module % 2 == 1; - } else if (side == PosZ) { - return module % 2 == 0; - } else { - return false; - } - } else if (subdet == Barrel) { - if (side == Center) { - if (layer <= 3) { - return module % 2 == 1; - } else if (layer >= 4) { - return module % 2 == 0; - } else { - return false; - } - } else if (side == NegZ or side == PosZ) { - if (layer <= 2) { - return module % 2 == 1; - } else if (layer == 3) { - return module % 2 == 0; - } else { - return false; - } - } else { - return false; - } - } else { - return false; - } - } - - static bool parseIsLower(bool isInvertedx, unsigned int detId) { - return (isInvertedx) ? !(detId & 1) : (detId & 1); - } - - static unsigned int parsePartnerModuleId(unsigned int detId, bool isLowerx, bool isInvertedx) { - return isLowerx ? (isInvertedx ? detId - 1 : detId + 1) : (isInvertedx ? detId + 1 : detId - 1); - } - - template - void setData(TBuff const& buf) { - detIds = buf.detIds_buf.data(); - moduleMap = buf.moduleMap_buf.data(); - mapdetId = buf.mapdetId_buf.data(); - mapIdx = buf.mapIdx_buf.data(); - nConnectedModules = buf.nConnectedModules_buf.data(); - drdzs = buf.drdzs_buf.data(); - dxdys = buf.dxdys_buf.data(); - nModules = buf.nModules_buf.data(); - nLowerModules = buf.nLowerModules_buf.data(); - partnerModuleIndices = buf.partnerModuleIndices_buf.data(); - - layers = buf.layers_buf.data(); - rings = buf.rings_buf.data(); - modules = buf.modules_buf.data(); - rods = buf.rods_buf.data(); - subdets = buf.subdets_buf.data(); - sides = buf.sides_buf.data(); - eta = buf.eta_buf.data(); - r = buf.r_buf.data(); - isInverted = buf.isInverted_buf.data(); - isLower = buf.isLower_buf.data(); - isAnchor = buf.isAnchor_buf.data(); - moduleType = buf.moduleType_buf.data(); - moduleLayerType = buf.moduleLayerType_buf.data(); - lstLayers = buf.lstLayers_buf.data(); - connectedPixels = buf.connectedPixels_buf.data(); - } - }; - - template - struct ModulesBuffer { - Buf detIds_buf; - Buf moduleMap_buf; - Buf mapdetId_buf; - Buf mapIdx_buf; - Buf nConnectedModules_buf; - Buf drdzs_buf; - Buf dxdys_buf; - Buf nModules_buf; - Buf nLowerModules_buf; - Buf partnerModuleIndices_buf; - - Buf layers_buf; - Buf rings_buf; - Buf modules_buf; - Buf rods_buf; - Buf subdets_buf; - Buf sides_buf; - Buf eta_buf; - Buf r_buf; - Buf isInverted_buf; - Buf isLower_buf; - Buf isAnchor_buf; - Buf moduleType_buf; - Buf moduleLayerType_buf; - Buf lstLayers_buf; - Buf connectedPixels_buf; - - Modules data_; - - ModulesBuffer(TDev const& dev, unsigned int nMod, unsigned int nPixs) - : detIds_buf(allocBufWrapper(dev, nMod)), - moduleMap_buf(allocBufWrapper(dev, nMod * max_connected_modules)), - mapdetId_buf(allocBufWrapper(dev, nMod)), - mapIdx_buf(allocBufWrapper(dev, nMod)), - nConnectedModules_buf(allocBufWrapper(dev, nMod)), - drdzs_buf(allocBufWrapper(dev, nMod)), - dxdys_buf(allocBufWrapper(dev, nMod)), - nModules_buf(allocBufWrapper(dev, 1)), - nLowerModules_buf(allocBufWrapper(dev, 1)), - partnerModuleIndices_buf(allocBufWrapper(dev, nMod)), - - layers_buf(allocBufWrapper(dev, nMod)), - rings_buf(allocBufWrapper(dev, nMod)), - modules_buf(allocBufWrapper(dev, nMod)), - rods_buf(allocBufWrapper(dev, nMod)), - subdets_buf(allocBufWrapper(dev, nMod)), - sides_buf(allocBufWrapper(dev, nMod)), - eta_buf(allocBufWrapper(dev, nMod)), - r_buf(allocBufWrapper(dev, nMod)), - isInverted_buf(allocBufWrapper(dev, nMod)), - isLower_buf(allocBufWrapper(dev, nMod)), - isAnchor_buf(allocBufWrapper(dev, nMod)), - moduleType_buf(allocBufWrapper(dev, nMod)), - moduleLayerType_buf(allocBufWrapper(dev, nMod)), - lstLayers_buf(allocBufWrapper(dev, nMod)), - connectedPixels_buf(allocBufWrapper(dev, nPixs)) { - data_.setData(*this); - } - - template - inline void copyFromSrc(TQueue queue, ModulesBuffer const& src, bool isFull = true) { - alpaka::memcpy(queue, detIds_buf, src.detIds_buf); - if (isFull) { - alpaka::memcpy(queue, moduleMap_buf, src.moduleMap_buf); - alpaka::memcpy(queue, mapdetId_buf, src.mapdetId_buf); - alpaka::memcpy(queue, mapIdx_buf, src.mapIdx_buf); - alpaka::memcpy(queue, nConnectedModules_buf, src.nConnectedModules_buf); - alpaka::memcpy(queue, drdzs_buf, src.drdzs_buf); - alpaka::memcpy(queue, dxdys_buf, src.dxdys_buf); - } - alpaka::memcpy(queue, nModules_buf, src.nModules_buf); - alpaka::memcpy(queue, nLowerModules_buf, src.nLowerModules_buf); - if (isFull) { - alpaka::memcpy(queue, partnerModuleIndices_buf, src.partnerModuleIndices_buf); - } - - alpaka::memcpy(queue, layers_buf, src.layers_buf); - alpaka::memcpy(queue, rings_buf, src.rings_buf); - alpaka::memcpy(queue, modules_buf, src.modules_buf); - alpaka::memcpy(queue, rods_buf, src.rods_buf); - alpaka::memcpy(queue, subdets_buf, src.subdets_buf); - alpaka::memcpy(queue, sides_buf, src.sides_buf); - alpaka::memcpy(queue, eta_buf, src.eta_buf); - alpaka::memcpy(queue, r_buf, src.r_buf); - if (isFull) { - alpaka::memcpy(queue, isInverted_buf, src.isInverted_buf); - } - alpaka::memcpy(queue, isLower_buf, src.isLower_buf); - if (isFull) { - alpaka::memcpy(queue, isAnchor_buf, src.isAnchor_buf); - } - alpaka::memcpy(queue, moduleType_buf, src.moduleType_buf); - if (isFull) { - alpaka::memcpy(queue, moduleLayerType_buf, src.moduleLayerType_buf); - alpaka::memcpy(queue, lstLayers_buf, src.lstLayers_buf); - alpaka::memcpy(queue, connectedPixels_buf, src.connectedPixels_buf); - } - } - - template - ModulesBuffer(TQueue queue, ModulesBuffer const& src, unsigned int nMod, unsigned int nPixs) - : ModulesBuffer(alpaka::getDev(queue), nMod, nPixs) { - copyFromSrc(queue, src); - } - - inline Modules const* data() const { return &data_; } - }; - -} // namespace lst -#endif diff --git a/RecoTracker/LSTCore/interface/ModulesSoA.h b/RecoTracker/LSTCore/interface/ModulesSoA.h new file mode 100644 index 0000000000000..81b1150006bd2 --- /dev/null +++ b/RecoTracker/LSTCore/interface/ModulesSoA.h @@ -0,0 +1,57 @@ +#ifndef RecoTracker_LSTCore_interface_ModulesSoA_h +#define RecoTracker_LSTCore_interface_ModulesSoA_h + +#include "DataFormats/SoATemplate/interface/SoALayout.h" +#include "DataFormats/Portable/interface/PortableCollection.h" + +namespace lst { + + enum SubDet { InnerPixel = 0, Barrel = 5, Endcap = 4 }; + + enum Side { NegZ = 1, PosZ = 2, Center = 3 }; + + enum ModuleType { PS, TwoS, PixelModule }; + + enum ModuleLayerType { Pixel, Strip, InnerPixelLayer }; + + GENERATE_SOA_LAYOUT(ModulesSoALayout, + SOA_COLUMN(unsigned int, detIds), + SOA_COLUMN(Params_Modules::ArrayU16xMaxConnected, moduleMap), + SOA_COLUMN(unsigned int, mapdetId), + SOA_COLUMN(uint16_t, mapIdx), + SOA_COLUMN(uint16_t, nConnectedModules), + SOA_COLUMN(float, drdzs), + SOA_COLUMN(float, dxdys), + SOA_SCALAR(uint16_t, nModules), + SOA_SCALAR(uint16_t, nLowerModules), + SOA_COLUMN(uint16_t, partnerModuleIndices), + SOA_COLUMN(short, layers), + SOA_COLUMN(short, rings), + SOA_COLUMN(short, modules), + SOA_COLUMN(short, rods), + SOA_COLUMN(short, subdets), + SOA_COLUMN(short, sides), + SOA_COLUMN(float, eta), + SOA_COLUMN(float, r), + SOA_COLUMN(bool, isInverted), + SOA_COLUMN(bool, isLower), + SOA_COLUMN(bool, isAnchor), + SOA_COLUMN(ModuleType, moduleType), + SOA_COLUMN(ModuleLayerType, moduleLayerType), + SOA_COLUMN(int, lstLayers)) + + GENERATE_SOA_LAYOUT(ModulesPixelSoALayout, SOA_COLUMN(unsigned int, connectedPixels)) + + using ModulesSoA = ModulesSoALayout<>; + using ModulesPixelSoA = ModulesPixelSoALayout<>; + + using Modules = ModulesSoA::View; + using ModulesConst = ModulesSoA::ConstView; + using ModulesPixel = ModulesPixelSoA::View; + using ModulesPixelConst = ModulesPixelSoA::ConstView; + + using ModulesHostCollection = PortableHostMultiCollection; + +} // namespace lst + +#endif diff --git a/RecoTracker/LSTCore/interface/alpaka/ModulesDeviceCollection.h b/RecoTracker/LSTCore/interface/alpaka/ModulesDeviceCollection.h new file mode 100644 index 0000000000000..a7510feb0d540 --- /dev/null +++ b/RecoTracker/LSTCore/interface/alpaka/ModulesDeviceCollection.h @@ -0,0 +1,12 @@ +#ifndef RecoTracker_LSTCore_interface_alpaka_ModulesDeviceCollection_h +#define RecoTracker_LSTCore_interface_alpaka_ModulesDeviceCollection_h + +#include "DataFormats/Portable/interface/alpaka/PortableCollection.h" + +#include "RecoTracker/LSTCore/interface/ModulesSoA.h" + +namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { + using ModulesDeviceCollection = PortableCollection2; +} // namespace ALPAKA_ACCELERATOR_NAMESPACE::lst + +#endif diff --git a/RecoTracker/LSTCore/src/ModuleMethods.h b/RecoTracker/LSTCore/src/ModuleMethods.h index bf51e262f69e5..ca2dfe3d7c44e 100644 --- a/RecoTracker/LSTCore/src/ModuleMethods.h +++ b/RecoTracker/LSTCore/src/ModuleMethods.h @@ -5,7 +5,7 @@ #include #include "RecoTracker/LSTCore/interface/Constants.h" -#include "RecoTracker/LSTCore/interface/Module.h" +#include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/TiltedGeometry.h" #include "RecoTracker/LSTCore/interface/EndcapGeometry.h" #include "RecoTracker/LSTCore/interface/ModuleConnectionMap.h" @@ -24,14 +24,53 @@ namespace lst { // https://github.com/cms-sw/cmssw/blob/5e809e8e0a625578aa265dc4b128a93830cb5429/Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h#L29 }; - inline void fillPixelMap(ModulesBuffer& modulesBuf, - uint16_t nModules, - unsigned int& nPixels, - PixelMap& pixelMapping, - MapPLStoLayer const& pLStoLayer, - ModuleMetaData const& mmd) { - pixelMapping.pixelModuleIndex = mmd.detIdToIndex.at(1); + bool parseIsLower(bool isInvertedx, unsigned int detId) { return (isInvertedx) ? !(detId & 1) : (detId & 1); } + + unsigned int parsePartnerModuleId(unsigned int detId, bool isLowerx, bool isInvertedx) { + return isLowerx ? (isInvertedx ? detId - 1 : detId + 1) : (isInvertedx ? detId + 1 : detId - 1); + } + bool parseIsInverted(short subdet, short side, short module, short layer) { + if (subdet == Endcap) { + if (side == NegZ) { + return module % 2 == 1; + } else if (side == PosZ) { + return module % 2 == 0; + } else { + return false; + } + } else if (subdet == Barrel) { + if (side == Center) { + if (layer <= 3) { + return module % 2 == 1; + } else if (layer >= 4) { + return module % 2 == 0; + } else { + return false; + } + } else if (side == NegZ or side == PosZ) { + if (layer <= 2) { + return module % 2 == 1; + } else if (layer == 3) { + return module % 2 == 0; + } else { + return false; + } + } else { + return false; + } + } else { + return false; + } + } + + inline std::tuple, + unsigned int, + std::vector, + unsigned int, + std::vector> + getConnectedPixels(uint16_t nModules, unsigned int& nPixels, PixelMap& pixelMapping, MapPLStoLayer const& pLStoLayer) { std::vector connectedModuleDetIds; std::vector connectedModuleDetIds_pos; std::vector connectedModuleDetIds_neg; @@ -77,31 +116,21 @@ namespace lst { totalSizes_neg += sizes_neg; } - unsigned int connectedPix_size = totalSizes + totalSizes_pos + totalSizes_neg; - nPixels = connectedPix_size; - - // Now we re-initialize connectedPixels_buf since nPixels is now known - modulesBuf.connectedPixels_buf = cms::alpakatools::make_host_buffer(nPixels); - modulesBuf.data_.setData(modulesBuf); - - unsigned int* connectedPixels = modulesBuf.connectedPixels_buf.data(); + nPixels = totalSizes + totalSizes_pos + totalSizes_neg; - for (unsigned int icondet = 0; icondet < totalSizes; icondet++) { - connectedPixels[icondet] = mmd.detIdToIndex.at(connectedModuleDetIds[icondet]); - } - for (unsigned int icondet = 0; icondet < totalSizes_pos; icondet++) { - connectedPixels[icondet + totalSizes] = mmd.detIdToIndex.at(connectedModuleDetIds_pos[icondet]); - } - for (unsigned int icondet = 0; icondet < totalSizes_neg; icondet++) { - connectedPixels[icondet + totalSizes + totalSizes_pos] = mmd.detIdToIndex.at(connectedModuleDetIds_neg[icondet]); - } + return {totalSizes, + connectedModuleDetIds, + totalSizes_pos, + connectedModuleDetIds_pos, + totalSizes_neg, + connectedModuleDetIds_neg}; } - inline void fillConnectedModuleArrayExplicit(ModulesBuffer& modulesBuf, + inline void fillConnectedModuleArrayExplicit(Modules modules, ModuleMetaData const& mmd, ModuleConnectionMap const& moduleConnectionMap) { - uint16_t* moduleMap = modulesBuf.moduleMap_buf.data(); - uint16_t* nConnectedModules = modulesBuf.nConnectedModules_buf.data(); + Params_Modules::ArrayU16xMaxConnected* moduleMap = modules.moduleMap(); + uint16_t* nConnectedModules = modules.nConnectedModules(); for (auto it = mmd.detIdToIndex.begin(); it != mmd.detIdToIndex.end(); ++it) { unsigned int detId = it->first; @@ -109,14 +138,14 @@ namespace lst { auto& connectedModules = moduleConnectionMap.getConnectedModuleDetIds(detId); nConnectedModules[index] = connectedModules.size(); for (uint16_t i = 0; i < nConnectedModules[index]; i++) { - moduleMap[index * max_connected_modules + i] = mmd.detIdToIndex.at(connectedModules[i]); + moduleMap[index][i] = mmd.detIdToIndex.at(connectedModules[i]); } } } - inline void fillMapArraysExplicit(ModulesBuffer& modulesBuf, ModuleMetaData const& mmd) { - uint16_t* mapIdx = modulesBuf.mapIdx_buf.data(); - unsigned int* mapdetId = modulesBuf.mapdetId_buf.data(); + inline void fillMapArraysExplicit(Modules modules, ModuleMetaData const& mmd) { + uint16_t* mapIdx = modules.mapIdx(); + unsigned int* mapdetId = modules.mapdetId(); unsigned int counter = 0; for (auto it = mmd.detIdToIndex.begin(); it != mmd.detIdToIndex.end(); ++it) { @@ -188,44 +217,54 @@ namespace lst { nModules = counter; } - inline ModulesBuffer loadModulesFromFile(MapPLStoLayer const& pLStoLayer, - const char* moduleMetaDataFilePath, - uint16_t& nModules, - uint16_t& nLowerModules, - unsigned int& nPixels, - PixelMap& pixelMapping, - const EndcapGeometry& endcapGeometry, - const TiltedGeometry& tiltedGeometry, - const ModuleConnectionMap& moduleConnectionMap) { + inline std::unique_ptr loadModulesFromFile(MapPLStoLayer const& pLStoLayer, + const char* moduleMetaDataFilePath, + uint16_t& nModules, + uint16_t& nLowerModules, + unsigned int& nPixels, + PixelMap& pixelMapping, + const EndcapGeometry& endcapGeometry, + const TiltedGeometry& tiltedGeometry, + const ModuleConnectionMap& moduleConnectionMap) { ModuleMetaData mmd; loadCentroidsFromFile(moduleMetaDataFilePath, mmd, nModules); - // Initialize modulesBuf, but with nPixels = 0 - // The fields that require nPixels are re-initialized in fillPixelMap - ModulesBuffer modulesBuf(cms::alpakatools::host(), nModules, 0); + // TODO: this whole section could use some refactoring + auto [totalSizes, + connectedModuleDetIds, + totalSizes_pos, + connectedModuleDetIds_pos, + totalSizes_neg, + connectedModuleDetIds_neg] = getConnectedPixels(nModules, nPixels, pixelMapping, pLStoLayer); + + std::array const modules_sizes{{static_cast(nModules), static_cast(nPixels)}}; + + auto modulesHC = std::make_unique(modules_sizes, cms::alpakatools::host()); + + auto modules_view = modulesHC->view(); // Getting the underlying data pointers - unsigned int* host_detIds = modulesBuf.detIds_buf.data(); - short* host_layers = modulesBuf.layers_buf.data(); - short* host_rings = modulesBuf.rings_buf.data(); - short* host_rods = modulesBuf.rods_buf.data(); - short* host_modules = modulesBuf.modules_buf.data(); - short* host_subdets = modulesBuf.subdets_buf.data(); - short* host_sides = modulesBuf.sides_buf.data(); - float* host_eta = modulesBuf.eta_buf.data(); - float* host_r = modulesBuf.r_buf.data(); - bool* host_isInverted = modulesBuf.isInverted_buf.data(); - bool* host_isLower = modulesBuf.isLower_buf.data(); - bool* host_isAnchor = modulesBuf.isAnchor_buf.data(); - ModuleType* host_moduleType = modulesBuf.moduleType_buf.data(); - ModuleLayerType* host_moduleLayerType = modulesBuf.moduleLayerType_buf.data(); - float* host_dxdys = modulesBuf.dxdys_buf.data(); - float* host_drdzs = modulesBuf.drdzs_buf.data(); - uint16_t* host_nModules = modulesBuf.nModules_buf.data(); - uint16_t* host_nLowerModules = modulesBuf.nLowerModules_buf.data(); - uint16_t* host_partnerModuleIndices = modulesBuf.partnerModuleIndices_buf.data(); - int* host_lstLayers = modulesBuf.lstLayers_buf.data(); + unsigned int* host_detIds = modules_view.detIds(); + short* host_layers = modules_view.layers(); + short* host_rings = modules_view.rings(); + short* host_rods = modules_view.rods(); + short* host_modules = modules_view.modules(); + short* host_subdets = modules_view.subdets(); + short* host_sides = modules_view.sides(); + float* host_eta = modules_view.eta(); + float* host_r = modules_view.r(); + bool* host_isInverted = modules_view.isInverted(); + bool* host_isLower = modules_view.isLower(); + bool* host_isAnchor = modules_view.isAnchor(); + ModuleType* host_moduleType = modules_view.moduleType(); + ModuleLayerType* host_moduleLayerType = modules_view.moduleLayerType(); + float* host_dxdys = modules_view.dxdys(); + float* host_drdzs = modules_view.drdzs(); + uint16_t* host_nModules = &modules_view.nModules(); + uint16_t* host_nLowerModules = &modules_view.nLowerModules(); + uint16_t* host_partnerModuleIndices = modules_view.partnerModuleIndices(); + int* host_lstLayers = modules_view.lstLayers(); //reassign detIdToIndex indices here nLowerModules = (nModules - 1) / 2; @@ -257,8 +296,8 @@ namespace lst { r = 0; } else { setDerivedQuantities(detId, layer, ring, rod, module, subdet, side, m_x, m_y, m_z, eta, r); - isInverted = lst::Modules::parseIsInverted(subdet, side, module, layer); - isLower = lst::Modules::parseIsLower(isInverted, detId); + isInverted = parseIsInverted(subdet, side, module, layer); + isLower = parseIsLower(isInverted, detId); } if (isLower) { index = lowerModuleCounter; @@ -316,7 +355,7 @@ namespace lst { auto& index = it->second; if (detId != 1) { host_partnerModuleIndices[index] = - mmd.detIdToIndex[lst::Modules::parsePartnerModuleId(detId, host_isLower[index], host_isInverted[index])]; + mmd.detIdToIndex[parsePartnerModuleId(detId, host_isLower[index], host_isInverted[index])]; //add drdz and slope importing stuff here! if (host_drdzs[index] == 0) { host_drdzs[index] = host_drdzs[host_partnerModuleIndices[index]]; @@ -327,15 +366,29 @@ namespace lst { } } - fillPixelMap(modulesBuf, nModules, nPixels, pixelMapping, pLStoLayer, mmd); - *host_nModules = nModules; *host_nLowerModules = nLowerModules; - fillConnectedModuleArrayExplicit(modulesBuf, mmd, moduleConnectionMap); - fillMapArraysExplicit(modulesBuf, mmd); + // Fill pixel part + pixelMapping.pixelModuleIndex = mmd.detIdToIndex.at(1); + + auto modulesPixel_view = modulesHC->view(); + auto connectedPixels = alpaka::createView( + cms::alpakatools::host(), modulesPixel_view.connectedPixels(), modulesPixel_view.metadata().size()); + for (unsigned int icondet = 0; icondet < totalSizes; icondet++) { + connectedPixels[icondet] = mmd.detIdToIndex.at(connectedModuleDetIds[icondet]); + } + for (unsigned int icondet = 0; icondet < totalSizes_pos; icondet++) { + connectedPixels[icondet + totalSizes] = mmd.detIdToIndex.at(connectedModuleDetIds_pos[icondet]); + } + for (unsigned int icondet = 0; icondet < totalSizes_neg; icondet++) { + connectedPixels[icondet + totalSizes + totalSizes_pos] = mmd.detIdToIndex.at(connectedModuleDetIds_neg[icondet]); + } + + fillConnectedModuleArrayExplicit(modules_view, mmd, moduleConnectionMap); + fillMapArraysExplicit(modules_view, mmd); - return modulesBuf; + return modulesHC; } } // namespace lst #endif diff --git a/RecoTracker/LSTCore/src/alpaka/Event.dev.cc b/RecoTracker/LSTCore/src/alpaka/Event.dev.cc index 724a69a7c189b..9e7cd1eddb612 100644 --- a/RecoTracker/LSTCore/src/alpaka/Event.dev.cc +++ b/RecoTracker/LSTCore/src/alpaka/Event.dev.cc @@ -74,7 +74,7 @@ void Event::resetEventSync() { pixelTripletsInCPU_.reset(); pixelQuintupletsInCPU_.reset(); trackCandidatesHC_.reset(); - modulesInCPU_.reset(); + modulesHC_.reset(); } void Event::addHitToEvent(std::vector const& x, @@ -140,7 +140,7 @@ void Event::addHitToEvent(std::vector const& x, nModules_, nEndCapMap_, endcapGeometry_.const_view(), - *modulesBuffers_.data(), + modules_.const_view(), hitsDC_->view(), hitsDC_->view(), nHits); @@ -152,7 +152,7 @@ void Event::addHitToEvent(std::vector const& x, alpaka::exec(queue_, module_ranges_workdiv, ModuleRangesKernel{}, - *modulesBuffers_.data(), + modules_.const_view(), hitsDC_->view(), nLowerModules_); } @@ -208,7 +208,7 @@ void Event::addPixelSegmentToEvent(std::vector const& hitIndices0, alpaka::exec(queue_, createMDArrayRangesGPU_workDiv, CreateMDArrayRangesGPU{}, - *modulesBuffers_.data(), + modules_.const_view(), rangesDC_->view()); auto nTotalMDs_buf_h = cms::alpakatools::make_host_buffer(queue_, (Idx)1u); @@ -238,7 +238,7 @@ void Event::addPixelSegmentToEvent(std::vector const& hitIndices0, alpaka::exec(queue_, createSegmentArrayRanges_workDiv, CreateSegmentArrayRanges{}, - *modulesBuffers_.data(), + modules_.const_view(), rangesDC_->view(), miniDoubletsDC_->const_view()); @@ -325,7 +325,7 @@ void Event::addPixelSegmentToEvent(std::vector const& hitIndices0, alpaka::exec(queue_, addPixelSegmentToEvent_workdiv, AddPixelSegmentToEventKernel{}, - *modulesBuffers_.data(), + modules_.const_view(), rangesDC_->const_view(), hitsDC_->view(), miniDoubletsDC_->view(), @@ -359,7 +359,7 @@ void Event::createMiniDoublets() { alpaka::exec(queue_, createMDArrayRangesGPU_workDiv, CreateMDArrayRangesGPU{}, - *modulesBuffers_.data(), + modules_.const_view(), rangesDC_->view()); auto nTotalMDs_buf_h = cms::alpakatools::make_host_buffer(queue_, (Idx)1u); @@ -390,7 +390,7 @@ void Event::createMiniDoublets() { alpaka::exec(queue_, createMiniDoubletsInGPUv2_workDiv, CreateMiniDoubletsInGPUv2{}, - *modulesBuffers_.data(), + modules_.const_view(), hitsDC_->const_view(), hitsDC_->const_view(), miniDoubletsDC_->view(), @@ -402,7 +402,7 @@ void Event::createMiniDoublets() { alpaka::exec(queue_, addMiniDoubletRangesToEventExplicit_workDiv, AddMiniDoubletRangesToEventExplicit{}, - *modulesBuffers_.data(), + modules_.const_view(), miniDoubletsDC_->view(), rangesDC_->view(), rangesDC_->const_view(), @@ -437,7 +437,7 @@ void Event::createSegmentsWithModuleMap() { alpaka::exec(queue_, createSegmentsInGPUv2_workDiv, CreateSegmentsInGPUv2{}, - *modulesBuffers_.data(), + modules_.const_view(), miniDoubletsDC_->const_view(), miniDoubletsDC_->const_view(), segmentsDC_->view(), @@ -450,7 +450,7 @@ void Event::createSegmentsWithModuleMap() { alpaka::exec(queue_, addSegmentRangesToEventExplicit_workDiv, AddSegmentRangesToEventExplicit{}, - *modulesBuffers_.data(), + modules_.const_view(), segmentsDC_->view(), rangesDC_->view(), rangesDC_->const_view()); @@ -467,7 +467,7 @@ void Event::createTriplets() { alpaka::exec(queue_, createTripletArrayRanges_workDiv, CreateTripletArrayRanges{}, - *modulesBuffers_.data(), + modules_.const_view(), rangesDC_->view(), segmentsDC_->const_view()); @@ -496,8 +496,11 @@ void Event::createTriplets() { // ... same for module_nConnectedModules // FIXME: replace by ES host data + auto modules = modules_.const_view(); auto module_nConnectedModules_buf_h = cms::alpakatools::make_host_buffer(queue_, nLowerModules_); - alpaka::memcpy(queue_, module_nConnectedModules_buf_h, modulesBuffers_.nConnectedModules_buf, nLowerModules_); + auto module_nConnectedModules_buf_d = + alpaka::createView(devAcc_, modules.nConnectedModules(), nLowerModules_); // only lower modules + alpaka::memcpy(queue_, module_nConnectedModules_buf_h, module_nConnectedModules_buf_d, nLowerModules_); alpaka::wait(queue_); // wait for nSegments and module_nConnectedModules before using @@ -530,7 +533,7 @@ void Event::createTriplets() { alpaka::exec(queue_, createTripletsInGPUv2_workDiv, CreateTripletsInGPUv2{}, - *modulesBuffers_.data(), + modules_.const_view(), miniDoubletsDC_->const_view(), segmentsDC_->const_view(), segmentsDC_->const_view(), @@ -545,7 +548,7 @@ void Event::createTriplets() { alpaka::exec(queue_, addTripletRangesToEventExplicit_workDiv, AddTripletRangesToEventExplicit{}, - *modulesBuffers_.data(), + modules_.const_view(), *tripletsInGPU_, rangesDC_->view(), rangesDC_->const_view()); @@ -570,7 +573,7 @@ void Event::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets) { alpaka::exec(queue_, crossCleanpT3_workDiv, CrossCleanpT3{}, - *modulesBuffers_.data(), + modules_.const_view(), rangesDC_->const_view(), *pixelTripletsInGPU_, segmentsDC_->const_view(), @@ -614,7 +617,7 @@ void Event::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets) { alpaka::exec(queue_, crossCleanT5_workDiv, CrossCleanT5{}, - *modulesBuffers_.data(), + modules_.const_view(), *quintupletsInGPU_, *pixelQuintupletsInGPU_, *pixelTripletsInGPU_, @@ -642,7 +645,7 @@ void Event::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets) { alpaka::exec(queue_, checkHitspLS_workDiv, CheckHitspLS{}, - *modulesBuffers_.data(), + modules_.const_view(), segmentsDC_->const_view(), segmentsDC_->view(), true); @@ -656,7 +659,7 @@ void Event::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets) { alpaka::exec(queue_, crossCleanpLS_workDiv, CrossCleanpLS{}, - *modulesBuffers_.data(), + modules_.const_view(), rangesDC_->const_view(), *pixelTripletsInGPU_, trackCandidatesDC_->view(), @@ -803,7 +806,8 @@ void Event::createPixelTriplets() { alpaka::exec(queue_, createPixelTripletsInGPUFromMapv2_workDiv, CreatePixelTripletsInGPUFromMapv2{}, - *modulesBuffers_.data(), + modules_.const_view(), + modules_.const_view(), rangesDC_->const_view(), miniDoubletsDC_->const_view(), segmentsDC_->const_view(), @@ -840,7 +844,7 @@ void Event::createQuintuplets() { alpaka::exec(queue_, createEligibleModulesListForQuintupletsGPU_workDiv, CreateEligibleModulesListForQuintupletsGPU{}, - *modulesBuffers_.data(), + modules_.const_view(), *tripletsInGPU_, rangesDC_->view()); @@ -872,7 +876,7 @@ void Event::createQuintuplets() { alpaka::exec(queue_, createQuintupletsInGPUv2_workDiv, CreateQuintupletsInGPUv2{}, - *modulesBuffers_.data(), + modules_.const_view(), miniDoubletsDC_->const_view(), segmentsDC_->const_view(), *tripletsInGPU_, @@ -888,7 +892,7 @@ void Event::createQuintuplets() { alpaka::exec(queue_, removeDupQuintupletsInGPUAfterBuild_workDiv, RemoveDupQuintupletsInGPUAfterBuild{}, - *modulesBuffers_.data(), + modules_.const_view(), *quintupletsInGPU_, rangesDC_->const_view()); @@ -897,7 +901,7 @@ void Event::createQuintuplets() { alpaka::exec(queue_, addQuintupletRangesToEventExplicit_workDiv, AddQuintupletRangesToEventExplicit{}, - *modulesBuffers_.data(), + modules_.const_view(), *quintupletsInGPU_, rangesDC_->view(), rangesDC_->const_view()); @@ -917,7 +921,7 @@ void Event::pixelLineSegmentCleaning(bool no_pls_dupclean) { alpaka::exec(queue_, checkHitspLS_workDiv, CheckHitspLS{}, - *modulesBuffers_.data(), + modules_.const_view(), segmentsDC_->const_view(), segmentsDC_->view(), false); @@ -1020,7 +1024,8 @@ void Event::createPixelQuintuplets() { alpaka::exec(queue_, createPixelQuintupletsInGPUFromMapv2_workDiv, CreatePixelQuintupletsInGPUFromMapv2{}, - *modulesBuffers_.data(), + modules_.const_view(), + modules_.const_view(), miniDoubletsDC_->const_view(), segmentsDC_->const_view(), segmentsDC_->view(), @@ -1069,12 +1074,16 @@ void Event::addMiniDoubletsToEventExplicit() { auto nMDs_view = alpaka::createView(devAcc_, mdsOccupancy.nMDs(), nLowerModules_); // exclude pixel part alpaka::memcpy(queue_, nMDsCPU_buf, nMDs_view, nLowerModules_); + auto modules = modules_.const_view(); + // FIXME: replace by ES host data auto module_subdets_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); - alpaka::memcpy(queue_, module_subdets_buf, modulesBuffers_.subdets_buf, nLowerModules_); + auto module_subdets_view = alpaka::createView(devAcc_, modules.subdets(), nLowerModules_); // only lower modules + alpaka::memcpy(queue_, module_subdets_buf, module_subdets_view, nLowerModules_); auto module_layers_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); - alpaka::memcpy(queue_, module_layers_buf, modulesBuffers_.layers_buf, nLowerModules_); + auto module_layers_view = alpaka::createView(devAcc_, modules.layers(), nLowerModules_); // only lower modules + alpaka::memcpy(queue_, module_layers_buf, module_layers_view, nLowerModules_); auto module_hitRanges_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); auto hits = hitsDC_->view(); @@ -1105,12 +1114,16 @@ void Event::addSegmentsToEventExplicit() { alpaka::createView(devAcc_, segmentsDC_->const_view().nSegments(), nLowerModules_); alpaka::memcpy(queue_, nSegmentsCPU_buf, nSegments_buf, nLowerModules_); + auto modules = modules_.const_view(); + // FIXME: replace by ES host data auto module_subdets_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); - alpaka::memcpy(queue_, module_subdets_buf, modulesBuffers_.subdets_buf, nLowerModules_); + auto module_subdets_view = alpaka::createView(devAcc_, modules.subdets(), nLowerModules_); // only lower modules + alpaka::memcpy(queue_, module_subdets_buf, module_subdets_view, nLowerModules_); auto module_layers_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); - alpaka::memcpy(queue_, module_layers_buf, modulesBuffers_.layers_buf, nLowerModules_); + auto module_layers_view = alpaka::createView(devAcc_, modules.layers(), nLowerModules_); // only lower modules + alpaka::memcpy(queue_, module_layers_buf, module_layers_view, nLowerModules_); alpaka::wait(queue_); // wait for inputs before using them @@ -1133,12 +1146,16 @@ void Event::addQuintupletsToEventExplicit() { auto nQuintupletsCPU_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); alpaka::memcpy(queue_, nQuintupletsCPU_buf, quintupletsBuffers_->nQuintuplets_buf); + auto modules = modules_.const_view(); + // FIXME: replace by ES host data auto module_subdets_buf = allocBufWrapper(cms::alpakatools::host(), nModules_, queue_); - alpaka::memcpy(queue_, module_subdets_buf, modulesBuffers_.subdets_buf, nModules_); + auto module_subdets_view = alpaka::createView(devAcc_, modules.subdets(), modules.metadata().size()); + alpaka::memcpy(queue_, module_subdets_buf, module_subdets_view, nModules_); auto module_layers_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); - alpaka::memcpy(queue_, module_layers_buf, modulesBuffers_.layers_buf, nLowerModules_); + auto module_layers_view = alpaka::createView(devAcc_, modules.layers(), nLowerModules_); // only lower modules + alpaka::memcpy(queue_, module_layers_buf, module_layers_view, nLowerModules_); auto module_quintupletModuleIndices_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); auto rangesOccupancy = rangesDC_->view(); @@ -1168,12 +1185,16 @@ void Event::addTripletsToEventExplicit() { auto nTripletsCPU_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); alpaka::memcpy(queue_, nTripletsCPU_buf, tripletsBuffers_->nTriplets_buf); + auto modules = modules_.const_view(); + // FIXME: replace by ES host data auto module_subdets_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); - alpaka::memcpy(queue_, module_subdets_buf, modulesBuffers_.subdets_buf, nLowerModules_); + auto module_subdets_view = alpaka::createView(devAcc_, modules.subdets(), nLowerModules_); // only lower modules + alpaka::memcpy(queue_, module_subdets_buf, module_subdets_view, nLowerModules_); auto module_layers_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); - alpaka::memcpy(queue_, module_layers_buf, modulesBuffers_.layers_buf, nLowerModules_); + auto module_layers_view = alpaka::createView(devAcc_, modules.layers(), nLowerModules_); // only lower modules + alpaka::memcpy(queue_, module_layers_buf, module_layers_view, nLowerModules_); alpaka::wait(queue_); // wait for inputs before using them @@ -1732,14 +1753,20 @@ const TrackCandidatesHostCollection& Event::getTrackCandidatesInCMSSW(bool sync) return trackCandidatesHC_.value(); } -ModulesBuffer& Event::getModules(bool isFull, bool sync) { - if (!modulesInCPU_) { - // The last input here is just a small placeholder for the allocation. - modulesInCPU_.emplace(cms::alpakatools::host(), nModules_, nPixels_); - - modulesInCPU_->copyFromSrc(queue_, modulesBuffers_, isFull); - if (sync) - alpaka::wait(queue_); // host consumers expect filled data +template +typename TSoA::ConstView Event::getModules(bool sync) { + if constexpr (std::is_same_v) { + return modules_.const_view(); + } else { + if (!modulesHC_) { + modulesHC_.emplace( + cms::alpakatools::CopyToHost>::copyAsync( + queue_, modules_)); + if (sync) + alpaka::wait(queue_); // host consumers expect filled data + } + return modulesHC_->const_view(); } - return modulesInCPU_.value(); } +template ModulesConst Event::getModules(bool); +template ModulesPixelConst Event::getModules(bool); diff --git a/RecoTracker/LSTCore/src/alpaka/Event.h b/RecoTracker/LSTCore/src/alpaka/Event.h index 9e33be57474a7..326beb81bc0e4 100644 --- a/RecoTracker/LSTCore/src/alpaka/Event.h +++ b/RecoTracker/LSTCore/src/alpaka/Event.h @@ -6,9 +6,10 @@ #include "RecoTracker/LSTCore/interface/TrackCandidatesHostCollection.h" #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" #include "RecoTracker/LSTCore/interface/alpaka/LST.h" -#include "RecoTracker/LSTCore/interface/Module.h" +#include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/alpaka/ObjectRangesDeviceCollection.h" #include "RecoTracker/LSTCore/interface/alpaka/EndcapGeometryDevDeviceCollection.h" +#include "RecoTracker/LSTCore/interface/alpaka/ModulesDeviceCollection.h" #include "Hit.h" #include "Segment.h" @@ -66,7 +67,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { std::optional segmentsHC_; std::optional> tripletsInCPU_; std::optional trackCandidatesHC_; - std::optional> modulesInCPU_; + std::optional modulesHC_; std::optional> quintupletsInCPU_; std::optional> pixelTripletsInCPU_; std::optional> pixelQuintupletsInCPU_; @@ -77,7 +78,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { const uint16_t nLowerModules_; const unsigned int nPixels_; const unsigned int nEndCapMap_; - ModulesBuffer const& modulesBuffers_; + ModulesDeviceCollection const& modules_; PixelMap const& pixelMapping_; EndcapGeometryDevDeviceCollection const& endcapGeometry_; @@ -90,7 +91,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { nLowerModules_(deviceESData->nLowerModules), nPixels_(deviceESData->nPixels), nEndCapMap_(deviceESData->nEndCapMap), - modulesBuffers_(deviceESData->modulesBuffers), + modules_(*deviceESData->modules), pixelMapping_(*deviceESData->pixelMapping), endcapGeometry_(*deviceESData->endcapGeometry) { initSync(verbose); @@ -194,7 +195,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { PixelQuintupletsBuffer& getPixelQuintuplets(bool sync = true); const TrackCandidatesHostCollection& getTrackCandidates(bool sync = true); const TrackCandidatesHostCollection& getTrackCandidatesInCMSSW(bool sync = true); - ModulesBuffer& getModules(bool isFull = false, bool sync = true); + template + typename TSoA::ConstView getModules(bool sync = true); }; } // namespace ALPAKA_ACCELERATOR_NAMESPACE::lst diff --git a/RecoTracker/LSTCore/src/alpaka/Hit.h b/RecoTracker/LSTCore/src/alpaka/Hit.h index 57be2f5fc2df1..5416662c7aa7a 100644 --- a/RecoTracker/LSTCore/src/alpaka/Hit.h +++ b/RecoTracker/LSTCore/src/alpaka/Hit.h @@ -2,7 +2,7 @@ #define RecoTracker_LSTCore_src_alpaka_Hit_h #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" -#include "RecoTracker/LSTCore/interface/Module.h" +#include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/alpaka/HitsDeviceCollection.h" namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { @@ -80,14 +80,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { struct ModuleRangesKernel { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - Modules modulesInGPU, + ModulesConst modules, HitsOccupancy hitsOccupancy, int nLowerModules) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); for (int lowerIndex = globalThreadIdx[2]; lowerIndex < nLowerModules; lowerIndex += gridThreadExtent[2]) { - uint16_t upperIndex = modulesInGPU.partnerModuleIndices[lowerIndex]; + uint16_t upperIndex = modules.partnerModuleIndices()[lowerIndex]; if (hitsOccupancy.hitRanges()[lowerIndex][0] != -1 && hitsOccupancy.hitRanges()[upperIndex][0] != -1) { hitsOccupancy.hitRangesLower()[lowerIndex] = hitsOccupancy.hitRanges()[lowerIndex][0]; hitsOccupancy.hitRangesUpper()[lowerIndex] = hitsOccupancy.hitRanges()[upperIndex][0]; @@ -108,7 +108,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { unsigned int nModules, // Number of modules unsigned int nEndCapMap, // Number of elements in endcap map EndcapGeometryDevConst endcapGeometry, - Modules modulesInGPU, + ModulesConst modules, Hits hits, HitsOccupancy hitsOccupancy, unsigned int nHits) const // Total number of hits in event @@ -129,12 +129,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { ((ihit_z > 0) - (ihit_z < 0)) * alpaka::math::acosh( acc, alpaka::math::sqrt(acc, ihit_x * ihit_x + ihit_y * ihit_y + ihit_z * ihit_z) / hits.rts()[ihit]); - int found_index = binary_search(modulesInGPU.mapdetId, iDetId, nModules); - uint16_t lastModuleIndex = modulesInGPU.mapIdx[found_index]; + int found_index = binary_search(modules.mapdetId(), iDetId, nModules); + uint16_t lastModuleIndex = modules.mapIdx()[found_index]; hits.moduleIndices()[ihit] = lastModuleIndex; - if (modulesInGPU.subdets[lastModuleIndex] == Endcap && modulesInGPU.moduleType[lastModuleIndex] == TwoS) { + if (modules.subdets()[lastModuleIndex] == Endcap && modules.moduleType()[lastModuleIndex] == TwoS) { found_index = binary_search(geoMapDetId, iDetId, nEndCapMap); float phi = geoMapPhi[found_index]; float cos_phi = alpaka::math::cos(acc, phi); diff --git a/RecoTracker/LSTCore/src/alpaka/Kernels.h b/RecoTracker/LSTCore/src/alpaka/Kernels.h index 839fb42b23fb2..a9701e2d93645 100644 --- a/RecoTracker/LSTCore/src/alpaka/Kernels.h +++ b/RecoTracker/LSTCore/src/alpaka/Kernels.h @@ -2,7 +2,7 @@ #define RecoTracker_LSTCore_src_alpaka_Kernels_h #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" -#include "RecoTracker/LSTCore/interface/Module.h" +#include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h" #include "Hit.h" @@ -145,14 +145,13 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { struct RemoveDupQuintupletsInGPUAfterBuild { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - Modules modulesInGPU, + ModulesConst modules, Quintuplets quintupletsInGPU, ObjectOccupancyConst objectOccupancy) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); - for (unsigned int lowmod = globalThreadIdx[0]; lowmod < *modulesInGPU.nLowerModules; - lowmod += gridThreadExtent[0]) { + for (unsigned int lowmod = globalThreadIdx[0]; lowmod < modules.nLowerModules(); lowmod += gridThreadExtent[0]) { unsigned int nQuintuplets_lowmod = quintupletsInGPU.nQuintuplets[lowmod]; int quintupletModuleIndices_lowmod = objectOccupancy.quintupletModuleIndices()[lowmod]; @@ -335,14 +334,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { struct CheckHitspLS { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - Modules modulesInGPU, + ModulesConst modules, SegmentsOccupancyConst segmentsOccupancy, SegmentsPixel segmentsPixel, bool secondpass) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); - int pixelModuleIndex = *modulesInGPU.nLowerModules; + int pixelModuleIndex = modules.nLowerModules(); unsigned int nPixelSegments = segmentsOccupancy.nSegments()[pixelModuleIndex]; if (nPixelSegments > n_max_pixel_segments_per_module) diff --git a/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h b/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h index 312220dba44d4..295562baa3e4d 100644 --- a/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h +++ b/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h @@ -6,7 +6,7 @@ #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" #include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h" #include "RecoTracker/LSTCore/interface/alpaka/MiniDoubletsDeviceCollection.h" -#include "RecoTracker/LSTCore/interface/Module.h" +#include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/EndcapGeometry.h" #include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h" @@ -17,7 +17,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { ALPAKA_FN_ACC ALPAKA_FN_INLINE void addMDToMemory(TAcc const& acc, MiniDoublets mds, HitsConst hits, - Modules const& modulesInGPU, + ModulesConst modules, unsigned int lowerHitIdx, unsigned int upperHitIdx, uint16_t lowerModuleIdx, @@ -35,7 +35,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { mds.moduleIndices()[idx] = lowerModuleIdx; unsigned int anchorHitIndex, outerHitIndex; - if (modulesInGPU.moduleType[lowerModuleIdx] == PS and modulesInGPU.moduleLayerType[lowerModuleIdx] == Strip) { + if (modules.moduleType()[lowerModuleIdx] == PS and modules.moduleLayerType()[lowerModuleIdx] == Strip) { mds.anchorHitIndices()[idx] = upperHitIdx; mds.outerHitIndices()[idx] = lowerHitIdx; @@ -85,14 +85,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { mds.outerLowEdgeY()[idx] = hits.lowEdgeYs()[outerHitIndex]; } - ALPAKA_FN_ACC ALPAKA_FN_INLINE float isTighterTiltedModules(Modules const& modulesInGPU, uint16_t moduleIndex) { + ALPAKA_FN_ACC ALPAKA_FN_INLINE float isTighterTiltedModules(ModulesConst modules, uint16_t moduleIndex) { // The "tighter" tilted modules are the subset of tilted modules that have smaller spacing // This is the same as what was previously considered as"isNormalTiltedModules" // See Figure 9.1 of https://cds.cern.ch/record/2272264/files/CMS-TDR-014.pdf - short subdet = modulesInGPU.subdets[moduleIndex]; - short layer = modulesInGPU.layers[moduleIndex]; - short side = modulesInGPU.sides[moduleIndex]; - short rod = modulesInGPU.rods[moduleIndex]; + short subdet = modules.subdets()[moduleIndex]; + short layer = modules.layers()[moduleIndex]; + short side = modules.sides()[moduleIndex]; + short rod = modules.rods()[moduleIndex]; if (subdet == Barrel) { if ((side != Center and layer == 3) or (side == NegZ and layer == 2 and rod > 5) or @@ -105,7 +105,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { return false; } - ALPAKA_FN_ACC ALPAKA_FN_INLINE float moduleGapSize(Modules const& modulesInGPU, uint16_t moduleIndex) { + ALPAKA_FN_ACC ALPAKA_FN_INLINE float moduleGapSize(ModulesConst modules, uint16_t moduleIndex) { float miniDeltaTilted[3] = {0.26f, 0.26f, 0.26f}; float miniDeltaFlat[6] = {0.26f, 0.16f, 0.16f, 0.18f, 0.18f, 0.18f}; float miniDeltaLooseTilted[3] = {0.4f, 0.4f, 0.4f}; @@ -135,16 +135,16 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } } - unsigned int iL = modulesInGPU.layers[moduleIndex] - 1; - unsigned int iR = modulesInGPU.rings[moduleIndex] - 1; - short subdet = modulesInGPU.subdets[moduleIndex]; - short side = modulesInGPU.sides[moduleIndex]; + unsigned int iL = modules.layers()[moduleIndex] - 1; + unsigned int iR = modules.rings()[moduleIndex] - 1; + short subdet = modules.subdets()[moduleIndex]; + short side = modules.sides()[moduleIndex]; float moduleSeparation = 0; if (subdet == Barrel and side == Center) { moduleSeparation = miniDeltaFlat[iL]; - } else if (isTighterTiltedModules(modulesInGPU, moduleIndex)) { + } else if (isTighterTiltedModules(modules, moduleIndex)) { moduleSeparation = miniDeltaTilted[iL]; } else if (subdet == Endcap) { moduleSeparation = miniDeltaEndcap[iL][iR]; @@ -158,7 +158,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE float dPhiThreshold( - TAcc const& acc, float rt, Modules const& modulesInGPU, uint16_t moduleIndex, float dPhi = 0, float dz = 0) { + TAcc const& acc, float rt, ModulesConst modules, uint16_t moduleIndex, float dPhi = 0, float dz = 0) { // ================================================================= // Various constants // ================================================================= @@ -168,28 +168,28 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { // Computing some components that make up the cut threshold // ================================================================= - unsigned int iL = modulesInGPU.layers[moduleIndex] - 1; + unsigned int iL = modules.layers()[moduleIndex] - 1; const float miniSlope = alpaka::math::asin(acc, alpaka::math::min(acc, rt * k2Rinv1GeVf / ptCut, kSinAlphaMax)); const float rLayNominal = - ((modulesInGPU.subdets[moduleIndex] == Barrel) ? kMiniRminMeanBarrel[iL] : kMiniRminMeanEndcap[iL]); + ((modules.subdets()[moduleIndex] == Barrel) ? kMiniRminMeanBarrel[iL] : kMiniRminMeanEndcap[iL]); const float miniPVoff = 0.1f / rLayNominal; - const float miniMuls = ((modulesInGPU.subdets[moduleIndex] == Barrel) ? kMiniMulsPtScaleBarrel[iL] * 3.f / ptCut - : kMiniMulsPtScaleEndcap[iL] * 3.f / ptCut); - const bool isTilted = modulesInGPU.subdets[moduleIndex] == Barrel and modulesInGPU.sides[moduleIndex] != Center; + const float miniMuls = ((modules.subdets()[moduleIndex] == Barrel) ? kMiniMulsPtScaleBarrel[iL] * 3.f / ptCut + : kMiniMulsPtScaleEndcap[iL] * 3.f / ptCut); + const bool isTilted = modules.subdets()[moduleIndex] == Barrel and modules.sides()[moduleIndex] != Center; //the lower module is sent in irrespective of its layer type. We need to fetch the drdz properly float drdz; if (isTilted) { - if (modulesInGPU.moduleType[moduleIndex] == PS and modulesInGPU.moduleLayerType[moduleIndex] == Strip) { - drdz = modulesInGPU.drdzs[moduleIndex]; + if (modules.moduleType()[moduleIndex] == PS and modules.moduleLayerType()[moduleIndex] == Strip) { + drdz = modules.drdzs()[moduleIndex]; } else { - drdz = modulesInGPU.drdzs[modulesInGPU.partnerModuleIndices[moduleIndex]]; + drdz = modules.drdzs()[modules.partnerModuleIndices()[moduleIndex]]; } } else { drdz = 0; } const float miniTilt2 = ((isTilted) ? (0.5f * 0.5f) * (kPixelPSZpitch * kPixelPSZpitch) * (drdz * drdz) / - (1.f + drdz * drdz) / moduleGapSize(modulesInGPU, moduleIndex) + (1.f + drdz * drdz) / moduleGapSize(modules, moduleIndex) : 0); // Compute luminous region requirement for endcap @@ -199,12 +199,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { // Return the threshold value // ================================================================= // Following condition is met if the module is central and flatly lying - if (modulesInGPU.subdets[moduleIndex] == Barrel and modulesInGPU.sides[moduleIndex] == Center) { + if (modules.subdets()[moduleIndex] == Barrel and modules.sides()[moduleIndex] == Center) { return miniSlope + alpaka::math::sqrt(acc, miniMuls * miniMuls + miniPVoff * miniPVoff); } // Following condition is met if the module is central and tilted - else if (modulesInGPU.subdets[moduleIndex] == Barrel and - modulesInGPU.sides[moduleIndex] != Center) //all types of tilted modules + else if (modules.subdets()[moduleIndex] == Barrel and + modules.sides()[moduleIndex] != Center) //all types of tilted modules { return miniSlope + alpaka::math::sqrt(acc, miniMuls * miniMuls + miniPVoff * miniPVoff + miniTilt2 * miniSlope * miniSlope); @@ -217,7 +217,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_INLINE ALPAKA_FN_ACC void shiftStripHits(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, uint16_t lowerModuleIndex, uint16_t upperModuleIndex, unsigned int lowerHitIndex, @@ -267,16 +267,16 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float drprime_x; // x-component of drprime float drprime_y; // y-component of drprime const float& slope = - modulesInGPU.dxdys[lowerModuleIndex]; // The slope of the possible strip hits for a given module in x-y plane + modules.dxdys()[lowerModuleIndex]; // The slope of the possible strip hits for a given module in x-y plane float absArctanSlope; float angleM; // the angle M is the angle of rotation of the module in x-y plane if the possible strip hits are along the x-axis, then angleM = 0, and if the possible strip hits are along y-axis angleM = 90 degrees float absdzprime; // The distance between the two points after shifting - const float& drdz_ = modulesInGPU.drdzs[lowerModuleIndex]; + const float& drdz_ = modules.drdzs()[lowerModuleIndex]; // Assign hit pointers based on their hit type - if (modulesInGPU.moduleType[lowerModuleIndex] == PS) { + if (modules.moduleType()[lowerModuleIndex] == PS) { // TODO: This is somewhat of an mystery.... somewhat confused why this is the case - if (modulesInGPU.subdets[lowerModuleIndex] == Barrel ? modulesInGPU.moduleLayerType[lowerModuleIndex] != Pixel - : modulesInGPU.moduleLayerType[lowerModuleIndex] == Pixel) { + if (modules.subdets()[lowerModuleIndex] == Barrel ? modules.moduleLayerType()[lowerModuleIndex] != Pixel + : modules.moduleLayerType()[lowerModuleIndex] == Pixel) { xo = xUpper; yo = yUpper; xp = xLower; @@ -301,7 +301,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } // If it is endcap some of the math gets simplified (and also computers don't like infinities) - isEndcap = modulesInGPU.subdets[lowerModuleIndex] == Endcap; + isEndcap = modules.subdets()[lowerModuleIndex] == Endcap; // NOTE: TODO: Keep in mind that the sin(atan) function can be simplified to something like x / sqrt(1 + x^2) and similar for cos // I am not sure how slow sin, atan, cos, functions are in c++. If x / sqrt(1 + x^2) are faster change this later to reduce arithmetic computation time @@ -313,10 +313,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { acc, drdz_)); // The tilt module on the positive z-axis has negative drdz slope in r-z plane and vice versa - moduleSeparation = moduleGapSize(modulesInGPU, lowerModuleIndex); + moduleSeparation = moduleGapSize(modules, lowerModuleIndex); // Sign flips if the pixel is later layer - if (modulesInGPU.moduleType[lowerModuleIndex] == PS and modulesInGPU.moduleLayerType[lowerModuleIndex] != Pixel) { + if (modules.moduleType()[lowerModuleIndex] == PS and modules.moduleLayerType()[lowerModuleIndex] != Pixel) { moduleSeparation *= -1; } @@ -368,7 +368,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { angleA)); // module separation sign is for shifting in radial direction for z-axis direction take care of the sign later // Depending on which one as closer to the interactin point compute the new z wrt to the pixel properly - if (modulesInGPU.moduleLayerType[lowerModuleIndex] == Pixel) { + if (modules.moduleLayerType()[lowerModuleIndex] == Pixel) { abszn = alpaka::math::abs(acc, zp) + absdzprime; } else { abszn = alpaka::math::abs(acc, zp) - absdzprime; @@ -383,7 +383,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC bool runMiniDoubletDefaultAlgoBarrel(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, uint16_t lowerModuleIndex, uint16_t upperModuleIndex, unsigned int lowerHitIndex, @@ -405,7 +405,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float zUpper, float rtUpper) { dz = zLower - zUpper; - const float dzCut = modulesInGPU.moduleType[lowerModuleIndex] == PS ? 2.f : 10.f; + const float dzCut = modules.moduleType()[lowerModuleIndex] == PS ? 2.f : 10.f; const float sign = ((dz > 0) - (dz < 0)) * ((zLower > 0) - (zLower < 0)); const float invertedcrossercut = (alpaka::math::abs(acc, dz) > 2) * sign; @@ -414,20 +414,20 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float miniCut = 0; - miniCut = modulesInGPU.moduleLayerType[lowerModuleIndex] == Pixel - ? dPhiThreshold(acc, rtLower, modulesInGPU, lowerModuleIndex) - : dPhiThreshold(acc, rtUpper, modulesInGPU, lowerModuleIndex); + miniCut = modules.moduleLayerType()[lowerModuleIndex] == Pixel + ? dPhiThreshold(acc, rtLower, modules, lowerModuleIndex) + : dPhiThreshold(acc, rtUpper, modules, lowerModuleIndex); // Cut #2: dphi difference // Ref to original code: https://github.com/slava77/cms-tkph2-ntuple/blob/184d2325147e6930030d3d1f780136bc2dd29ce6/doubletAnalysis.C#L3085 float xn = 0.f, yn = 0.f; // , zn = 0; float shiftedRt2; - if (modulesInGPU.sides[lowerModuleIndex] != Center) // If barrel and not center it is tilted + if (modules.sides()[lowerModuleIndex] != Center) // If barrel and not center it is tilted { // Shift the hits and calculate new xn, yn position float shiftedCoords[3]; shiftStripHits(acc, - modulesInGPU, + modules, lowerModuleIndex, upperModuleIndex, lowerHitIndex, @@ -445,7 +445,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { yn = shiftedCoords[1]; // Lower or the upper hit needs to be modified depending on which one was actually shifted - if (modulesInGPU.moduleLayerType[lowerModuleIndex] == Pixel) { + if (modules.moduleLayerType()[lowerModuleIndex] == Pixel) { shiftedX = xn; shiftedY = yn; shiftedZ = zUpper; @@ -474,10 +474,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { // Cut #3: The dphi change going from lower Hit to upper Hit // Ref to original code: https://github.com/slava77/cms-tkph2-ntuple/blob/184d2325147e6930030d3d1f780136bc2dd29ce6/doubletAnalysis.C#L3076 - if (modulesInGPU.sides[lowerModuleIndex] != Center) { + if (modules.sides()[lowerModuleIndex] != Center) { // When it is tilted, use the new shifted positions // TODO: This is somewhat of an mystery.... somewhat confused why this is the case - if (modulesInGPU.moduleLayerType[lowerModuleIndex] != Pixel) { + if (modules.moduleLayerType()[lowerModuleIndex] != Pixel) { // dPhi Change should be calculated so that the upper hit has higher rt. // In principle, this kind of check rt_lower < rt_upper should not be necessary because the hit shifting should have taken care of this. // (i.e. the strip hit is shifted to be aligned in the line of sight from interaction point to pixel hit of PS module guaranteeing rt ordering) @@ -510,7 +510,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC bool runMiniDoubletDefaultAlgoEndcap(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, uint16_t lowerModuleIndex, uint16_t upperModuleIndex, unsigned int lowerHitIndex, @@ -544,7 +544,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { return false; // Cut #2 : drt cut. The dz difference can't be larger than 1cm. (max separation is 4mm for modules in the endcap) // Ref to original code: https://github.com/slava77/cms-tkph2-ntuple/blob/184d2325147e6930030d3d1f780136bc2dd29ce6/doubletAnalysis.C#L3100 - const float drtCut = modulesInGPU.moduleType[lowerModuleIndex] == PS ? 2.f : 10.f; + const float drtCut = modules.moduleType()[lowerModuleIndex] == PS ? 2.f : 10.f; drt = rtLower - rtUpper; if (alpaka::math::abs(acc, drt) >= drtCut) return false; @@ -553,7 +553,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float shiftedCoords[3]; shiftStripHits(acc, - modulesInGPU, + modules, lowerModuleIndex, upperModuleIndex, lowerHitIndex, @@ -572,9 +572,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { yn = shiftedCoords[1]; zn = shiftedCoords[2]; - if (modulesInGPU.moduleType[lowerModuleIndex] == PS) { + if (modules.moduleType()[lowerModuleIndex] == PS) { // Appropriate lower or upper hit is modified after checking which one was actually shifted - if (modulesInGPU.moduleLayerType[lowerModuleIndex] == Pixel) { + if (modules.moduleLayerType()[lowerModuleIndex] == Pixel) { shiftedX = xn; shiftedY = yn; shiftedZ = zUpper; @@ -597,14 +597,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { // dz needs to change if it is a PS module where the strip hits are shifted in order to properly account for the case when a tilted module falls under "endcap logic" // if it was an endcap it will have zero effect - if (modulesInGPU.moduleType[lowerModuleIndex] == PS) { - dz = modulesInGPU.moduleLayerType[lowerModuleIndex] == Pixel ? zLower - zn : zUpper - zn; + if (modules.moduleType()[lowerModuleIndex] == PS) { + dz = modules.moduleLayerType()[lowerModuleIndex] == Pixel ? zLower - zn : zUpper - zn; } float miniCut = 0; - miniCut = modulesInGPU.moduleLayerType[lowerModuleIndex] == Pixel - ? dPhiThreshold(acc, rtLower, modulesInGPU, lowerModuleIndex, dPhi, dz) - : dPhiThreshold(acc, rtUpper, modulesInGPU, lowerModuleIndex, dPhi, dz); + miniCut = modules.moduleLayerType()[lowerModuleIndex] == Pixel + ? dPhiThreshold(acc, rtLower, modules, lowerModuleIndex, dPhi, dz) + : dPhiThreshold(acc, rtUpper, modules, lowerModuleIndex, dPhi, dz); if (alpaka::math::abs(acc, dPhi) >= miniCut) return false; @@ -621,7 +621,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC bool runMiniDoubletDefaultAlgo(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, uint16_t lowerModuleIndex, uint16_t upperModuleIndex, unsigned int lowerHitIndex, @@ -642,9 +642,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float yUpper, float zUpper, float rtUpper) { - if (modulesInGPU.subdets[lowerModuleIndex] == Barrel) { + if (modules.subdets()[lowerModuleIndex] == Barrel) { return runMiniDoubletDefaultAlgoBarrel(acc, - modulesInGPU, + modules, lowerModuleIndex, upperModuleIndex, lowerHitIndex, @@ -667,7 +667,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { rtUpper); } else { return runMiniDoubletDefaultAlgoEndcap(acc, - modulesInGPU, + modules, lowerModuleIndex, upperModuleIndex, lowerHitIndex, @@ -694,7 +694,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { struct CreateMiniDoubletsInGPUv2 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - Modules modulesInGPU, + ModulesConst modules, HitsConst hits, HitsOccupancyConst hitsOccupancy, MiniDoublets mds, @@ -703,9 +703,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); - for (uint16_t lowerModuleIndex = globalThreadIdx[1]; lowerModuleIndex < (*modulesInGPU.nLowerModules); + for (uint16_t lowerModuleIndex = globalThreadIdx[1]; lowerModuleIndex < modules.nLowerModules(); lowerModuleIndex += gridThreadExtent[1]) { - uint16_t upperModuleIndex = modulesInGPU.partnerModuleIndices[lowerModuleIndex]; + uint16_t upperModuleIndex = modules.partnerModuleIndices()[lowerModuleIndex]; int nLowerHits = hitsOccupancy.hitRangesnLower()[lowerModuleIndex]; int nUpperHits = hitsOccupancy.hitRangesnUpper()[lowerModuleIndex]; if (hitsOccupancy.hitRangesLower()[lowerModuleIndex] == -1) @@ -734,7 +734,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float dz, dphi, dphichange, shiftedX, shiftedY, shiftedZ, noShiftedDphi, noShiftedDphiChange; bool success = runMiniDoubletDefaultAlgo(acc, - modulesInGPU, + modules, lowerModuleIndex, upperModuleIndex, lowerHitArrayIndex, @@ -770,7 +770,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { addMDToMemory(acc, mds, hits, - modulesInGPU, + modules, lowerHitArrayIndex, upperHitArrayIndex, lowerModuleIndex, @@ -792,7 +792,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { struct CreateMDArrayRangesGPU { template - ALPAKA_FN_ACC void operator()(TAcc const& acc, Modules modulesInGPU, ObjectOccupancy objectOccupancy) const { + ALPAKA_FN_ACC void operator()(TAcc const& acc, ModulesConst modules, ObjectOccupancy objectOccupancy) const { // implementation is 1D with a single block static_assert(std::is_same_v, "Should be Acc1D"); ALPAKA_ASSERT_ACC((alpaka::getWorkDiv(acc)[0] == 1)); @@ -810,11 +810,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { // Create variables outside of the for loop. int occupancy, category_number, eta_number; - for (uint16_t i = globalThreadIdx[0]; i < *modulesInGPU.nLowerModules; i += gridThreadExtent[0]) { - short module_rings = modulesInGPU.rings[i]; - short module_layers = modulesInGPU.layers[i]; - short module_subdets = modulesInGPU.subdets[i]; - float module_eta = alpaka::math::abs(acc, modulesInGPU.eta[i]); + for (uint16_t i = globalThreadIdx[0]; i < modules.nLowerModules(); i += gridThreadExtent[0]) { + short module_rings = modules.rings()[i]; + short module_layers = modules.layers()[i]; + short module_subdets = modules.subdets()[i]; + float module_eta = alpaka::math::abs(acc, modules.eta()[i]); if (module_layers <= 3 && module_subdets == 5) category_number = 0; @@ -878,7 +878,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { // Wait for all threads to finish before reporting final values alpaka::syncBlockThreads(acc); if (cms::alpakatools::once_per_block(acc)) { - objectOccupancy.miniDoubletModuleIndices()[*modulesInGPU.nLowerModules] = nTotalMDs; + objectOccupancy.miniDoubletModuleIndices()[modules.nLowerModules()] = nTotalMDs; objectOccupancy.nTotalMDs() = nTotalMDs; } } @@ -887,7 +887,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { struct AddMiniDoubletRangesToEventExplicit { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - Modules modulesInGPU, + ModulesConst modules, MiniDoubletsOccupancy mdsOccupancy, ObjectRanges ranges, ObjectOccupancyConst objectOccupancy, @@ -899,7 +899,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); - for (uint16_t i = globalThreadIdx[0]; i < *modulesInGPU.nLowerModules; i += gridThreadExtent[0]) { + for (uint16_t i = globalThreadIdx[0]; i < modules.nLowerModules(); i += gridThreadExtent[0]) { if (mdsOccupancy.nMDs()[i] == 0 or hitsOccupancy.hitRanges()[i][0] == -1) { ranges.mdRanges()[i][0] = -1; ranges.mdRanges()[i][1] = -1; diff --git a/RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h b/RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h index 6a125b96070cb..e2ae196192b06 100644 --- a/RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h +++ b/RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h @@ -2,7 +2,7 @@ #define RecoTracker_LSTCore_src_alpaka_NeuralNetwork_h #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" -#include "RecoTracker/LSTCore/interface/Module.h" +#include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "NeuralNetworkWeights.h" #include "Segment.h" @@ -16,7 +16,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE float runInference(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, Triplets const& tripletsInGPU, @@ -55,51 +55,51 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { uint16_t lowerModuleIndex5 = lowerModuleIndices[4]; // Compute some convenience variables short layer2_adjustment = 0; - if (modulesInGPU.layers[lowerModuleIndex1] == 1) { + if (modules.layers()[lowerModuleIndex1] == 1) { layer2_adjustment = 1; // get upper segment to be in second layer } unsigned int md_idx_for_t5_eta_phi = segments.mdIndices()[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 + bool is_endcap1 = (modules.subdets()[lowerModuleIndex1] == 4); // true if anchor hit 1 is in the endcap + bool is_endcap2 = (modules.subdets()[lowerModuleIndex2] == 4); // true if anchor hit 2 is in the endcap + bool is_endcap3 = (modules.subdets()[lowerModuleIndex3] == 4); // true if anchor hit 3 is in the endcap + bool is_endcap4 = (modules.subdets()[lowerModuleIndex4] == 4); // true if anchor hit 4 is in the endcap + bool is_endcap5 = (modules.subdets()[lowerModuleIndex5] == 4); // true if anchor hit 5 is in the endcap // Build DNN input vector (corresponding output N-tuple branch noted in parenthetical in comment) float x[38] = { - alpaka::math::log10(acc, 2 * k2Rinv1GeVf * innerRadius), // inner T3 pT (t3_pt) - mds.anchorEta()[mdIndex1], // inner T3 anchor hit 1 eta (t3_0_eta) - mds.anchorPhi()[mdIndex1], // inner T3 anchor hit 1 phi (t3_0_phi) - mds.anchorZ()[mdIndex1], // inner T3 anchor hit 1 z (t3_0_z) - alpaka::math::sqrt(acc, x1 * x1 + y1 * y1), // 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) - mds.anchorEta()[mdIndex2], // inner T3 anchor hit 2 eta (t3_2_eta) - mds.anchorPhi()[mdIndex2], // inner T3 anchor hit 2 phi (t3_2_phi) - mds.anchorZ()[mdIndex2], // inner T3 anchor hit 2 z (t3_2_z) - alpaka::math::sqrt(acc, x2 * x2 + y2 * y2), // 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) - mds.anchorEta()[mdIndex3], // inner T3 anchor hit 3 eta (t3_4_eta) - mds.anchorPhi()[mdIndex3], // inner T3 anchor hit 3 phi (t3_4_phi) - mds.anchorZ()[mdIndex3], // inner T3 anchor hit 3 z (t3_4_z) - alpaka::math::sqrt(acc, x3 * x3 + y3 * y3), // 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) - alpaka::math::log10(acc, 2 * k2Rinv1GeVf * outerRadius), // outer T3 pT (t3_pt) - mds.anchorEta()[mdIndex3], // outer T3 anchor hit 4 eta (t3_0_eta) - mds.anchorPhi()[mdIndex3], // outer T3 anchor hit 4 phi (t3_0_phi) - mds.anchorZ()[mdIndex3], // outer T3 anchor hit 3 eta (t3_0_z) - alpaka::math::sqrt(acc, x3 * x3 + y3 * y3), // outer T3 anchor hit 3 r (t3_0_r) - float(modulesInGPU.layers[lowerModuleIndex3] + 6 * is_endcap3), // outer T3 anchor hit 3 layer (t3_0_layer) - mds.anchorEta()[mdIndex4], // outer T3 anchor hit 4 eta (t3_2_eta) - mds.anchorPhi()[mdIndex4], // outer T3 anchor hit 4 phi (t3_2_phi) - mds.anchorZ()[mdIndex4], // outer T3 anchor hit 4 z (t3_2_z) - alpaka::math::sqrt(acc, x4 * x4 + y4 * y4), // 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) - mds.anchorEta()[mdIndex5], // outer T3 anchor hit 5 eta (t3_4_eta) - mds.anchorPhi()[mdIndex5], // outer T3 anchor hit 5 phi (t3_4_phi) - mds.anchorZ()[mdIndex5], // outer T3 anchor hit 5 z (t3_4_z) - alpaka::math::sqrt(acc, x5 * x5 + y5 * y5), // 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) + alpaka::math::log10(acc, 2 * k2Rinv1GeVf * innerRadius), // inner T3 pT (t3_pt) + mds.anchorEta()[mdIndex1], // inner T3 anchor hit 1 eta (t3_0_eta) + mds.anchorPhi()[mdIndex1], // inner T3 anchor hit 1 phi (t3_0_phi) + mds.anchorZ()[mdIndex1], // inner T3 anchor hit 1 z (t3_0_z) + alpaka::math::sqrt(acc, x1 * x1 + y1 * y1), // inner T3 anchor hit 1 r (t3_0_r) + float(modules.layers()[lowerModuleIndex1] + 6 * is_endcap1), // inner T3 anchor hit 1 layer (t3_0_layer) + mds.anchorEta()[mdIndex2], // inner T3 anchor hit 2 eta (t3_2_eta) + mds.anchorPhi()[mdIndex2], // inner T3 anchor hit 2 phi (t3_2_phi) + mds.anchorZ()[mdIndex2], // inner T3 anchor hit 2 z (t3_2_z) + alpaka::math::sqrt(acc, x2 * x2 + y2 * y2), // inner T3 anchor hit 2 r (t3_2_r) + float(modules.layers()[lowerModuleIndex2] + 6 * is_endcap2), // inner T3 anchor hit 2 layer (t3_2_layer) + mds.anchorEta()[mdIndex3], // inner T3 anchor hit 3 eta (t3_4_eta) + mds.anchorPhi()[mdIndex3], // inner T3 anchor hit 3 phi (t3_4_phi) + mds.anchorZ()[mdIndex3], // inner T3 anchor hit 3 z (t3_4_z) + alpaka::math::sqrt(acc, x3 * x3 + y3 * y3), // inner T3 anchor hit 3 r (t3_4_r) + float(modules.layers()[lowerModuleIndex3] + 6 * is_endcap3), // inner T3 anchor hit 3 layer (t3_4_layer) + alpaka::math::log10(acc, 2 * k2Rinv1GeVf * outerRadius), // outer T3 pT (t3_pt) + mds.anchorEta()[mdIndex3], // outer T3 anchor hit 4 eta (t3_0_eta) + mds.anchorPhi()[mdIndex3], // outer T3 anchor hit 4 phi (t3_0_phi) + mds.anchorZ()[mdIndex3], // outer T3 anchor hit 3 eta (t3_0_z) + alpaka::math::sqrt(acc, x3 * x3 + y3 * y3), // outer T3 anchor hit 3 r (t3_0_r) + float(modules.layers()[lowerModuleIndex3] + 6 * is_endcap3), // outer T3 anchor hit 3 layer (t3_0_layer) + mds.anchorEta()[mdIndex4], // outer T3 anchor hit 4 eta (t3_2_eta) + mds.anchorPhi()[mdIndex4], // outer T3 anchor hit 4 phi (t3_2_phi) + mds.anchorZ()[mdIndex4], // outer T3 anchor hit 4 z (t3_2_z) + alpaka::math::sqrt(acc, x4 * x4 + y4 * y4), // outer T3 anchor hit 4 r (t3_2_r) + float(modules.layers()[lowerModuleIndex4] + 6 * is_endcap4), // outer T3 anchor hit 4 layer (t3_2_layer) + mds.anchorEta()[mdIndex5], // outer T3 anchor hit 5 eta (t3_4_eta) + mds.anchorPhi()[mdIndex5], // outer T3 anchor hit 5 phi (t3_4_phi) + mds.anchorZ()[mdIndex5], // outer T3 anchor hit 5 z (t3_4_z) + alpaka::math::sqrt(acc, x5 * x5 + y5 * y5), // outer T3 anchor hit 5 r (t3_4_r) + float(modules.layers()[lowerModuleIndex5] + 6 * is_endcap5), // outer T3 anchor hit 5 layer (t3_4_layer) alpaka::math::log10(acc, (innerRadius + outerRadius) * k2Rinv1GeVf), // T5 pT (t5_pt) mds.anchorEta()[md_idx_for_t5_eta_phi], // T5 eta (t5_eta) mds.anchorPhi()[md_idx_for_t5_eta_phi], // T5 phi (t5_phi) diff --git a/RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h b/RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h index 61d043b6a9c87..4080ca0c1a62d 100644 --- a/RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h +++ b/RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h @@ -2,7 +2,7 @@ #define RecoTracker_LSTCore_src_alpaka_PixelQuintuplet_h #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" -#include "RecoTracker/LSTCore/interface/Module.h" +#include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h" #include "Segment.h" @@ -107,7 +107,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { inline void setData(PixelQuintupletsBuffer& buf) { data_.setData(buf); } }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addPixelQuintupletToMemory(Modules const& modulesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void addPixelQuintupletToMemory(ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, Quintuplets const& quintupletsInGPU, @@ -202,7 +202,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { pixelQuintupletsInGPU.rPhiChiSquaredInwards[pixelQuintupletIndex] = rPhiChiSquaredInwards; } - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT5RZChiSquaredCuts(Modules const& modulesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT5RZChiSquaredCuts(ModulesConst modules, uint16_t lowerModuleIndex1, uint16_t lowerModuleIndex2, uint16_t lowerModuleIndex3, @@ -210,20 +210,20 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { uint16_t lowerModuleIndex5, float rzChiSquared) { const int layer1 = - modulesInGPU.layers[lowerModuleIndex1] + 6 * (modulesInGPU.subdets[lowerModuleIndex1] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex1] == Endcap and modulesInGPU.moduleType[lowerModuleIndex1] == TwoS); + modules.layers()[lowerModuleIndex1] + 6 * (modules.subdets()[lowerModuleIndex1] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex1] == Endcap and modules.moduleType()[lowerModuleIndex1] == TwoS); const int layer2 = - modulesInGPU.layers[lowerModuleIndex2] + 6 * (modulesInGPU.subdets[lowerModuleIndex2] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex2] == Endcap and modulesInGPU.moduleType[lowerModuleIndex2] == TwoS); + modules.layers()[lowerModuleIndex2] + 6 * (modules.subdets()[lowerModuleIndex2] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex2] == Endcap and modules.moduleType()[lowerModuleIndex2] == TwoS); const int layer3 = - modulesInGPU.layers[lowerModuleIndex3] + 6 * (modulesInGPU.subdets[lowerModuleIndex3] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex3] == Endcap and modulesInGPU.moduleType[lowerModuleIndex3] == TwoS); + modules.layers()[lowerModuleIndex3] + 6 * (modules.subdets()[lowerModuleIndex3] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex3] == Endcap and modules.moduleType()[lowerModuleIndex3] == TwoS); const int layer4 = - modulesInGPU.layers[lowerModuleIndex4] + 6 * (modulesInGPU.subdets[lowerModuleIndex4] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex4] == Endcap and modulesInGPU.moduleType[lowerModuleIndex4] == TwoS); + modules.layers()[lowerModuleIndex4] + 6 * (modules.subdets()[lowerModuleIndex4] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex4] == Endcap and modules.moduleType()[lowerModuleIndex4] == TwoS); const int layer5 = - modulesInGPU.layers[lowerModuleIndex5] + 6 * (modulesInGPU.subdets[lowerModuleIndex5] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex5] == Endcap and modulesInGPU.moduleType[lowerModuleIndex5] == TwoS); + modules.layers()[lowerModuleIndex5] + 6 * (modules.subdets()[lowerModuleIndex5] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex5] == Endcap and modules.moduleType()[lowerModuleIndex5] == TwoS); if (layer1 == 1 and layer2 == 2 and layer3 == 3) { if (layer4 == 12 and layer5 == 13) { @@ -287,7 +287,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { return true; } - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT5RPhiChiSquaredCuts(Modules const& modulesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT5RPhiChiSquaredCuts(ModulesConst modules, uint16_t lowerModuleIndex1, uint16_t lowerModuleIndex2, uint16_t lowerModuleIndex3, @@ -295,20 +295,20 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { uint16_t lowerModuleIndex5, float rPhiChiSquared) { const int layer1 = - modulesInGPU.layers[lowerModuleIndex1] + 6 * (modulesInGPU.subdets[lowerModuleIndex1] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex1] == Endcap and modulesInGPU.moduleType[lowerModuleIndex1] == TwoS); + modules.layers()[lowerModuleIndex1] + 6 * (modules.subdets()[lowerModuleIndex1] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex1] == Endcap and modules.moduleType()[lowerModuleIndex1] == TwoS); const int layer2 = - modulesInGPU.layers[lowerModuleIndex2] + 6 * (modulesInGPU.subdets[lowerModuleIndex2] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex2] == Endcap and modulesInGPU.moduleType[lowerModuleIndex2] == TwoS); + modules.layers()[lowerModuleIndex2] + 6 * (modules.subdets()[lowerModuleIndex2] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex2] == Endcap and modules.moduleType()[lowerModuleIndex2] == TwoS); const int layer3 = - modulesInGPU.layers[lowerModuleIndex3] + 6 * (modulesInGPU.subdets[lowerModuleIndex3] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex3] == Endcap and modulesInGPU.moduleType[lowerModuleIndex3] == TwoS); + modules.layers()[lowerModuleIndex3] + 6 * (modules.subdets()[lowerModuleIndex3] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex3] == Endcap and modules.moduleType()[lowerModuleIndex3] == TwoS); const int layer4 = - modulesInGPU.layers[lowerModuleIndex4] + 6 * (modulesInGPU.subdets[lowerModuleIndex4] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex4] == Endcap and modulesInGPU.moduleType[lowerModuleIndex4] == TwoS); + modules.layers()[lowerModuleIndex4] + 6 * (modules.subdets()[lowerModuleIndex4] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex4] == Endcap and modules.moduleType()[lowerModuleIndex4] == TwoS); const int layer5 = - modulesInGPU.layers[lowerModuleIndex5] + 6 * (modulesInGPU.subdets[lowerModuleIndex5] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex5] == Endcap and modulesInGPU.moduleType[lowerModuleIndex5] == TwoS); + modules.layers()[lowerModuleIndex5] + 6 * (modules.subdets()[lowerModuleIndex5] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex5] == Endcap and modules.moduleType()[lowerModuleIndex5] == TwoS); if (layer1 == 1 and layer2 == 2 and layer3 == 3) { if (layer4 == 12 and layer5 == 13) { @@ -420,7 +420,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE void computeSigmasForRegression_pT5(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, const uint16_t* lowerModuleIndices, float* delta1, float* delta2, @@ -442,11 +442,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float inv2 = kPixelPSZpitch / kWidth2S; float inv3 = kStripPSZpitch / kWidth2S; for (size_t i = 0; i < nPoints; i++) { - moduleType = modulesInGPU.moduleType[lowerModuleIndices[i]]; - moduleSubdet = modulesInGPU.subdets[lowerModuleIndices[i]]; - moduleSide = modulesInGPU.sides[lowerModuleIndices[i]]; - const float& drdz = modulesInGPU.drdzs[lowerModuleIndices[i]]; - slopes[i] = modulesInGPU.dxdys[lowerModuleIndices[i]]; + moduleType = modules.moduleType()[lowerModuleIndices[i]]; + moduleSubdet = modules.subdets()[lowerModuleIndices[i]]; + moduleSide = modules.sides()[lowerModuleIndices[i]]; + const float& drdz = modules.drdzs()[lowerModuleIndices[i]]; + slopes[i] = modules.dxdys()[lowerModuleIndices[i]]; //category 1 - barrel PS flat if (moduleSubdet == Barrel and moduleType == PS and moduleSide == Center) { delta1[i] = inv1; @@ -506,7 +506,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT5RPhiChiSquared(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, uint16_t* lowerModuleIndices, float g, float f, @@ -521,7 +521,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { bool isFlat[5]; float chiSquared = 0; - computeSigmasForRegression_pT5(acc, modulesInGPU, lowerModuleIndices, delta1, delta2, slopes, isFlat); + computeSigmasForRegression_pT5(acc, modules, lowerModuleIndices, delta1, delta2, slopes, isFlat); chiSquared = computeChiSquaredpT5(acc, 5, xs, ys, delta1, delta2, slopes, isFlat, g, f, radius); return chiSquared; @@ -542,7 +542,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { return chiSquared; } - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT5RPhiChiSquaredInwardsCuts(Modules const& modulesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT5RPhiChiSquaredInwardsCuts(ModulesConst modules, uint16_t lowerModuleIndex1, uint16_t lowerModuleIndex2, uint16_t lowerModuleIndex3, @@ -550,20 +550,20 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { uint16_t lowerModuleIndex5, float rPhiChiSquared) { const int layer1 = - modulesInGPU.layers[lowerModuleIndex1] + 6 * (modulesInGPU.subdets[lowerModuleIndex1] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex1] == Endcap and modulesInGPU.moduleType[lowerModuleIndex1] == TwoS); + modules.layers()[lowerModuleIndex1] + 6 * (modules.subdets()[lowerModuleIndex1] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex1] == Endcap and modules.moduleType()[lowerModuleIndex1] == TwoS); const int layer2 = - modulesInGPU.layers[lowerModuleIndex2] + 6 * (modulesInGPU.subdets[lowerModuleIndex2] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex2] == Endcap and modulesInGPU.moduleType[lowerModuleIndex2] == TwoS); + modules.layers()[lowerModuleIndex2] + 6 * (modules.subdets()[lowerModuleIndex2] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex2] == Endcap and modules.moduleType()[lowerModuleIndex2] == TwoS); const int layer3 = - modulesInGPU.layers[lowerModuleIndex3] + 6 * (modulesInGPU.subdets[lowerModuleIndex3] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex3] == Endcap and modulesInGPU.moduleType[lowerModuleIndex3] == TwoS); + modules.layers()[lowerModuleIndex3] + 6 * (modules.subdets()[lowerModuleIndex3] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex3] == Endcap and modules.moduleType()[lowerModuleIndex3] == TwoS); const int layer4 = - modulesInGPU.layers[lowerModuleIndex4] + 6 * (modulesInGPU.subdets[lowerModuleIndex4] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex4] == Endcap and modulesInGPU.moduleType[lowerModuleIndex4] == TwoS); + modules.layers()[lowerModuleIndex4] + 6 * (modules.subdets()[lowerModuleIndex4] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex4] == Endcap and modules.moduleType()[lowerModuleIndex4] == TwoS); const int layer5 = - modulesInGPU.layers[lowerModuleIndex5] + 6 * (modulesInGPU.subdets[lowerModuleIndex5] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex5] == Endcap and modulesInGPU.moduleType[lowerModuleIndex5] == TwoS); + modules.layers()[lowerModuleIndex5] + 6 * (modules.subdets()[lowerModuleIndex5] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex5] == Endcap and modules.moduleType()[lowerModuleIndex5] == TwoS); if (layer1 == 1 and layer2 == 2 and layer3 == 3) { if (layer4 == 12 and layer5 == 13) { @@ -629,7 +629,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT5RZChiSquared(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, uint16_t* lowerModuleIndices, float* rtPix, float* zPix, @@ -645,13 +645,13 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float RMSE = 0; for (size_t i = 0; i < Params_T5::kLayers; i++) { uint16_t& lowerModuleIndex = lowerModuleIndices[i]; - const int moduleType = modulesInGPU.moduleType[lowerModuleIndex]; - const int moduleSide = modulesInGPU.sides[lowerModuleIndex]; - const int moduleSubdet = modulesInGPU.subdets[lowerModuleIndex]; + const int moduleType = modules.moduleType()[lowerModuleIndex]; + const int moduleSide = modules.sides()[lowerModuleIndex]; + const int moduleSubdet = modules.subdets()[lowerModuleIndex]; residual = (moduleSubdet == Barrel) ? (zs[i] - zPix[0]) - slope * (rts[i] - rtPix[0]) : (rts[i] - rtPix[0]) - (zs[i] - zPix[0]) / slope; - const float& drdz = modulesInGPU.drdzs[lowerModuleIndex]; + const float& drdz = modules.drdzs()[lowerModuleIndex]; //PS Modules if (moduleType == 0) { error2 = kPixelPSZpitch * kPixelPSZpitch; @@ -673,7 +673,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runPixelQuintupletDefaultAlgo(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, ObjectOccupancyConst objectOccupancy, MiniDoubletsConst mds, SegmentsConst segments, @@ -697,7 +697,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { centerYTemp; if (not runPixelTripletDefaultAlgo(acc, - modulesInGPU, + modules, objectOccupancy, mds, segments, @@ -750,10 +750,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { mds.anchorRt()[fourthMDIndex], mds.anchorRt()[fifthMDIndex]}; - rzChiSquared = computePT5RZChiSquared(acc, modulesInGPU, lowerModuleIndices, rtPix, zPix, rts, zs); + rzChiSquared = computePT5RZChiSquared(acc, modules, lowerModuleIndices, rtPix, zPix, rts, zs); if (/*pixelRadius*/ 0 < 5.0f * kR1GeVf) { // FIXME: pixelRadius is not defined yet - if (not passPT5RZChiSquaredCuts(modulesInGPU, + if (not passPT5RZChiSquaredCuts(modules, lowerModuleIndex1, lowerModuleIndex2, lowerModuleIndex3, @@ -784,11 +784,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float T5CenterY = quintupletsInGPU.regressionF[quintupletIndex]; quintupletRadius = quintupletsInGPU.regressionRadius[quintupletIndex]; - rPhiChiSquared = - computePT5RPhiChiSquared(acc, modulesInGPU, lowerModuleIndices, centerX, centerY, pixelRadius, xs, ys); + rPhiChiSquared = computePT5RPhiChiSquared(acc, modules, lowerModuleIndices, centerX, centerY, pixelRadius, xs, ys); if (pixelRadius < 5.0f * kR1GeVf) { - if (not passPT5RPhiChiSquaredCuts(modulesInGPU, + if (not passPT5RPhiChiSquaredCuts(modules, lowerModuleIndex1, lowerModuleIndex2, lowerModuleIndex3, @@ -803,7 +802,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { rPhiChiSquaredInwards = computePT5RPhiChiSquaredInwards(T5CenterX, T5CenterY, quintupletRadius, xPix, yPix); if (quintupletsInGPU.regressionRadius[quintupletIndex] < 5.0f * kR1GeVf) { - if (not passPT5RPhiChiSquaredInwardsCuts(modulesInGPU, + if (not passPT5RPhiChiSquaredInwardsCuts(modules, lowerModuleIndex1, lowerModuleIndex2, lowerModuleIndex3, @@ -822,7 +821,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { struct CreatePixelQuintupletsInGPUFromMapv2 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - Modules modulesInGPU, + ModulesConst modules, + ModulesPixelConst modulesPixel, MiniDoubletsConst mds, SegmentsConst segments, SegmentsPixel segmentsPixel, @@ -843,12 +843,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { for (unsigned int iLSModule = connectedPixelIndex[i_pLS] + globalBlockIdx[0]; iLSModule < iLSModule_max; iLSModule += gridBlockExtent[0]) { //these are actual module indices - uint16_t quintupletLowerModuleIndex = modulesInGPU.connectedPixels[iLSModule]; - if (quintupletLowerModuleIndex >= *modulesInGPU.nLowerModules) + uint16_t quintupletLowerModuleIndex = modulesPixel.connectedPixels()[iLSModule]; + if (quintupletLowerModuleIndex >= modules.nLowerModules()) continue; - if (modulesInGPU.moduleType[quintupletLowerModuleIndex] == TwoS) + if (modules.moduleType()[quintupletLowerModuleIndex] == TwoS) continue; - uint16_t pixelModuleIndex = *modulesInGPU.nLowerModules; + uint16_t pixelModuleIndex = modules.nLowerModules(); if (segmentsPixel.isDup()[i_pLS]) continue; unsigned int nOuterQuintuplets = quintupletsInGPU.nQuintuplets[quintupletLowerModuleIndex]; @@ -871,7 +871,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float rzChiSquared, rPhiChiSquared, rPhiChiSquaredInwards, pixelRadius, quintupletRadius, centerX, centerY; bool success = runPixelQuintupletDefaultAlgo(acc, - modulesInGPU, + modules, objectOccupancy, mds, segments, @@ -901,7 +901,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float eta = __H2F(quintupletsInGPU.eta[quintupletIndex]); float phi = __H2F(quintupletsInGPU.phi[quintupletIndex]); - addPixelQuintupletToMemory(modulesInGPU, + addPixelQuintupletToMemory(modules, mds, segments, quintupletsInGPU, diff --git a/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h b/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h index 442a00d14f274..3c4f1d2771676 100644 --- a/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h +++ b/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h @@ -2,7 +2,7 @@ #define RecoTracker_LSTCore_src_alpaka_PixelTriplet_h #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" -#include "RecoTracker/LSTCore/interface/Module.h" +#include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h" #include "Triplet.h" @@ -15,7 +15,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runTripletDefaultAlgoPPBB(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, ObjectOccupancyConst objectOccupancy, MiniDoubletsConst mds, SegmentsConst segments, @@ -31,7 +31,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { unsigned int fourthMDIndex); template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runTripletDefaultAlgoPPEE(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, ObjectOccupancyConst objectOccupancy, MiniDoubletsConst mds, SegmentsConst segments, @@ -244,7 +244,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runPixelTrackletDefaultAlgopT3(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, ObjectOccupancyConst objectOccupancy, MiniDoubletsConst mds, SegmentsConst segments, @@ -254,8 +254,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { uint16_t outerOuterLowerModuleIndex, unsigned int innerSegmentIndex, unsigned int outerSegmentIndex) { - short outerInnerLowerModuleSubdet = modulesInGPU.subdets[outerInnerLowerModuleIndex]; - short outerOuterLowerModuleSubdet = modulesInGPU.subdets[outerOuterLowerModuleIndex]; + short outerInnerLowerModuleSubdet = modules.subdets()[outerInnerLowerModuleIndex]; + short outerOuterLowerModuleSubdet = modules.subdets()[outerOuterLowerModuleIndex]; unsigned int firstMDIndex = segments.mdIndices()[innerSegmentIndex][0]; unsigned int secondMDIndex = segments.mdIndices()[innerSegmentIndex][1]; @@ -266,7 +266,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { if (outerInnerLowerModuleSubdet == Barrel and (outerOuterLowerModuleSubdet == Barrel or outerOuterLowerModuleSubdet == Endcap)) { return runTripletDefaultAlgoPPBB(acc, - modulesInGPU, + modules, objectOccupancy, mds, segments, @@ -282,7 +282,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { fourthMDIndex); } else if (outerInnerLowerModuleSubdet == Endcap and outerOuterLowerModuleSubdet == Endcap) { return runTripletDefaultAlgoPPEE(acc, - modulesInGPU, + modules, objectOccupancy, mds, segments, @@ -300,20 +300,20 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { return false; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RZChiSquaredCuts(Modules const& modulesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RZChiSquaredCuts(ModulesConst modules, uint16_t lowerModuleIndex1, uint16_t lowerModuleIndex2, uint16_t lowerModuleIndex3, float rzChiSquared) { const int layer1 = - modulesInGPU.layers[lowerModuleIndex1] + 6 * (modulesInGPU.subdets[lowerModuleIndex1] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex1] == Endcap and modulesInGPU.moduleType[lowerModuleIndex1] == TwoS); + modules.layers()[lowerModuleIndex1] + 6 * (modules.subdets()[lowerModuleIndex1] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex1] == Endcap and modules.moduleType()[lowerModuleIndex1] == TwoS); const int layer2 = - modulesInGPU.layers[lowerModuleIndex2] + 6 * (modulesInGPU.subdets[lowerModuleIndex2] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex2] == Endcap and modulesInGPU.moduleType[lowerModuleIndex2] == TwoS); + modules.layers()[lowerModuleIndex2] + 6 * (modules.subdets()[lowerModuleIndex2] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex2] == Endcap and modules.moduleType()[lowerModuleIndex2] == TwoS); const int layer3 = - modulesInGPU.layers[lowerModuleIndex3] + 6 * (modulesInGPU.subdets[lowerModuleIndex3] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex3] == Endcap and modulesInGPU.moduleType[lowerModuleIndex3] == TwoS); + modules.layers()[lowerModuleIndex3] + 6 * (modules.subdets()[lowerModuleIndex3] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex3] == Endcap and modules.moduleType()[lowerModuleIndex3] == TwoS); if (layer1 == 8 and layer2 == 9 and layer3 == 10) { return rzChiSquared < 13.6067f; @@ -400,7 +400,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { //TODO: merge this one and the pT5 function later into a single function template ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT3RPhiChiSquared(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, uint16_t* lowerModuleIndices, float g, float f, @@ -413,11 +413,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float inv1 = kWidthPS / kWidth2S; float inv2 = kPixelPSZpitch / kWidth2S; for (size_t i = 0; i < 3; i++) { - ModuleType moduleType = modulesInGPU.moduleType[lowerModuleIndices[i]]; - short moduleSubdet = modulesInGPU.subdets[lowerModuleIndices[i]]; - short moduleSide = modulesInGPU.sides[lowerModuleIndices[i]]; - float drdz = modulesInGPU.drdzs[lowerModuleIndices[i]]; - slopes[i] = modulesInGPU.dxdys[lowerModuleIndices[i]]; + ModuleType moduleType = modules.moduleType()[lowerModuleIndices[i]]; + short moduleSubdet = modules.subdets()[lowerModuleIndices[i]]; + short moduleSide = modules.sides()[lowerModuleIndices[i]]; + float drdz = modules.drdzs()[lowerModuleIndices[i]]; + slopes[i] = modules.dxdys()[lowerModuleIndices[i]]; //category 1 - barrel PS flat if (moduleSubdet == Barrel and moduleType == PS and moduleSide == Center) { delta1[i] = inv1; @@ -481,20 +481,20 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { }; //90pc threshold - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RPhiChiSquaredCuts(Modules const& modulesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RPhiChiSquaredCuts(ModulesConst modules, uint16_t lowerModuleIndex1, uint16_t lowerModuleIndex2, uint16_t lowerModuleIndex3, float chiSquared) { const int layer1 = - modulesInGPU.layers[lowerModuleIndex1] + 6 * (modulesInGPU.subdets[lowerModuleIndex1] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex1] == Endcap and modulesInGPU.moduleType[lowerModuleIndex1] == TwoS); + modules.layers()[lowerModuleIndex1] + 6 * (modules.subdets()[lowerModuleIndex1] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex1] == Endcap and modules.moduleType()[lowerModuleIndex1] == TwoS); const int layer2 = - modulesInGPU.layers[lowerModuleIndex2] + 6 * (modulesInGPU.subdets[lowerModuleIndex2] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex2] == Endcap and modulesInGPU.moduleType[lowerModuleIndex2] == TwoS); + modules.layers()[lowerModuleIndex2] + 6 * (modules.subdets()[lowerModuleIndex2] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex2] == Endcap and modules.moduleType()[lowerModuleIndex2] == TwoS); const int layer3 = - modulesInGPU.layers[lowerModuleIndex3] + 6 * (modulesInGPU.subdets[lowerModuleIndex3] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex3] == Endcap and modulesInGPU.moduleType[lowerModuleIndex3] == TwoS); + modules.layers()[lowerModuleIndex3] + 6 * (modules.subdets()[lowerModuleIndex3] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex3] == Endcap and modules.moduleType()[lowerModuleIndex3] == TwoS); if (layer1 == 8 and layer2 == 9 and layer3 == 10) { return chiSquared < 7.003f; @@ -525,20 +525,20 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { return true; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RPhiChiSquaredInwardsCuts(Modules const& modulesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RPhiChiSquaredInwardsCuts(ModulesConst modules, uint16_t lowerModuleIndex1, uint16_t lowerModuleIndex2, uint16_t lowerModuleIndex3, float chiSquared) { const int layer1 = - modulesInGPU.layers[lowerModuleIndex1] + 6 * (modulesInGPU.subdets[lowerModuleIndex1] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex1] == Endcap and modulesInGPU.moduleType[lowerModuleIndex1] == TwoS); + modules.layers()[lowerModuleIndex1] + 6 * (modules.subdets()[lowerModuleIndex1] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex1] == Endcap and modules.moduleType()[lowerModuleIndex1] == TwoS); const int layer2 = - modulesInGPU.layers[lowerModuleIndex2] + 6 * (modulesInGPU.subdets[lowerModuleIndex2] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex2] == Endcap and modulesInGPU.moduleType[lowerModuleIndex2] == TwoS); + modules.layers()[lowerModuleIndex2] + 6 * (modules.subdets()[lowerModuleIndex2] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex2] == Endcap and modules.moduleType()[lowerModuleIndex2] == TwoS); const int layer3 = - modulesInGPU.layers[lowerModuleIndex3] + 6 * (modulesInGPU.subdets[lowerModuleIndex3] == Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex3] == Endcap and modulesInGPU.moduleType[lowerModuleIndex3] == TwoS); + modules.layers()[lowerModuleIndex3] + 6 * (modules.subdets()[lowerModuleIndex3] == Endcap) + + 5 * (modules.subdets()[lowerModuleIndex3] == Endcap and modules.moduleType()[lowerModuleIndex3] == TwoS); if (layer1 == 7 and layer2 == 8 and layer3 == 9) // endcap layer 1,2,3, ps { @@ -691,18 +691,18 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passRadiusCriterion(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, float pixelRadius, float pixelRadiusError, float tripletRadius, int16_t lowerModuleIndex, uint16_t middleModuleIndex, uint16_t upperModuleIndex) { - if (modulesInGPU.subdets[lowerModuleIndex] == Endcap) { + if (modules.subdets()[lowerModuleIndex] == Endcap) { return passRadiusCriterionEEE(acc, pixelRadius, pixelRadiusError, tripletRadius); - } else if (modulesInGPU.subdets[middleModuleIndex] == Endcap) { + } else if (modules.subdets()[middleModuleIndex] == Endcap) { return passRadiusCriterionBEE(acc, pixelRadius, pixelRadiusError, tripletRadius); - } else if (modulesInGPU.subdets[upperModuleIndex] == Endcap) { + } else if (modules.subdets()[upperModuleIndex] == Endcap) { return passRadiusCriterionBBE(acc, pixelRadius, pixelRadiusError, tripletRadius); } else { return passRadiusCriterionBBB(acc, pixelRadius, pixelRadiusError, tripletRadius); @@ -711,7 +711,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT3RZChiSquared(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, const uint16_t* lowerModuleIndices, const float* rtPix, const float* xPix, @@ -743,9 +743,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float zsi = zs[i] / 100; float rtsi = rts[i] / 100; uint16_t lowerModuleIndex = lowerModuleIndices[i]; - const int moduleType = modulesInGPU.moduleType[lowerModuleIndex]; - const int moduleSide = modulesInGPU.sides[lowerModuleIndex]; - const int moduleSubdet = modulesInGPU.subdets[lowerModuleIndex]; + const int moduleType = modules.moduleType()[lowerModuleIndex]; + const int moduleSide = modules.sides()[lowerModuleIndex]; + const int moduleSubdet = modules.subdets()[lowerModuleIndex]; // calculation is detailed documented here https://indico.cern.ch/event/1185895/contributions/4982756/attachments/2526561/4345805/helix%20pT3%20summarize.pdf float diffr, diffz; @@ -787,7 +787,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { //special dispensation to tilted PS modules! if (moduleType == 0 and moduleSubdet == Barrel and moduleSide != Center) { - float drdz = modulesInGPU.drdzs[lowerModuleIndex]; + float drdz = modules.drdzs()[lowerModuleIndex]; error2 /= (1 + drdz * drdz); } RMSE += (residual * residual) / error2; @@ -800,7 +800,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runPixelTripletDefaultAlgo(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, ObjectOccupancyConst objectOccupancy, MiniDoubletsConst mds, SegmentsConst segments, @@ -826,7 +826,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { { // pixel segment vs inner segment of the triplet if (not runPixelTrackletDefaultAlgopT3(acc, - modulesInGPU, + modules, objectOccupancy, mds, segments, @@ -840,7 +840,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { //pixel segment vs outer segment of triplet if (not runPixelTrackletDefaultAlgopT3(acc, - modulesInGPU, + modules, objectOccupancy, mds, segments, @@ -889,7 +889,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { f = tripletsInGPU.circleCenterY[tripletIndex]; if (not passRadiusCriterion(acc, - modulesInGPU, + modules, pixelRadius, pixelRadiusError, tripletRadius, @@ -911,7 +911,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float zPix[Params_pLS::kLayers] = {mds.anchorZ()[pixelInnerMDIndex], mds.anchorZ()[pixelOuterMDIndex]}; rzChiSquared = computePT3RZChiSquared(acc, - modulesInGPU, + modules, lowerModuleIndices, rtPix, xPix, @@ -926,19 +926,16 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { pixelSegmentPy, pixelSegmentPz, pixelSegmentCharge); - if (not passPT3RZChiSquaredCuts( - modulesInGPU, lowerModuleIndex, middleModuleIndex, upperModuleIndex, rzChiSquared)) + if (not passPT3RZChiSquaredCuts(modules, lowerModuleIndex, middleModuleIndex, upperModuleIndex, rzChiSquared)) return false; } else { rzChiSquared = -1; } - rPhiChiSquared = - computePT3RPhiChiSquared(acc, modulesInGPU, lowerModuleIndices, pixelG, pixelF, pixelRadiusPCA, xs, ys); + rPhiChiSquared = computePT3RPhiChiSquared(acc, modules, lowerModuleIndices, pixelG, pixelF, pixelRadiusPCA, xs, ys); if (runChiSquaredCuts and pixelSegmentPt < 5.0f) { - if (not passPT3RPhiChiSquaredCuts( - modulesInGPU, lowerModuleIndex, middleModuleIndex, upperModuleIndex, rPhiChiSquared)) + if (not passPT3RPhiChiSquaredCuts(modules, lowerModuleIndex, middleModuleIndex, upperModuleIndex, rPhiChiSquared)) return false; } @@ -948,7 +945,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { if (runChiSquaredCuts and pixelSegmentPt < 5.0f) { if (not passPT3RPhiChiSquaredInwardsCuts( - modulesInGPU, lowerModuleIndex, middleModuleIndex, upperModuleIndex, rPhiChiSquaredInwards)) + modules, lowerModuleIndex, middleModuleIndex, upperModuleIndex, rPhiChiSquaredInwards)) return false; } centerX = 0; @@ -959,7 +956,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { struct CreatePixelTripletsInGPUFromMapv2 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - Modules modulesInGPU, + ModulesConst modules, + ModulesPixelConst modulesPixel, ObjectOccupancyConst objectOccupancy, MiniDoubletsConst mds, SegmentsConst segments, @@ -980,21 +978,21 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { for (unsigned int iLSModule = connectedPixelIndex[i_pLS] + globalBlockIdx[0]; iLSModule < iLSModule_max; iLSModule += gridBlockExtent[0]) { uint16_t tripletLowerModuleIndex = - modulesInGPU - .connectedPixels[iLSModule]; //connected pixels will have the appropriate lower module index by default! + modulesPixel.connectedPixels() + [iLSModule]; //connected pixels will have the appropriate lower module index by default! #ifdef WARNINGS - if (tripletLowerModuleIndex >= *modulesInGPU.nLowerModules) { - printf("tripletLowerModuleIndex %d >= modulesInGPU.nLowerModules %d \n", + if (tripletLowerModuleIndex >= modules.nLowerModules()) { + printf("tripletLowerModuleIndex %d >= modules.nLowerModules %d \n", tripletLowerModuleIndex, - *modulesInGPU.nLowerModules); + modules.nLowerModules()); continue; //sanity check } #endif //Removes 2S-2S :FIXME: filter these out in the pixel map - if (modulesInGPU.moduleType[tripletLowerModuleIndex] == TwoS) + if (modules.moduleType()[tripletLowerModuleIndex] == TwoS) continue; - uint16_t pixelModuleIndex = *modulesInGPU.nLowerModules; + uint16_t pixelModuleIndex = modules.nLowerModules(); unsigned int nOuterTriplets = tripletsInGPU.nTriplets[tripletLowerModuleIndex]; if (nOuterTriplets == 0) continue; @@ -1007,10 +1005,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { continue; //don't make pT3s for those pixels that are part of pT5 short layer2_adjustment; - if (modulesInGPU.layers[tripletLowerModuleIndex] == 1) { + if (modules.layers()[tripletLowerModuleIndex] == 1) { layer2_adjustment = 1; } //get upper segment to be in second layer - else if (modulesInGPU.layers[tripletLowerModuleIndex] == 2) { + else if (modules.layers()[tripletLowerModuleIndex] == 2) { layer2_adjustment = 0; } // get lower segment to be in second layer else { @@ -1022,7 +1020,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { outerTripletArrayIndex += gridThreadExtent[2]) { unsigned int outerTripletIndex = objectOccupancy.tripletModuleIndices()[tripletLowerModuleIndex] + outerTripletArrayIndex; - if (modulesInGPU.moduleType[tripletsInGPU.lowerModuleIndices[3 * outerTripletIndex + 1]] == TwoS) + if (modules.moduleType()[tripletsInGPU.lowerModuleIndices[3 * outerTripletIndex + 1]] == TwoS) continue; //REMOVES PS-2S if (tripletsInGPU.partOfPT5[outerTripletIndex]) @@ -1030,7 +1028,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float pixelRadius, tripletRadius, rPhiChiSquared, rzChiSquared, rPhiChiSquaredInwards, centerX, centerY; bool success = runPixelTripletDefaultAlgo(acc, - modulesInGPU, + modules, objectOccupancy, mds, segments, @@ -1194,7 +1192,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runTripletDefaultAlgoPPBB(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, ObjectOccupancyConst objectOccupancy, MiniDoubletsConst mds, SegmentsConst segments, @@ -1210,7 +1208,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { unsigned int fourthMDIndex) { float dPhi, betaIn, betaOut, pt_beta, zLo, zHi, zLoPointed, zHiPointed, dPhiCut, betaOutCut; - bool isPS_OutLo = (modulesInGPU.moduleType[outerInnerLowerModuleIndex] == PS); + bool isPS_OutLo = (modules.moduleType()[outerInnerLowerModuleIndex] == PS); float rt_InLo = mds.anchorRt()[firstMDIndex]; float rt_InUp = mds.anchorRt()[secondMDIndex]; @@ -1316,8 +1314,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float alpha_InLo = __H2F(segments.dPhiChanges()[innerSegmentIndex]); float alpha_OutLo = __H2F(segments.dPhiChanges()[outerSegmentIndex]); - bool isEC_lastLayer = modulesInGPU.subdets[outerOuterLowerModuleIndex] == Endcap and - modulesInGPU.moduleType[outerOuterLowerModuleIndex] == TwoS; + bool isEC_lastLayer = modules.subdets()[outerOuterLowerModuleIndex] == Endcap and + modules.moduleType()[outerOuterLowerModuleIndex] == TwoS; float alpha_OutUp, alpha_OutUp_highEdge, alpha_OutUp_lowEdge; alpha_OutUp = deltaPhi(acc, x_OutUp, y_OutUp, x_OutUp - x_OutLo, y_OutUp - y_OutLo); @@ -1452,7 +1450,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runTripletDefaultAlgoPPEE(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, ObjectOccupancyConst objectOccupancy, MiniDoubletsConst mds, SegmentsConst segments, @@ -1468,7 +1466,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { unsigned int fourthMDIndex) { float dPhi, betaIn, betaOut, pt_beta, rtLo, rtHi, dPhiCut, betaOutCut; - bool isPS_OutLo = (modulesInGPU.moduleType[outerInnerLowerModuleIndex] == PS); + bool isPS_OutLo = (modules.moduleType()[outerInnerLowerModuleIndex] == PS); float z_InUp = mds.anchorZ()[secondMDIndex]; float z_OutLo = mds.anchorZ()[thirdMDIndex]; @@ -1512,7 +1510,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { const float dzDrtScale = alpaka::math::tan(acc, slope) / slope; //FIXME: need approximate value const float dLum = alpaka::math::copysign(acc, kDeltaZLum, z_InUp); - bool isOutSgInnerMDPS = modulesInGPU.moduleType[outerInnerLowerModuleIndex] == PS; + bool isOutSgInnerMDPS = modules.moduleType()[outerInnerLowerModuleIndex] == PS; const float rtGeom1 = isOutSgInnerMDPS ? kPixelPSZpitch @@ -1578,8 +1576,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float alpha_InLo = __H2F(segments.dPhiChanges()[innerSegmentIndex]); float alpha_OutLo = __H2F(segments.dPhiChanges()[outerSegmentIndex]); - bool isEC_lastLayer = modulesInGPU.subdets[outerOuterLowerModuleIndex] == Endcap and - modulesInGPU.moduleType[outerOuterLowerModuleIndex] == TwoS; + bool isEC_lastLayer = modules.subdets()[outerOuterLowerModuleIndex] == Endcap and + modules.moduleType()[outerOuterLowerModuleIndex] == TwoS; float alpha_OutUp, alpha_OutUp_highEdge, alpha_OutUp_lowEdge; diff --git a/RecoTracker/LSTCore/src/alpaka/Quintuplet.h b/RecoTracker/LSTCore/src/alpaka/Quintuplet.h index ec8f7bc339d20..c47cf2eff3da4 100644 --- a/RecoTracker/LSTCore/src/alpaka/Quintuplet.h +++ b/RecoTracker/LSTCore/src/alpaka/Quintuplet.h @@ -4,7 +4,7 @@ #include "HeterogeneousCore/AlpakaInterface/interface/workdivision.h" #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" -#include "RecoTracker/LSTCore/interface/Module.h" +#include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/EndcapGeometry.h" #include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h" @@ -232,7 +232,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } //90% constraint - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passChiSquaredConstraint(Modules const& modulesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passChiSquaredConstraint(ModulesConst modules, uint16_t lowerModuleIndex1, uint16_t lowerModuleIndex2, uint16_t lowerModuleIndex3, @@ -240,11 +240,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { uint16_t lowerModuleIndex5, float chiSquared) { // Using lstLayer numbering convention defined in ModuleMethods.h - const int layer1 = modulesInGPU.lstLayers[lowerModuleIndex1]; - const int layer2 = modulesInGPU.lstLayers[lowerModuleIndex2]; - const int layer3 = modulesInGPU.lstLayers[lowerModuleIndex3]; - const int layer4 = modulesInGPU.lstLayers[lowerModuleIndex4]; - const int layer5 = modulesInGPU.lstLayers[lowerModuleIndex5]; + const int layer1 = modules.lstLayers()[lowerModuleIndex1]; + const int layer2 = modules.lstLayers()[lowerModuleIndex2]; + const int layer3 = modules.lstLayers()[lowerModuleIndex3]; + const int layer4 = modules.lstLayers()[lowerModuleIndex4]; + const int layer5 = modules.lstLayers()[lowerModuleIndex5]; if (layer1 == 7 and layer2 == 8 and layer3 == 9) { if (layer4 == 10 and layer5 == 11) { @@ -317,7 +317,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { //bounds can be found at http://uaf-10.t2.ucsd.edu/~bsathian/SDL/T5_RZFix/t5_rz_thresholds.txt template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passT5RZConstraint(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, MiniDoubletsConst mds, unsigned int firstMDIndex, unsigned int secondMDIndex, @@ -349,18 +349,18 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { const float& z5 = mds.anchorZ()[fifthMDIndex] / 100; // Using lst_layer numbering convention defined in ModuleMethods.h - const int layer1 = modulesInGPU.lstLayers[lowerModuleIndex1]; - const int layer2 = modulesInGPU.lstLayers[lowerModuleIndex2]; - const int layer3 = modulesInGPU.lstLayers[lowerModuleIndex3]; - const int layer4 = modulesInGPU.lstLayers[lowerModuleIndex4]; - const int layer5 = modulesInGPU.lstLayers[lowerModuleIndex5]; + const int layer1 = modules.lstLayers()[lowerModuleIndex1]; + const int layer2 = modules.lstLayers()[lowerModuleIndex2]; + const int layer3 = modules.lstLayers()[lowerModuleIndex3]; + const int layer4 = modules.lstLayers()[lowerModuleIndex4]; + const int layer5 = modules.lstLayers()[lowerModuleIndex5]; //slope computed using the internal T3s - const int moduleType1 = modulesInGPU.moduleType[lowerModuleIndex1]; //0 is ps, 1 is 2s - const int moduleType2 = modulesInGPU.moduleType[lowerModuleIndex2]; - const int moduleType3 = modulesInGPU.moduleType[lowerModuleIndex3]; - const int moduleType4 = modulesInGPU.moduleType[lowerModuleIndex4]; - const int moduleType5 = modulesInGPU.moduleType[lowerModuleIndex5]; + const int moduleType1 = modules.moduleType()[lowerModuleIndex1]; //0 is ps, 1 is 2s + const int moduleType2 = modules.moduleType()[lowerModuleIndex2]; + const int moduleType3 = modules.moduleType()[lowerModuleIndex3]; + const int moduleType4 = modules.moduleType()[lowerModuleIndex4]; + const int moduleType5 = modules.moduleType()[lowerModuleIndex5]; const float& x1 = mds.anchorX()[firstMDIndex] / 100; const float& x2 = mds.anchorX()[secondMDIndex] / 100; @@ -576,14 +576,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float drdz; short side, subdets; if (i == 2) { - drdz = alpaka::math::abs(acc, modulesInGPU.drdzs[lowerModuleIndex2]); - side = modulesInGPU.sides[lowerModuleIndex2]; - subdets = modulesInGPU.subdets[lowerModuleIndex2]; + drdz = alpaka::math::abs(acc, modules.drdzs()[lowerModuleIndex2]); + side = modules.sides()[lowerModuleIndex2]; + subdets = modules.subdets()[lowerModuleIndex2]; } if (i == 3) { - drdz = alpaka::math::abs(acc, modulesInGPU.drdzs[lowerModuleIndex3]); - side = modulesInGPU.sides[lowerModuleIndex3]; - subdets = modulesInGPU.subdets[lowerModuleIndex3]; + drdz = alpaka::math::abs(acc, modules.drdzs()[lowerModuleIndex3]); + side = modules.sides()[lowerModuleIndex3]; + subdets = modules.subdets()[lowerModuleIndex3]; } if (i == 2 || i == 3) { residual = (layeri <= 6 && ((side == Center) or (drdz < 1))) ? diffz : diffr; @@ -1011,7 +1011,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE void computeSigmasForRegression(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, const uint16_t* lowerModuleIndices, float* delta1, float* delta2, @@ -1034,11 +1034,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float inv2 = kPixelPSZpitch / kWidth2S; float inv3 = kStripPSZpitch / kWidth2S; for (size_t i = 0; i < nPoints; i++) { - moduleType = modulesInGPU.moduleType[lowerModuleIndices[i]]; - moduleSubdet = modulesInGPU.subdets[lowerModuleIndices[i]]; - moduleSide = modulesInGPU.sides[lowerModuleIndices[i]]; - const float& drdz = modulesInGPU.drdzs[lowerModuleIndices[i]]; - slopes[i] = modulesInGPU.dxdys[lowerModuleIndices[i]]; + moduleType = modules.moduleType()[lowerModuleIndices[i]]; + moduleSubdet = modules.subdets()[lowerModuleIndices[i]]; + moduleSide = modules.sides()[lowerModuleIndices[i]]; + const float& drdz = modules.drdzs()[lowerModuleIndices[i]]; + slopes[i] = modules.dxdys()[lowerModuleIndices[i]]; //category 1 - barrel PS flat if (moduleSubdet == Barrel and moduleType == PS and moduleSide == Center) { delta1[i] = inv1; @@ -1341,7 +1341,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runQuintupletDefaultAlgoBBBB(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, uint16_t innerInnerLowerModuleIndex, @@ -1354,8 +1354,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { unsigned int secondMDIndex, unsigned int thirdMDIndex, unsigned int fourthMDIndex) { - bool isPS_InLo = (modulesInGPU.moduleType[innerInnerLowerModuleIndex] == PS); - bool isPS_OutLo = (modulesInGPU.moduleType[outerInnerLowerModuleIndex] == PS); + bool isPS_InLo = (modules.moduleType()[innerInnerLowerModuleIndex] == PS); + bool isPS_OutLo = (modules.moduleType()[outerInnerLowerModuleIndex] == PS); float rt_InLo = mds.anchorRt()[firstMDIndex]; float rt_InOut = mds.anchorRt()[secondMDIndex]; @@ -1433,8 +1433,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float alpha_InLo = __H2F(segments.dPhiChanges()[innerSegmentIndex]); float alpha_OutLo = __H2F(segments.dPhiChanges()[outerSegmentIndex]); - bool isEC_lastLayer = modulesInGPU.subdets[outerOuterLowerModuleIndex] == Endcap and - modulesInGPU.moduleType[outerOuterLowerModuleIndex] == TwoS; + bool isEC_lastLayer = modules.subdets()[outerOuterLowerModuleIndex] == Endcap and + modules.moduleType()[outerOuterLowerModuleIndex] == TwoS; float alpha_OutUp, alpha_OutUp_highEdge, alpha_OutUp_lowEdge; @@ -1583,7 +1583,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runQuintupletDefaultAlgoBBEE(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, uint16_t innerInnerLowerModuleIndex, @@ -1596,8 +1596,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { unsigned int secondMDIndex, unsigned int thirdMDIndex, unsigned int fourthMDIndex) { - bool isPS_InLo = (modulesInGPU.moduleType[innerInnerLowerModuleIndex] == PS); - bool isPS_OutLo = (modulesInGPU.moduleType[outerInnerLowerModuleIndex] == PS); + bool isPS_InLo = (modules.moduleType()[innerInnerLowerModuleIndex] == PS); + bool isPS_OutLo = (modules.moduleType()[outerInnerLowerModuleIndex] == PS); float rt_InLo = mds.anchorRt()[firstMDIndex]; float rt_InOut = mds.anchorRt()[secondMDIndex]; @@ -1621,7 +1621,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { return false; float dLum = alpaka::math::copysign(acc, kDeltaZLum, z_InLo); - bool isOutSgInnerMDPS = modulesInGPU.moduleType[outerInnerLowerModuleIndex] == PS; + bool isOutSgInnerMDPS = modules.moduleType()[outerInnerLowerModuleIndex] == PS; float rtGeom1 = isOutSgInnerMDPS ? kPixelPSZpitch : kStrip2SZpitch; float zGeom1 = alpaka::math::copysign(acc, zGeom, z_InLo); float rtLo = rt_InLo * (1.f + (z_OutLo - z_InLo - zGeom1) / (z_InLo + zGeom1 + dLum) / dzDrtScale) - @@ -1711,8 +1711,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float betaOutRHmin = betaOut; float betaOutRHmax = betaOut; - bool isEC_secondLayer = (modulesInGPU.subdets[innerOuterLowerModuleIndex] == Endcap) and - (modulesInGPU.moduleType[innerOuterLowerModuleIndex] == TwoS); + bool isEC_secondLayer = (modules.subdets()[innerOuterLowerModuleIndex] == Endcap) and + (modules.moduleType()[innerOuterLowerModuleIndex] == TwoS); if (isEC_secondLayer) { betaInRHmin = betaIn - sdIn_alpha_min + sdIn_alpha; @@ -1797,7 +1797,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { const float dBetaRIn2 = 0; // TODO-RH float dBetaROut = 0; - if (modulesInGPU.moduleType[outerOuterLowerModuleIndex] == TwoS) { + if (modules.moduleType()[outerOuterLowerModuleIndex] == TwoS) { dBetaROut = (alpaka::math::sqrt(acc, mds.anchorHighEdgeX()[fourthMDIndex] * mds.anchorHighEdgeX()[fourthMDIndex] + mds.anchorHighEdgeY()[fourthMDIndex] * mds.anchorHighEdgeY()[fourthMDIndex]) - @@ -1828,7 +1828,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runQuintupletDefaultAlgoEEEE(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, uint16_t innerInnerLowerModuleIndex, @@ -1860,8 +1860,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { return false; float dLum = alpaka::math::copysign(acc, kDeltaZLum, z_InLo); - bool isOutSgInnerMDPS = modulesInGPU.moduleType[outerInnerLowerModuleIndex] == PS; - bool isInSgInnerMDPS = modulesInGPU.moduleType[innerInnerLowerModuleIndex] == PS; + bool isOutSgInnerMDPS = modules.moduleType()[outerInnerLowerModuleIndex] == PS; + bool isInSgInnerMDPS = modules.moduleType()[innerInnerLowerModuleIndex] == PS; float rtGeom = (isInSgInnerMDPS and isOutSgInnerMDPS) ? 2.f * kPixelPSZpitch : (isInSgInnerMDPS or isOutSgInnerMDPS) ? kPixelPSZpitch + kStrip2SZpitch @@ -1879,7 +1879,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { if ((rtOut < rtLo) || (rtOut > rtHi)) return false; - bool isInSgOuterMDPS = modulesInGPU.moduleType[innerOuterLowerModuleIndex] == PS; + bool isInSgOuterMDPS = modules.moduleType()[innerOuterLowerModuleIndex] == PS; const float drtSDIn = rt_InOut - rt_InLo; const float dzSDIn = z_InOut - z_InLo; @@ -2053,7 +2053,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runQuintupletAlgoSelector(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, uint16_t innerInnerLowerModuleIndex, @@ -2066,15 +2066,15 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { unsigned int secondMDIndex, unsigned int thirdMDIndex, unsigned int fourthMDIndex) { - short innerInnerLowerModuleSubdet = modulesInGPU.subdets[innerInnerLowerModuleIndex]; - short innerOuterLowerModuleSubdet = modulesInGPU.subdets[innerOuterLowerModuleIndex]; - short outerInnerLowerModuleSubdet = modulesInGPU.subdets[outerInnerLowerModuleIndex]; - short outerOuterLowerModuleSubdet = modulesInGPU.subdets[outerOuterLowerModuleIndex]; + short innerInnerLowerModuleSubdet = modules.subdets()[innerInnerLowerModuleIndex]; + short innerOuterLowerModuleSubdet = modules.subdets()[innerOuterLowerModuleIndex]; + short outerInnerLowerModuleSubdet = modules.subdets()[outerInnerLowerModuleIndex]; + short outerOuterLowerModuleSubdet = modules.subdets()[outerOuterLowerModuleIndex]; if (innerInnerLowerModuleSubdet == Barrel and innerOuterLowerModuleSubdet == Barrel and outerInnerLowerModuleSubdet == Barrel and outerOuterLowerModuleSubdet == Barrel) { return runQuintupletDefaultAlgoBBBB(acc, - modulesInGPU, + modules, mds, segments, innerInnerLowerModuleIndex, @@ -2090,7 +2090,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } else if (innerInnerLowerModuleSubdet == Barrel and innerOuterLowerModuleSubdet == Barrel and outerInnerLowerModuleSubdet == Endcap and outerOuterLowerModuleSubdet == Endcap) { return runQuintupletDefaultAlgoBBEE(acc, - modulesInGPU, + modules, mds, segments, innerInnerLowerModuleIndex, @@ -2106,7 +2106,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } else if (innerInnerLowerModuleSubdet == Barrel and innerOuterLowerModuleSubdet == Barrel and outerInnerLowerModuleSubdet == Barrel and outerOuterLowerModuleSubdet == Endcap) { return runQuintupletDefaultAlgoBBBB(acc, - modulesInGPU, + modules, mds, segments, innerInnerLowerModuleIndex, @@ -2122,7 +2122,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } else if (innerInnerLowerModuleSubdet == Barrel and innerOuterLowerModuleSubdet == Endcap and outerInnerLowerModuleSubdet == Endcap and outerOuterLowerModuleSubdet == Endcap) { return runQuintupletDefaultAlgoBBEE(acc, - modulesInGPU, + modules, mds, segments, innerInnerLowerModuleIndex, @@ -2138,7 +2138,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } else if (innerInnerLowerModuleSubdet == Endcap and innerOuterLowerModuleSubdet == Endcap and outerInnerLowerModuleSubdet == Endcap and outerOuterLowerModuleSubdet == Endcap) { return runQuintupletDefaultAlgoEEEE(acc, - modulesInGPU, + modules, mds, segments, innerInnerLowerModuleIndex, @@ -2158,7 +2158,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runQuintupletDefaultAlgo(TAcc const& acc, - Modules& modulesInGPU, + ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, Triplets& tripletsInGPU, @@ -2200,7 +2200,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { unsigned int fifthMDIndex = segments.mdIndices()[fourthSegmentIndex][1]; if (not runQuintupletAlgoSelector(acc, - modulesInGPU, + modules, mds, segments, lowerModuleIndex1, @@ -2216,7 +2216,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { return false; if (not runQuintupletAlgoSelector(acc, - modulesInGPU, + modules, mds, segments, lowerModuleIndex1, @@ -2251,21 +2251,21 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float x3Vec[] = {x3, x3, x3}; float y3Vec[] = {y3, y3, y3}; - if (modulesInGPU.subdets[lowerModuleIndex1] == Endcap and modulesInGPU.moduleType[lowerModuleIndex1] == TwoS) { + if (modules.subdets()[lowerModuleIndex1] == Endcap and modules.moduleType()[lowerModuleIndex1] == TwoS) { x1Vec[1] = mds.anchorLowEdgeX()[firstMDIndex]; x1Vec[2] = mds.anchorHighEdgeX()[firstMDIndex]; y1Vec[1] = mds.anchorLowEdgeY()[firstMDIndex]; y1Vec[2] = mds.anchorHighEdgeY()[firstMDIndex]; } - if (modulesInGPU.subdets[lowerModuleIndex2] == Endcap and modulesInGPU.moduleType[lowerModuleIndex2] == TwoS) { + if (modules.subdets()[lowerModuleIndex2] == Endcap and modules.moduleType()[lowerModuleIndex2] == TwoS) { x2Vec[1] = mds.anchorLowEdgeX()[secondMDIndex]; x2Vec[2] = mds.anchorHighEdgeX()[secondMDIndex]; y2Vec[1] = mds.anchorLowEdgeY()[secondMDIndex]; y2Vec[2] = mds.anchorHighEdgeY()[secondMDIndex]; } - if (modulesInGPU.subdets[lowerModuleIndex3] == Endcap and modulesInGPU.moduleType[lowerModuleIndex3] == TwoS) { + if (modules.subdets()[lowerModuleIndex3] == Endcap and modules.moduleType()[lowerModuleIndex3] == TwoS) { x3Vec[1] = mds.anchorLowEdgeX()[thirdMDIndex]; x3Vec[2] = mds.anchorHighEdgeX()[thirdMDIndex]; @@ -2280,7 +2280,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { x1Vec[i] = x4; y1Vec[i] = y4; } - if (modulesInGPU.subdets[lowerModuleIndex4] == Endcap and modulesInGPU.moduleType[lowerModuleIndex4] == TwoS) { + if (modules.subdets()[lowerModuleIndex4] == Endcap and modules.moduleType()[lowerModuleIndex4] == TwoS) { x1Vec[1] = mds.anchorLowEdgeX()[fourthMDIndex]; x1Vec[2] = mds.anchorHighEdgeX()[fourthMDIndex]; @@ -2295,7 +2295,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { x2Vec[i] = x5; y2Vec[i] = y5; } - if (modulesInGPU.subdets[lowerModuleIndex5] == Endcap and modulesInGPU.moduleType[lowerModuleIndex5] == TwoS) { + if (modules.subdets()[lowerModuleIndex5] == Endcap and modules.moduleType()[lowerModuleIndex5] == TwoS) { x2Vec[1] = mds.anchorLowEdgeX()[fifthMDIndex]; x2Vec[2] = mds.anchorHighEdgeX()[fifthMDIndex]; @@ -2317,7 +2317,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float inner_pt = 2 * k2Rinv1GeVf * innerRadius; if (not passT5RZConstraint(acc, - modulesInGPU, + modules, mds, firstMDIndex, secondMDIndex, @@ -2344,25 +2344,21 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { //split by category bool matchedRadii; - if (modulesInGPU.subdets[lowerModuleIndex1] == Barrel and modulesInGPU.subdets[lowerModuleIndex2] == Barrel and - modulesInGPU.subdets[lowerModuleIndex3] == Barrel and modulesInGPU.subdets[lowerModuleIndex4] == Barrel and - modulesInGPU.subdets[lowerModuleIndex5] == Barrel) { + if (modules.subdets()[lowerModuleIndex1] == Barrel and modules.subdets()[lowerModuleIndex2] == Barrel and + modules.subdets()[lowerModuleIndex3] == Barrel and modules.subdets()[lowerModuleIndex4] == Barrel and + modules.subdets()[lowerModuleIndex5] == Barrel) { matchedRadii = matchRadiiBBBBB(acc, innerRadius, bridgeRadius, outerRadius); - } else if (modulesInGPU.subdets[lowerModuleIndex1] == Barrel and - modulesInGPU.subdets[lowerModuleIndex2] == Barrel and - modulesInGPU.subdets[lowerModuleIndex3] == Barrel and - modulesInGPU.subdets[lowerModuleIndex4] == Barrel and - modulesInGPU.subdets[lowerModuleIndex5] == Endcap) { + } else if (modules.subdets()[lowerModuleIndex1] == Barrel and modules.subdets()[lowerModuleIndex2] == Barrel and + modules.subdets()[lowerModuleIndex3] == Barrel and modules.subdets()[lowerModuleIndex4] == Barrel and + modules.subdets()[lowerModuleIndex5] == Endcap) { matchedRadii = matchRadiiBBBBE(acc, innerRadius, bridgeRadius, outerRadius); - } else if (modulesInGPU.subdets[lowerModuleIndex1] == Barrel and - modulesInGPU.subdets[lowerModuleIndex2] == Barrel and - modulesInGPU.subdets[lowerModuleIndex3] == Barrel and - modulesInGPU.subdets[lowerModuleIndex4] == Endcap and - modulesInGPU.subdets[lowerModuleIndex5] == Endcap) { - if (modulesInGPU.layers[lowerModuleIndex1] == 1) { + } else if (modules.subdets()[lowerModuleIndex1] == Barrel and modules.subdets()[lowerModuleIndex2] == Barrel and + modules.subdets()[lowerModuleIndex3] == Barrel and modules.subdets()[lowerModuleIndex4] == Endcap and + modules.subdets()[lowerModuleIndex5] == Endcap) { + if (modules.layers()[lowerModuleIndex1] == 1) { matchedRadii = matchRadiiBBBEE12378(acc, innerRadius, bridgeRadius, outerRadius, bridgeRadiusMin2S, bridgeRadiusMax2S); - } else if (modulesInGPU.layers[lowerModuleIndex1] == 2) { + } else if (modules.layers()[lowerModuleIndex1] == 2) { matchedRadii = matchRadiiBBBEE23478(acc, innerRadius, bridgeRadius, outerRadius, bridgeRadiusMin2S, bridgeRadiusMax2S); } else { @@ -2371,15 +2367,13 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } } - else if (modulesInGPU.subdets[lowerModuleIndex1] == Barrel and modulesInGPU.subdets[lowerModuleIndex2] == Barrel and - modulesInGPU.subdets[lowerModuleIndex3] == Endcap and modulesInGPU.subdets[lowerModuleIndex4] == Endcap and - modulesInGPU.subdets[lowerModuleIndex5] == Endcap) { + else if (modules.subdets()[lowerModuleIndex1] == Barrel and modules.subdets()[lowerModuleIndex2] == Barrel and + modules.subdets()[lowerModuleIndex3] == Endcap and modules.subdets()[lowerModuleIndex4] == Endcap and + modules.subdets()[lowerModuleIndex5] == Endcap) { matchedRadii = matchRadiiBBEEE(acc, innerRadius, bridgeRadius, outerRadius, bridgeRadiusMin2S, bridgeRadiusMax2S); - } else if (modulesInGPU.subdets[lowerModuleIndex1] == Barrel and - modulesInGPU.subdets[lowerModuleIndex2] == Endcap and - modulesInGPU.subdets[lowerModuleIndex3] == Endcap and - modulesInGPU.subdets[lowerModuleIndex4] == Endcap and - modulesInGPU.subdets[lowerModuleIndex5] == Endcap) { + } else if (modules.subdets()[lowerModuleIndex1] == Barrel and modules.subdets()[lowerModuleIndex2] == Endcap and + modules.subdets()[lowerModuleIndex3] == Endcap and modules.subdets()[lowerModuleIndex4] == Endcap and + modules.subdets()[lowerModuleIndex5] == Endcap) { matchedRadii = matchRadiiBEEEE(acc, innerRadius, bridgeRadius, @@ -2412,7 +2406,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float sigmas2[5], delta1[5], delta2[5], slopes[5]; bool isFlat[5]; - computeSigmasForRegression(acc, modulesInGPU, lowerModuleIndices, delta1, delta2, slopes, isFlat); + computeSigmasForRegression(acc, modules, lowerModuleIndices, delta1, delta2, slopes, isFlat); regressionRadius = computeRadiusUsingRegression(acc, Params_T5::kLayers, xVec, @@ -2429,7 +2423,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { #ifdef USE_T5_DNN unsigned int mdIndices[] = {firstMDIndex, secondMDIndex, thirdMDIndex, fourthMDIndex, fifthMDIndex}; float inference = t5dnn::runInference(acc, - modulesInGPU, + modules, mds, segments, tripletsInGPU, @@ -2450,7 +2444,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { #ifdef USE_RPHICHI2 // extra chi squared cuts! if (regressionRadius < 5.0f / (2.f * k2Rinv1GeVf)) { - if (not passChiSquaredConstraint(modulesInGPU, + if (not passChiSquaredConstraint(modules, lowerModuleIndex1, lowerModuleIndex2, lowerModuleIndex3, @@ -2476,7 +2470,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { mds.outerY()[fifthMDIndex]}; computeSigmasForRegression(acc, - modulesInGPU, + modules, lowerModuleIndices, nonAnchorDelta1, nonAnchorDelta2, @@ -2501,7 +2495,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { struct CreateQuintupletsInGPUv2 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - Modules modulesInGPU, + ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, Triplets tripletsInGPU, @@ -2514,7 +2508,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { for (int iter = globalThreadIdx[0]; iter < nEligibleT5Modules; iter += gridThreadExtent[0]) { uint16_t lowerModule1 = objectOccupancy.indicesOfEligibleT5Modules()[iter]; short layer2_adjustment; - int layer = modulesInGPU.layers[lowerModule1]; + int layer = modules.layers()[lowerModule1]; if (layer == 1) { layer2_adjustment = 1; } // get upper segment to be in second layer @@ -2544,7 +2538,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { bool TightCutFlag = false; bool success = runQuintupletDefaultAlgo(acc, - modulesInGPU, + modules, mds, segments, tripletsInGPU, @@ -2630,7 +2624,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { struct CreateEligibleModulesListForQuintupletsGPU { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - Modules modulesInGPU, + ModulesConst modules, Triplets tripletsInGPU, ObjectOccupancy objectOccupancy) const { // implementation is 1D with a single block @@ -2652,13 +2646,13 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { // Create variables outside of the for loop. int occupancy, category_number, eta_number; - for (int i = globalThreadIdx[0]; i < *modulesInGPU.nLowerModules; i += gridThreadExtent[0]) { + for (int i = globalThreadIdx[0]; i < modules.nLowerModules(); i += gridThreadExtent[0]) { // Condition for a quintuple to exist for a module // TCs don't exist for layers 5 and 6 barrel, and layers 2,3,4,5 endcap - short module_rings = modulesInGPU.rings[i]; - short module_layers = modulesInGPU.layers[i]; - short module_subdets = modulesInGPU.subdets[i]; - float module_eta = alpaka::math::abs(acc, modulesInGPU.eta[i]); + short module_rings = modules.rings()[i]; + short module_layers = modules.layers()[i]; + short module_subdets = modules.subdets()[i]; + float module_eta = alpaka::math::abs(acc, modules.eta()[i]); if (tripletsInGPU.nTriplets[i] == 0) continue; @@ -2734,7 +2728,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { struct AddQuintupletRangesToEventExplicit { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - Modules modulesInGPU, + ModulesConst modules, Quintuplets quintupletsInGPU, ObjectRanges ranges, ObjectOccupancyConst objectOccupancy) const { @@ -2745,7 +2739,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); - for (uint16_t i = globalThreadIdx[0]; i < *modulesInGPU.nLowerModules; i += gridThreadExtent[0]) { + for (uint16_t i = globalThreadIdx[0]; i < modules.nLowerModules(); i += gridThreadExtent[0]) { if (quintupletsInGPU.nQuintuplets[i] == 0 or objectOccupancy.quintupletModuleIndices()[i] == -1) { ranges.quintupletRanges()[i][0] = -1; ranges.quintupletRanges()[i][1] = -1; diff --git a/RecoTracker/LSTCore/src/alpaka/Segment.h b/RecoTracker/LSTCore/src/alpaka/Segment.h index 659e1b97f4bb3..56afd2d6d6d47 100644 --- a/RecoTracker/LSTCore/src/alpaka/Segment.h +++ b/RecoTracker/LSTCore/src/alpaka/Segment.h @@ -6,7 +6,7 @@ #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" #include "RecoTracker/LSTCore/interface/SegmentsSoA.h" #include "RecoTracker/LSTCore/interface/alpaka/SegmentsDeviceCollection.h" -#include "RecoTracker/LSTCore/interface/Module.h" +#include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/EndcapGeometry.h" #include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h" @@ -15,15 +15,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { - ALPAKA_FN_ACC ALPAKA_FN_INLINE float isTighterTiltedModules_seg(Modules const& modulesInGPU, - unsigned int moduleIndex) { + ALPAKA_FN_ACC ALPAKA_FN_INLINE float isTighterTiltedModules_seg(ModulesConst modules, unsigned int moduleIndex) { // The "tighter" tilted modules are the subset of tilted modules that have smaller spacing // This is the same as what was previously considered as"isNormalTiltedModules" // See Figure 9.1 of https://cds.cern.ch/record/2272264/files/CMS-TDR-014.pdf - short subdet = modulesInGPU.subdets[moduleIndex]; - short layer = modulesInGPU.layers[moduleIndex]; - short side = modulesInGPU.sides[moduleIndex]; - short rod = modulesInGPU.rods[moduleIndex]; + short subdet = modules.subdets()[moduleIndex]; + short layer = modules.layers()[moduleIndex]; + short side = modules.sides()[moduleIndex]; + short rod = modules.rods()[moduleIndex]; return (subdet == Barrel) && (((side != Center) && (layer == 3)) || ((side == NegZ) && (((layer == 2) && (rod > 5)) || ((layer == 1) && (rod > 9)))) || @@ -69,7 +68,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { return moduleSeparation; } - ALPAKA_FN_ACC ALPAKA_FN_INLINE float moduleGapSize_seg(Modules const& modulesInGPU, unsigned int moduleIndex) { + ALPAKA_FN_ACC ALPAKA_FN_INLINE float moduleGapSize_seg(ModulesConst modules, unsigned int moduleIndex) { static constexpr float miniDeltaTilted[3] = {0.26f, 0.26f, 0.26f}; static constexpr float miniDeltaFlat[6] = {0.26f, 0.16f, 0.16f, 0.18f, 0.18f, 0.18f}; static constexpr float miniDeltaLooseTilted[3] = {0.4f, 0.4f, 0.4f}; @@ -80,16 +79,16 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { {0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.18f, 0.18f, /*10*/ 0.18f, 0.18f, 0.18f, 0.18f, 0.18f}, {0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.18f, /*10*/ 0.18f, 0.18f, 0.18f, 0.18f, 0.18f}}; - unsigned int iL = modulesInGPU.layers[moduleIndex] - 1; - unsigned int iR = modulesInGPU.rings[moduleIndex] - 1; - short subdet = modulesInGPU.subdets[moduleIndex]; - short side = modulesInGPU.sides[moduleIndex]; + unsigned int iL = modules.layers()[moduleIndex] - 1; + unsigned int iR = modules.rings()[moduleIndex] - 1; + short subdet = modules.subdets()[moduleIndex]; + short side = modules.sides()[moduleIndex]; float moduleSeparation = 0; if (subdet == Barrel and side == Center) { moduleSeparation = miniDeltaFlat[iL]; - } else if (isTighterTiltedModules_seg(modulesInGPU, moduleIndex)) { + } else if (isTighterTiltedModules_seg(modules, moduleIndex)) { moduleSeparation = miniDeltaTilted[iL]; } else if (subdet == Endcap) { moduleSeparation = miniDeltaEndcap[iL][iR]; @@ -104,7 +103,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE void dAlphaThreshold(TAcc const& acc, float* dAlphaThresholdValues, - Modules const& modulesInGPU, + ModulesConst modules, MiniDoubletsConst mds, float xIn, float yIn, @@ -118,9 +117,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { uint16_t outerLowerModuleIndex, unsigned int innerMDIndex, unsigned int outerMDIndex) { - float sdMuls = (modulesInGPU.subdets[innerLowerModuleIndex] == Barrel) - ? kMiniMulsPtScaleBarrel[modulesInGPU.layers[innerLowerModuleIndex] - 1] * 3.f / ptCut - : kMiniMulsPtScaleEndcap[modulesInGPU.layers[innerLowerModuleIndex] - 1] * 3.f / ptCut; + float sdMuls = (modules.subdets()[innerLowerModuleIndex] == Barrel) + ? kMiniMulsPtScaleBarrel[modules.layers()[innerLowerModuleIndex] - 1] * 3.f / ptCut + : kMiniMulsPtScaleEndcap[modules.layers()[innerLowerModuleIndex] - 1] * 3.f / ptCut; //more accurate then outer rt - inner rt float segmentDr = alpaka::math::sqrt(acc, (yOut - yIn) * (yOut - yIn) + (xOut - xIn) * (xOut - xIn)); @@ -129,14 +128,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { alpaka::math::asin(acc, alpaka::math::min(acc, segmentDr * k2Rinv1GeVf / ptCut, kSinAlphaMax)); bool isInnerTilted = - modulesInGPU.subdets[innerLowerModuleIndex] == Barrel and modulesInGPU.sides[innerLowerModuleIndex] != Center; + modules.subdets()[innerLowerModuleIndex] == Barrel and modules.sides()[innerLowerModuleIndex] != Center; bool isOuterTilted = - modulesInGPU.subdets[outerLowerModuleIndex] == Barrel and modulesInGPU.sides[outerLowerModuleIndex] != Center; + modules.subdets()[outerLowerModuleIndex] == Barrel and modules.sides()[outerLowerModuleIndex] != Center; - float drdzInner = modulesInGPU.drdzs[innerLowerModuleIndex]; - float drdzOuter = modulesInGPU.drdzs[outerLowerModuleIndex]; - float innerModuleGapSize = moduleGapSize_seg(modulesInGPU, innerLowerModuleIndex); - float outerModuleGapSize = moduleGapSize_seg(modulesInGPU, outerLowerModuleIndex); + float drdzInner = modules.drdzs()[innerLowerModuleIndex]; + float drdzOuter = modules.drdzs()[outerLowerModuleIndex]; + float innerModuleGapSize = moduleGapSize_seg(modules, innerLowerModuleIndex); + float outerModuleGapSize = moduleGapSize_seg(modules, outerLowerModuleIndex); const float innerminiTilt2 = isInnerTilted ? ((0.5f * 0.5f) * (kPixelPSZpitch * kPixelPSZpitch) * (drdzInner * drdzInner) / (1.f + drdzInner * drdzInner) / (innerModuleGapSize * innerModuleGapSize)) @@ -152,14 +151,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float sdLumForInnerMini2; float sdLumForOuterMini2; - if (modulesInGPU.subdets[innerLowerModuleIndex] == Barrel) { + if (modules.subdets()[innerLowerModuleIndex] == Barrel) { sdLumForInnerMini2 = innerminiTilt2 * (dAlpha_Bfield * dAlpha_Bfield); } else { sdLumForInnerMini2 = (mds.dphis()[innerMDIndex] * mds.dphis()[innerMDIndex]) * (kDeltaZLum * kDeltaZLum) / (mds.dzs()[innerMDIndex] * mds.dzs()[innerMDIndex]); } - if (modulesInGPU.subdets[outerLowerModuleIndex] == Barrel) { + if (modules.subdets()[outerLowerModuleIndex] == Barrel) { sdLumForOuterMini2 = outerminiTilt2 * (dAlpha_Bfield * dAlpha_Bfield); } else { sdLumForOuterMini2 = (mds.dphis()[outerMDIndex] * mds.dphis()[outerMDIndex]) * (kDeltaZLum * kDeltaZLum) / @@ -169,21 +168,21 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { // Unique stuff for the segment dudes alone float dAlpha_res_inner = 0.02f / miniDelta * - (modulesInGPU.subdets[innerLowerModuleIndex] == Barrel ? 1.0f : alpaka::math::abs(acc, zIn) / rtIn); + (modules.subdets()[innerLowerModuleIndex] == Barrel ? 1.0f : alpaka::math::abs(acc, zIn) / rtIn); float dAlpha_res_outer = 0.02f / miniDelta * - (modulesInGPU.subdets[outerLowerModuleIndex] == Barrel ? 1.0f : alpaka::math::abs(acc, zOut) / rtOut); + (modules.subdets()[outerLowerModuleIndex] == Barrel ? 1.0f : alpaka::math::abs(acc, zOut) / rtOut); float dAlpha_res = dAlpha_res_inner + dAlpha_res_outer; - if (modulesInGPU.subdets[innerLowerModuleIndex] == Barrel and modulesInGPU.sides[innerLowerModuleIndex] == Center) { + if (modules.subdets()[innerLowerModuleIndex] == Barrel and modules.sides()[innerLowerModuleIndex] == Center) { dAlphaThresholdValues[0] = dAlpha_Bfield + alpaka::math::sqrt(acc, dAlpha_res * dAlpha_res + sdMuls * sdMuls); } else { dAlphaThresholdValues[0] = dAlpha_Bfield + alpaka::math::sqrt(acc, dAlpha_res * dAlpha_res + sdMuls * sdMuls + sdLumForInnerMini2); } - if (modulesInGPU.subdets[outerLowerModuleIndex] == Barrel and modulesInGPU.sides[outerLowerModuleIndex] == Center) { + if (modules.subdets()[outerLowerModuleIndex] == Barrel and modules.sides()[outerLowerModuleIndex] == Center) { dAlphaThresholdValues[1] = dAlpha_Bfield + alpaka::math::sqrt(acc, dAlpha_res * dAlpha_res + sdMuls * sdMuls); } else { dAlphaThresholdValues[1] = @@ -289,7 +288,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runSegmentDefaultAlgoBarrel(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, MiniDoubletsConst mds, uint16_t innerLowerModuleIndex, uint16_t outerLowerModuleIndex, @@ -301,9 +300,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float& dPhiChange, float& dPhiChangeMin, float& dPhiChangeMax) { - float sdMuls = (modulesInGPU.subdets[innerLowerModuleIndex] == Barrel) - ? kMiniMulsPtScaleBarrel[modulesInGPU.layers[innerLowerModuleIndex] - 1] * 3.f / ptCut - : kMiniMulsPtScaleEndcap[modulesInGPU.layers[innerLowerModuleIndex] - 1] * 3.f / ptCut; + float sdMuls = (modules.subdets()[innerLowerModuleIndex] == Barrel) + ? kMiniMulsPtScaleBarrel[modules.layers()[innerLowerModuleIndex] - 1] * 3.f / ptCut + : kMiniMulsPtScaleEndcap[modules.layers()[innerLowerModuleIndex] - 1] * 3.f / ptCut; float xIn, yIn, zIn, rtIn, xOut, yOut, zOut, rtOut; @@ -321,7 +320,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float sdPVoff = 0.1f / rtOut; float dzDrtScale = alpaka::math::tan(acc, sdSlope) / sdSlope; //FIXME: need appropriate value - const float zGeom = modulesInGPU.layers[innerLowerModuleIndex] <= 2 ? 2.f * kPixelPSZpitch : 2.f * kStrip2SZpitch; + const float zGeom = modules.layers()[innerLowerModuleIndex] <= 2 ? 2.f * kPixelPSZpitch : 2.f * kStrip2SZpitch; float zLo = zIn + (zIn - kDeltaZLum) * (rtOut / rtIn - 1.f) * (zIn > 0.f ? 1.f : dzDrtScale) - zGeom; //slope-correction only on outer end @@ -345,7 +344,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float dAlphaThresholdValues[3]; dAlphaThreshold(acc, dAlphaThresholdValues, - modulesInGPU, + modules, mds, xIn, yIn, @@ -379,7 +378,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runSegmentDefaultAlgoEndcap(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, MiniDoubletsConst mds, uint16_t innerLowerModuleIndex, uint16_t outerLowerModuleIndex, @@ -403,8 +402,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { zOut = mds.anchorZ()[outerMDIndex]; rtOut = mds.anchorRt()[outerMDIndex]; - bool outerLayerEndcapTwoS = (modulesInGPU.subdets[outerLowerModuleIndex] == Endcap) && - (modulesInGPU.moduleType[outerLowerModuleIndex] == TwoS); + bool outerLayerEndcapTwoS = + (modules.subdets()[outerLowerModuleIndex] == Endcap) && (modules.moduleType()[outerLowerModuleIndex] == TwoS); float sdSlope = alpaka::math::asin(acc, alpaka::math::min(acc, rtOut * k2Rinv1GeVf / ptCut, kSinAlphaMax)); float disks2SMinRadius = 60.f; @@ -459,7 +458,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float dAlphaThresholdValues[3]; dAlphaThreshold(acc, dAlphaThresholdValues, - modulesInGPU, + modules, mds, xIn, yIn, @@ -493,7 +492,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runSegmentDefaultAlgo(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, MiniDoubletsConst mds, uint16_t innerLowerModuleIndex, uint16_t outerLowerModuleIndex, @@ -505,10 +504,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float& dPhiChange, float& dPhiChangeMin, float& dPhiChangeMax) { - if (modulesInGPU.subdets[innerLowerModuleIndex] == Barrel and - modulesInGPU.subdets[outerLowerModuleIndex] == Barrel) { + if (modules.subdets()[innerLowerModuleIndex] == Barrel and modules.subdets()[outerLowerModuleIndex] == Barrel) { return runSegmentDefaultAlgoBarrel(acc, - modulesInGPU, + modules, mds, innerLowerModuleIndex, outerLowerModuleIndex, @@ -522,7 +520,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { dPhiChangeMax); } else { return runSegmentDefaultAlgoEndcap(acc, - modulesInGPU, + modules, mds, innerLowerModuleIndex, outerLowerModuleIndex, @@ -540,7 +538,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { struct CreateSegmentsInGPUv2 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - Modules modulesInGPU, + ModulesConst modules, MiniDoubletsConst mds, MiniDoubletsOccupancyConst mdsOccupancy, Segments segments, @@ -552,18 +550,17 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { auto const gridBlockExtent = alpaka::getWorkDiv(acc); auto const blockThreadExtent = alpaka::getWorkDiv(acc); - for (uint16_t innerLowerModuleIndex = globalBlockIdx[2]; innerLowerModuleIndex < (*modulesInGPU.nLowerModules); + for (uint16_t innerLowerModuleIndex = globalBlockIdx[2]; innerLowerModuleIndex < modules.nLowerModules(); innerLowerModuleIndex += gridBlockExtent[2]) { unsigned int nInnerMDs = mdsOccupancy.nMDs()[innerLowerModuleIndex]; if (nInnerMDs == 0) continue; - unsigned int nConnectedModules = modulesInGPU.nConnectedModules[innerLowerModuleIndex]; + unsigned int nConnectedModules = modules.nConnectedModules()[innerLowerModuleIndex]; for (uint16_t outerLowerModuleArrayIdx = blockThreadIdx[1]; outerLowerModuleArrayIdx < nConnectedModules; outerLowerModuleArrayIdx += blockThreadExtent[1]) { - uint16_t outerLowerModuleIndex = - modulesInGPU.moduleMap[innerLowerModuleIndex * max_connected_modules + outerLowerModuleArrayIdx]; + uint16_t outerLowerModuleIndex = modules.moduleMap()[innerLowerModuleIndex][outerLowerModuleArrayIdx]; unsigned int nOuterMDs = mdsOccupancy.nMDs()[outerLowerModuleIndex]; @@ -589,7 +586,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { dPhiChangeMin = 0; dPhiChangeMax = 0; if (runSegmentDefaultAlgo(acc, - modulesInGPU, + modules, mds, innerLowerModuleIndex, outerLowerModuleIndex, @@ -642,7 +639,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { struct CreateSegmentArrayRanges { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - Modules modulesInGPU, + ModulesConst modules, ObjectOccupancy objectOccupancy, MiniDoubletsConst mds) const { // implementation is 1D with a single block @@ -662,17 +659,17 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { // Create variables outside of the for loop. int occupancy, category_number, eta_number; - for (uint16_t i = globalThreadIdx[0]; i < *modulesInGPU.nLowerModules; i += gridThreadExtent[0]) { - if (modulesInGPU.nConnectedModules[i] == 0) { + for (uint16_t i = globalThreadIdx[0]; i < modules.nLowerModules(); i += gridThreadExtent[0]) { + if (modules.nConnectedModules()[i] == 0) { objectOccupancy.segmentModuleIndices()[i] = nTotalSegments; objectOccupancy.segmentModuleOccupancy()[i] = 0; continue; } - short module_rings = modulesInGPU.rings[i]; - short module_layers = modulesInGPU.layers[i]; - short module_subdets = modulesInGPU.subdets[i]; - float module_eta = alpaka::math::abs(acc, modulesInGPU.eta[i]); + short module_rings = modules.rings()[i]; + short module_layers = modules.layers()[i]; + short module_subdets = modules.subdets()[i]; + float module_eta = alpaka::math::abs(acc, modules.eta()[i]); if (module_layers <= 3 && module_subdets == 5) category_number = 0; @@ -737,7 +734,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { // Wait for all threads to finish before reporting final values alpaka::syncBlockThreads(acc); if (cms::alpakatools::once_per_block(acc)) { - objectOccupancy.segmentModuleIndices()[*modulesInGPU.nLowerModules] = nTotalSegments; + objectOccupancy.segmentModuleIndices()[modules.nLowerModules()] = nTotalSegments; objectOccupancy.nTotalSegs() = nTotalSegments; } } @@ -746,7 +743,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { struct AddSegmentRangesToEventExplicit { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - Modules modulesInGPU, + ModulesConst modules, SegmentsOccupancyConst segmentsOccupancy, ObjectRanges ranges, ObjectOccupancyConst objectOccupancy) const { @@ -757,7 +754,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); - for (uint16_t i = globalThreadIdx[0]; i < *modulesInGPU.nLowerModules; i += gridThreadExtent[0]) { + for (uint16_t i = globalThreadIdx[0]; i < modules.nLowerModules(); i += gridThreadExtent[0]) { if (segmentsOccupancy.nSegments()[i] == 0) { ranges.segmentRanges()[i][0] = -1; ranges.segmentRanges()[i][1] = -1; @@ -773,7 +770,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { struct AddPixelSegmentToEventKernel { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - Modules modulesInGPU, + ModulesConst modules, ObjectOccupancyConst objectOccupancy, HitsConst hits, MiniDoublets mds, @@ -797,7 +794,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { addMDToMemory(acc, mds, hits, - modulesInGPU, + modules, hitIndices0[tid], hitIndices1[tid], pixelModuleIndex, @@ -813,7 +810,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { addMDToMemory(acc, mds, hits, - modulesInGPU, + modules, hitIndices2[tid], hitIndices3[tid], pixelModuleIndex, diff --git a/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h b/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h index 1c7389bbce8a0..8064b69219eab 100644 --- a/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h +++ b/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h @@ -2,7 +2,7 @@ #define RecoTracker_LSTCore_src_alpaka_TrackCandidate_h #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" -#include "RecoTracker/LSTCore/interface/Module.h" +#include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/TrackCandidatesHostCollection.h" #include "RecoTracker/LSTCore/interface/TrackCandidatesSoA.h" #include "RecoTracker/LSTCore/interface/alpaka/TrackCandidatesDeviceCollection.h" @@ -112,7 +112,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { struct CrossCleanpT3 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - Modules modulesInGPU, + ModulesConst modules, ObjectOccupancyConst objectOccupancy, PixelTriplets pixelTripletsInGPU, SegmentsPixelConst segmentsPixel, @@ -130,7 +130,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float eta1 = __H2F(pixelTripletsInGPU.eta_pix[pixelTripletIndex]); float phi1 = __H2F(pixelTripletsInGPU.phi_pix[pixelTripletIndex]); - int pixelModuleIndex = *modulesInGPU.nLowerModules; + int pixelModuleIndex = modules.nLowerModules(); unsigned int prefix = objectOccupancy.segmentModuleIndices()[pixelModuleIndex]; unsigned int nPixelQuintuplets = *pixelQuintupletsInGPU.nPixelQuintuplets; @@ -153,7 +153,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { struct CrossCleanT5 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - Modules modulesInGPU, + ModulesConst modules, Quintuplets quintupletsInGPU, PixelQuintuplets pixelQuintupletsInGPU, PixelTriplets pixelTripletsInGPU, @@ -162,7 +162,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { auto const gridThreadExtent = alpaka::getWorkDiv(acc); for (int innerInnerInnerLowerModuleArrayIndex = globalThreadIdx[0]; - innerInnerInnerLowerModuleArrayIndex < *(modulesInGPU.nLowerModules); + innerInnerInnerLowerModuleArrayIndex < modules.nLowerModules(); innerInnerInnerLowerModuleArrayIndex += gridThreadExtent[0]) { if (objectOccupancy.quintupletModuleIndices()[innerInnerInnerLowerModuleArrayIndex] == -1) continue; @@ -208,7 +208,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { struct CrossCleanpLS { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - Modules modulesInGPU, + ModulesConst modules, ObjectOccupancyConst objectOccupancy, PixelTriplets pixelTripletsInGPU, TrackCandidates cands, @@ -221,7 +221,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); - int pixelModuleIndex = *modulesInGPU.nLowerModules; + int pixelModuleIndex = modules.nLowerModules(); unsigned int nPixels = segmentsOccupancy.nSegments()[pixelModuleIndex]; for (unsigned int pixelArrayIndex = globalThreadIdx[2]; pixelArrayIndex < nPixels; pixelArrayIndex += gridThreadExtent[2]) { diff --git a/RecoTracker/LSTCore/src/alpaka/Triplet.h b/RecoTracker/LSTCore/src/alpaka/Triplet.h index ba1fd4d1387c8..216b846195213 100644 --- a/RecoTracker/LSTCore/src/alpaka/Triplet.h +++ b/RecoTracker/LSTCore/src/alpaka/Triplet.h @@ -4,7 +4,7 @@ #include "HeterogeneousCore/AlpakaInterface/interface/workdivision.h" #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" -#include "RecoTracker/LSTCore/interface/Module.h" +#include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h" #include "Segment.h" @@ -136,7 +136,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { }; #ifdef CUT_VALUE_DEBUG - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addTripletToMemory(Modules const& modulesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void addTripletToMemory(ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, Triplets& tripletsInGPU, @@ -154,7 +154,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float circleCenterY, unsigned int tripletIndex) #else - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addTripletToMemory(Modules const& modulesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void addTripletToMemory(ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, Triplets& tripletsInGPU, @@ -181,11 +181,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { tripletsInGPU.circleCenterX[tripletIndex] = circleCenterX; tripletsInGPU.circleCenterY[tripletIndex] = circleCenterY; tripletsInGPU.logicalLayers[tripletIndex * Params_T3::kLayers] = - modulesInGPU.layers[innerInnerLowerModuleIndex] + (modulesInGPU.subdets[innerInnerLowerModuleIndex] == 4) * 6; + modules.layers()[innerInnerLowerModuleIndex] + (modules.subdets()[innerInnerLowerModuleIndex] == 4) * 6; tripletsInGPU.logicalLayers[tripletIndex * Params_T3::kLayers + 1] = - modulesInGPU.layers[middleLowerModuleIndex] + (modulesInGPU.subdets[middleLowerModuleIndex] == 4) * 6; + modules.layers()[middleLowerModuleIndex] + (modules.subdets()[middleLowerModuleIndex] == 4) * 6; tripletsInGPU.logicalLayers[tripletIndex * Params_T3::kLayers + 2] = - modulesInGPU.layers[outerOuterLowerModuleIndex] + (modulesInGPU.subdets[outerOuterLowerModuleIndex] == 4) * 6; + modules.layers()[outerOuterLowerModuleIndex] + (modules.subdets()[outerOuterLowerModuleIndex] == 4) * 6; //get the hits unsigned int firstMDIndex = segments.mdIndices()[innerSegmentIndex][0]; unsigned int secondMDIndex = segments.mdIndices()[innerSegmentIndex][1]; @@ -206,7 +206,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passRZConstraint(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, MiniDoubletsConst mds, uint16_t innerInnerLowerModuleIndex, uint16_t middleLowerModuleIndex, @@ -224,9 +224,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { const float& z3 = mds.anchorZ()[thirdMDIndex]; // Using lst_layer numbering convention defined in ModuleMethods.h - const int layer1 = modulesInGPU.lstLayers[innerInnerLowerModuleIndex]; - const int layer2 = modulesInGPU.lstLayers[middleLowerModuleIndex]; - const int layer3 = modulesInGPU.lstLayers[outerOuterLowerModuleIndex]; + const int layer1 = modules.lstLayers()[innerInnerLowerModuleIndex]; + const int layer2 = modules.lstLayers()[middleLowerModuleIndex]; + const int layer3 = modules.lstLayers()[outerOuterLowerModuleIndex]; const float residual = z2 - ((z3 - z1) / (r3 - r1) * (r2 - r1) + z1); @@ -265,7 +265,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPointingConstraintBBB(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, uint16_t innerInnerLowerModuleIndex, @@ -279,8 +279,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { unsigned int innerSegmentIndex, float& betaIn, float& betaInCut) { - bool isPSIn = (modulesInGPU.moduleType[innerInnerLowerModuleIndex] == PS); - bool isPSOut = (modulesInGPU.moduleType[outerOuterLowerModuleIndex] == PS); + bool isPSIn = (modules.moduleType()[innerInnerLowerModuleIndex] == PS); + bool isPSOut = (modules.moduleType()[outerOuterLowerModuleIndex] == PS); float rtIn = mds.anchorRt()[firstMDIndex]; float rtMid = mds.anchorRt()[secondMDIndex]; @@ -360,7 +360,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPointingConstraintBBE(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, uint16_t innerInnerLowerModuleIndex, @@ -376,8 +376,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { unsigned int outerSegmentIndex, float& betaIn, float& betaInCut) { - bool isPSIn = (modulesInGPU.moduleType[innerInnerLowerModuleIndex] == PS); - bool isPSOut = (modulesInGPU.moduleType[outerOuterLowerModuleIndex] == PS); + bool isPSIn = (modules.moduleType()[innerInnerLowerModuleIndex] == PS); + bool isPSOut = (modules.moduleType()[outerOuterLowerModuleIndex] == PS); float rtIn = mds.anchorRt()[firstMDIndex]; float rtMid = mds.anchorRt()[secondMDIndex]; @@ -400,7 +400,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { return false; float dLum = alpaka::math::copysign(acc, kDeltaZLum, zIn); - bool isOutSgInnerMDPS = modulesInGPU.moduleType[outerOuterLowerModuleIndex] == PS; + bool isOutSgInnerMDPS = modules.moduleType()[outerOuterLowerModuleIndex] == PS; float rtGeom1 = isOutSgInnerMDPS ? kPixelPSZpitch : kStrip2SZpitch; float zGeom1 = alpaka::math::copysign(acc, zGeom, zIn); float rtLo = rtIn * (1.f + (zOut - zIn - zGeom1) / (zIn + zGeom1 + dLum) / dzDrtScale) - @@ -479,7 +479,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPointingConstraintEEE(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, uint16_t innerInnerLowerModuleIndex, @@ -512,8 +512,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { return false; float dLum = alpaka::math::copysign(acc, kDeltaZLum, zIn); - bool isOutSgOuterMDPS = modulesInGPU.moduleType[outerOuterLowerModuleIndex] == PS; - bool isInSgInnerMDPS = modulesInGPU.moduleType[innerInnerLowerModuleIndex] == PS; + bool isOutSgOuterMDPS = modules.moduleType()[outerOuterLowerModuleIndex] == PS; + bool isInSgInnerMDPS = modules.moduleType()[innerInnerLowerModuleIndex] == PS; float rtGeom = (isInSgInnerMDPS and isOutSgOuterMDPS) ? 2.f * kPixelPSZpitch : (isInSgInnerMDPS or isOutSgOuterMDPS) ? kPixelPSZpitch + kStrip2SZpitch @@ -527,7 +527,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { if ((rtOut < rtLo) || (rtOut > rtHi)) return false; - bool isInSgOuterMDPS = modulesInGPU.moduleType[outerOuterLowerModuleIndex] == PS; + bool isInSgOuterMDPS = modules.moduleType()[outerOuterLowerModuleIndex] == PS; float drtSDIn = rtMid - rtIn; float dzSDIn = zMid - zIn; @@ -600,7 +600,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPointingConstraint(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, uint16_t innerInnerLowerModuleIndex, @@ -616,14 +616,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { unsigned int outerSegmentIndex, float& betaIn, float& betaInCut) { - short innerInnerLowerModuleSubdet = modulesInGPU.subdets[innerInnerLowerModuleIndex]; - short middleLowerModuleSubdet = modulesInGPU.subdets[middleLowerModuleIndex]; - short outerOuterLowerModuleSubdet = modulesInGPU.subdets[outerOuterLowerModuleIndex]; + short innerInnerLowerModuleSubdet = modules.subdets()[innerInnerLowerModuleIndex]; + short middleLowerModuleSubdet = modules.subdets()[middleLowerModuleIndex]; + short outerOuterLowerModuleSubdet = modules.subdets()[outerOuterLowerModuleIndex]; if (innerInnerLowerModuleSubdet == Barrel and middleLowerModuleSubdet == Barrel and outerOuterLowerModuleSubdet == Barrel) { return passPointingConstraintBBB(acc, - modulesInGPU, + modules, mds, segments, innerInnerLowerModuleIndex, @@ -640,7 +640,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } else if (innerInnerLowerModuleSubdet == Barrel and middleLowerModuleSubdet == Barrel and outerOuterLowerModuleSubdet == Endcap) { return passPointingConstraintBBE(acc, - modulesInGPU, + modules, mds, segments, innerInnerLowerModuleIndex, @@ -659,7 +659,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } else if (innerInnerLowerModuleSubdet == Barrel and middleLowerModuleSubdet == Endcap and outerOuterLowerModuleSubdet == Endcap) { return passPointingConstraintBBE(acc, - modulesInGPU, + modules, mds, segments, innerInnerLowerModuleIndex, @@ -681,7 +681,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { else if (innerInnerLowerModuleSubdet == Endcap and middleLowerModuleSubdet == Endcap and outerOuterLowerModuleSubdet == Endcap) { return passPointingConstraintEEE(acc, - modulesInGPU, + modules, mds, segments, innerInnerLowerModuleIndex, @@ -735,7 +735,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runTripletConstraintsAndAlgo(TAcc const& acc, - Modules const& modulesInGPU, + ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, uint16_t innerInnerLowerModuleIndex, @@ -759,7 +759,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { unsigned int thirdMDIndex = segments.mdIndices()[outerSegmentIndex][1]; if (not(passRZConstraint(acc, - modulesInGPU, + modules, mds, innerInnerLowerModuleIndex, middleLowerModuleIndex, @@ -769,7 +769,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { thirdMDIndex))) return false; if (not(passPointingConstraint(acc, - modulesInGPU, + modules, mds, segments, innerInnerLowerModuleIndex, @@ -801,7 +801,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { struct CreateTripletsInGPUv2 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - Modules modulesInGPU, + ModulesConst modules, MiniDoubletsConst mds, SegmentsConst segments, SegmentsOccupancyConst segmentsOccupancy, @@ -816,10 +816,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { for (uint16_t innerLowerModuleArrayIdx = globalThreadIdx[0]; innerLowerModuleArrayIdx < nonZeroModules; innerLowerModuleArrayIdx += gridThreadExtent[0]) { uint16_t innerInnerLowerModuleIndex = index_gpu[innerLowerModuleArrayIdx]; - if (innerInnerLowerModuleIndex >= *modulesInGPU.nLowerModules) + if (innerInnerLowerModuleIndex >= modules.nLowerModules()) continue; - uint16_t nConnectedModules = modulesInGPU.nConnectedModules[innerInnerLowerModuleIndex]; + uint16_t nConnectedModules = modules.nConnectedModules()[innerInnerLowerModuleIndex]; if (nConnectedModules == 0) continue; @@ -842,7 +842,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float zOut, rtOut, betaIn, betaInCut, circleRadius, circleCenterX, circleCenterY; bool success = runTripletConstraintsAndAlgo(acc, - modulesInGPU, + modules, mds, segments, innerInnerLowerModuleIndex, @@ -875,7 +875,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { unsigned int tripletIndex = objectOccupancy.tripletModuleIndices()[innerInnerLowerModuleIndex] + tripletModuleIndex; #ifdef CUT_VALUE_DEBUG - addTripletToMemory(modulesInGPU, + addTripletToMemory(modules, mds, segments, tripletsInGPU, @@ -893,7 +893,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { circleCenterY, tripletIndex); #else - addTripletToMemory(modulesInGPU, + addTripletToMemory(modules, mds, segments, tripletsInGPU, @@ -919,7 +919,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { struct CreateTripletArrayRanges { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - Modules modulesInGPU, + ModulesConst modules, ObjectOccupancy objectOccupancy, SegmentsOccupancyConst segmentsOccupancy) const { // implementation is 1D with a single block @@ -939,17 +939,17 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { // Create variables outside of the for loop. int occupancy, category_number, eta_number; - for (uint16_t i = globalThreadIdx[0]; i < *modulesInGPU.nLowerModules; i += gridThreadExtent[0]) { + for (uint16_t i = globalThreadIdx[0]; i < modules.nLowerModules(); i += gridThreadExtent[0]) { if (segmentsOccupancy.nSegments()[i] == 0) { objectOccupancy.tripletModuleIndices()[i] = nTotalTriplets; objectOccupancy.tripletModuleOccupancy()[i] = 0; continue; } - short module_rings = modulesInGPU.rings[i]; - short module_layers = modulesInGPU.layers[i]; - short module_subdets = modulesInGPU.subdets[i]; - float module_eta = alpaka::math::abs(acc, modulesInGPU.eta[i]); + short module_rings = modules.rings()[i]; + short module_layers = modules.layers()[i]; + short module_subdets = modules.subdets()[i]; + float module_eta = alpaka::math::abs(acc, modules.eta()[i]); if (module_layers <= 3 && module_subdets == 5) category_number = 0; @@ -1022,7 +1022,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { struct AddTripletRangesToEventExplicit { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - Modules modulesInGPU, + ModulesConst modules, Triplets tripletsInGPU, ObjectRanges ranges, ObjectOccupancyConst objectOccupancy) const { @@ -1033,7 +1033,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); - for (uint16_t i = globalThreadIdx[0]; i < *modulesInGPU.nLowerModules; i += gridThreadExtent[0]) { + for (uint16_t i = globalThreadIdx[0]; i < modules.nLowerModules(); i += gridThreadExtent[0]) { if (tripletsInGPU.nTriplets[i] == 0) { ranges.tripletRanges()[i][0] = -1; ranges.tripletRanges()[i][1] = -1; diff --git a/RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc b/RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc index 82afe0f7fa04d..def6c9810993a 100644 --- a/RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc +++ b/RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc @@ -31,8 +31,8 @@ std::vector getPixelHitsFrompLS(Event* event, unsigned int pLS) { SegmentsConst segments = event->getSegments(); MiniDoubletsConst miniDoublets = event->getMiniDoublets(); auto objectOccupancy = event->getRanges(); - Modules const* modulesEvt = event->getModules().data(); - const unsigned int pLS_offset = objectOccupancy.segmentModuleIndices()[*(modulesEvt->nLowerModules)]; + auto modulesEvt = event->getModules(); + const unsigned int pLS_offset = objectOccupancy.segmentModuleIndices()[modulesEvt.nLowerModules()]; unsigned int MD_1 = segments.mdIndices()[pLS + pLS_offset][0]; unsigned int MD_2 = segments.mdIndices()[pLS + pLS_offset][1]; unsigned int hit_1 = miniDoublets.anchorHitIndices()[MD_1]; @@ -227,8 +227,8 @@ std::tuple, std::vector> getHitIdxsAndHi unsigned int getPixelLSFrompT3(Event* event, unsigned int pT3) { PixelTriplets const* pixelTriplets = event->getPixelTriplets().data(); auto objectOccupancy = event->getRanges(); - Modules const* modulesEvt = event->getModules().data(); - const unsigned int pLS_offset = objectOccupancy.segmentModuleIndices()[*(modulesEvt->nLowerModules)]; + auto modulesEvt = event->getModules(); + const unsigned int pLS_offset = objectOccupancy.segmentModuleIndices()[modulesEvt.nLowerModules()]; return pixelTriplets->pixelSegmentIndices[pT3] - pLS_offset; } @@ -316,8 +316,8 @@ std::tuple, std::vector> getHitIdxsAndHi unsigned int getPixelLSFrompT5(Event* event, unsigned int pT5) { PixelQuintuplets const* pixelQuintuplets = event->getPixelQuintuplets().data(); auto objectOccupancy = event->getRanges(); - Modules const* modulesEvt = event->getModules().data(); - const unsigned int pLS_offset = objectOccupancy.segmentModuleIndices()[*(modulesEvt->nLowerModules)]; + auto modulesEvt = event->getModules(); + const unsigned int pLS_offset = objectOccupancy.segmentModuleIndices()[modulesEvt.nLowerModules()]; return pixelQuintuplets->pixelIndices[pT5] - pLS_offset; } diff --git a/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc b/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc index b96c8d4e82eed..c5b5c43b58cba 100644 --- a/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc +++ b/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc @@ -294,7 +294,7 @@ void setPixelQuintupletOutputBranches(Event* event) { PixelQuintuplets const* pixelQuintuplets = event->getPixelQuintuplets().data(); Quintuplets const* quintuplets = event->getQuintuplets().data(); SegmentsPixelConst segmentsPixel = event->getSegments(); - Modules const* modules = event->getModules().data(); + auto modules = event->getModules(); int n_accepted_simtrk = ana.tx->getBranch>("sim_TC_matched").size(); unsigned int nPixelQuintuplets = @@ -316,8 +316,8 @@ void setPixelQuintupletOutputBranches(Event* event) { int layer_binary = 1; int moduleType_binary = 0; for (size_t i = 0; i < module_idx.size(); i += 2) { - layer_binary |= (1 << (modules->layers[module_idx[i]] + 6 * (modules->subdets[module_idx[i]] == 4))); - moduleType_binary |= (modules->moduleType[module_idx[i]] << i); + layer_binary |= (1 << (modules.layers()[module_idx[i]] + 6 * (modules.subdets()[module_idx[i]] == 4))); + moduleType_binary |= (modules.moduleType()[module_idx[i]] << i); } std::vector simidx = matchedSimTrkIdxs(hit_idx, hit_type); ana.tx->pushbackToBranch("pT5_isFake", static_cast(simidx.size() == 0)); @@ -368,13 +368,13 @@ void setPixelQuintupletOutputBranches(Event* event) { void setQuintupletOutputBranches(Event* event) { Quintuplets const* quintuplets = event->getQuintuplets().data(); auto objectOccupancy = event->getRanges(); - Modules const* modules = event->getModules().data(); + auto modules = event->getModules(); int n_accepted_simtrk = ana.tx->getBranch>("sim_TC_matched").size(); std::vector sim_t5_matched(n_accepted_simtrk); std::vector> t5_matched_simIdx; - for (unsigned int lowerModuleIdx = 0; lowerModuleIdx < *(modules->nLowerModules); ++lowerModuleIdx) { + for (unsigned int lowerModuleIdx = 0; lowerModuleIdx < modules.nLowerModules(); ++lowerModuleIdx) { int nQuintuplets = quintuplets->nQuintuplets[lowerModuleIdx]; for (unsigned int idx = 0; idx < nQuintuplets; idx++) { unsigned int quintupletIndex = objectOccupancy.quintupletModuleIndices()[lowerModuleIdx] + idx; @@ -389,8 +389,8 @@ void setQuintupletOutputBranches(Event* event) { int layer_binary = 0; int moduleType_binary = 0; for (size_t i = 0; i < module_idx.size(); i += 2) { - layer_binary |= (1 << (modules->layers[module_idx[i]] + 6 * (modules->subdets[module_idx[i]] == 4))); - moduleType_binary |= (modules->moduleType[module_idx[i]] << i); + layer_binary |= (1 << (modules.layers()[module_idx[i]] + 6 * (modules.subdets()[module_idx[i]] == 4))); + moduleType_binary |= (modules.moduleType()[module_idx[i]] << i); } std::vector simidx = matchedSimTrkIdxs(hit_idx, hit_type); @@ -438,7 +438,7 @@ void setQuintupletOutputBranches(Event* event) { //________________________________________________________________________________________________________________________________ void setPixelTripletOutputBranches(Event* event) { PixelTriplets const* pixelTriplets = event->getPixelTriplets().data(); - Modules const* modules = event->getModules().data(); + auto modules = event->getModules(); SegmentsPixelConst segmentsPixel = event->getSegments(); int n_accepted_simtrk = ana.tx->getBranch>("sim_TC_matched").size(); @@ -461,8 +461,8 @@ void setPixelTripletOutputBranches(Event* event) { int layer_binary = 1; int moduleType_binary = 0; for (size_t i = 0; i < module_idx.size(); i += 2) { - layer_binary |= (1 << (modules->layers[module_idx[i]] + 6 * (modules->subdets[module_idx[i]] == 4))); - moduleType_binary |= (modules->moduleType[module_idx[i]] << i); + layer_binary |= (1 << (modules.layers()[module_idx[i]] + 6 * (modules.subdets()[module_idx[i]] == 4))); + moduleType_binary |= (modules.moduleType()[module_idx[i]] << i); } ana.tx->pushbackToBranch("pT3_isFake", static_cast(simidx.size() == 0)); ana.tx->pushbackToBranch("pT3_pt", pt); @@ -504,7 +504,7 @@ void setGnnNtupleBranches(Event* event) { SegmentsOccupancyConst segmentsOccupancy = event->getSegments(); MiniDoubletsOccupancyConst miniDoublets = event->getMiniDoublets(); auto hitsEvt = event->getHits(); - Modules const* modules = event->getModules().data(); + auto modules = event->getModules(); auto objectOccupancy = event->getRanges(); auto const& trackCandidates = event->getTrackCandidates().const_view(); @@ -515,7 +515,7 @@ void setGnnNtupleBranches(Event* event) { // Loop over modules (lower ones where the MDs are saved) unsigned int nTotalMD = 0; unsigned int nTotalLS = 0; - for (unsigned int idx = 0; idx < *(modules->nLowerModules); ++idx) { + for (unsigned int idx = 0; idx < modules.nLowerModules(); ++idx) { nTotalMD += miniDoublets.nMDs()[idx]; nTotalLS += segmentsOccupancy.nSegments()[idx]; } @@ -545,7 +545,7 @@ void setGnnNtupleBranches(Event* event) { // std::cout << " nTotalLS: " << nTotalLS << std::endl; // Loop over modules (lower ones where the MDs are saved) - for (unsigned int idx = 0; idx < *(modules->nLowerModules); ++idx) { + for (unsigned int idx = 0; idx < modules.nLowerModules(); ++idx) { // // Loop over minidoublets // for (unsigned int jdx = 0; jdx < miniDoublets->nMDs[idx]; jdx++) // { @@ -944,11 +944,11 @@ std::tuple, std::vectorgetModules().data(); + auto modules = event->getModules(); auto ranges = event->getRanges(); int nHits = 0; - for (unsigned int idx = 0; idx <= *(modules->nLowerModules); + for (unsigned int idx = 0; idx <= modules.nLowerModules(); idx++) // "<=" because cheating to include pixel track candidate lower module { nHits += ranges.hitRanges()[2 * idx][1] - ranges.hitRanges()[2 * idx][0] + 1; @@ -960,14 +960,14 @@ void printHitMultiplicities(Event* event) { //________________________________________________________________________________________________________________________________ void printMiniDoubletMultiplicities(Event* event) { MiniDoubletsOccupancyConst miniDoublets = event->getMiniDoublets(); - Modules const* modules = event->getModules().data(); + auto modules = event->getModules(); int nMiniDoublets = 0; int totOccupancyMiniDoublets = 0; - for (unsigned int idx = 0; idx <= *(modules->nModules); + for (unsigned int idx = 0; idx <= modules.nModules(); idx++) // "<=" because cheating to include pixel track candidate lower module { - if (modules->isLower[idx]) { + if (modules.isLower()[idx]) { nMiniDoublets += miniDoublets.nMDs()[idx]; totOccupancyMiniDoublets += miniDoublets.totOccupancyMDs()[idx]; } @@ -989,11 +989,11 @@ void printMDs(Event* event) { MiniDoubletsConst miniDoublets = event->getMiniDoublets(); MiniDoubletsOccupancyConst miniDoubletsOccupancy = event->getMiniDoublets(); auto hitsEvt = event->getHits(); - Modules const* modules = event->getModules().data(); + auto modules = event->getModules(); auto objectOccupancy = event->getRanges(); // Then obtain the lower module index - for (unsigned int idx = 0; idx <= *(modules->nLowerModules); ++idx) { + for (unsigned int idx = 0; idx <= modules.nLowerModules(); ++idx) { for (unsigned int iMD = 0; iMD < miniDoubletsOccupancy.nMDs()[idx]; iMD++) { unsigned int mdIdx = objectOccupancy.miniDoubletModuleIndices()[idx] + iMD; unsigned int LowerHitIndex = miniDoublets.anchorHitIndices()[mdIdx]; @@ -1013,11 +1013,11 @@ void printLSs(Event* event) { SegmentsOccupancyConst segmentsOccupancy = event->getSegments(); MiniDoubletsConst miniDoublets = event->getMiniDoublets(); auto hitsEvt = event->getHits(); - Modules const* modules = event->getModules().data(); + auto modules = event->getModules(); auto objectOccupancy = event->getRanges(); int nSegments = 0; - for (unsigned int i = 0; i < *(modules->nLowerModules); ++i) { + for (unsigned int i = 0; i < modules.nLowerModules(); ++i) { unsigned int idx = i; //modules->lowerModuleIndices[i]; nSegments += segmentsOccupancy.nSegments()[idx]; for (unsigned int jdx = 0; jdx < segmentsOccupancy.nSegments()[idx]; jdx++) { @@ -1046,10 +1046,10 @@ void printpLSs(Event* event) { SegmentsOccupancyConst segmentsOccupancy = event->getSegments(); MiniDoubletsConst miniDoublets = event->getMiniDoublets(); auto hitsEvt = event->getHits(); - Modules const* modules = event->getModules().data(); + auto modules = event->getModules(); auto objectOccupancy = event->getRanges(); - unsigned int i = *(modules->nLowerModules); + unsigned int i = modules.nLowerModules(); unsigned int idx = i; //modules->lowerModuleIndices[i]; int npLS = segmentsOccupancy.nSegments()[idx]; for (unsigned int jdx = 0; jdx < segmentsOccupancy.nSegments()[idx]; jdx++) { @@ -1077,9 +1077,9 @@ void printT3s(Event* event) { SegmentsConst segments = event->getSegments(); MiniDoubletsConst miniDoublets = event->getMiniDoublets(); auto hitsEvt = event->getHits(); - Modules const* modules = event->getModules().data(); + auto modules = event->getModules(); int nTriplets = 0; - for (unsigned int i = 0; i < *(modules->nLowerModules); ++i) { + for (unsigned int i = 0; i < modules.nLowerModules(); ++i) { // unsigned int idx = modules->lowerModuleIndices[i]; nTriplets += triplets->nTriplets[i]; unsigned int idx = i;