Introduction to GEANT4

From UCL HEP PBT Wiki

Revision as of 13:31, 3 July 2014 by IlinaMediaWiki (Talk | contribs)
Jump to: navigation, search

GEANT4 is a software toolkit based on C++. In your code you have to define:

  • Your experimental setup - geometry, materials and primary particles.
  • Which physics process you are interested in.
  • You may take actions during the simulation - inspect and store results.

The interaction with GEANT4 is done via base classes.

Mandatory classes
  • G4VUserDetectorConstruction : Describe the experimental setup, geometry and materials
  • G4VUserPhysicsList : Define particles, physics processes and range cuts
  • G4UserPrimaryGeneratorAction : Describe particle source, source dimensions, initial position, energy spectrum, angular distributions
Optional classes
  • G4UserRunAction : Define and store histograms
  • G4UserEventAction : Event selection and analysis of simulation data
  • G4UserStackingAction : Customize priority of tracks
  • G4UserTrackingAction : Decide whether a trajectory should be stored or not
  • G4UserSteppingAction : Kill, suspend, postpone a track
Manager class
  • G4RunManager : Manages the simulation process


The function main() defines the skeleton of your simulation code. Inside the function you instantiate G4RunManager and notify it of your mandatory and optional classes. Example main() function:

{

// Run manager construction

G4RunManager* runManager = new G4RunManager;


// mandatory user initialization classes

runManager->SetUserInitialization(new MyDetectorConstruction);

runManager->SetUserInitialization(new myPhysicsList);


// mandatory user action classes

runManager->SetUserAction(new MyPrimaryGeneratorAction);


// optional user action classes

runManager->SetUserAction(new MyEventAction);

runManager->SetUserAction(new MyRunAction);

...

}

Personal tools