Using G4PrimaryVertex and G4PrimaryParticle, i can get the energy at the beginning of an event, but i want to know how much energy each particle loses during an event. I'm simulating particles travelling through a medium.
You could use the extended/electromagnetic/TestEm11 example as reference. In the example the use of SteppingAction and EventAction classes is demonstrated by scoring the energy deposited per event.
The way I am usually doing it is creating a dummy variable under EventAction, accessing it through SteppingAction and adding up the deposited energy from step->GetTotalEnergyDeposit. After each event I just dump whatever I want to a txt file.