| [828] | 1 | // $Id: README.TXT,v 1.1 1999/01/07 16:14:15 gunter Exp $
|
|---|
| 2 |
|
|---|
| 3 | GEANT4
|
|---|
| 4 |
|
|---|
| 5 | This directory contains several examples of GEANT4 main programs,
|
|---|
| 6 | from very simple cases (a purely batch program),
|
|---|
| 7 | to interactive programs based on the G4 command line interface,
|
|---|
| 8 | to more complex cases programs touching most of the G4 functionality.
|
|---|
| 9 |
|
|---|
| 10 | Those main programs provide just examples of initialization and usage
|
|---|
| 11 | of the GEANT4 toolkit classes, but the user is also free to define his
|
|---|
| 12 | own way and functions to initialize G4 and write the main program.
|
|---|
| 13 |
|
|---|
| 14 | A typical GEANT4 main program looks like the following:
|
|---|
| 15 |
|
|---|
| 16 | int main() {
|
|---|
| 17 |
|
|---|
| 18 | // Create Run Manager
|
|---|
| 19 | G4RunManager * runManager = new G4RunManager;
|
|---|
| 20 |
|
|---|
| 21 | // Register User Classes to the RunManager
|
|---|
| 22 | // Mandatory classes -----------------------
|
|---|
| 23 | // Detector geometry
|
|---|
| 24 | runManager-> set_userInitialization(new MyDetectorConstruction);
|
|---|
| 25 | // Physics List
|
|---|
| 26 | runManager-> set_userInitialization(new MyPhysicsList);
|
|---|
| 27 | // Primary Generator
|
|---|
| 28 | runManager->set_userAction(new MyPrimaryGeneratorAction);
|
|---|
| 29 |
|
|---|
| 30 | // Optiolnal classes -----------------------
|
|---|
| 31 | // User Actions
|
|---|
| 32 | runManager->set_userAction(new MyRunAction);
|
|---|
| 33 | runManager->set_userAction(new MyEventAction);
|
|---|
| 34 | runManager->set_userAction(new MyStackingAction);
|
|---|
| 35 | runManager->set_userAction(new MyTrackingAction);
|
|---|
| 36 | runManager->set_userAction(new MySteppingAction);
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 | // Define (G)UI terminal for interactive mode
|
|---|
| 40 | G4UIsession * session = new G4UIterminal;
|
|---|
| 41 |
|
|---|
| 42 | // User interactions
|
|---|
| 43 | session->sessionStart();
|
|---|
| 44 |
|
|---|
| 45 | // Termination
|
|---|
| 46 | delete session;
|
|---|
| 47 | delete runManager;
|
|---|
| 48 | return 0;
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | First of all, user must create the RunManager. The RunManager controles
|
|---|
| 52 | run sequence by receiving messages from the user via UIsession.
|
|---|
| 53 | The following are a part of commands for run controle;
|
|---|
| 54 | /run/initialize * Initialize G4 kernel.
|
|---|
| 55 | /run/beamOn * Start a Run.
|
|---|
| 56 | /run/verbose * Set the verbose level of G4RunManager.
|
|---|
| 57 | /run/abort * Abort current run processing.
|
|---|
| 58 | For example, event loop will start by using "/run/beamOn" commands.
|
|---|
| 59 |
|
|---|
| 60 | In order to execute simulation, user must provide geometrical
|
|---|
| 61 | configuration of his own detector. In addition information of
|
|---|
| 62 | primary events must be given with a list of particle types and
|
|---|
| 63 | processes for them.
|
|---|
| 64 |
|
|---|
| 65 | So, user must provide his own classes derived from the following
|
|---|
| 66 | three abstract classes by implementing their pure virtual functions
|
|---|
| 67 | and register those user classes to the RunManager.
|
|---|
| 68 |
|
|---|
| 69 | G4VUserDetectorConstruction - Detector Geometry, Materials
|
|---|
| 70 | pure virtual functions
|
|---|
| 71 | G4VPhysicalVolume* construct()
|
|---|
| 72 | - construct detectors;
|
|---|
| 73 | normally implemented to serve as the entry point
|
|---|
| 74 | for the tree of methods describing solids, volumes,
|
|---|
| 75 | materials and sensitive detectors.
|
|---|
| 76 |
|
|---|
| 77 | G4VUserPhysicsList - Particle types and Processes
|
|---|
| 78 | pure virtual functions
|
|---|
| 79 | void constructParticle()
|
|---|
| 80 | - construct particles;
|
|---|
| 81 | normally implemented to select desired particle types.
|
|---|
| 82 | void constructPhysics()
|
|---|
| 83 | - construct procesess;
|
|---|
| 84 | normally implemented to select desired physics processes
|
|---|
| 85 | for each particle types and register them to the ProcessManager.
|
|---|
| 86 | void setCuts(G4double aValue)
|
|---|
| 87 | - sets a cut value;
|
|---|
| 88 | normally implemented to set cut value in range for all
|
|---|
| 89 | particle types.
|
|---|
| 90 |
|
|---|
| 91 | G4VUserPrimaryGeneratorAction - Event Generator selection
|
|---|
| 92 | pure virtual functions
|
|---|
| 93 | void generatePrimaries(G4Event* anEvent)
|
|---|
| 94 | - generate a event with primary particles
|
|---|
| 95 | normally implemented to select the desired event generation
|
|---|
| 96 | mechanism, such as the ParticleGun or the PYTHIA interface.
|
|---|
| 97 |
|
|---|
| 98 | In addition to the above mandatory classes, there are 5 user classes
|
|---|
| 99 | to customize the default functionality of GEANT4 simulation.
|
|---|
| 100 |
|
|---|
| 101 | G4UserRunAction - Actions for each Run
|
|---|
| 102 | G4UserEventAction - Actions for each Event
|
|---|
| 103 | G4UserStackingAction - Tracks Stacking selection
|
|---|
| 104 | G4UserTrackingAction - Actions for each Track
|
|---|
| 105 | G4UserSteppingAction - Actions for each Step
|
|---|
| 106 |
|
|---|
| 107 | The virtual functions belonging to the classes above are:
|
|---|
| 108 |
|
|---|
| 109 | G4UserRunAction - void beginOfRunAction(G4Run*)
|
|---|
| 110 | - void endOfRunAction(G4Run*)
|
|---|
| 111 |
|
|---|
| 112 | G4UserEventAction - void beginOfEventAction(G4Event*)
|
|---|
| 113 | - void endOfEventAction(G4Event*)
|
|---|
| 114 |
|
|---|
| 115 | G4UserStackingAction - G4ClassificationOfNewTrack
|
|---|
| 116 | classifyNewTrack(G4Track *const)
|
|---|
| 117 | - void newStage()
|
|---|
| 118 | - void prepareNewEvent()
|
|---|
| 119 |
|
|---|
| 120 | G4UserTrackingAction - void preUserTrackingAction()
|
|---|
| 121 | - void postUserTrackingAction()
|
|---|
| 122 |
|
|---|
| 123 | G4UserSteppingAction - void userSteppingAction()
|
|---|
| 124 |
|
|---|
| 125 | Finally, more details can be found in the header files and in the source
|
|---|
| 126 | code relative to the classes outlined above.
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|