Introduction to GEANT4
From UCL HEP PBT Wiki
m |
m |
||
Line 1: | Line 1: | ||
== <span style="color:#000080"> Introduction </span> == | == <span style="color:#000080"> Introduction </span> == | ||
+ | |||
GEANT4 is a software toolkit based on C++. In your code you have to define: | GEANT4 is a software toolkit based on C++. In your code you have to define: | ||
Line 28: | Line 29: | ||
== <span style="color:#000080"> The function main() </span> == | == <span style="color:#000080"> The function main() </span> == | ||
+ | |||
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 MyDetectorConstruction, MyPhysicsList, MyPrimaryGeneratorAction, MyEventAction and MyRunAction 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 MyDetectorConstruction, MyPhysicsList, MyPrimaryGeneratorAction, MyEventAction and MyRunAction are derived classes from the GEANT4 base classes: | ||
Line 63: | Line 65: | ||
== <span style="color:#000080"> Experimental setup </span> == | == <span style="color:#000080"> Experimental setup </span> == | ||
+ | |||
You can define your experiment by using three base classes: | You can define your experiment by using three base classes: | ||
Line 107: | Line 110: | ||
<span style="color:#800000"> H2O->AddElement(O, natoms=1); </span> | <span style="color:#800000"> H2O->AddElement(O, natoms=1); </span> | ||
+ | |||
== <span style="color:#000080"> Physics processes </span> == | == <span style="color:#000080"> Physics processes </span> == | ||
+ | |||
Two kinds of base physics list classes are available for users to derive from <span style="color:#ff0000"> G4VUserPhysicsList </span> and <span style="color:#ff0000"> G4ModularPhysicsList </span>. There exist also prepackaged physics list. | Two kinds of base physics list classes are available for users to derive from <span style="color:#ff0000"> G4VUserPhysicsList </span> and <span style="color:#ff0000"> G4ModularPhysicsList </span>. There exist also prepackaged physics list. | ||
Line 114: | Line 119: | ||
=== <span style="color:#000080"> Simple physics lists </span> === | === <span style="color:#000080"> Simple physics lists </span> === | ||
+ | |||
The class <span style="color:#ff0000"> G4VUserPhysicsList </span> is used for simple physics lists. It has three methods: | The class <span style="color:#ff0000"> G4VUserPhysicsList </span> is used for simple physics lists. It has three methods: | ||
Line 123: | Line 129: | ||
- | + | You can define your own class derived from the base class <span style="color:#ff0000"> G4VUserPhysicsList </span> in the following way: | |
Line 141: | Line 147: | ||
- | Now | + | Now implement the methods ConstructParticle(), ConstructProcess() and SetCuts(): |
Line 161: | Line 167: | ||
GEANT4 provides a variety of physics processes. These processes are decoupled from one another and the user can select those processes which are relevant to his/her simulation. There are seven categories of processes provided by GEANT4: | GEANT4 provides a variety of physics processes. These processes are decoupled from one another and the user can select those processes which are relevant to his/her simulation. There are seven categories of processes provided by GEANT4: | ||
- | + | <div style="column-count:2;-moz-column-count:2;-webkit-column-count:2"> | |
- | + | * electromagnetic | |
- | + | * hadronic | |
- | + | * decay | |
- | + | * photolepton-hadron | |
- | + | * optical | |
- | + | * parameterization | |
- | + | * transportation | |
- | + | </div> | |
- | In method ConstructProcess() you | + | In method ConstructProcess() you define your physics processes: |
Line 213: | Line 219: | ||
+ | <span style="color:#800000"> void MyPhysicsList::ConstructGeneral() </span> | ||
- | <span style="color:#800000"> | + | <span style="color:#800000"> G4Decay* theDecayProcess = new G4Decay() </span> |
+ | <span style="color:#800000"> { aParticleIterator->reset(); </span> | ||
+ | <span style="color:#800000"> while( (*aParticleIterator)() ){ </span> | ||
+ | <span style="color:#800000"> G4ParticleDefinition* particle = aParticleIterator->value(); </span> | ||
+ | |||
+ | <span style="color:#800000"> G4ProcessManager* pmanager = particle->GetProcessManager(); </span> | ||
+ | <span style="color:#800000"> if theDecayProcess->IsApplicable(*particle)) { </span> | ||
+ | |||
+ | <span style="color:#800000"> pmanager->AddProcess(theDecayProcess); </span> | ||
+ | |||
+ | <span style="color:#800000"> pmanager->SetProcessOrdering(theDecayProcess,idxPostStep); </span> | ||
+ | |||
+ | <span style="color:#800000"> pmanager->SetProcessOrdering(theDecayProcess,idxAtRest); }}} </span> | ||