From 1bbe66374e0b720a6fb04dff563051dc9f21d27c Mon Sep 17 00:00:00 2001 From: Slava Krutelyov Date: Tue, 22 Oct 2024 06:52:37 -0700 Subject: [PATCH] migrate triplets to SoATemplate --- RecoTracker/LSTCore/interface/Constants.h | 3 + .../interface/TripletsHostCollection.h | 10 + RecoTracker/LSTCore/interface/TripletsSoA.h | 42 ++++ .../alpaka/TripletsDeviceCollection.h | 10 + RecoTracker/LSTCore/src/alpaka/Event.dev.cc | 109 +++++---- RecoTracker/LSTCore/src/alpaka/Event.h | 19 +- .../LSTCore/src/alpaka/NeuralNetwork.h | 10 +- .../LSTCore/src/alpaka/PixelQuintuplet.h | 26 +- RecoTracker/LSTCore/src/alpaka/PixelTriplet.h | 79 +++--- RecoTracker/LSTCore/src/alpaka/Quintuplet.h | 101 ++++---- .../LSTCore/src/alpaka/TrackCandidate.h | 2 - RecoTracker/LSTCore/src/alpaka/Triplet.h | 228 +++--------------- .../standalone/code/core/AccessHelper.cc | 10 +- .../standalone/code/core/write_lst_ntuple.cc | 15 +- 14 files changed, 286 insertions(+), 378 deletions(-) create mode 100644 RecoTracker/LSTCore/interface/TripletsHostCollection.h create mode 100644 RecoTracker/LSTCore/interface/TripletsSoA.h create mode 100644 RecoTracker/LSTCore/interface/alpaka/TripletsDeviceCollection.h diff --git a/RecoTracker/LSTCore/interface/Constants.h b/RecoTracker/LSTCore/interface/Constants.h index 8fe8d99aa1b29..e380e8017b973 100644 --- a/RecoTracker/LSTCore/interface/Constants.h +++ b/RecoTracker/LSTCore/interface/Constants.h @@ -97,6 +97,9 @@ namespace lst { }; struct Params_T3 { static constexpr int kLayers = 3, kHits = 6; + using ArrayU8xLayers = edm::StdArray; + using ArrayU16xLayers = edm::StdArray; + using ArrayUxHits = edm::StdArray; }; struct Params_pT3 { static constexpr int kLayers = 5, kHits = 10; diff --git a/RecoTracker/LSTCore/interface/TripletsHostCollection.h b/RecoTracker/LSTCore/interface/TripletsHostCollection.h new file mode 100644 index 0000000000000..6eaebd97e5bf6 --- /dev/null +++ b/RecoTracker/LSTCore/interface/TripletsHostCollection.h @@ -0,0 +1,10 @@ +#ifndef RecoTracker_LSTCore_interface_TripletsHostCollection_h +#define RecoTracker_LSTCore_interface_TripletsHostCollection_h + +#include "RecoTracker/LSTCore/interface/TripletsSoA.h" +#include "DataFormats/Portable/interface/PortableHostCollection.h" + +namespace lst { + using TripletsHostCollection = PortableHostMultiCollection; +} // namespace lst +#endif diff --git a/RecoTracker/LSTCore/interface/TripletsSoA.h b/RecoTracker/LSTCore/interface/TripletsSoA.h new file mode 100644 index 0000000000000..e0407ef3a0912 --- /dev/null +++ b/RecoTracker/LSTCore/interface/TripletsSoA.h @@ -0,0 +1,42 @@ +#ifndef RecoTracker_LSTCore_interface_TripletsSoA_h +#define RecoTracker_LSTCore_interface_TripletsSoA_h + +#include +#include "DataFormats/Common/interface/StdArray.h" +#include "DataFormats/SoATemplate/interface/SoALayout.h" + +#include "RecoTracker/LSTCore/interface/Constants.h" + +namespace lst { + GENERATE_SOA_LAYOUT(TripletsSoALayout, + SOA_COLUMN(ArrayUx2, segmentIndices), // inner and outer segment indices + SOA_COLUMN(Params_T3::ArrayU16xLayers, lowerModuleIndices), // lower module index in each layer + SOA_COLUMN(Params_T3::ArrayU8xLayers, logicalLayers), // layer ID + SOA_COLUMN(Params_T3::ArrayUxHits, hitIndices), // hit indices + SOA_COLUMN(FPX, betaIn), // beta/chord angle of the inner segment + SOA_COLUMN(float, centerX), // lower/anchor-hit based circle center x + SOA_COLUMN(float, centerY), // lower/anchor-hit based circle center y + SOA_COLUMN(float, radius), // lower/anchor-hit based circle radius +#ifdef CUT_VALUE_DEBUG + SOA_COLUMN(float, zOut), + SOA_COLUMN(float, rtOut), + SOA_COLUMN(float, betaInCut), +#endif + SOA_COLUMN(bool, partOfPT5), // is it used in a pT5 + SOA_COLUMN(bool, partOfT5), // is it used in a T5 + SOA_COLUMN(bool, partOfPT3)); // is it used in a pT3 + + using TripletsSoA = TripletsSoALayout<>; + using Triplets = TripletsSoA::View; + using TripletsConst = TripletsSoA::ConstView; + + GENERATE_SOA_LAYOUT(TripletsOccupancySoALayout, + SOA_COLUMN(unsigned int, nTriplets), + SOA_COLUMN(unsigned int, totOccupancyTriplets)); + + using TripletsOccupancySoA = TripletsOccupancySoALayout<>; + using TripletsOccupancy = TripletsOccupancySoA::View; + using TripletsOccupancyConst = TripletsOccupancySoA::ConstView; + +} // namespace lst +#endif diff --git a/RecoTracker/LSTCore/interface/alpaka/TripletsDeviceCollection.h b/RecoTracker/LSTCore/interface/alpaka/TripletsDeviceCollection.h new file mode 100644 index 0000000000000..ea709a7d78efd --- /dev/null +++ b/RecoTracker/LSTCore/interface/alpaka/TripletsDeviceCollection.h @@ -0,0 +1,10 @@ +#ifndef RecoTracker_LSTCore_interface_TripletsDeviceCollection_h +#define RecoTracker_LSTCore_interface_TripletsDeviceCollection_h + +#include "RecoTracker/LSTCore/interface/TripletsSoA.h" +#include "DataFormats/Portable/interface/alpaka/PortableCollection.h" + +namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { + using TripletsDeviceCollection = PortableCollection2; +} // namespace ALPAKA_ACCELERATOR_NAMESPACE::lst +#endif diff --git a/RecoTracker/LSTCore/src/alpaka/Event.dev.cc b/RecoTracker/LSTCore/src/alpaka/Event.dev.cc index dead003e4e92c..e1d3ae01793ea 100644 --- a/RecoTracker/LSTCore/src/alpaka/Event.dev.cc +++ b/RecoTracker/LSTCore/src/alpaka/Event.dev.cc @@ -2,6 +2,11 @@ #include "Event.h" +#include "MiniDoublet.h" +#include "Segment.h" +#include "TrackCandidate.h" +#include "Triplet.h" + using Device = ALPAKA_ACCELERATOR_NAMESPACE::Device; using Queue = ALPAKA_ACCELERATOR_NAMESPACE::Queue; using Acc1D = ALPAKA_ACCELERATOR_NAMESPACE::Acc1D; @@ -57,8 +62,7 @@ void Event::resetEventSync() { rangesInGPU_.reset(); rangesBuffers_.reset(); segmentsDC_.reset(); - tripletsInGPU_.reset(); - tripletsBuffers_.reset(); + tripletsDC_.reset(); quintupletsInGPU_.reset(); quintupletsBuffers_.reset(); trackCandidatesDC_.reset(); @@ -71,7 +75,7 @@ void Event::resetEventSync() { rangesInCPU_.reset(); miniDoubletsHC_.reset(); segmentsHC_.reset(); - tripletsInCPU_.reset(); + tripletsHC_.reset(); quintupletsInCPU_.reset(); pixelTripletsInCPU_.reset(); pixelQuintupletsInCPU_.reset(); @@ -419,7 +423,7 @@ void Event::createSegmentsWithModuleMap() { } void Event::createTriplets() { - if (!tripletsInGPU_) { + if (!tripletsDC_) { WorkDiv1D const createTripletArrayRanges_workDiv = createWorkDiv({1}, {1024}, {1}); alpaka::exec(queue_, @@ -435,11 +439,24 @@ void Event::createTriplets() { alpaka::memcpy(queue_, maxTriplets_buf_h, rangesBuffers_->device_nTotalTrips_buf); alpaka::wait(queue_); // wait to get the value before using it - tripletsInGPU_.emplace(); - tripletsBuffers_.emplace(*maxTriplets_buf_h.data(), nLowerModules_, devAcc_, queue_); - tripletsInGPU_->setData(*tripletsBuffers_); - - alpaka::memcpy(queue_, tripletsBuffers_->nMemoryLocations_buf, maxTriplets_buf_h); + std::array const triplets_sizes{ + {static_cast(*maxTriplets_buf_h.data()), static_cast(nLowerModules_)}}; + tripletsDC_.emplace(triplets_sizes, queue_); + + auto tripletsOccupancy = tripletsDC_->view(); + auto nTriplets_view = + alpaka::createView(devAcc_, tripletsOccupancy.nTriplets(), tripletsOccupancy.metadata().size()); + alpaka::memset(queue_, nTriplets_view, 0u); + auto totOccupancyTriplets_view = + alpaka::createView(devAcc_, tripletsOccupancy.totOccupancyTriplets(), tripletsOccupancy.metadata().size()); + alpaka::memset(queue_, totOccupancyTriplets_view, 0u); + auto triplets = tripletsDC_->view(); + auto partOfPT5_view = alpaka::createView(devAcc_, triplets.partOfPT5(), triplets.metadata().size()); + alpaka::memset(queue_, partOfPT5_view, 0u); + auto partOfT5_view = alpaka::createView(devAcc_, triplets.partOfT5(), triplets.metadata().size()); + alpaka::memset(queue_, partOfT5_view, 0u); + auto partOfPT3_view = alpaka::createView(devAcc_, triplets.partOfPT3(), triplets.metadata().size()); + alpaka::memset(queue_, partOfPT3_view, 0u); } uint16_t nonZeroModules = 0; @@ -481,17 +498,18 @@ void Event::createTriplets() { Vec3D const threadsPerBlockCreateTrip{1, 16, 16}; Vec3D const blocksPerGridCreateTrip{max_blocks, 1, 1}; - WorkDiv3D const createTripletsInGPUv2_workDiv = + WorkDiv3D const createTriplets_workDiv = createWorkDiv(blocksPerGridCreateTrip, threadsPerBlockCreateTrip, elementsPerThread); alpaka::exec(queue_, - createTripletsInGPUv2_workDiv, - CreateTripletsInGPUv2{}, + createTriplets_workDiv, + CreateTriplets{}, *modulesBuffers_.data(), miniDoubletsDC_->const_view(), segmentsDC_->const_view(), segmentsDC_->const_view(), - *tripletsInGPU_, + tripletsDC_->view(), + tripletsDC_->view(), *rangesInGPU_, index_gpu_buf.data(), nonZeroModules); @@ -502,7 +520,7 @@ void Event::createTriplets() { addTripletRangesToEventExplicit_workDiv, AddTripletRangesToEventExplicit{}, *modulesBuffers_.data(), - *tripletsInGPU_, + tripletsDC_->const_view(), *rangesInGPU_); if (addObjects_) { @@ -761,7 +779,8 @@ void Event::createPixelTriplets() { miniDoubletsDC_->const_view(), segmentsDC_->const_view(), segmentsDC_->const_view(), - *tripletsInGPU_, + tripletsDC_->view(), + tripletsDC_->const_view(), *pixelTripletsInGPU_, connectedPixelSize_dev_buf.data(), connectedPixelIndex_dev_buf.data(), @@ -794,7 +813,7 @@ void Event::createQuintuplets() { createEligibleModulesListForQuintupletsGPU_workDiv, CreateEligibleModulesListForQuintupletsGPU{}, *modulesBuffers_.data(), - *tripletsInGPU_, + tripletsDC_->const_view(), *rangesInGPU_); auto nEligibleT5Modules_buf = allocBufWrapper(cms::alpakatools::host(), 1, queue_); @@ -826,7 +845,8 @@ void Event::createQuintuplets() { *modulesBuffers_.data(), miniDoubletsDC_->const_view(), segmentsDC_->const_view(), - *tripletsInGPU_, + tripletsDC_->view(), + tripletsDC_->const_view(), *quintupletsInGPU_, *rangesInGPU_, nEligibleT5Modules); @@ -974,7 +994,7 @@ void Event::createPixelQuintuplets() { miniDoubletsDC_->const_view(), segmentsDC_->const_view(), segmentsDC_->view(), - *tripletsInGPU_, + tripletsDC_->view(), *quintupletsInGPU_, *pixelQuintupletsInGPU_, connectedPixelSize_dev_buf.data(), @@ -1110,8 +1130,10 @@ void Event::addQuintupletsToEventExplicit() { } void Event::addTripletsToEventExplicit() { + auto tripletsOccupancy = tripletsDC_->const_view(); + auto nTriplets_view = alpaka::createView(devAcc_, tripletsOccupancy.nTriplets(), nLowerModules_); auto nTripletsCPU_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); - alpaka::memcpy(queue_, nTripletsCPU_buf, tripletsBuffers_->nTriplets_buf); + alpaka::memcpy(queue_, nTripletsCPU_buf, nTriplets_view); // FIXME: replace by ES host data auto module_subdets_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); @@ -1441,43 +1463,24 @@ template SegmentsConst Event::getSegments(bool); template SegmentsOccupancyConst Event::getSegments(bool); template SegmentsPixelConst Event::getSegments(bool); -TripletsBuffer& Event::getTriplets(bool sync) { - if (!tripletsInCPU_) { - // Get nMemoryLocations parameter to initialize host based tripletsInCPU_ - auto nMemHost_buf_h = cms::alpakatools::make_host_buffer(queue_, 1u); - alpaka::memcpy(queue_, nMemHost_buf_h, tripletsBuffers_->nMemoryLocations_buf); - alpaka::wait(queue_); // wait for the value before using +template +typename TSoA::ConstView Event::getTriplets(bool sync) { + if constexpr (std::is_same_v) { + return tripletsDC_->const_view(); + } else { + if (!tripletsHC_) { + tripletsHC_.emplace( + cms::alpakatools::CopyToHost>::copyAsync( + queue_, *tripletsDC_)); - auto const nMemHost = *nMemHost_buf_h.data(); - tripletsInCPU_.emplace(nMemHost, nLowerModules_, cms::alpakatools::host(), queue_); - tripletsInCPU_->setData(*tripletsInCPU_); - - alpaka::memcpy(queue_, tripletsInCPU_->nMemoryLocations_buf, tripletsBuffers_->nMemoryLocations_buf); -#ifdef CUT_VALUE_DEBUG - alpaka::memcpy(queue_, tripletsInCPU_->zOut_buf, tripletsBuffers_->zOut_buf, nMemHost); - alpaka::memcpy(queue_, tripletsInCPU_->zLo_buf, tripletsBuffers_->zLo_buf, nMemHost); - alpaka::memcpy(queue_, tripletsInCPU_->zHi_buf, tripletsBuffers_->zHi_buf, nMemHost); - alpaka::memcpy(queue_, tripletsInCPU_->zLoPointed_buf, tripletsBuffers_->zLoPointed_buf, nMemHost); - alpaka::memcpy(queue_, tripletsInCPU_->zHiPointed_buf, tripletsBuffers_->zHiPointed_buf, nMemHost); - alpaka::memcpy(queue_, tripletsInCPU_->dPhiCut_buf, tripletsBuffers_->dPhiCut_buf, nMemHost); - alpaka::memcpy(queue_, tripletsInCPU_->betaInCut_buf, tripletsBuffers_->betaInCut_buf, nMemHost); - alpaka::memcpy(queue_, tripletsInCPU_->rtLo_buf, tripletsBuffers_->rtLo_buf, nMemHost); - alpaka::memcpy(queue_, tripletsInCPU_->rtHi_buf, tripletsBuffers_->rtHi_buf, nMemHost); -#endif - alpaka::memcpy( - queue_, tripletsInCPU_->hitIndices_buf, tripletsBuffers_->hitIndices_buf, Params_T3::kHits * nMemHost); - alpaka::memcpy( - queue_, tripletsInCPU_->logicalLayers_buf, tripletsBuffers_->logicalLayers_buf, Params_T3::kLayers * nMemHost); - alpaka::memcpy(queue_, tripletsInCPU_->segmentIndices_buf, tripletsBuffers_->segmentIndices_buf, 2 * nMemHost); - alpaka::memcpy(queue_, tripletsInCPU_->betaIn_buf, tripletsBuffers_->betaIn_buf, nMemHost); - alpaka::memcpy(queue_, tripletsInCPU_->circleRadius_buf, tripletsBuffers_->circleRadius_buf, nMemHost); - alpaka::memcpy(queue_, tripletsInCPU_->nTriplets_buf, tripletsBuffers_->nTriplets_buf); - alpaka::memcpy(queue_, tripletsInCPU_->totOccupancyTriplets_buf, tripletsBuffers_->totOccupancyTriplets_buf); - if (sync) - alpaka::wait(queue_); // host consumers expect filled data + if (sync) + alpaka::wait(queue_); // host consumers expect filled data + } } - return tripletsInCPU_.value(); + return tripletsHC_->const_view(); } +template TripletsConst Event::getTriplets(bool); +template TripletsOccupancyConst Event::getTriplets(bool); QuintupletsBuffer& Event::getQuintuplets(bool sync) { if (!quintupletsInCPU_) { diff --git a/RecoTracker/LSTCore/src/alpaka/Event.h b/RecoTracker/LSTCore/src/alpaka/Event.h index 49460c20fc48c..82a706d9d7dc4 100644 --- a/RecoTracker/LSTCore/src/alpaka/Event.h +++ b/RecoTracker/LSTCore/src/alpaka/Event.h @@ -3,20 +3,23 @@ #include +#include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h" +#include "RecoTracker/LSTCore/interface/SegmentsSoA.h" #include "RecoTracker/LSTCore/interface/TrackCandidatesHostCollection.h" +#include "RecoTracker/LSTCore/interface/TripletsHostCollection.h" #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" #include "RecoTracker/LSTCore/interface/alpaka/LST.h" +#include "RecoTracker/LSTCore/interface/alpaka/MiniDoubletsDeviceCollection.h" +#include "RecoTracker/LSTCore/interface/alpaka/SegmentsDeviceCollection.h" +#include "RecoTracker/LSTCore/interface/alpaka/TrackCandidatesDeviceCollection.h" +#include "RecoTracker/LSTCore/interface/alpaka/TripletsDeviceCollection.h" #include "RecoTracker/LSTCore/interface/Module.h" #include "Hit.h" -#include "Segment.h" -#include "Triplet.h" #include "Kernels.h" #include "Quintuplet.h" -#include "MiniDoublet.h" #include "PixelQuintuplet.h" #include "PixelTriplet.h" -#include "TrackCandidate.h" #include "HeterogeneousCore/AlpakaInterface/interface/host.h" @@ -49,8 +52,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { std::optional> hitsBuffers_; std::optional miniDoubletsDC_; std::optional segmentsDC_; - std::optional tripletsInGPU_; - std::optional> tripletsBuffers_; + std::optional tripletsDC_; std::optional quintupletsInGPU_; std::optional> quintupletsBuffers_; std::optional trackCandidatesDC_; @@ -64,7 +66,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { std::optional> hitsInCPU_; std::optional miniDoubletsHC_; std::optional segmentsHC_; - std::optional> tripletsInCPU_; + std::optional tripletsHC_; std::optional trackCandidatesHC_; std::optional> modulesInCPU_; std::optional> quintupletsInCPU_; @@ -185,7 +187,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { typename TSoA::ConstView getMiniDoublets(bool sync = true); template typename TSoA::ConstView getSegments(bool sync = true); - TripletsBuffer& getTriplets(bool sync = true); + template + typename TSoA::ConstView getTriplets(bool sync = true); QuintupletsBuffer& getQuintuplets(bool sync = true); PixelTripletsBuffer& getPixelTriplets(bool sync = true); PixelQuintupletsBuffer& getPixelQuintuplets(bool sync = true); diff --git a/RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h b/RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h index 6a125b96070cb..ff7e9d6656975 100644 --- a/RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h +++ b/RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h @@ -3,12 +3,12 @@ #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" #include "RecoTracker/LSTCore/interface/Module.h" +#include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h" +#include "RecoTracker/LSTCore/interface/SegmentsSoA.h" +#include "RecoTracker/LSTCore/interface/TripletsSoA.h" #include "NeuralNetworkWeights.h" -#include "Segment.h" -#include "MiniDoublet.h" #include "Hit.h" -#include "Triplet.h" namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { @@ -19,7 +19,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { Modules const& modulesInGPU, MiniDoubletsConst mds, SegmentsConst segments, - Triplets const& tripletsInGPU, + TripletsConst triplets, const float* xVec, const float* yVec, const unsigned int* mdIndices, @@ -59,7 +59,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { 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]; + segments.mdIndices()[triplets.segmentIndices()[innerTripletIndex][0]][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 diff --git a/RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h b/RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h index d33022cd112b1..5121819f15465 100644 --- a/RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h +++ b/RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h @@ -677,7 +677,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { MiniDoubletsConst mds, SegmentsConst segments, SegmentsPixelConst segmentsPixel, - Triplets const& tripletsInGPU, + TripletsConst triplets, Quintuplets const& quintupletsInGPU, unsigned int pixelSegmentIndex, unsigned int quintupletIndex, @@ -689,8 +689,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float& centerX, float& centerY, unsigned int pixelSegmentArrayIndex) { - unsigned int T5InnerT3Index = quintupletsInGPU.tripletIndices[2 * quintupletIndex]; - unsigned int T5OuterT3Index = quintupletsInGPU.tripletIndices[2 * quintupletIndex + 1]; + unsigned int t5InnerT3Index = quintupletsInGPU.tripletIndices[2 * quintupletIndex]; + unsigned int t5OuterT3Index = quintupletsInGPU.tripletIndices[2 * quintupletIndex + 1]; float pixelRadiusTemp, tripletRadius, rPhiChiSquaredTemp, rzChiSquaredTemp, rPhiChiSquaredInwardsTemp, centerXTemp, centerYTemp; @@ -701,9 +701,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { mds, segments, segmentsPixel, - tripletsInGPU, + triplets, pixelSegmentIndex, - T5InnerT3Index, + t5InnerT3Index, pixelRadiusTemp, tripletRadius, centerXTemp, @@ -714,10 +714,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { false)) return false; - unsigned int firstSegmentIndex = tripletsInGPU.segmentIndices[2 * T5InnerT3Index]; - unsigned int secondSegmentIndex = tripletsInGPU.segmentIndices[2 * T5InnerT3Index + 1]; - unsigned int thirdSegmentIndex = tripletsInGPU.segmentIndices[2 * T5OuterT3Index]; - unsigned int fourthSegmentIndex = tripletsInGPU.segmentIndices[2 * T5OuterT3Index + 1]; + unsigned int firstSegmentIndex = triplets.segmentIndices()[t5InnerT3Index][0]; + unsigned int secondSegmentIndex = triplets.segmentIndices()[t5InnerT3Index][1]; + unsigned int thirdSegmentIndex = triplets.segmentIndices()[t5OuterT3Index][0]; + unsigned int fourthSegmentIndex = triplets.segmentIndices()[t5OuterT3Index][1]; unsigned int pixelInnerMDIndex = segments.mdIndices()[pixelSegmentIndex][0]; unsigned int pixelOuterMDIndex = segments.mdIndices()[pixelSegmentIndex][1]; @@ -825,7 +825,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { MiniDoubletsConst mds, SegmentsConst segments, SegmentsPixel segmentsPixel, - Triplets tripletsInGPU, + Triplets triplets, Quintuplets quintupletsInGPU, PixelQuintuplets pixelQuintupletsInGPU, unsigned int* connectedPixelSize, @@ -875,7 +875,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { mds, segments, segmentsPixel, - tripletsInGPU, + triplets, quintupletsInGPU, pixelSegmentIndex, quintupletIndex, @@ -919,8 +919,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { centerX, centerY); - tripletsInGPU.partOfPT5[quintupletsInGPU.tripletIndices[2 * quintupletIndex]] = true; - tripletsInGPU.partOfPT5[quintupletsInGPU.tripletIndices[2 * quintupletIndex + 1]] = true; + triplets.partOfPT5()[quintupletsInGPU.tripletIndices[2 * quintupletIndex]] = true; + triplets.partOfPT5()[quintupletsInGPU.tripletIndices[2 * quintupletIndex + 1]] = true; segmentsPixel.partOfPT5()[i_pLS] = true; quintupletsInGPU.partOfPT5[quintupletIndex] = true; } // tot occupancy diff --git a/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h b/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h index 1401aefdf797d..d83e4ff352ec8 100644 --- a/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h +++ b/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h @@ -131,7 +131,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { ALPAKA_FN_ACC ALPAKA_FN_INLINE void addPixelTripletToMemory(MiniDoubletsConst mds, SegmentsConst segments, - Triplets const& tripletsInGPU, + TripletsConst triplets, PixelTriplets& pixelTripletsInGPU, unsigned int pixelSegmentIndex, unsigned int tripletIndex, @@ -166,22 +166,22 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { pixelTripletsInGPU.logicalLayers[Params_pT3::kLayers * pixelTripletIndex] = 0; pixelTripletsInGPU.logicalLayers[Params_pT3::kLayers * pixelTripletIndex + 1] = 0; pixelTripletsInGPU.logicalLayers[Params_pT3::kLayers * pixelTripletIndex + 2] = - tripletsInGPU.logicalLayers[tripletIndex * Params_T3::kLayers]; + triplets.logicalLayers()[tripletIndex][0]; pixelTripletsInGPU.logicalLayers[Params_pT3::kLayers * pixelTripletIndex + 3] = - tripletsInGPU.logicalLayers[tripletIndex * Params_T3::kLayers + 1]; + triplets.logicalLayers()[tripletIndex][1]; pixelTripletsInGPU.logicalLayers[Params_pT3::kLayers * pixelTripletIndex + 4] = - tripletsInGPU.logicalLayers[tripletIndex * Params_T3::kLayers + 2]; + triplets.logicalLayers()[tripletIndex][2]; pixelTripletsInGPU.lowerModuleIndices[Params_pT3::kLayers * pixelTripletIndex] = segments.innerLowerModuleIndices()[pixelSegmentIndex]; pixelTripletsInGPU.lowerModuleIndices[Params_pT3::kLayers * pixelTripletIndex + 1] = segments.outerLowerModuleIndices()[pixelSegmentIndex]; pixelTripletsInGPU.lowerModuleIndices[Params_pT3::kLayers * pixelTripletIndex + 2] = - tripletsInGPU.lowerModuleIndices[Params_T3::kLayers * tripletIndex]; + triplets.lowerModuleIndices()[tripletIndex][0]; pixelTripletsInGPU.lowerModuleIndices[Params_pT3::kLayers * pixelTripletIndex + 3] = - tripletsInGPU.lowerModuleIndices[Params_T3::kLayers * tripletIndex + 1]; + triplets.lowerModuleIndices()[tripletIndex][1]; pixelTripletsInGPU.lowerModuleIndices[Params_pT3::kLayers * pixelTripletIndex + 4] = - tripletsInGPU.lowerModuleIndices[Params_T3::kLayers * tripletIndex + 2]; + triplets.lowerModuleIndices()[tripletIndex][2]; unsigned int pixelInnerMD = segments.mdIndices()[pixelSegmentIndex][0]; unsigned int pixelOuterMD = segments.mdIndices()[pixelSegmentIndex][1]; @@ -191,18 +191,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 2] = mds.anchorHitIndices()[pixelOuterMD]; pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 3] = mds.outerHitIndices()[pixelOuterMD]; - pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 4] = - tripletsInGPU.hitIndices[Params_T3::kHits * tripletIndex]; - pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 5] = - tripletsInGPU.hitIndices[Params_T3::kHits * tripletIndex + 1]; - pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 6] = - tripletsInGPU.hitIndices[Params_T3::kHits * tripletIndex + 2]; - pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 7] = - tripletsInGPU.hitIndices[Params_T3::kHits * tripletIndex + 3]; - pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 8] = - tripletsInGPU.hitIndices[Params_T3::kHits * tripletIndex + 4]; - pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 9] = - tripletsInGPU.hitIndices[Params_T3::kHits * tripletIndex + 5]; + pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 4] = triplets.hitIndices()[tripletIndex][0]; + pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 5] = triplets.hitIndices()[tripletIndex][1]; + pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 6] = triplets.hitIndices()[tripletIndex][2]; + pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 7] = triplets.hitIndices()[tripletIndex][3]; + pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 8] = triplets.hitIndices()[tripletIndex][4]; + pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 9] = triplets.hitIndices()[tripletIndex][5]; pixelTripletsInGPU.rPhiChiSquared[pixelTripletIndex] = rPhiChiSquared; pixelTripletsInGPU.rPhiChiSquaredInwards[pixelTripletIndex] = rPhiChiSquaredInwards; pixelTripletsInGPU.rzChiSquared[pixelTripletIndex] = rzChiSquared; @@ -771,7 +765,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { MiniDoubletsConst mds, SegmentsConst segments, SegmentsPixelConst segmentsPixel, - Triplets const& tripletsInGPU, + TripletsConst triplets, unsigned int pixelSegmentIndex, unsigned int tripletIndex, float& pixelRadius, @@ -785,9 +779,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { //run pT4 compatibility between the pixel segment and inner segment, and between the pixel and outer segment of the triplet uint16_t pixelModuleIndex = segments.innerLowerModuleIndices()[pixelSegmentIndex]; - uint16_t lowerModuleIndex = tripletsInGPU.lowerModuleIndices[Params_T3::kLayers * tripletIndex]; - uint16_t middleModuleIndex = tripletsInGPU.lowerModuleIndices[Params_T3::kLayers * tripletIndex + 1]; - uint16_t upperModuleIndex = tripletsInGPU.lowerModuleIndices[Params_T3::kLayers * tripletIndex + 2]; + uint16_t lowerModuleIndex = triplets.lowerModuleIndices()[tripletIndex][0]; + uint16_t middleModuleIndex = triplets.lowerModuleIndices()[tripletIndex][1]; + uint16_t upperModuleIndex = triplets.lowerModuleIndices()[tripletIndex][2]; { // pixel segment vs inner segment of the triplet @@ -801,7 +795,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { lowerModuleIndex, middleModuleIndex, pixelSegmentIndex, - tripletsInGPU.segmentIndices[Params_LS::kLayers * tripletIndex])) + triplets.segmentIndices()[tripletIndex][0])) return false; //pixel segment vs outer segment of triplet @@ -815,7 +809,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { middleModuleIndex, upperModuleIndex, pixelSegmentIndex, - tripletsInGPU.segmentIndices[Params_LS::kLayers * tripletIndex + 1])) + triplets.segmentIndices()[tripletIndex][1])) return false; } @@ -837,8 +831,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { pixelRadius = pixelSegmentPt * kR1GeVf; float pixelRadiusError = pixelSegmentPtError * kR1GeVf; - unsigned int tripletInnerSegmentIndex = tripletsInGPU.segmentIndices[2 * tripletIndex]; - unsigned int tripletOuterSegmentIndex = tripletsInGPU.segmentIndices[2 * tripletIndex + 1]; + unsigned int tripletInnerSegmentIndex = triplets.segmentIndices()[tripletIndex][0]; + unsigned int tripletOuterSegmentIndex = triplets.segmentIndices()[tripletIndex][1]; unsigned int firstMDIndex = segments.mdIndices()[tripletInnerSegmentIndex][0]; unsigned int secondMDIndex = segments.mdIndices()[tripletInnerSegmentIndex][1]; @@ -850,9 +844,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { mds.anchorY()[firstMDIndex], mds.anchorY()[secondMDIndex], mds.anchorY()[thirdMDIndex]}; float g, f; - tripletRadius = tripletsInGPU.circleRadius[tripletIndex]; - g = tripletsInGPU.circleCenterX[tripletIndex]; - f = tripletsInGPU.circleCenterY[tripletIndex]; + tripletRadius = triplets.radius()[tripletIndex]; + g = triplets.centerX()[tripletIndex]; + f = triplets.centerY()[tripletIndex]; if (not passRadiusCriterion(acc, modulesInGPU, @@ -930,7 +924,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { MiniDoubletsConst mds, SegmentsConst segments, SegmentsPixelConst segmentsPixel, - Triplets tripletsInGPU, + Triplets triplets, + TripletsOccupancyConst tripletsOccupancy, PixelTriplets pixelTripletsInGPU, unsigned int* connectedPixelSize, unsigned int* connectedPixelIndex, @@ -961,7 +956,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { continue; uint16_t pixelModuleIndex = *modulesInGPU.nLowerModules; - unsigned int nOuterTriplets = tripletsInGPU.nTriplets[tripletLowerModuleIndex]; + unsigned int nOuterTriplets = tripletsOccupancy.nTriplets()[tripletLowerModuleIndex]; if (nOuterTriplets == 0) continue; @@ -988,10 +983,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { outerTripletArrayIndex += gridThreadExtent[2]) { unsigned int outerTripletIndex = rangesInGPU.tripletModuleIndices[tripletLowerModuleIndex] + outerTripletArrayIndex; - if (modulesInGPU.moduleType[tripletsInGPU.lowerModuleIndices[3 * outerTripletIndex + 1]] == TwoS) + if (modulesInGPU.moduleType[triplets.lowerModuleIndices()[outerTripletIndex][1]] == TwoS) continue; //REMOVES PS-2S - if (tripletsInGPU.partOfPT5[outerTripletIndex]) + if (triplets.partOfPT5()[outerTripletIndex]) continue; //don't create pT3s for T3s accounted in pT5s float pixelRadius, tripletRadius, rPhiChiSquared, rzChiSquared, rPhiChiSquaredInwards, centerX, centerY; @@ -1001,7 +996,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { mds, segments, segmentsPixel, - tripletsInGPU, + triplets, pixelSegmentIndex, outerTripletIndex, pixelRadius, @@ -1013,10 +1008,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { rPhiChiSquaredInwards); if (success) { - float phi = mds.anchorPhi()[segments.mdIndices()[tripletsInGPU.segmentIndices[2 * outerTripletIndex]] - [layer2_adjustment]]; - float eta = mds.anchorEta()[segments.mdIndices()[tripletsInGPU.segmentIndices[2 * outerTripletIndex]] - [layer2_adjustment]]; + float phi = + mds.anchorPhi()[segments + .mdIndices()[triplets.segmentIndices()[outerTripletIndex][0]][layer2_adjustment]]; + float eta = + mds.anchorEta()[segments + .mdIndices()[triplets.segmentIndices()[outerTripletIndex][0]][layer2_adjustment]]; float eta_pix = segmentsPixel.eta()[i_pLS]; float phi_pix = segmentsPixel.phi()[i_pLS]; float pt = segmentsPixel.ptIn()[i_pLS]; @@ -1032,7 +1029,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { alpaka::atomicAdd(acc, pixelTripletsInGPU.nPixelTriplets, 1u, alpaka::hierarchy::Threads{}); addPixelTripletToMemory(mds, segments, - tripletsInGPU, + triplets, pixelTripletsInGPU, pixelSegmentIndex, outerTripletIndex, @@ -1050,7 +1047,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { eta_pix, phi_pix, score); - tripletsInGPU.partOfPT3[outerTripletIndex] = true; + triplets.partOfPT3()[outerTripletIndex] = true; } } } // for outerTripletArrayIndex diff --git a/RecoTracker/LSTCore/src/alpaka/Quintuplet.h b/RecoTracker/LSTCore/src/alpaka/Quintuplet.h index 1d506c11c3d63..cd9ce9496397b 100644 --- a/RecoTracker/LSTCore/src/alpaka/Quintuplet.h +++ b/RecoTracker/LSTCore/src/alpaka/Quintuplet.h @@ -149,7 +149,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { return ((firstMin <= secondMin) && (secondMin < firstMax)) || ((secondMin < firstMin) && (firstMin < secondMax)); } - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addQuintupletToMemory(Triplets const& tripletsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void addQuintupletToMemory(TripletsConst triplets, Quintuplets& quintupletsInGPU, unsigned int innerTripletIndex, unsigned int outerTripletIndex, @@ -195,36 +195,26 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { quintupletsInGPU.regressionG[quintupletIndex] = regressionG; quintupletsInGPU.regressionF[quintupletIndex] = regressionF; quintupletsInGPU.logicalLayers[Params_T5::kLayers * quintupletIndex] = - tripletsInGPU.logicalLayers[Params_T3::kLayers * innerTripletIndex]; + triplets.logicalLayers()[innerTripletIndex][0]; quintupletsInGPU.logicalLayers[Params_T5::kLayers * quintupletIndex + 1] = - tripletsInGPU.logicalLayers[Params_T3::kLayers * innerTripletIndex + 1]; + triplets.logicalLayers()[innerTripletIndex][1]; quintupletsInGPU.logicalLayers[Params_T5::kLayers * quintupletIndex + 2] = - tripletsInGPU.logicalLayers[Params_T3::kLayers * innerTripletIndex + 2]; + triplets.logicalLayers()[innerTripletIndex][2]; quintupletsInGPU.logicalLayers[Params_T5::kLayers * quintupletIndex + 3] = - tripletsInGPU.logicalLayers[Params_T3::kLayers * outerTripletIndex + 1]; + triplets.logicalLayers()[outerTripletIndex][1]; quintupletsInGPU.logicalLayers[Params_T5::kLayers * quintupletIndex + 4] = - tripletsInGPU.logicalLayers[Params_T3::kLayers * outerTripletIndex + 2]; - - quintupletsInGPU.hitIndices[Params_T5::kHits * quintupletIndex] = - tripletsInGPU.hitIndices[Params_T3::kHits * innerTripletIndex]; - quintupletsInGPU.hitIndices[Params_T5::kHits * quintupletIndex + 1] = - tripletsInGPU.hitIndices[Params_T3::kHits * innerTripletIndex + 1]; - quintupletsInGPU.hitIndices[Params_T5::kHits * quintupletIndex + 2] = - tripletsInGPU.hitIndices[Params_T3::kHits * innerTripletIndex + 2]; - quintupletsInGPU.hitIndices[Params_T5::kHits * quintupletIndex + 3] = - tripletsInGPU.hitIndices[Params_T3::kHits * innerTripletIndex + 3]; - quintupletsInGPU.hitIndices[Params_T5::kHits * quintupletIndex + 4] = - tripletsInGPU.hitIndices[Params_T3::kHits * innerTripletIndex + 4]; - quintupletsInGPU.hitIndices[Params_T5::kHits * quintupletIndex + 5] = - tripletsInGPU.hitIndices[Params_T3::kHits * innerTripletIndex + 5]; - quintupletsInGPU.hitIndices[Params_T5::kHits * quintupletIndex + 6] = - tripletsInGPU.hitIndices[Params_T3::kHits * outerTripletIndex + 2]; - quintupletsInGPU.hitIndices[Params_T5::kHits * quintupletIndex + 7] = - tripletsInGPU.hitIndices[Params_T3::kHits * outerTripletIndex + 3]; - quintupletsInGPU.hitIndices[Params_T5::kHits * quintupletIndex + 8] = - tripletsInGPU.hitIndices[Params_T3::kHits * outerTripletIndex + 4]; - quintupletsInGPU.hitIndices[Params_T5::kHits * quintupletIndex + 9] = - tripletsInGPU.hitIndices[Params_T3::kHits * outerTripletIndex + 5]; + triplets.logicalLayers()[outerTripletIndex][2]; + + quintupletsInGPU.hitIndices[Params_T5::kHits * quintupletIndex] = triplets.hitIndices()[innerTripletIndex][0]; + quintupletsInGPU.hitIndices[Params_T5::kHits * quintupletIndex + 1] = triplets.hitIndices()[innerTripletIndex][1]; + quintupletsInGPU.hitIndices[Params_T5::kHits * quintupletIndex + 2] = triplets.hitIndices()[innerTripletIndex][2]; + quintupletsInGPU.hitIndices[Params_T5::kHits * quintupletIndex + 3] = triplets.hitIndices()[innerTripletIndex][3]; + quintupletsInGPU.hitIndices[Params_T5::kHits * quintupletIndex + 4] = triplets.hitIndices()[innerTripletIndex][4]; + quintupletsInGPU.hitIndices[Params_T5::kHits * quintupletIndex + 5] = triplets.hitIndices()[innerTripletIndex][5]; + quintupletsInGPU.hitIndices[Params_T5::kHits * quintupletIndex + 6] = triplets.hitIndices()[outerTripletIndex][2]; + quintupletsInGPU.hitIndices[Params_T5::kHits * quintupletIndex + 7] = triplets.hitIndices()[outerTripletIndex][3]; + quintupletsInGPU.hitIndices[Params_T5::kHits * quintupletIndex + 8] = triplets.hitIndices()[outerTripletIndex][4]; + quintupletsInGPU.hitIndices[Params_T5::kHits * quintupletIndex + 9] = triplets.hitIndices()[outerTripletIndex][5]; quintupletsInGPU.bridgeRadius[quintupletIndex] = bridgeRadius; quintupletsInGPU.rzChiSquared[quintupletIndex] = rzChiSquared; quintupletsInGPU.chiSquared[quintupletIndex] = rPhiChiSquared; @@ -750,12 +740,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } template - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool T5HasCommonMiniDoublet(Triplets const& tripletsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool T5HasCommonMiniDoublet(TripletsConst triplets, SegmentsConst segments, unsigned int innerTripletIndex, unsigned int outerTripletIndex) { - unsigned int innerOuterSegmentIndex = tripletsInGPU.segmentIndices[2 * innerTripletIndex + 1]; - unsigned int outerInnerSegmentIndex = tripletsInGPU.segmentIndices[2 * outerTripletIndex]; + unsigned int innerOuterSegmentIndex = triplets.segmentIndices()[innerTripletIndex][1]; + unsigned int outerInnerSegmentIndex = triplets.segmentIndices()[outerTripletIndex][0]; unsigned int innerOuterOuterMiniDoubletIndex = segments.mdIndices()[innerOuterSegmentIndex][1]; //inner triplet outer segment outer MD index unsigned int outerInnerInnerMiniDoubletIndex = @@ -2161,7 +2151,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { Modules& modulesInGPU, MiniDoubletsConst mds, SegmentsConst segments, - Triplets& tripletsInGPU, + TripletsConst triplets, uint16_t lowerModuleIndex1, uint16_t lowerModuleIndex2, uint16_t lowerModuleIndex3, @@ -2179,10 +2169,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float& chiSquared, float& nonAnchorChiSquared, bool& TightCutFlag) { - unsigned int firstSegmentIndex = tripletsInGPU.segmentIndices[2 * innerTripletIndex]; - unsigned int secondSegmentIndex = tripletsInGPU.segmentIndices[2 * innerTripletIndex + 1]; - unsigned int thirdSegmentIndex = tripletsInGPU.segmentIndices[2 * outerTripletIndex]; - unsigned int fourthSegmentIndex = tripletsInGPU.segmentIndices[2 * outerTripletIndex + 1]; + unsigned int firstSegmentIndex = triplets.segmentIndices()[innerTripletIndex][0]; + unsigned int secondSegmentIndex = triplets.segmentIndices()[innerTripletIndex][1]; + unsigned int thirdSegmentIndex = triplets.segmentIndices()[outerTripletIndex][0]; + unsigned int fourthSegmentIndex = triplets.segmentIndices()[outerTripletIndex][1]; unsigned int innerOuterOuterMiniDoubletIndex = segments.mdIndices()[secondSegmentIndex][1]; //inner triplet outer segment outer MD index @@ -2307,11 +2297,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { computeErrorInRadius(acc, x3Vec, y3Vec, x1Vec, y1Vec, x2Vec, y2Vec, outerRadiusMin2S, outerRadiusMax2S); float g, f; - outerRadius = tripletsInGPU.circleRadius[outerTripletIndex]; + outerRadius = triplets.radius()[outerTripletIndex]; bridgeRadius = computeRadiusFromThreeAnchorHits(acc, x2, y2, x3, y3, x4, y4, g, f); - innerRadius = tripletsInGPU.circleRadius[innerTripletIndex]; - g = tripletsInGPU.circleCenterX[innerTripletIndex]; - f = tripletsInGPU.circleCenterY[innerTripletIndex]; + innerRadius = triplets.radius()[innerTripletIndex]; + g = triplets.centerX()[innerTripletIndex]; + f = triplets.centerY()[innerTripletIndex]; #ifdef USE_RZCHI2 float inner_pt = 2 * k2Rinv1GeVf * innerRadius; @@ -2432,7 +2422,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { modulesInGPU, mds, segments, - tripletsInGPU, + triplets, xVec, yVec, mdIndices, @@ -2504,7 +2494,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { Modules modulesInGPU, MiniDoubletsConst mds, SegmentsConst segments, - Triplets tripletsInGPU, + Triplets triplets, + TripletsOccupancyConst tripletsOccupancy, Quintuplets quintupletsInGPU, ObjectRanges rangesInGPU, uint16_t nEligibleT5Modules) const { @@ -2524,18 +2515,18 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { else { continue; } - unsigned int nInnerTriplets = tripletsInGPU.nTriplets[lowerModule1]; + unsigned int nInnerTriplets = tripletsOccupancy.nTriplets()[lowerModule1]; for (unsigned int innerTripletArrayIndex = globalThreadIdx[1]; innerTripletArrayIndex < nInnerTriplets; innerTripletArrayIndex += gridThreadExtent[1]) { unsigned int innerTripletIndex = rangesInGPU.tripletModuleIndices[lowerModule1] + innerTripletArrayIndex; - uint16_t lowerModule2 = tripletsInGPU.lowerModuleIndices[Params_T3::kLayers * innerTripletIndex + 1]; - uint16_t lowerModule3 = tripletsInGPU.lowerModuleIndices[Params_T3::kLayers * innerTripletIndex + 2]; - unsigned int nOuterTriplets = tripletsInGPU.nTriplets[lowerModule3]; + uint16_t lowerModule2 = triplets.lowerModuleIndices()[innerTripletIndex][1]; + uint16_t lowerModule3 = triplets.lowerModuleIndices()[innerTripletIndex][2]; + unsigned int nOuterTriplets = tripletsOccupancy.nTriplets()[lowerModule3]; for (unsigned int outerTripletArrayIndex = globalThreadIdx[2]; outerTripletArrayIndex < nOuterTriplets; outerTripletArrayIndex += gridThreadExtent[2]) { unsigned int outerTripletIndex = rangesInGPU.tripletModuleIndices[lowerModule3] + outerTripletArrayIndex; - uint16_t lowerModule4 = tripletsInGPU.lowerModuleIndices[Params_T3::kLayers * outerTripletIndex + 1]; - uint16_t lowerModule5 = tripletsInGPU.lowerModuleIndices[Params_T3::kLayers * outerTripletIndex + 2]; + uint16_t lowerModule4 = triplets.lowerModuleIndices()[outerTripletIndex][1]; + uint16_t lowerModule5 = triplets.lowerModuleIndices()[outerTripletIndex][2]; float innerRadius, outerRadius, bridgeRadius, regressionG, regressionF, regressionRadius, rzChiSquared, chiSquared, nonAnchorChiSquared; //required for making distributions @@ -2545,7 +2536,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { modulesInGPU, mds, segments, - tripletsInGPU, + triplets, lowerModule1, lowerModule2, lowerModule3, @@ -2582,13 +2573,13 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } else { unsigned int quintupletIndex = rangesInGPU.quintupletModuleIndices[lowerModule1] + quintupletModuleIndex; - float phi = mds.anchorPhi()[segments.mdIndices()[tripletsInGPU.segmentIndices[2 * innerTripletIndex]] + float phi = mds.anchorPhi()[segments.mdIndices()[triplets.segmentIndices()[innerTripletIndex][0]] [layer2_adjustment]]; - float eta = mds.anchorEta()[segments.mdIndices()[tripletsInGPU.segmentIndices[2 * innerTripletIndex]] + float eta = mds.anchorEta()[segments.mdIndices()[triplets.segmentIndices()[innerTripletIndex][0]] [layer2_adjustment]]; float pt = (innerRadius + outerRadius) * k2Rinv1GeVf; float scores = chiSquared + nonAnchorChiSquared; - addQuintupletToMemory(tripletsInGPU, + addQuintupletToMemory(triplets, quintupletsInGPU, innerTripletIndex, outerTripletIndex, @@ -2614,8 +2605,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { quintupletIndex, TightCutFlag); - tripletsInGPU.partOfT5[quintupletsInGPU.tripletIndices[2 * quintupletIndex]] = true; - tripletsInGPU.partOfT5[quintupletsInGPU.tripletIndices[2 * quintupletIndex + 1]] = true; + triplets.partOfT5()[quintupletsInGPU.tripletIndices[2 * quintupletIndex]] = true; + triplets.partOfT5()[quintupletsInGPU.tripletIndices[2 * quintupletIndex + 1]] = true; } } } @@ -2629,7 +2620,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC void operator()(TAcc const& acc, Modules modulesInGPU, - Triplets tripletsInGPU, + TripletsOccupancyConst tripletsOccupancy, ObjectRanges rangesInGPU) const { // implementation is 1D with a single block static_assert(std::is_same_v, "Should be Acc1D"); @@ -2658,7 +2649,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { short module_subdets = modulesInGPU.subdets[i]; float module_eta = alpaka::math::abs(acc, modulesInGPU.eta[i]); - if (tripletsInGPU.nTriplets[i] == 0) + if (tripletsOccupancy.nTriplets()[i] == 0) continue; if (module_subdets == Barrel and module_layers >= 3) continue; diff --git a/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h b/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h index 5ff4b7ad478cf..855e457f98b65 100644 --- a/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h +++ b/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h @@ -3,9 +3,7 @@ #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" #include "RecoTracker/LSTCore/interface/Module.h" -#include "RecoTracker/LSTCore/interface/TrackCandidatesHostCollection.h" #include "RecoTracker/LSTCore/interface/TrackCandidatesSoA.h" -#include "RecoTracker/LSTCore/interface/alpaka/TrackCandidatesDeviceCollection.h" #include "Triplet.h" #include "Segment.h" diff --git a/RecoTracker/LSTCore/src/alpaka/Triplet.h b/RecoTracker/LSTCore/src/alpaka/Triplet.h index 3c8b4cddbe4ab..b5d4ed615ca68 100644 --- a/RecoTracker/LSTCore/src/alpaka/Triplet.h +++ b/RecoTracker/LSTCore/src/alpaka/Triplet.h @@ -5,6 +5,7 @@ #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" #include "RecoTracker/LSTCore/interface/Module.h" +#include "RecoTracker/LSTCore/interface/TripletsSoA.h" #include "Segment.h" #include "MiniDoublet.h" @@ -12,195 +13,57 @@ #include "ObjectRanges.h" namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { - struct Triplets { - unsigned int* segmentIndices; - uint16_t* lowerModuleIndices; //3 of them - unsigned int* nTriplets; - unsigned int* totOccupancyTriplets; - unsigned int* nMemoryLocations; - uint8_t* logicalLayers; - unsigned int* hitIndices; - FPX* betaIn; - float* circleRadius; - float* circleCenterX; - float* circleCenterY; - bool* partOfPT5; - bool* partOfT5; - bool* partOfPT3; -#ifdef CUT_VALUE_DEBUG - //debug variables - float* zOut; - float* rtOut; - float* betaInCut; -#endif - template - void setData(TBuff& buf) { - segmentIndices = buf.segmentIndices_buf.data(); - lowerModuleIndices = buf.lowerModuleIndices_buf.data(); - nTriplets = buf.nTriplets_buf.data(); - totOccupancyTriplets = buf.totOccupancyTriplets_buf.data(); - nMemoryLocations = buf.nMemoryLocations_buf.data(); - logicalLayers = buf.logicalLayers_buf.data(); - hitIndices = buf.hitIndices_buf.data(); - betaIn = buf.betaIn_buf.data(); - circleRadius = buf.circleRadius_buf.data(); - circleCenterX = buf.circleCenterX_buf.data(); - circleCenterY = buf.circleCenterY_buf.data(); - partOfPT5 = buf.partOfPT5_buf.data(); - partOfT5 = buf.partOfT5_buf.data(); - partOfPT3 = buf.partOfPT3_buf.data(); -#ifdef CUT_VALUE_DEBUG - zOut = buf.zOut_buf.data(); - rtOut = buf.rtOut_buf.data(); - betaInCut = buf.betaInCut_buf.data(); -#endif - } - }; - - template - struct TripletsBuffer { - Buf segmentIndices_buf; - Buf lowerModuleIndices_buf; - Buf nTriplets_buf; - Buf totOccupancyTriplets_buf; - Buf nMemoryLocations_buf; - Buf logicalLayers_buf; - Buf hitIndices_buf; - Buf betaIn_buf; - Buf circleRadius_buf; - Buf circleCenterX_buf; - Buf circleCenterY_buf; - Buf partOfPT5_buf; - Buf partOfT5_buf; - Buf partOfPT3_buf; - -#ifdef CUT_VALUE_DEBUG - Buf zOut_buf; - Buf rtOut_buf; - Buf deltaPhiPos_buf; - Buf deltaPhi_buf; - Buf zLo_buf; - Buf zHi_buf; - Buf zLoPointed_buf; - Buf zHiPointed_buf; - Buf dPhiCut_buf; - Buf betaInCut_buf; - Buf rtLo_buf; - Buf rtHi_buf; -#endif - - Triplets data_; - - template - TripletsBuffer(unsigned int maxTriplets, unsigned int nLowerModules, TDevAcc const& devAccIn, TQueue& queue) - : segmentIndices_buf(allocBufWrapper(devAccIn, 2 * maxTriplets, queue)), - lowerModuleIndices_buf(allocBufWrapper(devAccIn, Params_T3::kLayers * maxTriplets, queue)), - nTriplets_buf(allocBufWrapper(devAccIn, nLowerModules, queue)), - totOccupancyTriplets_buf(allocBufWrapper(devAccIn, nLowerModules, queue)), - nMemoryLocations_buf(allocBufWrapper(devAccIn, 1, queue)), - logicalLayers_buf(allocBufWrapper(devAccIn, maxTriplets * Params_T3::kLayers, queue)), - hitIndices_buf(allocBufWrapper(devAccIn, maxTriplets * Params_T3::kHits, queue)), - betaIn_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - circleRadius_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - circleCenterX_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - circleCenterY_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - partOfPT5_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - partOfT5_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - partOfPT3_buf(allocBufWrapper(devAccIn, maxTriplets, queue)) -#ifdef CUT_VALUE_DEBUG - , - zOut_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - rtOut_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - deltaPhiPos_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - deltaPhi_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - zLo_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - zHi_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - zLoPointed_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - zHiPointed_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - dPhiCut_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - betaInCut_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - rtLo_buf(allocBufWrapper(devAccIn, maxTriplets, queue)), - rtHi_buf(allocBufWrapper(devAccIn, maxTriplets, queue)) -#endif - { - alpaka::memset(queue, nTriplets_buf, 0u); - alpaka::memset(queue, totOccupancyTriplets_buf, 0u); - alpaka::memset(queue, partOfPT5_buf, false); - alpaka::memset(queue, partOfT5_buf, false); - alpaka::memset(queue, partOfPT3_buf, false); - } - - inline Triplets const* data() const { return &data_; } - inline void setData(TripletsBuffer& buf) { data_.setData(buf); } - }; - -#ifdef CUT_VALUE_DEBUG ALPAKA_FN_ACC ALPAKA_FN_INLINE void addTripletToMemory(Modules const& modulesInGPU, MiniDoubletsConst mds, SegmentsConst segments, - Triplets& tripletsInGPU, + Triplets& triplets, unsigned int innerSegmentIndex, unsigned int outerSegmentIndex, uint16_t innerInnerLowerModuleIndex, uint16_t middleLowerModuleIndex, uint16_t outerOuterLowerModuleIndex, +#ifdef CUT_VALUE_DEBUG float zOut, float rtOut, +#endif float betaIn, float betaInCut, float circleRadius, float circleCenterX, float circleCenterY, - unsigned int tripletIndex) -#else - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addTripletToMemory(Modules const& modulesInGPU, - MiniDoubletsConst mds, - SegmentsConst segments, - Triplets& tripletsInGPU, - unsigned int innerSegmentIndex, - unsigned int outerSegmentIndex, - uint16_t innerInnerLowerModuleIndex, - uint16_t middleLowerModuleIndex, - uint16_t outerOuterLowerModuleIndex, - float betaIn, - float circleRadius, - float circleCenterX, - float circleCenterY, - unsigned int tripletIndex) -#endif - { - tripletsInGPU.segmentIndices[tripletIndex * 2] = innerSegmentIndex; - tripletsInGPU.segmentIndices[tripletIndex * 2 + 1] = outerSegmentIndex; - tripletsInGPU.lowerModuleIndices[tripletIndex * Params_T3::kLayers] = innerInnerLowerModuleIndex; - tripletsInGPU.lowerModuleIndices[tripletIndex * Params_T3::kLayers + 1] = middleLowerModuleIndex; - tripletsInGPU.lowerModuleIndices[tripletIndex * Params_T3::kLayers + 2] = outerOuterLowerModuleIndex; - - tripletsInGPU.betaIn[tripletIndex] = __F2H(betaIn); - tripletsInGPU.circleRadius[tripletIndex] = circleRadius; - tripletsInGPU.circleCenterX[tripletIndex] = circleCenterX; - tripletsInGPU.circleCenterY[tripletIndex] = circleCenterY; - tripletsInGPU.logicalLayers[tripletIndex * Params_T3::kLayers] = + unsigned int tripletIndex) { + triplets.segmentIndices()[tripletIndex][0] = innerSegmentIndex; + triplets.segmentIndices()[tripletIndex][1] = outerSegmentIndex; + triplets.lowerModuleIndices()[tripletIndex][0] = innerInnerLowerModuleIndex; + triplets.lowerModuleIndices()[tripletIndex][1] = middleLowerModuleIndex; + triplets.lowerModuleIndices()[tripletIndex][2] = outerOuterLowerModuleIndex; + + triplets.betaIn()[tripletIndex] = __F2H(betaIn); + triplets.radius()[tripletIndex] = circleRadius; + triplets.centerX()[tripletIndex] = circleCenterX; + triplets.centerY()[tripletIndex] = circleCenterY; + triplets.logicalLayers()[tripletIndex][0] = modulesInGPU.layers[innerInnerLowerModuleIndex] + (modulesInGPU.subdets[innerInnerLowerModuleIndex] == 4) * 6; - tripletsInGPU.logicalLayers[tripletIndex * Params_T3::kLayers + 1] = + triplets.logicalLayers()[tripletIndex][1] = modulesInGPU.layers[middleLowerModuleIndex] + (modulesInGPU.subdets[middleLowerModuleIndex] == 4) * 6; - tripletsInGPU.logicalLayers[tripletIndex * Params_T3::kLayers + 2] = + triplets.logicalLayers()[tripletIndex][2] = modulesInGPU.layers[outerOuterLowerModuleIndex] + (modulesInGPU.subdets[outerOuterLowerModuleIndex] == 4) * 6; //get the hits unsigned int firstMDIndex = segments.mdIndices()[innerSegmentIndex][0]; unsigned int secondMDIndex = segments.mdIndices()[innerSegmentIndex][1]; unsigned int thirdMDIndex = segments.mdIndices()[outerSegmentIndex][1]; - tripletsInGPU.hitIndices[tripletIndex * Params_T3::kHits] = mds.anchorHitIndices()[firstMDIndex]; - tripletsInGPU.hitIndices[tripletIndex * Params_T3::kHits + 1] = mds.outerHitIndices()[firstMDIndex]; - tripletsInGPU.hitIndices[tripletIndex * Params_T3::kHits + 2] = mds.anchorHitIndices()[secondMDIndex]; - tripletsInGPU.hitIndices[tripletIndex * Params_T3::kHits + 3] = mds.outerHitIndices()[secondMDIndex]; - tripletsInGPU.hitIndices[tripletIndex * Params_T3::kHits + 4] = mds.anchorHitIndices()[thirdMDIndex]; - tripletsInGPU.hitIndices[tripletIndex * Params_T3::kHits + 5] = mds.outerHitIndices()[thirdMDIndex]; + triplets.hitIndices()[tripletIndex][0] = mds.anchorHitIndices()[firstMDIndex]; + triplets.hitIndices()[tripletIndex][1] = mds.outerHitIndices()[firstMDIndex]; + triplets.hitIndices()[tripletIndex][2] = mds.anchorHitIndices()[secondMDIndex]; + triplets.hitIndices()[tripletIndex][3] = mds.outerHitIndices()[secondMDIndex]; + triplets.hitIndices()[tripletIndex][4] = mds.anchorHitIndices()[thirdMDIndex]; + triplets.hitIndices()[tripletIndex][5] = mds.outerHitIndices()[thirdMDIndex]; #ifdef CUT_VALUE_DEBUG - tripletsInGPU.zOut[tripletIndex] = zOut; - tripletsInGPU.rtOut[tripletIndex] = rtOut; - tripletsInGPU.betaInCut[tripletIndex] = betaInCut; + triplets.zOut()[tripletIndex] = zOut; + triplets.rtOut()[tripletIndex] = rtOut; + triplets.betaInCut()[tripletIndex] = betaInCut; #endif } @@ -798,14 +661,15 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { return true; } - struct CreateTripletsInGPUv2 { + struct CreateTriplets { template ALPAKA_FN_ACC void operator()(TAcc const& acc, Modules modulesInGPU, MiniDoubletsConst mds, SegmentsConst segments, SegmentsOccupancyConst segmentsOccupancy, - Triplets tripletsInGPU, + Triplets triplets, + TripletsOccupancy tripletsOccupancy, ObjectRanges rangesInGPU, uint16_t* index_gpu, uint16_t nonZeroModules) const { @@ -861,7 +725,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { if (success) { unsigned int totOccupancyTriplets = alpaka::atomicAdd(acc, - &tripletsInGPU.totOccupancyTriplets[innerInnerLowerModuleIndex], + &tripletsOccupancy.totOccupancyTriplets()[innerInnerLowerModuleIndex], 1u, alpaka::hierarchy::Threads{}); if (static_cast(totOccupancyTriplets) >= @@ -871,43 +735,28 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { #endif } else { unsigned int tripletModuleIndex = alpaka::atomicAdd( - acc, &tripletsInGPU.nTriplets[innerInnerLowerModuleIndex], 1u, alpaka::hierarchy::Threads{}); + acc, &tripletsOccupancy.nTriplets()[innerInnerLowerModuleIndex], 1u, alpaka::hierarchy::Threads{}); unsigned int tripletIndex = rangesInGPU.tripletModuleIndices[innerInnerLowerModuleIndex] + tripletModuleIndex; -#ifdef CUT_VALUE_DEBUG addTripletToMemory(modulesInGPU, mds, segments, - tripletsInGPU, + triplets, innerSegmentIndex, outerSegmentIndex, innerInnerLowerModuleIndex, middleLowerModuleIndex, outerOuterLowerModuleIndex, +#ifdef CUT_VALUE_DEBUG zOut, rtOut, +#endif betaIn, betaInCut, circleRadius, circleCenterX, circleCenterY, tripletIndex); -#else - addTripletToMemory(modulesInGPU, - mds, - segments, - tripletsInGPU, - innerSegmentIndex, - outerSegmentIndex, - innerInnerLowerModuleIndex, - middleLowerModuleIndex, - outerOuterLowerModuleIndex, - betaIn, - circleRadius, - circleCenterX, - circleCenterY, - tripletIndex); -#endif } } } @@ -1023,7 +872,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_ACC void operator()(TAcc const& acc, Modules modulesInGPU, - Triplets tripletsInGPU, + TripletsOccupancyConst tripletsOccupancy, ObjectRanges rangesInGPU) const { // implementation is 1D with a single block static_assert(std::is_same_v, "Should be Acc1D"); @@ -1033,12 +882,13 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { auto const gridThreadExtent = alpaka::getWorkDiv(acc); for (uint16_t i = globalThreadIdx[0]; i < *modulesInGPU.nLowerModules; i += gridThreadExtent[0]) { - if (tripletsInGPU.nTriplets[i] == 0) { + if (tripletsOccupancy.nTriplets()[i] == 0) { rangesInGPU.tripletRanges[i * 2] = -1; rangesInGPU.tripletRanges[i * 2 + 1] = -1; } else { rangesInGPU.tripletRanges[i * 2] = rangesInGPU.tripletModuleIndices[i]; - rangesInGPU.tripletRanges[i * 2 + 1] = rangesInGPU.tripletModuleIndices[i] + tripletsInGPU.nTriplets[i] - 1; + rangesInGPU.tripletRanges[i * 2 + 1] = + rangesInGPU.tripletModuleIndices[i] + tripletsOccupancy.nTriplets()[i] - 1; } } } diff --git a/RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc b/RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc index 0ac4cfa539dc7..ab91e35505c3a 100644 --- a/RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc +++ b/RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc @@ -117,11 +117,11 @@ std::tuple, std::vector> getHitIdxsAndHi // ============== //____________________________________________________________________________________________ -std::vector getLSsFromT3(Event* event, unsigned int T3) { - Triplets const* triplets = event->getTriplets().data(); - unsigned int LS_1 = triplets->segmentIndices[2 * T3]; - unsigned int LS_2 = triplets->segmentIndices[2 * T3 + 1]; - return {LS_1, LS_2}; +std::vector getLSsFromT3(Event* event, unsigned int t3) { + auto const triplets = event->getTriplets(); + unsigned int ls_1 = triplets.segmentIndices()[t3][0]; + unsigned int ls_2 = triplets.segmentIndices()[t3][1]; + return {ls_1, ls_2}; } //____________________________________________________________________________________________ diff --git a/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc b/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc index 0c96e16db1bfc..aec9596412c6b 100644 --- a/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc +++ b/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc @@ -857,7 +857,7 @@ std::tuple, std::vectorgetTrackCandidates(); - Triplets const* triplets = event->getTriplets().data(); + auto const triplets = event->getTriplets(); SegmentsPixelConst segmentsPixel = event->getSegments(); // @@ -875,7 +875,7 @@ std::tuple, std::vectorcircleRadius[T3] * 2 * k2Rinv1GeVf; + float pt_T3 = triplets.radius()[T3] * 2 * k2Rinv1GeVf; // average pt const float pt = (pt_pLS + pt_T3) / 2; @@ -1073,7 +1073,8 @@ void printpLSs(Event* event) { //________________________________________________________________________________________________________________________________ void printT3s(Event* event) { - Triplets const* triplets = event->getTriplets().data(); + auto const triplets = event->getTriplets(); + auto const tripletsOccupancy = event->getTriplets(); SegmentsConst segments = event->getSegments(); MiniDoubletsConst miniDoublets = event->getMiniDoublets(); Hits const* hitsEvt = event->getHits().data(); @@ -1081,12 +1082,12 @@ void printT3s(Event* event) { int nTriplets = 0; for (unsigned int i = 0; i < *(modules->nLowerModules); ++i) { // unsigned int idx = modules->lowerModuleIndices[i]; - nTriplets += triplets->nTriplets[i]; + nTriplets += tripletsOccupancy.nTriplets()[i]; unsigned int idx = i; - for (unsigned int jdx = 0; jdx < triplets->nTriplets[idx]; jdx++) { + for (unsigned int jdx = 0; jdx < tripletsOccupancy.nTriplets()[idx]; jdx++) { unsigned int tpIdx = idx * 5000 + jdx; - unsigned int InnerSegmentIndex = triplets->segmentIndices[2 * tpIdx]; - unsigned int OuterSegmentIndex = triplets->segmentIndices[2 * tpIdx + 1]; + unsigned int InnerSegmentIndex = triplets.segmentIndices()[tpIdx][0]; + unsigned int OuterSegmentIndex = triplets.segmentIndices()[tpIdx][1]; unsigned int InnerSegmentInnerMiniDoubletIndex = segments.mdIndices()[InnerSegmentIndex][0]; unsigned int InnerSegmentOuterMiniDoubletIndex = segments.mdIndices()[InnerSegmentIndex][1]; unsigned int OuterSegmentOuterMiniDoubletIndex = segments.mdIndices()[OuterSegmentIndex][1];