Primary particle generated in a target

Hello,
I have a problem at hand where I need to know the photons generated in a high Z target, for example W, when electron beam hits it.
I made a scorer surrounding the target to score energy and number of photons coming out of W. But, ideally, since my target is thick, a lot of photons are generated and locally absorbed or utilized for neutron generation.
For my project I need to track information of every single photon that was generated and locally utilized.
Is there a way to do this?

I think, the outside scorer will only be giving me information of the photons that come out of the target without being utilized or absorbed.
Please let me know if I can refer to some example or any piece of code to track these (primary) photons.
Urgent!!

Thank you very much!

Hello!

To keep track of the photons generated within the target volume, try setting the target volume in your detector construction as a sensitive detector. Example B5 is a good place to start with using sensitive detectors. Within your sensitive detector class, you can tally the number of photons generated along with their total energy deposition within the target. You can then access the total “hit” information from your sensitive detector within your event action.

Start with B5, look at how sensitive detectors are defined along with how their classes are written and accessed in event action. See if you can make some progress. Feel free to ask any follow up questions!

Happy coding,

Charles