I have defined an optical fiber in which photons are produced and I want to record the time from their birth to the time they hit the detector. Some of them will exit the fiber some of them will hit the detector, I want to get the information only on those who hit the detector.
By recording postStepPoint->GetGlobalTime() it seems that it gives me only the time laps between the time at which the photon leaving the fiber and hitting the detector. (I get few ps for photons running along a 50m fiber, instead of Ln/c~250ns…)
I somehow changed the code in the tutorial such that it summing the postStepPoint->GetGlobalTime() for each steps but the resulting times don’t add up and I get zero in the end…
Do you have any suggestions or solutions regarding this problem ?
Yes, I’ve also tried using track->GetLocalTime() but it gives me the same thing, which is a much shorter time than expected. I call track->Get<local/Global>Time from SensitiveDetector::ProcessHits, but maybe I should call it somewhere else in the code?
Problem solved.
One must be careful when defining the refractive index. In fact, the refractive index definition allows the calculation of the group velocity in the G4MaterialPropertiesTable.cc. However, the calculation will result in a ‘NaN’ group velocity if your energy array for the refractive index has adjacent values that are identical… So no time can be calculated while the photon is in the material with an incorrectly defined energy array and the GlobalTime remains the same. As soon as the photon leaves the material, GlobalTime will increase normally. Consider returning an error if the energy array is misdefined, i.e. if the energy values are not strictly increasing.