Maximum step length

Hi,

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

In my DetectorConstruction.cc I wrote added:

logic_silicon->SetUserLimits(fStepLimit);
logic_package->SetUserLimits(fStepLimit);

In my case, in the run.mac file, the step size is 0.05mm. I wanted to confirm this and thus checked in my SteppingAction.cc 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?

Cheers,
Johan

1 Like

Hello!
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();
RegisterPhysics(stepLimitPhys);

when creating the physics lists. In example B2a that you mentioned it is done in the main() function inside the exampleB2a.cc 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
RegisterPhysics(stepLimitPhys);

Hope that works for your task.