The Geant4 toolkit includes several fully coded examples which demonstrate the implementation of the user classes required to build a customized simulation. Seven "novice" examples are provided ranging from the simulation of a non-interacting particle and a trivial detector, to the simulation of electromagnetic and hadronic physics processes in a complex detector. Each example may be used as a base from which more detailed applications can be developed. A set of "extended" examples implement simulations of actual high energy physics detectors and require some libraries in addition to those of Geant4. The "advanced" examples cover cases useful to the developement of the Geant4 toolkit itself.
The examples can be compiled and run without modification. Most
of them can be run both in interactive and batch mode using the
input macro files (*.in
) and reference output files
(*.out
) provided. These examples are run routinely as
part of the validation, or testing, of official releases of the Geant4
toolkit.
Descriptions of the 7 novice examples are provided here along with links to the code.
ExampleN01
(Description below)
Mandatory user classes
Demonstrates how Geant4 kernel works
ExampleN02
(Description below)
Simplified tracker geometry with uniform magnetic field
Electromagnetic processes
ExampleN03
(Description below)
Simplified calorimeter geometry
Electromagnetic processes
Various materials
ExampleN04
(Description below)
Simplified collider detector with a readout geometry
Full ``ordinary'' processes
PYTHIA primary events
Event filtering by stack
ExampleN05
(Description below)
Simplified BaBar calorimeter
EM shower parametrisation
ExampleN06
(Description below)
Optical photon processes
ExampleN07
(Description below)
Geometrical Regions for production thresholds
Dynamic geometry setups between runs
Primitive scorer and filter
Derived run class and run action
Table 9.1, Table 9.2 and Table 9.3 display the ``item charts'' for the examples currently prepared in the novice level.
ExampleN01
|
ExampleN02
|
ExampleN03
| |
comments | minimal set for geantino transportation | fixed target tracker geometry | EM shower in calorimeter |
Run |
main() for hard coded batch
|
main() for interactive mode
|
|
Event | event generator selection (particleGun) | event generator selection (particleGun) |
|
Tracking | hard coded verbose level setting | selecting secondaries | select trajectories |
Geometry | geometry definition (CSG) |
|
|
Hits/Digi | - | tracker type hits | calorimeter-type hits |
PIIM |
|
|
|
Physics | transportation | EM physics | EM physics |
Vis | - |
| detector & trajectory drawing |
(G)UI | - | GUI selection | GUI selection |
Global | - | - | - |
Table 9.1.
The ``item chart'' for novice level examples N01
,
N02
and N03
.
ExampleN04
|
ExampleN05
|
ExampleN06
| |
comments | simplified collider geometry | parametrised shower example | Optical photon example |
Run |
main() for interactive mode
|
main() for interactive mode
|
main() for interactive mode
|
Event |
| event generator selection (HEPEvtInterface) | event generator selection (particleGun) |
Tracking |
| - | - |
Geometry |
| ghost volume for shower parametrisation | geometry definition (BREP with rotation) |
Hits/Digi |
| Sensitive detector for shower parametrisation | - |
PIIM |
|
|
|
Physics | Full physics processes | Parametrized shower | Optical photon processes |
Vis |
| detector & hit drawing | - |
(G)UI | define user commands | define user commands | define user commands |
Global | - | - | random number engine |
Table 9.2.
The ``item chart'' for novice level examples N04
,
N05
, and N06
.
ExampleN07
| |
comments | Cuts per region |
Run |
|
Event | event generator selection (particleGun) |
Tracking | - |
Geometry |
|
Hits/Digi |
|
PIIM |
|
Physics | EM processes |
Vis | detector & trajectory drawing |
(G)UI | define user commands |
Global | - |
Table 9.3.
The ``item chart'' for novice level example N07
.
minimal set for geantino transportation
main()
(source file)
hard coded batch
construction and deletion of G4RunManager
hard coded verbose level setting to G4RunManager, G4EventManager and G4TrackingManager
construction and set of mandatory user classes
hard coded beamOn()
Hard coded UI command application
derived from G4VUserDetectorConstruction
definitions of single element materials
CSG solids
G4PVPlacement without rotation
derived from G4VUserPhysicsList
definition of geantino
assignment of transportation process
derived from G4VPrimaryGeneratorAction
construction of G4ParticleGun
primary event generation via particle gun
Detector: fixed target type
Processes: EM
Hits: tracker type hits
main()
(source file)
main()
for interactive mode (and batch mode via macro
file)
construction and deletion of (G)UI session and VisManager
random number engine
construction and deletion of G4RunManager
construction and set of mandatory user classes
derived from G4VUserDetectorConstruction
definitions of single-element, mixture and compound materials
CSG solids
Uniform magnetic field: construction of ExN02MagneticField
Physical Volumes
G4Placement volumes with & without rotation.
G4PVParameterised volumes without rotation
derived from G4MagneticField
Uniform field. ExN02MagneticField
derived from G4VUserPhysicsList
definition of geantinos, electrons, positrons, gammas
utilisation of transportation and 'standard' EM-processes
Interactivity: chooses processes interactively (=> messenger class)
derived from G4VPrimaryGeneratorAction
construction of G4ParticleGun
primary event generation via particle gun
derived from G4VUserRunAction
draw detector
derived from G4VUserEventAction
print time information
derived from G4VSensitiveDetector
tracker-type hit generation
derived from G4VHit
draw hit point
Visualize Em processes.
Interactivity: build messenger classes.
Gun: shoot particle randomly.
Tracking: collect energy deposition, total track length
main()
(source file)
main()
for interactive mode and batch mode via macro
file
construction and deletion of G4RunManager
construction and deletion of (G)UI session and VisManager
construction and set of mandatory user classes
automatic initialization of geometry and visualization via a macro file
derived from G4VUserDetectorConstruction
definitions of single materials and mixtures
CSG solids
G4PVPlacement without rotation
Interactivity: change detector size, material, magnetic field. (=>messenger class)
visualization
derived from G4VUserPhysicsList
definition of geantinos, gamma, leptons, light mesons barions and ions
Transportation process, 'standard' Em processes, Decay
Interactivity: SetCut, process on/off. (=> messenger class)
derived from G4VPrimaryGeneratorAction
construction of G4ParticleGun
primary event generation via particle gun
Interactivity: shoot particle randomly. (=> messenger class)
derived from G4VUserRunAction
draw detector and tracks
Interactivity: SetCut, process on/off.
Interactivity: change detector size, material, magnetic field.
derived from G4VUserEventAction
store trajectories
print end of event information (energy deposited, etc.)
derived from G4VUserSteppingAction
collect energy deposition, etc.
Simplified collider experiment geometry
Full hits/digits/trigger
main()
(source file)
construction and deletion of ExN04RunManager
construction and deletion of (G)UI session and VisManager
construction and set of user classes
derived from G4VUserDetectorConstruction
construction of ExN04MagneticField
definitions of mixture and compound materials
material-dependent CutOff
simplified collider geometry with Param/Replica
tracker/muon -- parametrised
calorimeter -- replica
derived from G4VPVParametrisation
parametrised sizes
derived from G4VPVParametrisation
parametrized position/rotation
derived from G4MagneticField
solenoid and toroidal fields
derived from G4VSensitiveDetector
tracker-type hit generation
derived from G4VHit
draw hit point
derived from G4VSensitiveDetector
calorimeter-type hit generation
derived from G4VHit
draw physical volume with variable color
derived from G4VSensitiveDetector
Scintillator-type hit generation
derived from G4VHit
draw physical volume with variable color
derived from G4VPrimaryGeneratorAction
construction of G4HEPEvtInterface
primary event generation with PYTHIA event
store the initial seeds
derived from G4UserStackingAction
``stage'' control and priority control
event abortion
derived from G4UImessenger
define abortion conditions
derived from G4UserTrackingAction
select trajectories
select secondaries
Use of shower parameterisation:
definition of an EM shower model
assignment to a Logical Volume
(definition of ghost volume when ready)
Interactivity: build of messengers classes
Hits/Digi: filled from detailed and parameterised simulation (calorimeter type hits ?)
main()
(source file)
main()
for interactive mode
construction and deletion of G4RunManager
construction and set of mandatory user classes
construction of the G4GlobalFastSimulationmanager
construction of a G4FastSimulationManager to assign fast simulation model to a logical volume (envelope)
(definition of ghost volume for parameterisation)
construction EM physics shower fast simulation model
derived from G4VFastSimulationModel
energy deposition in sensitive detector
derived from G4VFastSimulationModel
energy deposition in sensitive detector
derived from G4VUserDetectorConstruction
definitions of single materials and mixtures
CSG solids
G4PVPlacement
derived from G4VUserPhysicsList
assignment of G4FastSimulationManagerProcess
derived from G4VPrimaryGeneratorAction
construction of G4ParticleGun
primary event generation via particle gun
derived from G4VUserRunAction
draw detector
(activation/deactivation of parameterisation ?)
derived from G4VUserEventAction
print time information
Interactivity : build messenger classes.
Event : Gun, shoot charge particle at Cerenkov Radiator and Scintillator.
PIIM : material/mixture with optical and scintillation properties.
Geometry : volumes filled with optical materials and possessing surface properties.
Physics : define and initialize optical processes.
Tracking : generate Cerenkov radiation, collect energy deposition to produce scintillation.
Hits/Digi : PMT as detector.
Visualization : geometry, optical photon trajectories.
main()
(source file)
main()
for interactive mode and batch mode via macro
file
random number engine
construction and deletion of G4RunManager
construction and set of mandatory user classes
hard coded beamOn
derived from G4VUserDetectorConstruction
definitions of single materials and mixtures
generate and add Material Properties Table to materials
CSG and BREP solids
G4PVPlacement with rotation
definition of surfaces
generate and add Material Properties Table to surfaces
visualization
derived from G4VUserPhysicsList
definition of gamma, leptons and optical photons
transportation, 'standard' EM-processes, decay, Cerenkov, scintillation, 'standard' optical and boundary process
modify/augment optical process parameters
derived from G4VPrimaryGeneratorAction
construction of G4ParticleGun
primary event generation via particle gun
derived from G4VUserRunAction
draw detector
Geometry : Changing geometry of three simplified sandwitch calorimeters without re-building a world volume.
Region : Defining geometrical regions ans setting production thresholds for each region.
Run : Utilizing a concrete run class derived from G4Run base class for accumulating physics quantities and hits as a run.
Hits : Demonstrating the use of primitive scorer and filter classes without implementing sensitive detector class.
main()
(source file)
main()
for interactive mode and batch mode via macro
file
construction and deletion of G4RunManager
construction and deletion of G4VisExective and G4UITerminal
construction and set of mandatory user classes
construction and set of ExN07RunAction
derived from G4VUserDetectorConstruction
definitions of materials and mixtures
G4Box with G4PVPlacement and G4PVReplica
Dynamic changing of size, position, orientation and number of volumes
G4Region for each calorimeter tower
G4VPrimitiveScorer and G4VSDFilter
visualization
derived from G4UIMessenger
definition of example-specific geometry commands
derived from G4VUserPhysicsList
difine all types of particles
define standard EM and decay processes
production thresholds for each region
derived from G4VPrimaryGeneratorAction
construction of G4ParticleGun
primary event generation via particle gun
derived from G4UserRunAction
constructing ExN07Run class object
print out a run summary with ExN07Run class object
derived from G4Run
uses G4THitsMap template class to accumulate physics quantities
extracts event data from G4Event and add up to run data