next-exp / nexus

Geant4 simulation framework of the NEXT Collaboration
5 stars 55 forks source link

Add option to kill particle after step selection #206

Closed gonzaponte closed 1 year ago

gonzaponte commented 1 year ago

This PRs adds a command to SaveAllSteppingAction that allows killing the tracked particle once it has been selected. This is meant to reduce computation time when tracking photons that usually interact several times before absorption.

paolafer commented 1 year ago

If two volumes are selected, the particle is killed after it enters the first one. Is this the intended behaviour?

gonzaponte commented 1 year ago

Yes, if the particle interacts with any of the selected volumes, the particle is killed. The use case that motivated this development was to find out the first interaction point of photons with the tracking plane. Without killing the particles, the photons are reflected and propagated further, sometimes ending up with multiple interactions with the selected volumes. This was useless for me and a waste of cpu time.

paolafer commented 1 year ago

Ok. I found a typo in the description of the NEW_geantino macro files, you may fix it in this PR, since it's related: an specific vertex --> a specific vertex.

paolafer commented 1 year ago

Yes, if the particle interacts with any of the selected volumes, the particle is killed. The use case that motivated this development was to find out the first interaction point of photons with the tracking plane. Without killing the particles, the photons are reflected and propagated further, sometimes ending up with multiple interactions with the selected volumes. This was useless for me and a waste of cpu time.

Maybe you can add a comment in the macro line, explaining that this new parameter is to be used with only one selected volume.

gonzaponte commented 1 year ago

But it's not. It might be any number of volumes, and if the interaction happens with any of them, it's enough to kill it. For example, the macro I use in my studies contains:

/Actions/SaveAllSteppingAction/select_particle opticalphoton
/Actions/SaveAllSteppingAction/select_volume   DICE_BOARD
/Actions/SaveAllSteppingAction/select_volume   DICE_MASK
/Actions/SaveAllSteppingAction/select_volume   SIPMSensl
/Actions/SaveAllSteppingAction/select_volume   SUPPORT_PLATE

I'm interested in capturing every photon that hits the TP, regardless of where.