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

2 Likes

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.

1 Like

I’m running into the same issue as hulsman. I have registered the steplimit, applied it to all particles, but still I see larger than the set step length in the volume.

Relevant parts of my code shown below. Do you have some more ideas as to what goes wrong?
In my detector constructor:

G4Box* siBox = new G4Box("Si", siSizeXY / 2, siSizeXY / 2, siThickness / 2);
G4LogicalVolume* siLogVol = new G4LogicalVolume(siBox, siMaterial, "Si");
// Set the user limits for maximum step size in the Si volume
G4UserLimits* userLimits = new G4UserLimits();
userLimits->SetMaxAllowedStep(1.0 * um);
siLogVol->SetUserLimits(userLimits);

In my physics list

MyPhysicsList::MyPhysicsList() : G4VModularPhysicsList() {
    RegisterPhysics(new G4EmLivermorePhysics());
    RegisterPhysics(new G4DecayPhysics());
    RegisterPhysics(new G4RadioactiveDecayPhysics());

    G4StepLimiterPhysics* stepLimitPhys = new G4StepLimiterPhysics();
    stepLimitPhys->SetApplyToAll(true);
    RegisterPhysics(stepLimitPhys);
}

MyPhysicsList::~MyPhysicsList() {}