12.07.2015 Views

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Getting Started with <strong>Geant4</strong>- Running a Simple Example1. how the detector should be constructed,2. all the particles and all the physics processes to be simulated,3. how the primary particle(s) in an event should be produced and4. any additional requirements of the simulation.In the sample main() the linesrunManager->SetUserInitialization(new ExN01DetectorConstruction);runManager->SetUserInitialization(new ExN01PhysicsList);create objects which specify the detector geometry and physics processes, respectively, and pass their pointers tothe run manager. ExN01DetectorConstruction is an example of a user initialization class which is derived fromG4VUserDetectorConstruction. This is where the user describes the entire detector setup, including• its geometry,• the materials used in its construction,• a definition of its sensitive regions and• the readout schemes of the sensitive regions.Similarly ExN01PhysicsList is derived from G4VUserPhysicsList and requires the user to define• the particles to be used in the simulation,• the range cuts <strong>for</strong> these particles and• all the physics processes to be simulated.The next instruction in main()runManager->SetUserAction(new ExN01PrimaryGeneratorAction);creates an instance of a particle generator and passes its pointer to the run manager.ExN01PrimaryGeneratorAction is an example of a user action class which is derived fromG4VUserPrimaryGeneratorAction. In this class the user must describe the initial state of the primary event. Thisclass has a public virtual method named generatePrimaries() which will be invoked at the beginning ofeach event. Details will be given in Section 2.6. Note that <strong>Geant4</strong> does not provide any default behavior <strong>for</strong> generatinga primary event.The next instructionrunManager->Initialize();per<strong>for</strong>ms the detector construction, creates the physics processes, calculates cross sections and otherwise sets upthe run. The final run manager method in main()int numberOfEvent = 3;runManager->beamOn(numberOfEvent);begins a run of three sequentially processed events. The beamOn() method may be invoked any number oftimes within main() with each invocation representing a separate run. Once a run has begun neither the detectorsetup nor the physics processes may be changed. They may be changed between runs, however, as described inSection 3.4.4. More in<strong>for</strong>mation on G4RunManager in general is found in Section 3.4.3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!