Introduction to GEANT4

From UCL HEP PBT Wiki

Jump to: navigation, search
m
m
Line 109: Line 109:
== <span style="color:#000080"> Physics processes </span> ==  
== <span style="color:#000080"> Physics processes </span> ==  
 +
 +
There are two 
 +
<span style="color:#ff0000"> G4VUserPhysicsList </span> is a mandatory user class. It has three methods:
<span style="color:#ff0000"> G4VUserPhysicsList </span> is a mandatory user class. It has three methods:
Line 114: Line 117:
* ConstructParticles(): define all necessary particles;   
* ConstructParticles(): define all necessary particles;   
* ConstructProcesses(): define all necessary processes and assign them to proper particles;
* ConstructProcesses(): define all necessary processes and assign them to proper particles;
-
* SetCuts(): define production thresholds (in terms of range);  
+
* SetCuts(): define production thresholds in terms of range;  
-
GEANT4 provides a variety of physics processes of particle interactions with matter. There are seven categories of processes provided by GEANT4:
+
GEANT4 provides a variety of physics processes of particle interactions with matter. The processes are decoupled from one another and the user can select those ones which are relevant for the simulation. There are seven categories of processes provided by GEANT4:
# electromagnetic  
# electromagnetic  
Line 125: Line 128:
# photolepton-hadron  
# photolepton-hadron  
# optical
# optical
-
# parameterization
+
# parameterization - "fast simulation" physics
# transportation   
# transportation   
This example shows how to define your own class from the G4VUserPhysicsList base class.
This example shows how to define your own class from the G4VUserPhysicsList base class.
 +
������������<span style="color:#800000"> class MyPhysicsList:public G4VUserPhysicsList() </span>
-
<span style="color:#800000"> MyPhysicsList :: MyPhysicsList(): G4VUserPhysicsList() </span>
+
<span style="color:#800000"> { public: </span>
-
<span style="color:#800000"> { //Define production thresholds </span>
+
<span style="color:#800000"> MyPhysicsList(); </span>
-
<span style="color:#800000"> defaultCutValue = 1.0*cm;} </span>
+
<span style="color:#800000"> ~MyPhysicsList(); </span>
 +
<span style="color:#800000"> void ConstructParticle(); </span>
 +
<span style="color:#800000"> void ConstructProcess(); </span>
 +
 +
<span style="color:#800000"> void SetCuts(); } </span>
 +
 +
 +
Now you must implement the methods ConstructParticle(), ConstructProcess() and SetCuts().
 +
 +
<span style="color:#800000"> void MyPhysicsList :: ConstructParticles() </span>
<span style="color:#800000"> void MyPhysicsList :: ConstructParticles() </span>
Line 146: Line 159:
<span style="color:#800000"> G4Positron::PositronDefinition(); </span>
<span style="color:#800000"> G4Positron::PositronDefinition(); </span>
-
<span style="color:#800000"> G4Gamma::GammaDefinition();} </span>
+
<span style="color:#800000"> G4Proton::ProtonDefinition(); </span>
 +
<span style="color:#800000"> G4Neutron::NeutronDefinition(); </span>
 +
 +
<span style="color:#800000"> G4Gamma::GammaDefinition(); ... } </span>
 +
 +
 +
<span style="color:#800000"> void MyPhysicsList :: ConstructProcess() </span>
 +
 +
<span style="color:#800000"> { // Assign transportation process to all particles </span>
 +
 +
<span style="color:#800000"> AddTransportation(); </span>
 +
 +
<span style="color:#800000"> // Electromagnetic processes </span>
 +
 +
<span style="color:#800000"> ConstructEM(); </span>
 +
 +
<span style="color:#800000"> // Other processes </span>
 +
 +
<span style="color:#800000"> ConstructGeneral(); ... } </span>
 +
 +
 +
where the method Construct() can be defined as:
 +
 +
 +
<span style="color:#800000"> void MyPhysicsList::ConstructEM() </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"> G4String particleName = particle->GetParticleName(); </span>
 +
   
 +
<span style="color:#800000"> if (particleName == "gamma") { </span>
 +
   
 +
<span style="color:#800000"> pmanager->AddDiscreteProcess(new G4GammaConversion); ...} </span>
 +
   
<span style="color:#800000"> void MyPhysicsList :: SetCuts() </span>
<span style="color:#800000"> void MyPhysicsList :: SetCuts() </span>
-
<span style="color:#800000"> { //Set the production threshold </span>
+
<span style="color:#800000"> { defaultCutValue = 1.0*mm; </span>
 +
 
 +
<span style="color:#800000"> SetCutValue(defaultCutValue, "gamma"); </span>
 +
 
 +
<span style="color:#800000"> SetCutValue(defaultCutValue, "e+"); </span>
-
<span style="color:#800000"> SetCutsWithDefault();} </span>
+
<span style="color:#800000"> SetCutValue(defaultCutValue, "e-"); </span>

Revision as of 10:43, 7 July 2014

Personal tools