I would like to add TOF into my GEANT4 simulation, but I want to get TOF for each radiation detector.
I know that TOF can be done through GetGlobalTime function, but I do not understand well the physics behind.
I employed GetGlobalTime in the Stepping Action Class, and a counter (k). I understand that Stepping is called several times around a whole event, so to avoid count again the same particle I used counter (k). I saved the TOF and plot it for a run in different ntuples.
I did something like this:
if (volume == fScoringVolume1 && k1==0) {
G4StepPoint *preStepPoint = step->GetPreStepPoint();
G4double tof1 = preStepPoint->GetGlobalTime();
k1+=1;
fEventAction->AddTOF1(tof1); }
I got a TOF of 10 ns for a gamma source at 10 cm from the detector's cover; however, I am not quite sure if my simulation works properly.
Perhaps, someone who can help me with a GEANT4 example which does something similar or a GitHub repository.