Lowering the step-size in a particular G4 geometry


I am working on a specific simulation that is modified from the Magnetic Monopole code in Geant4 (/extended/exoticphysics/monopole). This simulation contains the geometry of a long (2-3m), thin (~1mm) cylindrical pipe made from Beryllium. I am propagating monopoles, initially from vacuum, towards the pipe. The simulation has a strong magnetic field of a few teslas along the z direction. The trajectories are curved due to the magnetic field. I understand that in vacuum, the monopole is expected to take a very long steps, if any. However, when it enters the beryllium volume (1mm thickness), I should be able to control the step length and the number of steps it takes in the volume, before the particle exits. However, no amount of stepping parameters that I change has any effect on the step-size.
I have attached

the stepping verbose of two monopoles, which take 3-4 steps in the pipe volume before they exit. I would like to decrease the step size and have the particles take a larger number of steps in the simulation (sure, it will increase the simulation time, but also the accuracy of results).

For decreasing the step-size, thus far, I’ve tried the following (but the modification does not affect the simulation).

  1. In the FieldSetup source file (attached), I have changed the fMinStep value of 1mm (default) to a much lower value.
  2. I included other parameters (from the application developers guide) such as deltaChord, deltaOneStep, deltaIntersection, epsMin, epsMax.
  3. I have also written a DetectorMessenger with a function SetMaxStepSize (defined in DetectorConstruction) and set it to 0.0001mm using a macro file.
  4. In the G4mplIonisationWithDeltaModel source code (for monopole ionization), I have changed the emin (LowEnergyLimit) to a very low value ~eV to lower the thresholds in the simulation.
  5. Similarly, in G4MonopoleTransportation, I had lower the value of fThreshold_Warning_Energy to a few eVs to lower thresholds.
    G4MonopoleFieldSetup.cc (4.6 KB)

If anyone could guide me further regarding the changes I could make in the simulation to control (lower) the step-size, I would be very thankful. Let me know if you have any questions.


Hi Aupreti,

To reduce the step size, you can add :

include “G4UserLimits.hh” → [detectorConstruction.]

include “G4UserLimits.hh”

G4double maxStep = 1.*mm;
myStepLimit = new G4UserLimits(maxStep);

Make changes in the PhysicsList as well;

include “G4StepLimiterPhysics.hh”
RegisterPhysics(new G4StepLimiterPhysics());

The above will change stepsize in the logical volume of your choice.

Greetings and Regards.

Hi Dr. Vijay Raj,

Thank you for your suggestions.
I have, however, already included these in my simulation.
The volume is a gdml model that is parsed into Geant4. In the DetectorConstruction, I have defined a function SetMaxStepSize as follows, and set the step size to a small value (either by calling this function in RunAction or through the macro);

void DetectorConstruction::SetMaxStepSize(G4double step)
        fMaxStepSize = step;
        G4int daughters = lWorldLogVol->GetNoDaughters();

        for (G4int i=0; i<daughters; i++)
                daughter[i] = lWorldLogVol->GetDaughter(i);
                G4cout << daughter[i]->GetName() << G4endl;
                        daughter[i]->GetLogicalVolume()->SetUserLimits(new G4UserLimits(fMaxStepSize));
        G4cout << "---------Max step size in the volume is ---------------" << fMaxStepSize << G4endl;

The G4StepLimiterPhysics is also registered in the main source file. Still I haven’t been able to modify the step size in the simulation.

Please let me know if you have any other suggestions.

just a wild guess, but maybe you need to call either of these (or something similar) after your modification of the step limits:


, as you probably have called G4RunManager::Initialize(); already at that point?

Hi Weller,

Thanks for your reply. However, including those lines still does not modify the step limits. I’m not sure if the issue is inherent to the Geant4 geometry that is in the form of a gdml file, with thickness of the pipe around 1mm, surrounded in vacuum.