Geant4 Reference
Free reference guide: Geant4 Reference
About Geant4 Reference
This Geant4 Reference is a searchable quick-reference guide for the Geant4 Monte Carlo particle transport simulation toolkit. It covers 27 essential Geant4 classes and macro commands with C++ code examples, organized into six categories: core simulation management classes, geometry construction with solid shapes and boolean operations, material definition using the NIST database and optical surfaces, physics list selection, particle source configuration, and visualization/analysis macros.
The reference includes core user action classes (G4RunManager initialization, G4VUserDetectorConstruction for geometry, G4VUserPrimaryGeneratorAction for beam definition, G4UserSteppingAction for per-step data collection, G4UserEventAction for event-level analysis, and G4VSensitiveDetector for hit collection), geometry solids (G4Box, G4Tubs, G4Sphere, G4PVPlacement, G4PVReplica, G4UnionSolid), and standard physics lists (FTFP_BERT for LHC, QGSP_BERT general-purpose, Shielding for radiation protection).
Designed for high-energy physicists, medical physics researchers, radiation protection engineers, detector design teams, and nuclear science students, this guide provides instant lookup of Geant4 API classes with compilable C++ code snippets and macro command syntax.
Key Features
- Core class reference covering G4RunManager initialization, detector construction, primary generator, stepping/event actions, and sensitive detectors
- Geometry solid guide for G4Box, G4Tubs, G4Sphere with half-length conventions, G4LogicalVolume, G4PVPlacement, G4PVReplica, and boolean G4UnionSolid
- Material definition using G4NistManager predefined database (G4_WATER, G4_Pb, G4_AIR) and custom G4Material element composition
- Optical surface properties for scintillator and Cherenkov detector simulations with G4OpticalSurface and G4LogicalBorderSurface
- Physics list selection guide: FTFP_BERT (LHC standard), QGSP_BERT (general-purpose), G4EmStandardPhysics, and Shielding for radiation protection
- Particle source configuration for G4GeneralParticleSource (complex beam profiles via macros) and G4ParticleGun (simple single-particle emission)
- Visualization macro commands for OpenGL viewer setup, trajectory drawing, hit display, and auto-refresh configuration
- G4AnalysisManager output guide for creating histograms and ntuples with ROOT/CSV/XML file output
Frequently Asked Questions
What Geant4 classes and commands does this reference cover?
This reference covers 27 entries across six categories: Core Classes (G4RunManager, G4VUserDetectorConstruction, G4VUserPrimaryGeneratorAction, G4UserSteppingAction, G4UserEventAction, G4SensitiveDetector), Geometry (G4Box, G4Tubs, G4Sphere, G4LogicalVolume, G4PVPlacement, G4PVReplica, G4UnionSolid), Materials (G4NistManager, G4Material, G4OpticalSurface), Physics Lists (FTFP_BERT, QGSP_BERT, G4EmStandardPhysics, Shielding), Particle Sources (G4GeneralParticleSource, G4ParticleGun), and Visualization/Macros (/vis/open, /run/beamOn, G4AnalysisManager, /run/initialize).
How do I set up a basic Geant4 simulation?
The G4RunManager entry shows the complete initialization sequence: create a run manager via G4RunManagerFactory, set the detector construction class, set a physics list (e.g., FTFP_BERT), register user actions (primary generator, stepping, event), call Initialize(), then BeamOn(N) to run N events. Each component has its own detailed entry with C++ code examples.
Which physics list should I use for my simulation?
The reference covers four physics lists: FTFP_BERT is the standard for LHC experiments using Fritiof above ~5 GeV and Bertini cascade for 0-10 GeV; QGSP_BERT uses Quark Gluon String model and is general-purpose; G4EmStandardPhysics handles electromagnetic processes (ionization, bremsstrahlung, scattering) and can be combined with G4OpticalPhysics; Shielding includes high-precision neutron models for radiation protection calculations.
How do I define geometry in Geant4?
The Geometry category covers the full workflow: create solids (G4Box with half-lengths, G4Tubs for cylinders, G4Sphere for spheres), combine them with G4UnionSolid for boolean operations, wrap in G4LogicalVolume with a material, then place using G4PVPlacement with position and rotation in a mother volume. G4PVReplica handles regular repeated structures like calorimeter layers.
How do I use the NIST material database?
G4NistManager::Instance() provides access to predefined materials. Use FindOrBuildMaterial() with standard names like "G4_WATER", "G4_Pb", "G4_AIR", "G4_Si", etc. For custom materials, create a G4Material with density and number of components, then add elements by name using FindOrBuildElement() with stoichiometric ratios.
What is the difference between G4ParticleGun and G4GeneralParticleSource?
G4ParticleGun is for simple simulations: set particle type, energy, position, and direction in C++ code for single-particle emission. G4GeneralParticleSource (GPS) supports complex beam profiles configured via macro commands (/gps/particle, /gps/energy, /gps/pos/type, /gps/pos/shape) including circular beams, surface sources, and energy spectra, without recompilation.
How do I collect energy deposit data in Geant4?
Two approaches are covered: G4UserSteppingAction calls UserSteppingAction() at every step where you can accumulate GetTotalEnergyDeposit() for specific volumes, and G4VSensitiveDetector with ProcessHits() creates hit objects stored in hit collections. G4UserEventAction aggregates step-level data per event, and G4AnalysisManager writes histograms and ntuples to output files.
Is this reference free to use?
Yes, this Geant4 reference is completely free with no usage limits or account required. All content loads in your browser with no server processing. It is part of liminfo.com's collection of free online reference tools for physicists and simulation engineers.