Photons generated by location of gamma interaction

I am simulating a gamma camera/scintillator, and need to separate the total number of produced photons by gamma-scintillator interaction location and process(photoelectric, Compton…).

So for example, if a photoelectric interaction occurs, the gamma interacts and produces a secondary electron, which in turn produces photons in later steps. So every secondary particle must be tracked for several steps until all possible photon production has been recorded.

How would I count these photons? Currently, the interaction locations are recorded from SteppingAction, but given the example above, a simple count of secondary photons is insufficient (as in the photoelectric example above, most photons are produced by the secondary electron).

I appreciate any suggestions you may have.
Thank you.

Since you’ve got a SteppingAction, this should be fairly easy. If you’re just wanting to count produced photons, you can filter on the particle type and on the step number (to avoid double counting).

Once you’ve selected a step, the track (G4Step::GetTrack()) has a pointer to the process which created it, G4Track::GetCreatorProcess(). You can use the process name to separate how the photon was produced (PE, Compton, brem, whatever).

Alternatively, you could set up the stepping action to look for electrons, and then look to see if any secondaries were produced on that step (G4Step::GetSecondaryInCurrentStep(), again to avoid double counting), and count up the photons in that list.

Finally, you could look for electrons as above, but wait until the track is in the fStopAndKill state, and then look at all the secondaries produced for the track (G4Step::GetSecondary()) in one pass.

1 Like

Thank you so much!

I was unaware of G4Track::GetCreatorProcess() and G4Step::GetSecondary().
Just to clarify, G4Step::GetSecondary() returns all the secondaries that were generated directly or indirectly (for the PE example - via an intermediate electron) by the track?

I will try to use G4Track::GetCreatorProcess(), but as the gamma may have multiple Compton interactions, for example, how would I filter with interaction location?’
I plan to use GetParentID() to iterate up the list of parents to find the initial gamma, and then I should be able to use fVtxPosition from the parent directly below the initial gamma to find vertex location.
Do you happen to know of a more efficient approach (the many comparisons will slow down the simulation)?

Regarding filtering the step number, could you please elaborate? If I filter by photon creation (G4Step::GetSecondaryInCurrentStep()), that would be sufficient, right?

I would rather not use the second method as that requires different checks for Compton and PE interactions, and the third method (assuming that I have understood it correctly) does not allow me to filter by interaction type.

I appreciate your help.

It seems that

iterating up the list of parents to find the initial gamma

will not be possible, as you previously mentioned here: Get G4Track by trackID.

No. It only returns the direct secondaries, for the currently active track/step. Previously constructed secondaries won’t get processed until the current track is stopped and killed.

The G4Track::GetVertexPosition() returns the location (in world coordinates) where the track was created.

If you count the produced secondaries directly, when they’re produced, then you don’t have to worry about step-number filtering. If you set up your SteppingAction to count photons directly (i.e., is the currently active track a photon?) then you can avoid double-counting by asking “Is the currently active track a photon, and is it on step #1?”. Otherwise, you’ll count it for step #1, step #2, step #3, etc.

1 Like