Mean arrival time of scintillation photons

Hello everyone i’m new at Geant4, i have a scintillation crystal attached to a detector.
I want to have the mean value of the arrival time of the photons at the detector.
How can i get it?
Thanks

Hi Dominik,

Presumably you’ve got a G4VSensitiveDetector defined where you’re detecting the scintillation optical photons. One method implemented for G4VSensitiveDetector is ProcessHits, which takes a G4Step* as an argument.

To get the time of detection, you could do something like this:

G4double timeOfArrival =
    step->GetPreStepPoint()->GetGlobalTime() +
    step->GetDeltaTime();

Or more simply just

G4double timeOfArrival = step->GetPostStepPoint()->GetGlobalTime();

The first option interpolates the time between the last and second-to-last step points. The second option is just the time of the last step point. Technically the first is more correct but the difference is slight (for photons with v = c).

For each hit, save that time somewhere using either one of the AnalysisManager classes, or some other way. Take care to get the units right on the time when doing analysis (maybe save timeOfArrival / us for instance). Take the mean of those times after the run is done. You could do this in G4UserRunAction::EndOfRunAction or in data processing separately in a different program.

Hope this helps!

Yes this helps me very much.
Thank you

I have a question about the mean value. Should i calculate the mean value in the runaction or in the eventaction?
Because i want to store the mean value of the scintillation arrival time of each gamma.

Saving in EventAction::EndOfEventAction is probably the simplest. That’s what is done in some examples, such as basic/B5. You could also collect all the arrival times somewhere and save them in RunAction::EndOfRunAction.

Also I realized I had an error in my last post, it should be ... + step->GetDeltaTime() / 2. Whoops.

William