Energy Deposit and HitsCollection


I am simulating a PET scanner. I am interested in the position and the energy when the photon hits the detector.
In the example B3, we assess the HitsCollector in the EventAction class and get the energy deposit.
That works fine with me and I get the energy deposit as expected.
However, when I want to get the energy deposit in a ProcessHits function taking G4double edep = aStep->GetTotalEnergyDeposit(); the value differs from the value I get in my EventAction.
I think I do not fully understand the connection between the HitsCollector and a Step. Could you please explain?
Thanks a lot.

To understand what is behind Hits collection, you can compare examples B4a and B4c

Thanks, I did not know the example before. Now the hits collection is clear.