Introduction to GEANT4

From UCL HEP PBT Wiki

Jump to: navigation, search
m
m
Line 77: Line 77:
-
<span style="color:#800000"> G4VSolid* pBoxSolid = new G4Box(“WaterBox”, 1.*m, 2.*m, 3.*m); </span>  
+
<span style="color:#800000"> class DetectorConstruction:public G4VUserDetectorConstruction { </span>
-
<span style="color:#800000"> G4LogicalVolume* pBoxLog = new G4LogicalVolume( pBoxSolid, water, “WaterBox”); </span>  
+
<span style="color:#800000"> public: </span>
 +
   
 +
<span style="color:#800000"> DetectorConstruction(); </span>
-
<span style="color:#800000"> G4VPhysicalVolume* aBoxPhys = new G4PVPlacement( pRotation, G4ThreeVector(posX, posY, posZ), pBoxLog, “WaterBox”, pWorldLog,
+
<span style="color:#800000"> ~DetectorConstruction(); </span>
-
false, copyNo); </span>  
+
 +
 +
<span style="color:#800000"> public: </span> 
 +
   
 +
<span style="color:#800000"> virtual G4VPhysicalVolume* Construct(); </span>
 +
 +
   
 +
<span style="color:#800000"> private: </span>
    
    
-
Your detector is always placed in a mother volume called the world volume. 
+
<span style="color:#800000"> void  DefineMaterials(); }; </span> 
-
The world volume is defined in a similar way:
+
 +
 +
Now construct the detector. Your detector is always placed in a mother volume called the world volume. 
 +
 +
 +
<span style="color:#800000"> G4PhysicalVolume* DetectorConstruction::Construct() { </span>
 +
 +
<span style="color:#800000"> ... </span>
 +
 +
<span style="color:#800000"> // World volume </span>
<span style="color:#800000"> G4VSolid* pWorld = new G4Box("World",5*m,5*m,5*m); </span>
<span style="color:#800000"> G4VSolid* pWorld = new G4Box("World",5*m,5*m,5*m); </span>
Line 96: Line 112:
-
The elements and materials used in the experiment are defined using classes <span style="color:#ff0000"> G4Element </span> and <span style="color:#ff0000"> G4Material </span>. For example water, hydrogen and oxygen are defined as:
+
<span style="color:#800000"> // Water box </span>
 +
 
 +
<span style="color:#800000"> G4VSolid* pBoxSolid = new G4Box(“WaterBox”, 1.*m, 2.*m, 3.*m); </span>
 +
 
 +
<span style="color:#800000"> G4LogicalVolume* pBoxLog = new G4LogicalVolume( pBoxSolid, water, “WaterBox”); </span>
 +
 
 +
<span style="color:#800000"> G4VPhysicalVolume* aBoxPhys = new G4PVPlacement( pRotation, G4ThreeVector(posX, posY, posZ), pBoxLog, “WaterBox”, pWorldLog, false, copyNo); ... } </span>
 +
 
 +
 
 +
The elements and materials are defined using classes <span style="color:#ff0000"> G4Element </span> and <span style="color:#ff0000"> G4Material </span>. For example water, hydrogen and oxygen are defined as:
 +
 
 +
<span style="color:#800000"> void DetectorConstruction::DefineMaterials() { </span>
 +
<span style="color:#800000"> ... </span>
<span style="color:#800000"> G4Element* H = new G4Element("Hydrogen","H",z=1.,a= 1.01*g/mole); </span>
<span style="color:#800000"> G4Element* H = new G4Element("Hydrogen","H",z=1.,a= 1.01*g/mole); </span>
Line 110: Line 138:
<span style="color:#800000"> H2O->AddElement(H, natoms=2); </span>  
<span style="color:#800000"> H2O->AddElement(H, natoms=2); </span>  
-
<span style="color:#800000"> H2O->AddElement(O, natoms=1); </span>  
+
<span style="color:#800000"> H2O->AddElement(O, natoms=1); ...} </span>  

Revision as of 10:44, 8 July 2014

Personal tools