Mismatch between gun energy and total deposition

Hello!
As a first try with an application, I have modified a bit example B4a to simulate photon showers in a block of homogeneous material. I then store in a file the (x,y,z) (final) coordinates of each step and the correspondent total energy deposition (step->GetTotalEnergyDeposit()).
I however realised that, when opening the output file and doing some preliminary processing, that the total energy deposited in the material (i.e. the sum of all step depositions) does not match the energy set for the particle gun. If I run more simulations (energies from 0 to 100 GeV), this mismatch seems to settle on a value of 3.25 times the ‘nominal’ gun energy.

scale

Do you have any idea of why and/or what I might be doing wrong?
Thanks a lot!

Federico

what is the ratio for the total deposition vs. the total energy of the primary (rest mass + kinetic energy)?

Did you run few events with /tracking/verbose 2 ?