Monoenergetic proton pencil beam

From UCL HEP PBT Wiki

Jump to: navigation, search
m
 
Line 3: Line 3:
This example shows the dose distribution in water along the incident proton beam. The beam hits the water cube surface and deposits a dose under the surface of the water. The volume of the water cube is divided into slices perpendicular to the incident beam. At each slice the deposited dose and energy is computed.  
This example shows the dose distribution in water along the incident proton beam. The beam hits the water cube surface and deposits a dose under the surface of the water. The volume of the water cube is divided into slices perpendicular to the incident beam. At each slice the deposited dose and energy is computed.  
-
The slices are created using class '''G4PVReplica'''. The energy and dose are scored using classes '''G4UserSteppingAction''' and '''G4UserRunAction'''. Alternatively, the energy and dose are scored using class '''G4ScoringManager''' by defining two scoring meshes in logitudinal and lateral direction of the beam. More information about scoring meshes can be found [https://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/html/ch04s08.html here]. Protons are generated using '''G4ParticleGun''' class. There is an option to chose among several '''EM''' and '''QGSP_BIC_EMY''' physics lists.
+
The slices are created using class '''G4PVReplica'''. The energy and the dose are scored using classes '''G4UserSteppingAction''' and '''G4UserRunAction'''. Alternatively, the energy and the dose are scored using class '''G4ScoringManager''' by defining two scoring meshes in longitudinal and lateral direction of the beam. More information about the scoring meshes can be found [https://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/html/ch04s08.html here]. The protons are generated using '''G4ParticleGun''' class. There is an option to chose among several '''EM''' and the '''QGSP_BIC_EMY''' physics lists.
-
== <span style="color:#000080"> Setting up the environment </span> ==
+
http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/ProtonPB/g4_00_6000e.png
-
; Connect to HEP cluster and create folder ProtonPBFolder in your area
+
The image shows the water box divided into slices using class '''G4PVReplica'''. Protons are in blue, photons are in green.
 +
 
 +
== <span style="color:#000080"> How to run the tutorial </span> ==
 +
 
 +
; Connect to the HEP cluster and create folder ProtonPBFolder in your area
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
ssh -X username@plus1.hep.ucl.ac.uk  
ssh -X username@plus1.hep.ucl.ac.uk  
-
password: type your password here
+
username@plus1.hep.ucl.ac.uk's password: type your password here
-
 
+
-
cd /home/username/
+
   
   
-
mkdir ProtonPBFolder  
+
[username@plus1 ~]$ mkdir ProtonPBFolder  
-
cd ProtonPBFolder   
+
[username@plus1 ~]$ cd ProtonPBFolder   
</pre>
</pre>
Line 24: Line 26:
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
source /unix/pbt/software/dev/bin/pbt-dev.sh   
+
[username@plus1 ProtonPBFolder]$ source /unix/pbt/software/dev/bin/pbt-dev.sh   
</pre>
</pre>
-
 
-
== <span style="color:#000080"> How to get the code </span> ==
 
; Copy the code to your working directory and rename it
; Copy the code to your working directory and rename it
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
cp -r /unix/pbt/tutorials/basic/ProtonPB .
+
[username@plus1 ProtonPBFolder]$ cp -r /unix/pbt/tutorials/basic/ProtonPB .
    
    
-
mv ProtonPB ProtonPB_source
+
[username@plus1 ProtonPBFolder]$ mv ProtonPB ProtonPB_source
</pre>
</pre>
-
 
-
== <span style="color:#000080"> How to run the code </span> ==
 
; Inside /home/username/ProtonPBFolder/ create a directory
; Inside /home/username/ProtonPBFolder/ create a directory
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
mkdir ProtonPB_build   
+
[username@plus1 ProtonPBFolder]$ mkdir ProtonPB_build   
</pre>
</pre>
Line 48: Line 46:
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
cd ProtonPB_build  
+
[username@plus1 ProtonPBFolder]$ cd ProtonPB_build  
-
cmake -DGeant4_DIR=/unix/pbt/software/dev /home/username/ProtonPBFolder/ProtonPB_source  
+
[username@plus1 ProtonPB_build]$ cmake -DGeant4_DIR=/unix/pbt/software/dev /home/username/ProtonPBFolder/ProtonPB_source  
-
make   
+
[username@plus1 ProtonPB_build]$ make   
</pre>
</pre>
-
; Run macro proton.mac. The macro generates 6000 events.
+
; Run macro proton.mac
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
./protonPB proton.mac
+
[username@plus1 ProtonPB_build]$ ./protonPB proton.mac
</pre>
</pre>
Line 76: Line 74:
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
pico DoseFile.txt
+
[username@plus1 ProtonPB_build]$ pico DoseFile.txt
</pre>
</pre>
   
   
Line 133: Line 131:
-
  The run consists of 6000 proton of 62 MeV through 4 cm  of Water (density: 1 g/cm3 ) divided into 50 slices.
+
  The run consists of 6000 proton of 62 MeV through 4 cm  of Water (density: 1 g/cm3 )  
 +
divided into 50 slices.
  Edep is the deposited energy in every slice.
  Edep is the deposited energy in every slice.
Line 206: Line 205:
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
root -l Proton.root
+
[username@plus1 ProtonPB_build]$ root -l Proton.root
-
new TBrowser
+
root [1] new TBrowser
Select ROOT Files and Proton.root
Select ROOT Files and Proton.root
Line 237: Line 236:
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
root -l  
+
[username@plus1 ProtonPB_build]$ root -l  
-
.x PlotSimulation.C
+
root [1] .x PlotSimulation.C
</pre>
</pre>
Line 245: Line 244:
http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/ProtonPB/Simulation1.png   
http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/ProtonPB/Simulation1.png   
 +
 +
You can also plot the file '''PlotDose.txt''' using MATLAB. Similarly to the previous example first copy the text file to your computer. In the terminal at your computer write:
 +
 +
<pre style="color: #800000; background-color: #dcdcdc">
 +
scp username@plus1.hep.ucl.ac.uk:/home/username/ProtonPBFolder/ProtonPB_build/PlotDose.txt .
 +
</pre>
 +
 +
Then, open MATLAB and follow the procedure:
 +
 +
* Import the file: Chose 'HOME' tab and 'Import Data'.
 +
* In the 'Import Data' window select the 'PlotDose.txt' file choosing the right path.
 +
* In the opened window select the data points in the 'IMPORT' tab. If you like, you can change the name of the variables. For example, 'x' instead of 'VarName1' and 'Dose' instead of 'VarName2'. Then, press 'Import Selection'/'Import Data'. 
 +
* Close the Import Window and in the Command Window type plot(x,Dose). Press Enter.
 +
 +
This plot will be created with added axis labels and a legend:
 +
 +
http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/ProtonPB/matlab1proton.png
You can also plot the data in '''DoseLongitudinalMesh.txt''' and '''DoseLateralMesh.txt''' which were created using commands '''/score/''' in the macro '''proton.mac'''. The file '''DoseLongitudinalMesh.txt''' will be used later to compare with data from the Clatterbridge Cancer Center. Now, use script '''PlotLateralDoseMesh.C''' to plot the lateral dose distribution.
You can also plot the data in '''DoseLongitudinalMesh.txt''' and '''DoseLateralMesh.txt''' which were created using commands '''/score/''' in the macro '''proton.mac'''. The file '''DoseLongitudinalMesh.txt''' will be used later to compare with data from the Clatterbridge Cancer Center. Now, use script '''PlotLateralDoseMesh.C''' to plot the lateral dose distribution.
 +
Before running the script substitude the commas in '''DoseLateralMesh.txt''' with spaces. Remove also the header in the text file. Then, save the text file as '''DoseLateralMesh_Mod.txt'''.
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
cp /home/username/ProtonPBFolder/ProtonPB_source/RootScripts/PlotLateralDoseMesh.C .
+
[username@plus1 ProtonPB_build]$ cp /home/username/ProtonPBFolder/ProtonPB_source/RootScripts/PlotLateralDoseMesh.C .
-
root -l  
+
[username@plus1 ProtonPB_build]$ root -l  
-
.x PlotLateralDoseMesh.C
+
root [1] .x PlotLateralDoseMesh.C
</pre>   
</pre>   
Line 260: Line 277:
http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/ProtonPB/SimulationLateralMesh.png
http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/ProtonPB/SimulationLateralMesh.png
-
=== <span style="color:#000080"> Changes in proton.mac </span> ===
+
=== <span style="color:#000080"> Run with different settings </span> ===
You can change the physics process, incident proton energy and number of slices etc. by
You can change the physics process, incident proton energy and number of slices etc. by
Line 266: Line 283:
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
pico proton.mac
+
[username@plus1 ProtonPB_build]$ pico proton.mac
</pre>   
</pre>   
-
This is what you will see:
+
This is the content of the macro:
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
Line 283: Line 300:
/protonPB/det/setSizeX  4 cm
/protonPB/det/setSizeX  4 cm
/protonPB/det/setSizeYZ 4 cm
/protonPB/det/setSizeYZ 4 cm
-
/protonPB/det/setSliceSizeYZ 1 cm
+
/protonPB/det/setSliceSizeYZ 4 cm
-
/protonPB/det/sliceNumber 30
+
/protonPB/det/sliceNumber 50
#
#
# define longitudinal scoring mesh
# define longitudinal scoring mesh
Line 290: Line 307:
/score/create/boxMesh waterMeshlongitudinal
/score/create/boxMesh waterMeshlongitudinal
/score/mesh/boxSize 2. 2. 2. cm
/score/mesh/boxSize 2. 2. 2. cm
-
/score/mesh/nBin 30 1 1
+
/score/mesh/nBin 50 1 1
/score/mesh/translate/xyz 0. 0. 0. cm
/score/mesh/translate/xyz 0. 0. 0. cm
/score/quantity/energyDeposit energyDeposit  
/score/quantity/energyDeposit energyDeposit  
Line 299: Line 316:
# centered at the Bragg peak
# centered at the Bragg peak
/score/create/boxMesh waterMeshlateral
/score/create/boxMesh waterMeshlateral
-
/score/mesh/boxSize 1. 2. 2. cm
+
/score/mesh/boxSize 0.1 2. 2. cm
-
/score/mesh/nBin 1 30 1
+
/score/mesh/nBin 1 1 50
/score/mesh/translate/xyz 1.2 0. 0. cm
/score/mesh/translate/xyz 1.2 0. 0. cm
/score/quantity/energyDeposit energyDeposit  
/score/quantity/energyDeposit energyDeposit  
Line 320: Line 337:
# initialize
# initialize
/run/initialize
/run/initialize
 +
#
 +
# visualisation
 +
#/control/execute visualisation.mac
#
#
/gun/particle proton
/gun/particle proton
Line 341: Line 361:
# number of events
# number of events
/run/beamOn 6000
/run/beamOn 6000
 +
#
 +
# drawing projections
 +
#/score/drawProjection waterMeshlongitudinal doseDeposit
 +
#/score/drawProjection waterMeshlateral doseDeposit
 +
#
# dump scores to a file
# dump scores to a file
/score/dumpQuantityToFile waterMeshlongitudinal doseDeposit DoseLongitudinalMesh.txt
/score/dumpQuantityToFile waterMeshlongitudinal doseDeposit DoseLongitudinalMesh.txt
Line 395: Line 420:
'''Change the number of slices'''
'''Change the number of slices'''
-
You can change the number of slices. The default number is 30. Keep in mind that  
+
You can change the number of slices. The default number is 50. Keep in mind that  
if you want to increase the number of slices you need to modify the file DetectorConstruction.hh in
if you want to increase the number of slices you need to modify the file DetectorConstruction.hh in
/ProtonPB_source/include/.
/ProtonPB_source/include/.
-
In DetectorConstruction.hh set MaxLayer to value bigger than the number of your slices. The default value is MaxLayer=40. For example, if you want to have 35 slices you do not need to modify MaxLayer. Then, only in proton.mac change the number of slices  
+
In DetectorConstruction.hh set MaxLayer to value bigger than the number of your slices. The default value is MaxLayer=60. For example, if you want to have 55 slices you do not need to modify MaxLayer. Then, only in proton.mac change the number of slices  
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
/protonPB/det/sliceNumber 35
+
/protonPB/det/sliceNumber 55
</pre>
</pre>
'''Modify the mesh'''
'''Modify the mesh'''
-
You can change the size of the mesh and the number of voxels by modifying  
+
You can change the size of the mesh (longitudinal and lateral) and the number of voxels by modifying their corresponding lines
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
Line 419: Line 444:
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
./protonPB proton.mac
+
[username@plus1 ProtonPB_build]$ ./protonPB proton.mac
</pre>
</pre>
   
   
Line 425: Line 450:
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
make  
+
[username@plus1 ProtonPB_build]$ make  
</pre>
</pre>
Line 432: Line 457:
=== <span style="color:#000080"> Visualisation </span> ===
=== <span style="color:#000080"> Visualisation </span> ===
-
Under construction (problems with OpenGL installed on plus1)
+
If you want to use visualisation, in macro '''proton.mac''' uncomment the line '''/control/execute visualisation.mac'''. This will run macro '''visualisation.mac''' with a specific visualisation setup.
 +
If you uncomment the lines '''/score/drawProjection waterMeshlongitudinal doseDeposit''' and '''/score/drawProjection waterMeshlateral doseDeposit''' you will draw the dose projections. In this example, we use '''DAWN''' event display. Before running the visualisation look at this [http://geant4.slac.stanford.edu/Presentations/vis/G4DAWNTutorial/G4DAWNTutorial.html DAWN tutorial].
 +
 
 +
To run the visualisation, first uncomment lines '''/control/execute visualisation.mac''' and '''/score/drawProjection waterMeshlongitudinal doseDeposit'''. Then, run the proton.mac
 +
 
 +
<pre style="color: #800000; background-color: #dcdcdc">
 +
[username@plus1 ProtonPB_build]$ ./protonPB proton.mac
 +
</pre>
 +
 
 +
In addition to the text files the code will create two .prim files, '''g4_00.prim''' and '''g4_01.prim'''. The first file contains detector geometry and particle interactions. The second file contains dose projections. While running the proton.mac you will be asked to open g4_00.prim in DAWN. In the opened window press OK. This will create your first visualisation:
 +
 
 +
http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/ProtonPB/g4_00_6000e.eps
 +
 
 +
The second file g4_01.prim will not open automatically. It will be created after the running is finished. Open the file in the following way:
 +
 
 +
<pre style="color: #800000; background-color: #dcdcdc">
 +
[username@plus1 ProtonPB_build]$ dawn g4_01.prim
 +
</pre>
 +
 
 +
In the opened window press OK and this will create the image:
 +
 
 +
http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/ProtonPB/g4_02_6000e.eps
 +
 
 +
You can modify the .prim files in DAWN. For example, in the DAWN display change the polar and azimuthal angles. 1) (polar angle, azimuthal angle) = (0,90) will create this image
 +
 
 +
http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/ProtonPB/g4_01_6000e.eps
 +
 
 +
2) (polar angle, azimuthal angle) = (90,0) will create this image
 +
 
 +
http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/ProtonPB/g4_04_6000e.eps
 +
 
 +
Now, in proton.mac macro uncomment '''/score/drawProjection waterMeshlateral doseDeposit''' and comment '''/score/drawProjection waterMeshlongitudinal doseDeposit'''. Run '''proton.mac''' with the new settings. The image with the lateral dose projections will look like that:
 +
 
 +
http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/ProtonPB/g4_03_6000e.eps   
== <span style="color:#000080"> Data from The Clatterbridge Cancer Centre </span> ==
== <span style="color:#000080"> Data from The Clatterbridge Cancer Centre </span> ==
Line 439: Line 497:
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
cp /home/username/ProtonPBFolder/ProtonPB_source/RootScripts/PlotData.C .
+
[username@plus1 ProtonPB_build]$ cp /home/username/ProtonPBFolder/ProtonPB_source/RootScripts/PlotData.C .
-
cp /home/username/ProtonPBFolder/ProtonPB_source/RootScripts/ClatterbridgeData.txt .
+
[username@plus1 ProtonPB_build]$ cp /home/username/ProtonPBFolder/ProtonPB_source/RootScripts/ClatterbridgeData.txt .
-
root -l  
+
[username@plus1 ProtonPB_build]$ root -l  
-
.x PlotData.C
+
root [1] .x PlotData.C
</pre>   
</pre>   
Line 458: Line 516:
   
   
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
cp /home/username/ProtonPBFolder/ProtonPB_source/RootScripts/PlotDataAndSim.C .
+
[username@plus1 ProtonPB_build]$ cp /home/username/ProtonPBFolder/ProtonPB_source/RootScripts/PlotDataAndSim.C .
-
root -l  
+
[username@plus1 ProtonPB_build]$ root -l  
-
.x PlotDataAndSim.C
+
root [1] .x PlotDataAndSim.C
</pre>   
</pre>   
Line 471: Line 529:
You can also compare data (ClatterbridgeData.txt) with simulation done with scoring mesh ('''DoseLongitudinalMesh.txt''').
You can also compare data (ClatterbridgeData.txt) with simulation done with scoring mesh ('''DoseLongitudinalMesh.txt''').
This can be done with script '''PlotDataAndSimMesh.C'''. This script works only if before running it you substitude the commas  
This can be done with script '''PlotDataAndSimMesh.C'''. This script works only if before running it you substitude the commas  
-
in '''DoseLongitudinalMesh.txt''' with spaces. Remove also the header in the text file.  
+
in '''DoseLongitudinalMesh.txt''' with spaces. Remove also the header in the text file. Save the new text file as '''DoseLongitudinalMesh_Mod.txt'''.  
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
cp /home/username/ProtonPBFolder/ProtonPB_source/RootScripts/PlotDataAndSimMesh.C .
+
[username@plus1 ProtonPB_build]$ cp /home/username/ProtonPBFolder/ProtonPB_source/RootScripts/PlotDataAndSimMesh.C .
-
root -l  
+
[username@plus1 ProtonPB_build]$ root -l  
-
.x PlotDataAndSimMesh.C
+
root [1] .x PlotDataAndSimMesh.C
</pre>   
</pre>   

Latest revision as of 13:36, 10 September 2014

Personal tools