When handing photons (gensteps) from Geant4 to the GPU, we need a way to identify which G4 event each photon belongs to after GPU ray tracing completes.
Approach: Encode the event ID into the photon's hit time by adding eventID*M, where M is a large multiplier. After GPU ray tracing, the original event ID can be recovered from each hit via hitTime / M (integer division), and the actual hit time via hitTime % M.
Constraint: M must be larger than the maximum possible hit time (i.e., longer than the longest-lived particle's lifetime) to avoid collisions between the encoded event ID and the real time value.
When handing photons (gensteps) from Geant4 to the GPU, we need a way to identify which G4 event each photon belongs to after GPU ray tracing completes.
Approach: Encode the event ID into the photon's hit time by adding eventID*M, where M is a large multiplier. After GPU ray tracing, the original event ID can be recovered from each hit via hitTime / M (integer division), and the actual hit time via hitTime % M.
Constraint: M must be larger than the maximum possible hit time (i.e., longer than the longest-lived particle's lifetime) to avoid collisions between the encoded event ID and the real time value.