Transverse energy deposit

Hi, I am new to Geant4.
I am currently working on a project in which I am asked to reconstruct the distribution of energy deposited by Carbon12 particles in a water absorber along the transverse direction with respect to the beam, by modifying the pre-existing geant4 example AnaEx01 (GitHub - carlomt/AnaEx01). The point I am not understanding is how to collect from G4Step the energy deposited in one particular direction.

Best regards,

just to clarify: do you really need to measure a direction of the energy deposition (would that be equal to the momentum direction of the particle just before the interaction?), or is it the" energy deposition as a function of distance along a certain direction", i.e.: the energy deposition along the penetration depth of the beam?