There is another option using the routine BXDRAW in order to obtain
the energy (and more parameters) when the particle of
interest enters and exists a region.
If you never used the BXDRAW routine maybe this thread can be useful for you:
Here It is explained how to obtain the angle of the particles, but the case for energy is
basically the same.