Steeping action and EventAction

Please fill out the following information to help in answering your question, and also see tips for posting code snippets. If you don’t provide this information it will take more time to help with your problem!

_Geant4 Version:_11.1.2
_Operating System:_Mac
CMake Version:

Dear all,
I am trying to get the neutron spectrum in a vacuum detector, so I plot the initial energy of the incedent neutron.

In the steeping action I called the kinetic energy of the particle (neutron) and I can see the correct energy.
But when I try to transport it to the event action at the ned of each event, it does not work. it copile but without correct energy. the registered energy is zero (initial energy)
I have attached the stepping action and event action files that I use.
can anyone help me in this issue (3.7 KB) (5.8 KB)
EventAction.hh (2.6 KB)
SteppingAction.hh (2.5 KB)

In EventAction::AddEdep(), you do not sum up fTotalEnergyDeposit over the event, but override it at each step (line ~80).
Therefore, in SteppingAction, you must invoke the function AddEdep() only once, in the desired volume.
In other word, move line 98 of to line 86