Maximum step length


I’m trying to understand something about setting a maximum step size. Following example B2, I could set a maximum step size.

In my I wrote added:


In my case, in the run.mac file, the step size is 0.05mm. I wanted to confirm this and thus checked in my what they step sizes were. I had the following line written:

G4cout << fStepLimit->GetMaxAllowedStep(*step->GetTrack()) / CLHEP::mm << " " << step->GetTrack()->GetStepLength() / CLHEP::mm << G4endl;

I noticed that if I’m in the volume of “logic_silicon” that the step length exceeds limit. However, as the output shows, it is properly set.

StepMax    StepLength
0.05        0.161304
0.05        0.166283
0.05        0.17639
0.05        0.169074
0.05        0.175563
...            ...

Could someone explain why this is the case? I am assuming that the track is a “snapshot of a particle” and the step the “delta information between tracks”.
Am I missing something about the underlying machinery?


1 Like

First of all, please check if you activated the G4StepLimiterPhysics.
If you didn’t, please add something like

#include "G4StepLimiterPhysics.hh"
G4StepLimiterPhysics* stepLimitPhys = new G4StepLimiterPhysics();

when creating the physics lists. In example B2a that you mentioned it is done in the main() function inside the file.

Another thing to check is the particle type. According to the comment in the G4StepLimiterPhysics.hh header, “by default the step limit is applied to charged particles only”. So if you use non-charged particles, you may try to set the fApplyToAll option like this:

#include "G4StepLimiterPhysics.hh"
G4StepLimiterPhysics* stepLimitPhys = new G4StepLimiterPhysics();
stepLimitPhys->SetApplyToAll(true); // activates step limit for ALL particles

Hope that works for your task.