From 74d29135c06c122f8ec69d247d4408253a4931c0 Mon Sep 17 00:00:00 2001 From: Mircho Rodozov Date: Mon, 16 Dec 2019 16:09:08 +0100 Subject: [PATCH] Update CaloSD.cc add proposed changes --- SimG4CMS/Calo/src/CaloSD.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/SimG4CMS/Calo/src/CaloSD.cc b/SimG4CMS/Calo/src/CaloSD.cc index a7c8f12263dc5..9b0f172d4e102 100644 --- a/SimG4CMS/Calo/src/CaloSD.cc +++ b/SimG4CMS/Calo/src/CaloSD.cc @@ -321,8 +321,9 @@ bool CaloSD::checkHit() { found = true; } } else if (nCheckedHits > 0) { - size_t minhit = (theHC->entries() > nCheckedHits ? theHC->entries() - nCheckedHits : 0); - int maxhit = theHC->entries() - 1; + int nhits = theHC->entries(); + int minhit = std::max(nhits - nCheckedHits, 0); + int maxhit = - 1; for (int j = maxhit; j > minhit; --j) { if ((*theHC)[j]->getID() == currentID) {