Introduction to GEANT4

From UCL HEP PBT Wiki

Jump to: navigation, search
m
m
Line 164: Line 164:
-
GEANT4 provides a variety of physics processes. These processes are decoupled from one another and you can select those which are relevant to your simulation. The processes are grouped in seven categories and their full list is available [http://geant4.cern.ch/support/proc_mod_catalog/processes/ here]:
+
GEANT4 provides a variety of physics processes. These processes are decoupled from one another and you can select those which are relevant to your simulation. The processes are grouped in seven categories and their list is available [http://geant4.cern.ch/support/proc_mod_catalog/processes/ here]:
<div style="column-count:2;-moz-column-count:2;-webkit-column-count:2">
<div style="column-count:2;-moz-column-count:2;-webkit-column-count:2">
Line 177: Line 177:
-
In method ConstructProcess() define your physics processes:
+
For each particle defined in ConstructParticle() assign all the physics processes that you want to
 +
consider in your simulation:  
    
    
Line 246: Line 247:
=== <span style="color:#000080"> Detailed physics lists </span> ===  
=== <span style="color:#000080"> Detailed physics lists </span> ===  
-
If you want to build more realistic physics list you have to use the class <span style="color:#ff0000"> G4VModularPhysicsList </span>. For example, the photon from the example above can undergo compton scattering apart from conversion. In <span style="color:#ff0000"> G4VModularPhysicsList </span> you can group the physics processes into separate modules: EM physics, hadronic physics, optical physics etc.  
+
If you want to build more realistic physics list you have to use the class <span style="color:#ff0000"> G4VModularPhysicsList </span>. For example, the photon from the example above can undergo compton scattering apart from conversion. In <span style="color:#ff0000"> G4VModularPhysicsList </span> you can group the physics processes into separate modules: EM physics, hadronic physics, decay physics etc.  
Line 252: Line 253:
-
<span style="color:#800000"> class MyPhysicsList:public G4VModularPhysicsList {
+
<span style="color:#800000"> class MyPhysicsList:public G4VModularPhysicsList { </span>
-
<span style="color:#800000"> public:
+
<span style="color:#800000"> public: </span>
-
<span style="color:#800000"> MyPhysicsList();
+
<span style="color:#800000"> MyPhysicsList(); </span>
-
<span style="color:#800000"> ~MyPhysicsList();
+
-
<span style="color:#800000"> virtual void ConstructParticle();
+
<span style="color:#800000"> ~MyPhysicsList(); </span>
 +
 
 +
<span style="color:#800000"> virtual void ConstructParticle(); </span>
      
      
-
<span style="color:#800000"> virtual void SetCuts();
+
<span style="color:#800000"> virtual void SetCuts(); </span>
          
          
-
<span style="color:#800000"> void AddPhysicsList(const G4String& name);
+
<span style="color:#800000"> void AddPhysicsList(const G4String& name); </span>
-
<span style="color:#800000"> virtual void ConstructProcess();
+
 
 +
<span style="color:#800000"> virtual void ConstructProcess(); </span>
        
        
-
<span style="color:#800000"> private:
+
<span style="color:#800000"> private: </span>
      
      
-
<span style="color:#800000"> G4String                            fEmName;
+
<span style="color:#800000"> G4String                            fEmName; </span>
-
<span style="color:#800000"> G4VPhysicsConstructor*              fEmPhysicsList;
+
-
<span style="color:#800000"> G4VPhysicsConstructor*              fDecPhysicsList;
+
-
<span style="color:#800000"> std::vector<G4VPhysicsConstructor*>  fHadronPhys; };
+
 +
<span style="color:#800000"> G4VPhysicsConstructor*              fEmPhysicsList; </span>
-
<span style="color:#800000"> MyPhysicsList::MyPhysicsList():G4ModularPhysicsList() { </span>
+
<span style="color:#800000"> G4VPhysicsConstructor*              fDecPhysicsList; </span>
-
<span style="color:#800000"> defaultCutValue = 1.0*mm; </span>
+
<span style="color:#800000"> std::vector<G4VPhysicsConstructor*>  fHadronPhysicsList; }; </span>
-
<span style="color:#800000"> RegisterPhysics(new ProtonPhysics()); // All physics processes having to do with protons </span>
 
-
<span style="color:#800000"> RegisterPhysics(new ElectronPhysics()); // All physics processes having to do with electrons </span>
+
Now we can build the physics lists:
-
<span style="color:#800000"> RegisterPhysics(new DecayPhysics()); // Physics of unstable particles </span>
 
 +
<span style="color:#800000"> void MyPhysicsList::AddPhysicsList(const G4String& name) { </span>
-
where for example class ProtonPhysics() is defined as:
+
<span style="color:#800000"> ... </span>
 +
<span style="color:#800000"> if (name == "emstandard_opt3") { </span>
 +
   
 +
<span style="color:#800000"> fEmName = name; </span> 
 +
   
 +
<span style="color:#800000"> delete fEmPhysicsList; </span>
 +
   
 +
<span style="color:#800000"> fEmPhysicsList = new G4EmStandardPhysics_option3(); </span> 
-
<span style="color:#800000"> class ProtonPhysics():public G4VPhysicsConstructor { </span>
+
<span style="color:#800000"> } else if (name == "emlivermore") { </span>
 +
 
 +
<span style="color:#800000"> fEmName = name; </span>
 +
   
 +
<span style="color:#800000"> delete fEmPhysicsList; </span>
 +
   
 +
<span style="color:#800000"> fEmPhysicsList = new G4EmLivermorePhysics(); </span>
-
<span style="color:#800000"> public: </span>
+
<span style="color:#800000"> } else if (name == "empenelope") { </span>
 +
   
 +
<span style="color:#800000"> fEmName = name; </span>
 +
   
 +
<span style="color:#800000"> delete fEmPhysicsList; </span>
 +
   
 +
<span style="color:#800000"> fEmPhysicsList = new G4EmPenelopePhysics(); </span>
-
<span style="color:#800000"> ProtonPhysics(const G4String& name="proton"); </span>
+
<span style="color:#800000"> } else if (name == "HElastic") { </span>
 +
   
 +
<span style="color:#800000"> fHadronPhysicsList.push_back( new G4HadronHElasticPhysics()); </span>
-
<span style="color:#800000"> virtual ~ProtonPhysics(); </span>
+
<span style="color:#800000"> } else if (name == "HInelastic") { </span>
 +
 
 +
<span style="color:#800000"> fHadronPhysicsList.push_back(new G4HadronInelasticQBBC()); </span>
 +
   
 +
<span style="color:#800000"> } ... } </span>
-
<span style="color:#800000"> virtual void ConstructParticle(); </span>
 
-
<span style="color:#800000"> virtual void ConstructProcess(); } </span>
+
and
-
Particle production thresholds are defined in method SetCuts():
+
<span style="color:#800000"> void MyPhysicsList::ConstructProcess() { </span>
-
 
+
-
 
+
<span style="color:#800000"> AddTransportation(); // transportation </span>
-
<span style="color:#800000"> void MyModPhysList::SetCuts() </span>
+
 
-
 
+
<span style="color:#800000"> fEmPhysicsList->ConstructProcess(); // electromagnetic physics list </span>
-
<span style="color:#800000"> {SetCutsWithDefault();} </span>
+
 +
<span style="color:#800000"> fDecPhysicsList->ConstructProcess(); // decay physics list </span>
 +
 
 +
<span style="color:#800000"> for(size_t i=0; i<fHadronPhys.size(); i++) { // hadronic physics lists </span>
 +
 
 +
<span style="color:#800000"> fHadronPhys[i]->ConstructProcess(); } } </span>
 +
 
=== <span style="color:#000080"> Pre-packaged physics lists </span> ===
=== <span style="color:#000080"> Pre-packaged physics lists </span> ===

Revision as of 10:02, 8 July 2014

Personal tools