Contents Previous Next Geant4 User's Guide
For Application Developers
Examples


9.1 Novice Examples


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.

9.1.1 Novice Example Summary

Descriptions of the 7 novice examples are provided here along with links to the code.

ExampleN01 (Description below)

ExampleN02 (Description below) ExampleN03 (Description below) ExampleN04 (Description below) ExampleN05 (Description below) ExampleN06 (Description below) ExampleN07 (Description below)

Tables 9.1.1, 9.1.2 and 9.1.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 main() for interactive mode
SetCut and Process On/Off
Event event generator selection (particleGun) event generator selection (particleGun) event generator selection (particleGun)
``end of event'' simple analysis in UserEventAction
Tracking hard coded verbose level setting selecting secondaries select trajectories
Geometry geometry definition (CSG) geometry definition (includes Parametrised volume) geometry definition (includes replica)
uniform magnetic field uniform magnetic field
Hits/Digi - tracker type hits calorimeter-type hits
PIIM minimal particle set EM particles set EM particles set
single element material mixtures and compound elements mixtures and compound elements
Physics transportation EM physics EM physics
Vis - detector & trajectory drawing detector & trajectory drawing
tracker type hits drawing
(G)UI - GUI selection GUI selection
Global - - -
Table 9.1.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 (HEPEvtInterface) event generator selection (particleGun)
Stack control
Tracking select trajectories - -
selecting secondaries
Geometry geometry definition (includes Param/Replica) Ghost volume for shower parametrisation geometry definition (BREP with rotation)
non-uniform magnetic field
Hits/Digi Tracker/calorimeter/counter types Sensitive detector for shower parametrisation -
ReadOut geometry
PIIM Full particle set EM set EM set
mixtures and compound elements mixtures and compound elements mixtures and compound elements
Physics Full physics processes Parametrized shower Optical photon processes
Vis detector & hit drawing detector & hit drawing -
calorimeter type hits drawing - -
(G)UI define user commands define user commands define user commands
Global - - random number engine
Table 9.1.2
The ``item chart'' for novice level examples N04, N05, and N06.

  ExampleN07
comments Cuts per region
Run main() for interactive mode
Customized run class
Event event generator selection (particleGun)
Tracking -
Geometry geometry definition (includes Replica)
Region
Hits/Digi Primitive scorer
Filter
PIIM EM set
mixtures and compound elements
Physics EM processes
Vis detector & trajectory drawing
(G)UI define user commands
Global -
Table 9.1.3
The ``item chart'' for novice level example N07.


9.1.2 Example N01

Basic concepts
minimal set for geantino transportation

Classes

main()
(source file)

ExN01DetectorConstruction

(header file) (source file)

ExN01PhysicsList

(header files) (source file)

ExN01PrimaryGeneratorAction

(header file) (source file)


9.1.3 Example N02

Basic concepts
Detector: fixed target type
Processes: EM
Hits: tracker type hits

Classes

main()
(source file)

ExN02DetectorConstruction

(header file) (source file)

ExN02MagneticField

(header file) (source file)

ExN02PhysicsList

(header file) (source file)

ExN02PrimaryGeneratorAction

(header file) (source file)

ExN02RunAction

(header file) (source file)

ExN02EventAction

(header file) (source file)

ExN02TrackerSD

(header file) (source file)

ExN02TrackerHit

(header file) (source file)

9.1.4 Example N03

Basic concepts
Visualize Em processes.
Interactivity: build messenger classes.
Gun: shoot particle randomly.
Tracking: collect energy deposition, total track length

Classes

main()
(source file)

ExN03DetectorConstruction

(header file) (source file)

ExN03PhysicsList

(header file) (source file)

ExN03PrimaryGeneratorAction

(header file) (source file)

ExN03RunAction

(header file) (source file)

ExN03EventAction

(header file) (source file)

ExN03SteppingAction

(header file) (source file)


9.1.5 Example N04

Basic concepts
Simplified collider experiment geometry
Full hits/digits/trigger

Classes

main()
(source file)

ExN04DetectorConstruction

(header file) (source file)

ExN04TrackerParametrisation

(header file) (source file)

ExN04CalorimeterParametrisation

(header file) (source file)

ExN04MagneticField

(header file) (source file)

ExN04TrackerSD

(header file) (source file)

ExN04TrackerHit

(header file) (source file)

ExN04CalorimeterSD

(header file) (source file)

ExN04CalorimeterHit

(header file) (source file)

ExN04MuonSD

(header file) (source file)

ExN04MuonHit

(header file) (source file)

ExN04PrimaryGeneratorAction

(header file) (source file)

ExN04EventAction

(header file) (source file)

ExN04StackingAction

(header file) (source file)

ExN04StackingActionMessenger

(header file) (source file)

ExN04TrackingAction

(header file) (source file)


9.1.6 Example N05

Basic concepts
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 ?)

Classes

main()
(source file)

ExN05EMShowerModel

(header file) (source file)

ExN05PionShowerModel

(header file) (source file)

ExN05DetectorConstruction

(header file) (source file)

ExN05PhysicsList

(header file) (source file)

ExN05PrimaryGeneratorAction

(header file) (source file)

ExN05RunAction

(header file) (source file)

ExN05EventAction

(header file) (source file)


9.1.7 Example N06

Basic concepts
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.

Classes

main()
(source file)

ExN06DetectorConstruction

(header file) (source file)

ExN06PhysicsList

(header file) (source file)

ExN06PrimaryGeneratorAction

(header file) (source file)

ExN06RunAction

(header file) (source file)


9.1.8 Example N07

Basic concepts
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.

Classes

main()
(source file)

ExN07DetectorConstruction

(header file) (source file)

ExN07DetectorMessenger

(header file) (source file)

ExN07PhysicsList

(header file) (source file)

ExN07PrimaryGeneratorAction

(header file) (source file)

ExN07RunAction

(header file) (source file)

ExN07Run

(header file) (source file)


About the authors