How to get the volume generated secondary particle

I want to know where the detected secondary particle is generated. But my geometry has many volumes which secondary is transmitted. Then, there are some volumes between the generated volume and the detector volume.
Please advice. Thanks.

I believe this should be straightforward to implement. Basically in my case I just G4cout all the info of each entry/step (or export this to a text file in my analysis script). This helps me gain insight of what’s happening at the micro-level and implement the changes in my analysis script. For instance, see the screenshot of a text file in my this post.

Also, check if this is of help as well.

Good luck!

Thanks. mksharma_iitk.