How to stop events when the deposited energy is above a threshold?

Please fill out the following information to help in answering your question, and also see tips for posting code snippets. If you don’t provide this information it will take more time to help with your problem!

Geant4 Version:
Operating System:
Compiler/Version:
CMake Version:


Hi,
I’m sorry if this question is already answered elsewhere, I couldn’t find the answer anywhere.

I’m simulating a simple calorimeter cell and use 120GeV muons as primary particles. Sometimes the deposited energy is very high, since I activated optical physics these events generate a big number of optical photons and it takes a lot of time to track them, although I’m not really interested in these events.

What i would like to do is calculate the deposited energy in the calorimeter, if it’s above a certain threshold, completely stop the tracking of all the particles and move on the next event, also without executing EndOfEventAction() so nothing gets recorded. In this way I could skip events where primary particles deposit, let’s say, more than 5 GeV in my calorimeter when the MVP is 150 MeV.

Is there a optimal way to do this in geant4?