General Particle Source (GPS)
Geant4 provides 3 ways for a user to generate primary particles for a simulation:
- C++: the hardest to learn and use, hence covered intensively in Geant4 User Guide for Application Developers, and demonstrated in most Geant4 official examples.
- Particle gun macro commands: the easiest to learn and use (no C++ at all), yet limited in its functionality.
- GPS macro commands provided by general particle source (GPS): as easy as particle gun, yet way more versatile. Their usage is demonstrated nicely in
.macfiles in the extended Geant4 example exgps. An outdated webpage contains a subset of exgps. It shows resulted distribution plots, which are very helpful to visualize effects of GPS macro commands.
GEARS and MinGLE example G4 applications accept both particle gun and GPS macro commands. For example, one can save the following macro commands to a file named run.mac and execute them using mingle run.mac.
# specify particle type
/gps/particle gamma
# specify particle energy
/gps/energy 1 keV
# specify particle source position
/gps/position -6 0 0 cm
# specify particle direction
/gps/direction 1 0 0
Default Settings of GPS
/run/beamOn with tracking verbosity of 2 without any setting on GPS reveals the default settings of GPS:
Idle> /tracking/verbose 2
Idle> /run/beamOn
G4WT3 > *********************************************************************************************************
G4WT3 > * G4Track Information: Particle = geantino, Track ID = 1, Parent ID = 0
G4WT3 > *********************************************************************************************************
G4WT3 >
G4WT3 > Step# X(mm) Y(mm) Z(mm) KinE(MeV) dE(MeV) StepLeng TrackLeng NextVolume ProcName
G4WT3 > 0 0 0 0 1 0 0 0 hall initStep
G4WT3 > 1 0 0 -1e+03 1 0 1e+03 1e+03 OutOfWorld CoupledTransportation
- Default particle: geantino
- Default energy: 1 MeV
- Default position: (0, 0, 0)
- Default direction: -z