Skip to content

Commit

Permalink
Fixed indexing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ariostas committed Sep 23, 2024
1 parent acff43f commit 37fe122
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 30 deletions.
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/src/alpaka/Event.dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ MiniDoubletsBuffer<alpaka_common::DevHost>& Event::getMiniDoublets(bool sync) {
template <typename TSoA>
typename TSoA::ConstView Event::getSegments(bool sync) {
if constexpr (std::is_same_v<Device, DevHost>)
return segmentsDev_->const_view<TSoA>();
return segmentsDev_->const_view<TSoA>();
if (!segmentsHost_) {
segmentsHost_.emplace(cms::alpakatools::CopyToHost<SegmentsDeviceCollection>::copyAsync(queue_, *segmentsDev_));
if (sync)
Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()[2 * tripletsInGPU.segmentIndices[2 * innerTripletIndex + layer2_adjustment]][0];
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
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex + 6] =
quintupletsInGPU.lowerModuleIndices[T5Index * Params_T5::kLayers + 4];

unsigned int pixelInnerMD = segments.mdIndices()[Params_pLS::kLayers * pixelIndex][0];
unsigned int pixelOuterMD = segments.mdIndices()[Params_pLS::kLayers * pixelIndex][1];
unsigned int pixelInnerMD = segments.mdIndices()[pixelIndex][0];
unsigned int pixelOuterMD = segments.mdIndices()[pixelIndex][1];

pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex] =
mdsInGPU.anchorHitIndices[pixelInnerMD];
Expand Down
18 changes: 8 additions & 10 deletions RecoTracker/LSTCore/src/alpaka/PixelTriplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
short outerInnerLowerModuleSubdet = modulesInGPU.subdets[outerInnerLowerModuleIndex];
short outerOuterLowerModuleSubdet = modulesInGPU.subdets[outerOuterLowerModuleIndex];

unsigned int firstMDIndex = segments.mdIndices()[Params_LS::kLayers * innerSegmentIndex][0];
unsigned int secondMDIndex = segments.mdIndices()[Params_LS::kLayers * innerSegmentIndex][1];
unsigned int firstMDIndex = segments.mdIndices()[innerSegmentIndex][0];
unsigned int secondMDIndex = segments.mdIndices()[innerSegmentIndex][1];

unsigned int thirdMDIndex = segments.mdIndices()[Params_LS::kLayers * outerSegmentIndex][0];
unsigned int fourthMDIndex = segments.mdIndices()[Params_LS::kLayers * outerSegmentIndex][1];
unsigned int thirdMDIndex = segments.mdIndices()[outerSegmentIndex][0];
unsigned int fourthMDIndex = segments.mdIndices()[outerSegmentIndex][1];

if (outerInnerLowerModuleSubdet == Barrel and
(outerOuterLowerModuleSubdet == Barrel or outerOuterLowerModuleSubdet == Endcap)) {
Expand Down Expand Up @@ -832,8 +832,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
float pixelF = segmentsPixel.circleCenterY()[pixelSegmentArrayIndex];
float pixelRadiusPCA = segmentsPixel.circleRadius()[pixelSegmentArrayIndex];

unsigned int pixelInnerMDIndex = segments.mdIndices()[Params_pLS::kLayers * pixelSegmentIndex][0];
unsigned int pixelOuterMDIndex = segments.mdIndices()[Params_pLS::kLayers * pixelSegmentIndex][1];
unsigned int pixelInnerMDIndex = segments.mdIndices()[pixelSegmentIndex][0];
unsigned int pixelOuterMDIndex = segments.mdIndices()[pixelSegmentIndex][1];

pixelRadius = pixelSegmentPt * kR1GeVf;
float pixelRadiusError = pixelSegmentPtError * kR1GeVf;
Expand Down Expand Up @@ -1014,11 +1014,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {

if (success) {
float phi =
mdsInGPU.anchorPhi[segments.mdIndices()[tripletsInGPU.segmentIndices[2 * outerTripletIndex] +
layer2_adjustment][0]];
mdsInGPU.anchorPhi[segments.mdIndices()[tripletsInGPU.segmentIndices[2 * outerTripletIndex]][layer2_adjustment]];
float eta =
mdsInGPU.anchorEta[segments.mdIndices()[tripletsInGPU.segmentIndices[2 * outerTripletIndex] +
layer2_adjustment][0]];
mdsInGPU.anchorEta[segments.mdIndices()[tripletsInGPU.segmentIndices[2 * outerTripletIndex]][layer2_adjustment]];
float eta_pix = segmentsPixel.eta()[i_pLS];
float phi_pix = segmentsPixel.phi()[i_pLS];
float pt = segmentsPixel.ptIn()[i_pLS];
Expand Down
6 changes: 2 additions & 4 deletions RecoTracker/LSTCore/src/alpaka/Quintuplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -2588,11 +2588,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
unsigned int quintupletIndex =
rangesInGPU.quintupletModuleIndices[lowerModule1] + quintupletModuleIndex;
float phi =
mdsInGPU.anchorPhi[segments.mdIndices()[tripletsInGPU.segmentIndices[2 * innerTripletIndex +
layer2_adjustment]][0]];
mdsInGPU.anchorPhi[segments.mdIndices()[tripletsInGPU.segmentIndices[2 * innerTripletIndex]][layer2_adjustment]];
float eta =
mdsInGPU.anchorEta[segments.mdIndices()[tripletsInGPU.segmentIndices[2 * innerTripletIndex +
layer2_adjustment]][0]];
mdsInGPU.anchorEta[segments.mdIndices()[tripletsInGPU.segmentIndices[2 * innerTripletIndex]][layer2_adjustment]];
float pt = (innerRadius + outerRadius) * k2Rinv1GeVf;
float scores = chiSquared + nonAnchorChiSquared;
addQuintupletToMemory(tripletsInGPU,
Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/src/alpaka/TrackCandidate.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
phits1[0] = hitsInGPU.idxs[mdsInGPU.anchorHitIndices[segments.mdIndices()[ix][0]]];
phits1[1] = hitsInGPU.idxs[mdsInGPU.anchorHitIndices[segments.mdIndices()[ix][1]]];
phits1[2] = hitsInGPU.idxs[mdsInGPU.outerHitIndices[segments.mdIndices()[ix][0]]];
phits1[3] = hitsInGPU.idxs[mdsInGPU.outerHitIndices[segments.mdIndices()[ix][0]]];
phits1[3] = hitsInGPU.idxs[mdsInGPU.outerHitIndices[segments.mdIndices()[ix][1]]];

phits2[0] = hitsInGPU.idxs[mdsInGPU.anchorHitIndices[segments.mdIndices()[jx][0]]];
phits2[1] = hitsInGPU.idxs[mdsInGPU.anchorHitIndices[segments.mdIndices()[jx][1]]];
Expand Down
8 changes: 4 additions & 4 deletions RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ std::vector<unsigned int> getPixelHitsFrompLS(Event* event, unsigned int pLS) {
ObjectRanges const* rangesEvt = event->getRanges().data();
Modules const* modulesEvt = event->getModules().data();
const unsigned int pLS_offset = rangesEvt->segmentModuleIndices[*(modulesEvt->nLowerModules)];
unsigned int MD_1 = segments.mdIndices()[2 * (pLS + pLS_offset)][0];
unsigned int MD_2 = segments.mdIndices()[2 * (pLS + pLS_offset)][1];
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];
unsigned int hit_2 = miniDoublets->outerHitIndices[MD_1];
unsigned int hit_3 = miniDoublets->anchorHitIndices[MD_2];
Expand Down Expand Up @@ -93,8 +93,8 @@ std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHi
//____________________________________________________________________________________________
std::vector<unsigned int> getMDsFromLS(Event* event, unsigned int LS) {
SegmentsConst segments = event->getSegments<SegmentsSoA>();
unsigned int MD_1 = segments.mdIndices()[2 * LS][0];
unsigned int MD_2 = segments.mdIndices()[2 * LS][1];
unsigned int MD_1 = segments.mdIndices()[LS][0];
unsigned int MD_2 = segments.mdIndices()[LS][1];
return {MD_1, MD_2};
}

Expand Down
14 changes: 7 additions & 7 deletions RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1021,8 +1021,8 @@ void printLSs(Event* event) {
nSegments += segmentsOccupancy.nSegments()[idx];
for (unsigned int jdx = 0; jdx < segmentsOccupancy.nSegments()[idx]; jdx++) {
unsigned int sgIdx = ranges->segmentModuleIndices[idx] + jdx;
unsigned int InnerMiniDoubletIndex = segments.mdIndices()[2 * sgIdx][0];
unsigned int OuterMiniDoubletIndex = segments.mdIndices()[2 * sgIdx][1];
unsigned int InnerMiniDoubletIndex = segments.mdIndices()[sgIdx][0];
unsigned int OuterMiniDoubletIndex = segments.mdIndices()[sgIdx][1];
unsigned int InnerMiniDoubletLowerHitIndex = miniDoublets->anchorHitIndices[InnerMiniDoubletIndex];
unsigned int InnerMiniDoubletUpperHitIndex = miniDoublets->outerHitIndices[InnerMiniDoubletIndex];
unsigned int OuterMiniDoubletLowerHitIndex = miniDoublets->anchorHitIndices[OuterMiniDoubletIndex];
Expand Down Expand Up @@ -1053,8 +1053,8 @@ void printpLSs(Event* event) {
int npLS = segmentsOccupancy.nSegments()[idx];
for (unsigned int jdx = 0; jdx < segmentsOccupancy.nSegments()[idx]; jdx++) {
unsigned int sgIdx = ranges->segmentModuleIndices[idx] + jdx;
unsigned int InnerMiniDoubletIndex = segments.mdIndices()[2 * sgIdx][0];
unsigned int OuterMiniDoubletIndex = segments.mdIndices()[2 * sgIdx][1];
unsigned int InnerMiniDoubletIndex = segments.mdIndices()[sgIdx][0];
unsigned int OuterMiniDoubletIndex = segments.mdIndices()[sgIdx][1];
unsigned int InnerMiniDoubletLowerHitIndex = miniDoublets->anchorHitIndices[InnerMiniDoubletIndex];
unsigned int InnerMiniDoubletUpperHitIndex = miniDoublets->outerHitIndices[InnerMiniDoubletIndex];
unsigned int OuterMiniDoubletLowerHitIndex = miniDoublets->anchorHitIndices[OuterMiniDoubletIndex];
Expand Down Expand Up @@ -1086,9 +1086,9 @@ void printT3s(Event* event) {
unsigned int tpIdx = idx * 5000 + jdx;
unsigned int InnerSegmentIndex = triplets->segmentIndices[2 * tpIdx];
unsigned int OuterSegmentIndex = triplets->segmentIndices[2 * tpIdx + 1];
unsigned int InnerSegmentInnerMiniDoubletIndex = segments.mdIndices()[2 * InnerSegmentIndex][0];
unsigned int InnerSegmentOuterMiniDoubletIndex = segments.mdIndices()[2 * InnerSegmentIndex][1];
unsigned int OuterSegmentOuterMiniDoubletIndex = segments.mdIndices()[2 * OuterSegmentIndex][1];
unsigned int InnerSegmentInnerMiniDoubletIndex = segments.mdIndices()[InnerSegmentIndex][0];
unsigned int InnerSegmentOuterMiniDoubletIndex = segments.mdIndices()[InnerSegmentIndex][1];
unsigned int OuterSegmentOuterMiniDoubletIndex = segments.mdIndices()[OuterSegmentIndex][1];

unsigned int hit_idx0 = miniDoublets->anchorHitIndices[InnerSegmentInnerMiniDoubletIndex];
unsigned int hit_idx1 = miniDoublets->outerHitIndices[InnerSegmentInnerMiniDoubletIndex];
Expand Down

0 comments on commit 37fe122

Please sign in to comment.