diff --git a/RecoHGCal/TICL/plugins/PatternRecognitionbyCLUE3D.cc b/RecoHGCal/TICL/plugins/PatternRecognitionbyCLUE3D.cc index 8470bbea04675..4af6e422698c9 100644 --- a/RecoHGCal/TICL/plugins/PatternRecognitionbyCLUE3D.cc +++ b/RecoHGCal/TICL/plugins/PatternRecognitionbyCLUE3D.cc @@ -532,7 +532,7 @@ void PatternRecognitionbyCLUE3D::calculateLocalDensity( const int etaWindow = 2; const int phiWindow = 2; int etaBinMin = std::max(tileOnLayer.etaBin(clustersOnLayer.eta[i]) - etaWindow, 0); - int etaBinMax = std::min(tileOnLayer.etaBin(clustersOnLayer.eta[i]) + etaWindow, nEtaBin); + int etaBinMax = std::min(tileOnLayer.etaBin(clustersOnLayer.eta[i]) + etaWindow, nEtaBin - 1); int phiBinMin = tileOnLayer.phiBin(clustersOnLayer.phi[i]) - phiWindow; int phiBinMax = tileOnLayer.phiBin(clustersOnLayer.phi[i]) + phiWindow; if (PatternRecognitionAlgoBaseT::algo_verbosity_ > VerbosityLevel::Advanced) { @@ -686,7 +686,7 @@ void PatternRecognitionbyCLUE3D::calculateDistanceToHigher( int etaWindow = 1; int phiWindow = 1; int etaBinMin = std::max(tileOnLayer.etaBin(clustersOnLayer.eta[i]) - etaWindow, 0); - int etaBinMax = std::min(tileOnLayer.etaBin(clustersOnLayer.eta[i]) + etaWindow, nEtaBin); + int etaBinMax = std::min(tileOnLayer.etaBin(clustersOnLayer.eta[i]) + etaWindow, nEtaBin - 1); int phiBinMin = tileOnLayer.phiBin(clustersOnLayer.phi[i]) - phiWindow; int phiBinMax = tileOnLayer.phiBin(clustersOnLayer.phi[i]) + phiWindow; for (int ieta = etaBinMin; ieta <= etaBinMax; ++ieta) {