Own loop code instead of command prompt

I would like to write own loop(instead of /control/loop) which could change energy of particle from 1 to 100 keV with 1keV period. By my first attempt i started with for operator over the single program.It’s supposed to use to change energy in G4ParticleGun class. However, after first cycle step i got a segmentation fault. Is anyone have a helpfull guidelines?

You want to generate primaries with a range of energy? Perhaps you want to use G4GeneralParticleSource (“GPS”) in your simulation, instead of G4ParticleGun.

1 Like

I would suggest GPS and a power-law distribution.