First of all, GEANT4 provides examples in order to simulate energy deposition or dose deposited. I am interested to know which one example give a sample of how to measure time of fligth (TOF).
I measure the time of fligth in stepping action class. I understand that stepping action class is employed in all the steps through an entire event, so I just recorded the time for the first interaction with detector volume.
I made something like this:
G4int k1=0;
if (volume == fScoringVolume1 && k1==0) {
G4StepPoint *preStepPoint = step->GetPreStepPoint();
G4double tof1 = preStepPoint->GetGlobalTime();
k1+=1;
fEventAction->AddTOF1(tof1);
}
I putted a counter k to avoid getting TOF in case the particle continues in the detector. I got an answer like this, but I do not know if it could be okay.
I will thank someone who can help me to validate my results or give me an GEANT4 example which makes something similar.