Depht profile energy

_Geant4 Version:11.2
_Operating System:ubuntu 22.04
_Compiler/Version:gcc 12
_CMake Version:3.16

Hello everyone
I want to vary the position of the source and measure the energy deposited in my detector in a loop in order to study the behavior of particles as a function of distance.
I would like to know if anyone knows a geant4 example on this.

Thank you very much