Get Original Kinetic Energy of Photon

Dear all,

I am simulating a PET scanner and an object containing the tracer Rubidium 82. Besides two 511 keV annihilation photons, Rubidium emits a 776 keV gamma photon. The photons are detected by the PET scanner. I would like to store which detected photon was an annihilation and which detected photon was the gamma photon.
As some gamma photons are down-scattered, I cannot simply distinguish by the detected energy. So I was thinking to separate the photons by knowing their energy during annihilation.
I tried to use
origEnergy =track->GetTotalEnergy();
or
origEnergy =track->GetVertexKineticEnergy();
But both possibilities are giving me sometimes the correct but also sometimes incorrect results.
Could you please help me with this?
Thanks in advance!
Elli

Dear @ElisabethPfaehler

I have never done it, so I am not fully sure. Maybe you can register each particle being created in a custom G4UserTrackingAction, so you can reconstruct the Monte Carlo Particle history when needed?

Particularly, I think the recording of the TrackID, ParentID, and CreatorProcess (for each track) can be done in G4UserTrackingAction::PreUserTrackingAction.

Best,
Alvaro