Introduction to GEANT4

From UCL HEP PBT Wiki

Jump to: navigation, search
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">
-
<span style="color:#800000"> int main() { </span>
+
int main() {  
    
    
-
<span style="color:#800000"> // Run manager construction </span>
+
// Run manager construction  
-
 
+
-
<span style="color:#800000"> G4RunManager* runManager = new G4RunManager; </span>
+
 +
G4RunManager* runManager = new G4RunManager;
-
<span style="color:#800000"> // mandatory user initialization classes </span>
 
-
<span style="color:#800000"> runManager->SetUserInitialization(new MyDetectorConstruction); </span>
+
// mandatory user initialization classes
-
<span style="color:#800000"> runManager->SetUserInitialization(new MyPhysicsList); </span>
+
runManager->SetUserInitialization(new MyDetectorConstruction);  
 +
runManager->SetUserInitialization(new MyPhysicsList);
-
<span style="color:#800000"> // mandatory user action classes  </span>
 
-
<span style="color:#800000"> runManager->SetUserAction(new MyPrimaryGeneratorAction); </span>
+
// mandatory user action classes 
 +
runManager->SetUserAction(new MyPrimaryGeneratorAction);
-
<span style="color:#800000"> // optional user action classes </span> 
 
-
<span style="color:#800000"> runManager->SetUserAction(new MyEventAction); </span>
+
// optional user action classes
-
<span style="color:#800000"> runManager->SetUserAction(new MyRunAction); ... } </span>
+
runManager->SetUserAction(new MyEventAction);
 +
runManager->SetUserAction(new MyRunAction); ... }
 +
</pre>
   
   
== <span style="color:#000080"> Experimental setup </span> ==
== <span style="color:#000080"> Experimental setup </span> ==

Revision as of 08:14, 10 July 2014

Personal tools