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. Novice Example Summary 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 , and display the ``item charts'' for the examples currently prepared in the novice level. The ``item chart'' for novice level examples <literal>N01</literal>, <literal>N02</literal> and <literal>N03</literal>. 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) uniform magnetic field geometry definition (includes replica) uniform magnetic field Hits/Digi - tracker type hits calorimeter-type hits PIIM minimal particle set single element material EM particles set mixtures and compound elements EM particles set mixtures and compound elements Physics transportation EM physics EM physics Vis - detector & trajectory drawing tracker type hits drawing detector & trajectory drawing (G)UI - GUI selection GUI selection Global - - -
The ``item chart'' for novice level examples <literal>N04</literal>, <literal>N05</literal>, and <literal>N06</literal>. 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) Stack control event generator selection (HEPEvtInterface) event generator selection (particleGun) Tracking select trajectories selecting secondaries - - Geometry geometry definition (includes Param/Replica) non-uniform magnetic field ghost volume for shower parametrisation geometry definition (BREP with rotation) Hits/Digi Tracker/calorimeter/counter types ReadOut geometry Sensitive detector for shower parametrisation - PIIM Full particle set mixtures and compound elements EM set mixtures and compound elements EM set mixtures and compound elements Physics Full physics processes Parametrized shower Optical photon processes Vis detector & hit drawing calorimeter type hits drawing detector & hit drawing - (G)UI define user commands define user commands define user commands Global - - random number engine
The ``item chart'' for novice level example <literal>N07</literal>. 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 -
Example N01 Basic concepts minimal set for geantino transportation Classes 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 ExN01DetectorConstruction (header file) (source file) derived from G4VUserDetectorConstruction definitions of single element materials CSG solids G4PVPlacement without rotation ExN01PhysicsList (header file) (source file) derived from G4VUserPhysicsList definition of geantino assignment of transportation process ExN01PrimaryGeneratorAction (header file) (source file) derived from G4VPrimaryGeneratorAction construction of G4ParticleGun primary event generation via particle gun Example N02 Basic concepts Detector: fixed target type Processes: EM Hits: tracker type hits Classes 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 ExN02DetectorConstruction (header file) (source file) 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 ExN02MagneticField (header file) (source file) derived from G4MagneticField Uniform field. ExN02MagneticField ExN02PhysicsList (header file) (source file) derived from G4VUserPhysicsList definition of geantinos, electrons, positrons, gammas utilisation of transportation and 'standard' EM-processes Interactivity: chooses processes interactively (=> messenger class) ExN02PrimaryGeneratorAction (header file) (source file) derived from G4VPrimaryGeneratorAction construction of G4ParticleGun primary event generation via particle gun ExN02RunAction (header file) (source file) derived from G4VUserRunAction draw detector ExN02EventAction (header file) (source file) derived from G4VUserEventAction print time information ExN02TrackerSD (header file) (source file) derived from G4VSensitiveDetector tracker-type hit generation ExN02TrackerHit (header file) (source file) derived from G4VHit draw hit point 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) 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 ExN03DetectorConstruction (header file) (source 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 ExN03PhysicsList (header file) (source file) 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) ExN03PrimaryGeneratorAction (header file) (source file) derived from G4VPrimaryGeneratorAction construction of G4ParticleGun primary event generation via particle gun Interactivity: shoot particle randomly. (=> messenger class) ExN03RunAction (header file) (source file) derived from G4VUserRunAction draw detector and tracks Interactivity: SetCut, process on/off. Interactivity: change detector size, material, magnetic field. ExN03EventAction (header file) (source file) derived from G4VUserEventAction store trajectories print end of event information (energy deposited, etc.) ExN03SteppingAction (header file) (source file) derived from G4VUserSteppingAction collect energy deposition, etc. Example N04 Basic concepts Simplified collider experiment geometry Full hits/digits/trigger Classes main() (source file) construction and deletion of ExN04RunManager construction and deletion of (G)UI session and VisManager construction and set of user classes ExN04DetectorConstruction (header file) (source file) 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 ExN04TrackerParametrisation (header file) (source file) derived from G4VPVParametrisation parametrised sizes ExN04CalorimeterParametrisation (header file) (source file) derived from G4VPVParametrisation parametrized position/rotation ExN04MagneticField (header file) (source file) derived from G4MagneticField solenoid and toroidal fields ExN04TrackerSD (header file) (source file) derived from G4VSensitiveDetector tracker-type hit generation ExN04TrackerHit (header file) (source file) derived from G4VHit draw hit point ExN04CalorimeterSD (header file) (source file) derived from G4VSensitiveDetector calorimeter-type hit generation ExN04CalorimeterHit (header file) (source file) derived from G4VHit draw physical volume with variable color ExN04MuonSD (header file) (source file) derived from G4VSensitiveDetector Scintillator-type hit generation ExN04MuonHit (header file) (source file) derived from G4VHit draw physical volume with variable color ExN04PrimaryGeneratorAction (header file) (source file) derived from G4VPrimaryGeneratorAction construction of G4HEPEvtInterface primary event generation with PYTHIA event ExN04EventAction (header file) (source file) store the initial seeds ExN04StackingAction (header file) (source file) derived from G4UserStackingAction ``stage'' control and priority control event abortion ExN04StackingActionMessenger (header file) (source file) derived from G4UImessenger define abortion conditions ExN04TrackingAction (header file) (source file) derived from G4UserTrackingAction select trajectories select secondaries 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) 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 ExN05EMShowerModel (header file) (source file) derived from G4VFastSimulationModel energy deposition in sensitive detector ExN05PionShowerModel (header file) (source file) derived from G4VFastSimulationModel energy deposition in sensitive detector ExN05DetectorConstruction (header file) (source file) derived from G4VUserDetectorConstruction definitions of single materials and mixtures CSG solids G4PVPlacement ExN05PhysicsList (header file) (source file) derived from G4VUserPhysicsList assignment of G4FastSimulationManagerProcess ExN05PrimaryGeneratorAction (header file) (source file) derived from G4VPrimaryGeneratorAction construction of G4ParticleGun primary event generation via particle gun ExN05RunAction (header file) (source file) derived from G4VUserRunAction draw detector (activation/deactivation of parameterisation ?) ExN05EventAction (header file) (source file) derived from G4VUserEventAction print time information 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) 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 ExN06DetectorConstruction (header file) (source file) 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 ExN06PhysicsList (header file) (source file) 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 ExN06PrimaryGeneratorAction (header file) (source file) derived from G4VPrimaryGeneratorAction construction of G4ParticleGun primary event generation via particle gun ExN06RunAction (header file) (source file) derived from G4VUserRunAction draw detector 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) 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 ExN07DetectorConstruction (header file) (source file) 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 ExN07DetectorMessenger (header file) (source file) derived from G4UIMessenger definition of example-specific geometry commands ExN07PhysicsList (header file) (source file) derived from G4VUserPhysicsList difine all types of particles define standard EM and decay processes production thresholds for each region ExN07PrimaryGeneratorAction (header file) (source file) derived from G4VPrimaryGeneratorAction construction of G4ParticleGun primary event generation via particle gun ExN07RunAction (header file) (source file) derived from G4UserRunAction constructing ExN07Run class object print out a run summary with ExN07Run class object ExN07Run (header file) (source file) derived from G4Run uses G4THitsMap template class to accumulate physics quantities extracts event data from G4Event and add up to run data