Introduction to GEANT4
From UCL HEP PBT Wiki
m |
|||
Line 34: | Line 34: | ||
The function <span style="color:#ff0000"> main() </span> defines the skeleton of your simulation code. Inside the function you instantiate <span style="color:#ff0000"> G4RunManager </span> and notify it of your mandatory and optional classes. This is example <span style="color:#ff0000"> main() </span> function, where <span style="color:#ff0000"> MyDetectorConstruction </span>, <span style="color:#ff0000"> MyPhysicsList </span>, <span style="color:#ff0000"> MyPrimaryGeneratorAction </span>, <span style="color:#ff0000"> MyEventAction </span> and <span style="color:#ff0000"> MyRunAction </span> are derived classes from the GEANT4 base classes: | The function <span style="color:#ff0000"> main() </span> defines the skeleton of your simulation code. Inside the function you instantiate <span style="color:#ff0000"> G4RunManager </span> and notify it of your mandatory and optional classes. This is example <span style="color:#ff0000"> main() </span> function, where <span style="color:#ff0000"> MyDetectorConstruction </span>, <span style="color:#ff0000"> MyPhysicsList </span>, <span style="color:#ff0000"> MyPrimaryGeneratorAction </span>, <span style="color:#ff0000"> MyEventAction </span> and <span style="color:#ff0000"> MyRunAction </span> are derived classes from the GEANT4 base classes: | ||
- | + | <pre style="color: #800000; background-color: #dcdcdc"> | |
- | < | + | int main() { |
- | + | // 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); ... } | ||
+ | </pre> | ||
== <span style="color:#000080"> Experimental setup </span> == | == <span style="color:#000080"> Experimental setup </span> == |