Dose-averaged LET profiles

Dear experts,
I want to plot dose-averaged LET versus depth. I use these commands in steppingaction but I can’t get the good results.

G4double stepLength = step->GetStepLength();
auto edepStep = step->GetTotalEnergyDeposit();
if (stepLength > 1e-6*mm)
G4double LET = edepStep / stepLength;
analysisManager->FillH1(10, zz/mm, LET/keV/um);

I attached my graph for a proton beam with 100MeV energy and my reference : the Depth-LET distributions of protons and different ions in a water phantom.
Would you please help me to plot this parameter?
Thank you very much

Calculate dE/dx step by step is very unstable. We need, at least, to have a control on the step length of tracked particles.
In example TestEm11, we apply another strategy which is explained in Readme :

  • accumulate Edep in SteppingAction
  • normalize histograms only once, at end of run (lines ~373-380 of
  • apply a StepMax mechanism (lines 148 and 272-287 of

Below, a macro for this example, and the corresponding plot.
rajab.mac.txt (451 Bytes)
rajab.out.txt (960 Bytes)