B1 example - andreagp/Geant4-tutorial GitHub Wiki
Once every thing is configured, in a terminal go the directory where you would like to clone Geant4-tutorial:
git clone [email protected]:andreagp/Geant4-tutorial.git
cd Geant4-tutorial/B1/
git status to confirm you are in master branch, then create your own branch
git checkout -b dev-yourusername
git status and confirm you are in the new branch
Now create a build directory:
mkdir ./../B1-build
cd ./../B1-build
Build and compile example:
cmake -DGeant4_DIR=$G4DIR ./../B1/
make
Run example"
./exampleB1
You should see a Qt4 window with the geometry of the simulation. In the Qt4 windows, type:
/run/beamOn 200
Open a new terminal and go to Geant4-tutorial/B1/ (where the source code is). Here check that you are in the right git branch because you are going to make modifications in the source code of the example.
Open src/B1DetectorConstruction.cc We are going to change "shape1" to a box.
First comment the conical shape section since you don't need it anymore:
// Conical section shape
/*
G4double shape1_rmina = 0.*cm, shape1_rmaxa = 2.*cm;
G4double shape1_rminb = 0.*cm, shape1_rmaxb = 4.*cm;
G4double shape1_hz = 3.*cm;
G4double shape1_phimin = 0.*deg, shape1_phimax = 360.*deg;
G4Cons* solidShape1 =
new G4Cons("Shape1",
shape1_rmina, shape1_rmaxa, shape1_rminb, shape1_rmaxb, shape1_hz,
shape1_phimin, shape1_phimax);
*/
Then add x,y,z variables and the G4Box solid:
//changed shape1 to a G4Box
G4double shape1_x = 4.*cm;
G4double shape1_y = 6.*cm;
G4double shape1_z = 2.*cm;
G4Box* solidShape1 =
new G4Box("Shape1", //its name
0.5*shape1_x, 0.5*shape1_y, 0.5*shape1_z); //its size
Now go to the build terminal and compile and run
make
./exampleB1
You should be able to see shape1 as a box instead of a cone
To change the geometry to a cylinder, add at the top of the file
#include <G4Tubs.hh>
Then (like the G4Box) after commenting the conical shape section, add the variables for the cylinder and the solid:
G4double R1 = 0. *cm;
G4double R2 = 2. *cm;
G4double hz = 10. *cm;
G4double stdeg = 0. *deg;
G4double spanningangle = 360. *deg;
G4Tubs* solidShape1 =
new G4Tubs("tracker1", R1, R2, hz, stdeg, spanningangle);
Save the file, return to the terminal and make, then ./exampleB1. You should see the cylinder appear.