From 7ca6d968b7492cf47eb7030b0eac77dbad98bd3e Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Mon, 8 Aug 2022 10:17:36 +0200 Subject: [PATCH] Handle pixel modules with all invalid pixels Handle the case where all pixels in a module are invalid or duplicate. --- .../plugins/gpuClusterChargeCut.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/RecoLocalTracker/SiPixelClusterizer/plugins/gpuClusterChargeCut.h b/RecoLocalTracker/SiPixelClusterizer/plugins/gpuClusterChargeCut.h index 093ef05717a0a..fcd31bf59490b 100644 --- a/RecoLocalTracker/SiPixelClusterizer/plugins/gpuClusterChargeCut.h +++ b/RecoLocalTracker/SiPixelClusterizer/plugins/gpuClusterChargeCut.h @@ -39,11 +39,21 @@ namespace gpuClustering { auto endModule = moduleStart[0]; for (auto module = firstModule; module < endModule; module += gridDim.x) { auto firstPixel = moduleStart[1 + module]; - while (id[firstPixel] == invalidModuleId) - ++firstPixel; // could be duplicates! auto thisModuleId = id[firstPixel]; + while (thisModuleId == invalidModuleId and firstPixel < numElements) { + // skip invalid or duplicate pixels + ++firstPixel; + thisModuleId = id[firstPixel]; + } + if (firstPixel >= numElements) { + // reached the end of the input while skipping the invalid pixels, nothing left to do + break; + } + if (thisModuleId != moduleId[module]) { + // reached the end of the module while skipping the invalid pixels, skip this module + continue; + } assert(thisModuleId < nMaxModules); - assert(thisModuleId == moduleId[module]); auto nclus = nClustersInModule[thisModuleId]; if (nclus == 0)