How to get individual photon energy depositions from sensitive detector?

Hi,

I’m trying to work out how to get the energy of each individual photon that hits my sensitive detector, without using event or stepping action. Currently, I’ve tried running this in my detector.cc :


I thought this might work since it successfully gives me the photon positions that hit the detector. However, it doesn’t actually work, since I keep getting ‘Photon energy = 0’ for each hit.

What else do I need to add to my detector.cc to get the individual photon energies? I don’t really want to complicate the simulation by adding event action or stepping action headers and source files.
Many thanks in advance

1 Like

The SD is exactly what you need. There are several things you want to adjust:

First, don’t kill the track.

Second, check the track type for G4Gamma before doing anything else:

if (track->GetDefinition() != G4Gamma::Definition()) return true;

Third, use the postStepPoint to get the position.

Test for (edep > 0) to find out if there was an energy deposit or not. Every track will always have a step that ends at a volume boundary. You don’t want to get fooled by those non-depositing steps.

Finally, you might not get an energy deposit, from a photon interaction. If the photon transferred enough energy, it might produce a secondary electron. The energy transfer is not recorded in edep, but rather as the kinetic energy of the new secondary. If you don’t want to make your SD sophisticated enough to collect all of the subsequent energy deposits, then you can test the G4Step to see if there were secondaries.

Alternatively, you can compare the energy of the post-step and pre-step points, and simply store the difference as the total energy transferred ffrom the photon.

2 Likes

Hi
I was thinking of a way for retrieving the position of energy depositions in say a scintillator block (primary gammas) and tried to look for an answer among the forum messages that I ended up with your answer to the initial post by @Erc.
In general, how can I get such positions for all edeps that can produce optical photons? I have tried to get the positions from the preStepPoint of a step with positive edep and zero step->GetNonIonizingEnergyDeposit(), but I guess this must not be accurate enough, since the results would be very much depending on the steps lengths.
Am I on the right track, especially if I want to get the edep positions in a micrometer-sized detector?
Many thanks

Could you create a new forum topic for your specific issue, rather than resurrecting an old thread?

Sure, sorry for that.