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.
Hi, let me add some clarifications: USRBDX is not an user routine, is a scoring card that automatically produces double differential distributions on a surface defined as the boundary between two adjacent regions, as previously advertised by @msabateg . So it allows to get the entering BEAMPART energy spectrum, if this fulfills @duarte.guerreiro’s needs (I do not fully understand how a very small bin energy interval corresponds to the energy distribution, though: in the USRBDX card you can define the energy distribution limits and the number of bins which the whole energy interval shall be divided into, this way defining the energy resolution of the resulting spectrum).
What @adonadon advertised is instead a specific entry (BXDRAW) of the mgdraw.f user routine, to be activated by the USERDUMP card, for a (more cumbersome but more detailed) event-by-event scoring to be set up by the user himself.