Only recording secondaries related to specific process

Hi all,

In my simulation, I want to focus on the energy deposition of secondaries whose parent track was created by a specific process: for example, energy loss of Compton electrons from scattering of higher energy bremsstrahlung gammas. However, I’ve been struggling to think of an efficient way to go about this.

What I currently do in my code is the following:

  • In PreUserTrackingAction, if a particle is a gamma and the track creator process is brems, then the track ID is appended to a vector in UserEventAction
  • In UserSteppingAction, the parent ID of the current track is compared to the vector of brems track IDs, and if there is a match, the energy deposition is recorded

This works, but slows down when a large number of brems gammas are produced. Has anyone encountered a similar situation before? Any feedback on how to go about this more efficiently would be greatly appreciated!

It is confusing what you are trying to do. Is it specifically, as an example, the compton energy loss from just the single scatter or all resulting secondaries of the compton electron or photon?