From 9e3f2ed55ace1d76d26911c34dcfcadbcdfb5d13 Mon Sep 17 00:00:00 2001 From: Shaun Roe <shaun.roe@cern.ch> Date: Mon, 15 Aug 2022 13:34:59 +0200 Subject: [PATCH] prevent -ve index into array --- .../ISF_FastCaloSimSD/src/LArFCS_StepInfoSD.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/LArFCS_StepInfoSD.cxx b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/LArFCS_StepInfoSD.cxx index d895fa64650d..f5542701830e 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/LArFCS_StepInfoSD.cxx +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/LArFCS_StepInfoSD.cxx @@ -150,6 +150,10 @@ G4bool LArFCS_StepInfoSD::ProcessHits(G4Step* a_step,G4TouchableHistory*) maxSubHitEnergyindex = i; } } + if (maxSubHitEnergyindex == -1){//because there were no hits; numberOfProcessedHits ==0 + G4cout << this->GetName()<<" WARNING ProcessHits: numberOfProcessedHits is zero" << G4endl; + continue; + } //Identifier for the subhit with max energy Identifier maxEnergyIdentifier = this->ConvertID(processedHits[maxSubHitEnergyindex].id); const CaloDetDescrElement *maxEnergyCell = m_calo_dd_man.get()->get_element(maxEnergyIdentifier); -- GitLab