Monoenergetic photon pencil beam
From UCL HEP PBT Wiki
Line 3: | Line 3: | ||
This example shows the dose distribution in water along the incident photon 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 photon 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'''. Photons are generated using '''G4ParticleGun''' class. There is an option to chose among several EM physics lists. | + | The slices are created using class '''G4PVReplica'''. The energy and dose are scored using classes '''G4UserSteppingAction''' and '''G4UserRunAction'''. Photons are generated using '''G4ParticleGun''' class. There is an option to chose among several '''EM''' physics lists. |
- | + | http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/PhotonPB/g4_00_6000e.png | |
- | ; Connect to HEP cluster and create folder PhotonPBFolder in your area | + | The image shows the water box divided into slices using class '''G4PVReplica'''. Photons are in green, electrons are in red. |
+ | |||
+ | == <span style="color:#000080"> How to run the tutorial </span> == | ||
+ | |||
+ | ; Connect to the HEP cluster and create folder PhotonPBFolder 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 |
- | + | ||
- | + | [username@plus1 ~]$ mkdir PhotonPBFolder | |
- | + | ||
- | mkdir PhotonPBFolder | + | |
- | cd PhotonPBFolder | + | [username@plus1 ~]$ cd PhotonPBFolder |
</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 PhotonPBFolder]$ source /unix/pbt/software/dev/bin/pbt-dev.sh |
</pre> | </pre> | ||
- | |||
- | |||
; 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/PhotonPB . | + | [username@plus1 PhotonPBFolder]$ cp -r /unix/pbt/tutorials/basic/PhotonPB . |
- | mv PhotonPB PhotonPB_source | + | [username@plus1 PhotonPBFolder]$ mv PhotonPB PhotonPB_source |
</pre> | </pre> | ||
- | |||
- | |||
; Inside /home/username/PhotonPBFolder/ create a directory | ; Inside /home/username/PhotonPBFolder/ create a directory | ||
<pre style="color: #800000; background-color: #dcdcdc"> | <pre style="color: #800000; background-color: #dcdcdc"> | ||
- | mkdir PhotonPB_build | + | [username@plus1 PhotonPBFolder]$ mkdir PhotonPB_build |
</pre> | </pre> | ||
Line 48: | Line 46: | ||
<pre style="color: #800000; background-color: #dcdcdc"> | <pre style="color: #800000; background-color: #dcdcdc"> | ||
- | cd PhotonPB_build | + | [username@plus1 PhotonPBFolder]$ cd PhotonPB_build |
- | cmake -DGeant4_DIR=/unix/pbt/software/dev /home/username/PhotonPBFolder/PhotonPB_source | + | [username@plus1 PhotonPB_build]$ cmake -DGeant4_DIR=/unix/pbt/software/dev /home/username/PhotonPBFolder/PhotonPB_source |
- | make | + | [username@plus1 PhotonPB_build]$ make |
</pre> | </pre> | ||
- | ; Run macro gamma.mac | + | ; Run macro gamma.mac |
<pre style="color: #800000; background-color: #dcdcdc"> | <pre style="color: #800000; background-color: #dcdcdc"> | ||
- | ./photonPB gamma.mac | + | [username@plus1 PhotonPB_build]$ ./photonPB gamma.mac |
</pre> | </pre> | ||
Line 69: | Line 67: | ||
=== <span style="color:#000080"> Text files </span> === | === <span style="color:#000080"> Text files </span> === | ||
- | This is output from '''DoseFile.txt''' with physics process '''emstandard_opt0''' and incident photon energy of '''20 MeV'''. | + | This is output from '''DoseFile.txt''' with physics process '''emstandard_opt0''' and incident photon energy of '''20 MeV'''. Use your favorite editor '''pico''', '''vi''', '''emacs''' etc. to open text files. For example, use editor pico: |
<pre style="color: #800000; background-color: #dcdcdc"> | <pre style="color: #800000; background-color: #dcdcdc"> | ||
- | Layers : x[mm] Edep | + | [username@plus1 PhotonPB_build]$ pico DoseFile.txt |
- | layer 1: 10 | + | </pre> |
- | layer 2: 20 | + | |
- | layer 3: 30 | + | <pre style="color: #800000; background-color: #dcdcdc"> |
- | layer 4: 40 | + | Layers : x[mm] Edep Edep/Ebeam[%] Dose Dose/MaxDose[%] |
- | layer 5: 50 | + | layer 1: 5 119.065 MeV 0.0992211 9.53818e-11 Gy 15.1483 |
- | layer | + | layer 2: 10 206.505 MeV 0.172088 1.65429e-10 Gy 26.2731 |
- | layer | + | layer 3: 15 259.584 MeV 0.21632 2.07949e-10 Gy 33.026 |
- | layer | + | layer 4: 20 311.898 MeV 0.259915 2.49858e-10 Gy 39.6819 |
- | layer | + | layer 5: 25 395.255 MeV 0.329379 3.16634e-10 Gy 50.2871 |
- | layer 10: 100 | + | layer 6: 30 439.052 MeV 0.365876 3.51719e-10 Gy 55.8592 |
- | layer | + | layer 7: 35 503.311 MeV 0.419426 4.03197e-10 Gy 64.0348 |
- | layer | + | layer 8: 40 573.742 MeV 0.478118 4.59618e-10 Gy 72.9954 |
- | layer | + | layer 9: 45 624.707 MeV 0.520589 5.00446e-10 Gy 79.4796 |
- | layer | + | layer 10: 50 678.383 MeV 0.565319 5.43445e-10 Gy 86.3086 |
- | layer | + | layer 11: 55 694.602 MeV 0.578835 5.56437e-10 Gy 88.3721 |
- | layer | + | layer 12: 60 710.771 MeV 0.592309 5.6939e-10 Gy 90.4292 |
- | layer | + | layer 13: 65 744.826 MeV 0.620689 5.96672e-10 Gy 94.762 |
- | layer | + | layer 14: 70 742.436 MeV 0.618697 5.94757e-10 Gy 94.4579 |
- | layer | + | layer 15: 75 771.713 MeV 0.643094 6.1821e-10 Gy 98.1827 |
- | layer | + | layer 16: 80 767.22 MeV 0.63935 6.14611e-10 Gy 97.611 |
+ | layer 17: 85 775.608 MeV 0.64634 6.21331e-10 Gy 98.6783 | ||
+ | layer 18: 90 762.779 MeV 0.635649 6.11053e-10 Gy 97.046 | ||
+ | layer 19: 95 785.997 MeV 0.654997 6.29653e-10 Gy 100 | ||
+ | layer 20: 100 735.186 MeV 0.612655 5.88949e-10 Gy 93.5355 | ||
+ | layer 21: 105 761.414 MeV 0.634512 6.0996e-10 Gy 96.8724 | ||
+ | layer 22: 110 721.836 MeV 0.60153 5.78254e-10 Gy 91.837 | ||
+ | layer 23: 115 730.726 MeV 0.608939 5.85376e-10 Gy 92.9681 | ||
+ | layer 24: 120 728.394 MeV 0.606995 5.83508e-10 Gy 92.6714 | ||
+ | layer 25: 125 744.904 MeV 0.620753 5.96734e-10 Gy 94.7719 | ||
+ | layer 26: 130 731.53 MeV 0.609608 5.8602e-10 Gy 93.0703 | ||
+ | layer 27: 135 702.85 MeV 0.585709 5.63045e-10 Gy 89.4215 | ||
+ | layer 28: 140 671.716 MeV 0.559763 5.38104e-10 Gy 85.4604 | ||
+ | layer 29: 145 676.297 MeV 0.56358 5.41773e-10 Gy 86.0432 | ||
+ | layer 30: 150 653.849 MeV 0.544875 5.23791e-10 Gy 83.1873 | ||
+ | layer 31: 155 674.152 MeV 0.561793 5.40055e-10 Gy 85.7703 | ||
+ | layer 32: 160 687.008 MeV 0.572507 5.50354e-10 Gy 87.406 | ||
+ | layer 33: 165 706.2 MeV 0.5885 5.65729e-10 Gy 89.8478 | ||
+ | layer 34: 170 700.841 MeV 0.584034 5.61435e-10 Gy 89.1659 | ||
+ | layer 35: 175 686.009 MeV 0.571674 5.49553e-10 Gy 87.2788 | ||
+ | layer 36: 180 658.891 MeV 0.549076 5.2783e-10 Gy 83.8287 | ||
+ | layer 37: 185 644.999 MeV 0.537499 5.16701e-10 Gy 82.0613 | ||
+ | layer 38: 190 655.81 MeV 0.546508 5.25362e-10 Gy 83.4367 | ||
+ | layer 39: 195 645.691 MeV 0.538075 5.17255e-10 Gy 82.1493 | ||
+ | layer 40: 200 0 eV 0 0 Gy 0 | ||
- | The run consists of 6000 gamma of 20 MeV through 20 cm of Water (density: 1 g/cm3 ) divided into | + | The run consists of 6000 gamma of 20 MeV through 20 cm of Water (density: 1 g/cm3 ) |
+ | divided into 40 slices. | ||
Edep is the deposited energy in every slice. | Edep is the deposited energy in every slice. | ||
Total incident energy(Ebeam)= 120 GeV | Total incident energy(Ebeam)= 120 GeV | ||
- | Total energy deposit= | + | Total energy deposit= 24.8344 GeV |
Dose is the deposited dose in every slice. | Dose is the deposited dose in every slice. | ||
MaxDose is the highest dose value from all slices. | MaxDose is the highest dose value from all slices. | ||
</pre> | </pre> | ||
- | This is '''PlotDose.txt'''. These values can be | + | This is '''PlotDose.txt'''. These values can be analyzed with MATLAB and ROOT . |
<pre style="color: #800000; background-color: #dcdcdc"> | <pre style="color: #800000; background-color: #dcdcdc"> | ||
- | 10 | + | 5 15.1483 |
- | 20 50. | + | 10 26.2731 |
- | 30 | + | 15 33.026 |
- | 40 | + | 20 39.6819 |
- | 50 | + | 25 50.2871 |
- | 60 | + | 30 55.8592 |
- | 70 | + | 35 64.0348 |
- | 80 | + | 40 72.9954 |
- | 90 | + | 45 79.4796 |
- | + | 50 86.3086 | |
- | 110 | + | 55 88.3721 |
- | 120 | + | 60 90.4292 |
- | 130 | + | 65 94.762 |
- | 140 | + | 70 94.4579 |
- | 150 | + | 75 98.1827 |
- | 160 | + | 80 97.611 |
- | 170 | + | 85 98.6783 |
- | 180 | + | 90 97.046 |
- | 190 | + | 95 100 |
+ | 100 93.5355 | ||
+ | 105 96.8724 | ||
+ | 110 91.837 | ||
+ | 115 92.9681 | ||
+ | 120 92.6714 | ||
+ | 125 94.7719 | ||
+ | 130 93.0703 | ||
+ | 135 89.4215 | ||
+ | 140 85.4604 | ||
+ | 145 86.0432 | ||
+ | 150 83.1873 | ||
+ | 155 85.7703 | ||
+ | 160 87.406 | ||
+ | 165 89.8478 | ||
+ | 170 89.1659 | ||
+ | 175 87.2788 | ||
+ | 180 83.8287 | ||
+ | 185 82.0613 | ||
+ | 190 83.4367 | ||
+ | 195 82.1493 | ||
200 0 | 200 0 | ||
</pre> | </pre> | ||
Line 134: | Line 177: | ||
<pre style="color: #800000; background-color: #dcdcdc"> | <pre style="color: #800000; background-color: #dcdcdc"> | ||
- | root -l Gamma.root | + | [username@plus1 PhotonPB_build]$ root -l Gamma.root |
- | new TBrowser | + | root [1] new TBrowser |
Select ROOT files and Gamma.root | Select ROOT files and Gamma.root | ||
Line 143: | Line 186: | ||
The histogram inside Gamma.root shows the energy deposition in water box: | The histogram inside Gamma.root shows the energy deposition in water box: | ||
- | http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/PhotonPB/ | + | http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/PhotonPB/Edep_PhotonB1.png |
- | === < | + | To exit the ROOT terminal type |
+ | |||
+ | <pre style="color: #800000; background-color: #dcdcdc"> | ||
+ | .q | ||
+ | </pre> | ||
+ | |||
+ | You can plot the dose deposition along the depth of the absorber ('''PlotDose.txt''') using script '''PlotSimulation.C''' from folder '''PhotonPB_source'''. Copy this script to your current '''PhotonPB_build''' directory: | ||
+ | |||
+ | <pre style="color: #800000; background-color: #dcdcdc"> | ||
+ | [username@plus1 PhotonPB_build]$ cp /home/username/PhotonPBFolder/PhotonPB_source/PlotSimulation.C . | ||
+ | </pre> | ||
+ | |||
+ | Then run the script: | ||
+ | |||
+ | <pre style="color: #800000; background-color: #dcdcdc"> | ||
+ | [username@plus1 PhotonPB_build]$ root -l | ||
+ | |||
+ | root [1] .x PlotSimulation.C | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | This will create '''Simulation.root''' file. Open the root file: | ||
+ | |||
+ | <pre style="color: #800000; background-color: #dcdcdc"> | ||
+ | [username@plus1 PhotonPB_build]$ root -l Simulation.root | ||
+ | |||
+ | root [1] new TBrowser | ||
+ | |||
+ | Select ROOT files and Gamma.root | ||
+ | </pre> | ||
+ | |||
+ | This is the result: | ||
+ | |||
+ | http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/PhotonPB/DoseDeposition1.png | ||
+ | |||
+ | You can also plot the file '''PlotDose.txt''' using MATLAB. This software is installed on the plus1 cluster but using it via ssh is not recommended because it is slow. If you have MATLAB installed on your computer you can import the '''PlotDose.txt''' file and plot it. You can also use the MATLAB installed on the computers at the Science Library. | ||
+ | Before proceeding with MATLAB you need to copy the text files from the cluster 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/PhotonPBFolder/PhotonPB_build/PlotDose.txt . | ||
+ | </pre> | ||
+ | |||
+ | The file '''PlotDose.txt''' will be copied in your current directory. 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/PhotonPB/matlab0photon.png | ||
+ | |||
+ | === <span style="color:#000080"> Run with different settings </span> === | ||
You can change the physics process, incident photon energy, phantom material, number of slices etc. by | You can change the physics process, incident photon energy, phantom material, number of slices etc. by | ||
- | modifying the macro gamma.mac. | + | modifying the macro gamma.mac. Open the macro with editor pico: |
<pre style="color: #800000; background-color: #dcdcdc"> | <pre style="color: #800000; background-color: #dcdcdc"> | ||
- | pico gamma.mac | + | [username@plus1 PhotonPB_build]$ pico gamma.mac |
</pre> | </pre> | ||
Line 170: | Line 266: | ||
/photonPB/det/setSizeX 20 cm | /photonPB/det/setSizeX 20 cm | ||
/photonPB/det/setSizeYZ 20 cm | /photonPB/det/setSizeYZ 20 cm | ||
- | /photonPB/det/setSliceSizeYZ | + | /photonPB/det/setSliceSizeYZ 20 cm |
- | /photonPB/det/sliceNumber | + | /photonPB/det/sliceNumber 40 |
# | # | ||
# set physics process | # set physics process | ||
/photonPB/phys/addPhysics emstandard_opt0 | /photonPB/phys/addPhysics emstandard_opt0 | ||
- | #photonPB/phys/addPhysics emlivermore | + | #/photonPB/phys/addPhysics emlivermore |
#/photonPB/phys/addPhysics empenelope | #/photonPB/phys/addPhysics empenelope | ||
# | # | ||
Line 188: | Line 284: | ||
/run/initialize | /run/initialize | ||
# | # | ||
+ | # visualisation | ||
+ | #/control/execute visualisation.mac | ||
+ | |||
# particle gun properties (type of | # particle gun properties (type of | ||
- | #particle and energy | + | #particle and energy) |
/gun/particle gamma | /gun/particle gamma | ||
+ | #/gun/particle e- | ||
/gun/energy 20 MeV | /gun/energy 20 MeV | ||
# | # | ||
Line 223: | Line 323: | ||
</pre> | </pre> | ||
- | The process '''emlivermore''' is used in low energy physics experiments. | + | The process '''emlivermore''' is used in low energy physics experiments. |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
'''Change the incident particle energy''' | '''Change the incident particle energy''' | ||
- | The default energy is 20 MeV. | + | The default energy is 20 MeV. The typical therapeutic beam energy used in radiotherapy is in the interval 0.3 to 20 MeV. In gamma.mac you can change the value of 20 MeV |
<pre style="color: #800000; background-color: #dcdcdc"> | <pre style="color: #800000; background-color: #dcdcdc"> | ||
Line 237: | Line 333: | ||
</pre> | </pre> | ||
- | to, for example, | + | to, for example, 1.25 MeV |
<pre style="color: #800000; background-color: #dcdcdc"> | <pre style="color: #800000; background-color: #dcdcdc"> | ||
- | /gun/energy | + | /gun/energy 1.25 MeV |
</pre> | </pre> | ||
- | + | This is the energy of the photon beams from cobalt-60 therapy machines. | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
Keep in mind that the primary particle generation is done at /PhotonPB_source/src/PrimaryGeneratorAction.cc. | Keep in mind that the primary particle generation is done at /PhotonPB_source/src/PrimaryGeneratorAction.cc. | ||
Line 303: | Line 395: | ||
</pre> | </pre> | ||
- | + | '''Change the type of incident particle''' | |
+ | |||
+ | In gamma.mac change the photon | ||
<pre style="color: #800000; background-color: #dcdcdc"> | <pre style="color: #800000; background-color: #dcdcdc"> | ||
- | + | /gun/particle gamma | |
+ | </pre> | ||
+ | |||
+ | to electron | ||
+ | |||
+ | <pre style="color: #800000; background-color: #dcdcdc"> | ||
+ | /gun/particle e- | ||
</pre> | </pre> | ||
'''Change the number of slices''' | '''Change the number of slices''' | ||
- | You can change the number of slices. The default number is | + | You can change the number of slices. The default number is 40. Keep in mind that |
if you want to have bigger number of slices you need to modify the file DetectorConstruction.hh in | if you want to have bigger number of slices you need to modify the file DetectorConstruction.hh in | ||
/PhotonPB_source/include/. | /PhotonPB_source/include/. | ||
- | In DetectorConstruction.hh set MaxLayer to a value which is bigger then the number of your slices. The default number is MaxLayer= | + | In DetectorConstruction.hh set MaxLayer to a value which is bigger then the number of your slices. The default number is MaxLayer=50. For example, if you want your box to be divided to 60 slices you need to set the value of MaxLayer to ,for example, 65 then in gamma.mac you need to change the number of slices: |
<pre style="color: #800000; background-color: #dcdcdc"> | <pre style="color: #800000; background-color: #dcdcdc"> | ||
- | /photonPB/det/sliceNumber | + | /photonPB/det/sliceNumber 60 |
</pre> | </pre> | ||
Line 330: | Line 430: | ||
<pre style="color: #800000; background-color: #dcdcdc"> | <pre style="color: #800000; background-color: #dcdcdc"> | ||
- | ./photonPB gamma.mac | + | [username@plus1 PhotonPB_build]$ ./photonPB gamma.mac |
</pre> | </pre> | ||
=== <span style="color:#000080"> Visualisation </span> === | === <span style="color:#000080"> Visualisation </span> === | ||
+ | |||
+ | If you want to use visualisation, in macro '''gamma.mac''' uncomment the line '''/control/execute visualisation.mac'''. This will run macro '''visualisation.mac''' with a specific visualisation setup. | ||
+ | In this example, we use '''DAWN''' event display. Before running the visualisation look at the [http://geant4.slac.stanford.edu/Presentations/vis/G4DAWNTutorial/G4DAWNTutorial.html DAWN tutorial]. | ||
+ | |||
+ | To run the visualisation, uncomment line '''/control/execute visualisation.mac''' and run the | ||
+ | gamma.mac macro | ||
+ | |||
+ | <pre style="color: #800000; background-color: #dcdcdc"> | ||
+ | [username@plus1 PhotonPB_build]$ ./photonPB gamma.mac | ||
+ | </pre> | ||
+ | |||
+ | In addition to the text files the code will create two .prim files, '''g4_00.prim''' and '''g4_01.prim'''. Both files contain detector geometry and particle interactions. While running the gamma.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/PhotonPB/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 PhotonPB_build]$ dawn g4_01.prim | ||
+ | </pre> | ||
+ | |||
+ | In the DAWN display change the polar and azimuthal angles to 0 and 90 degrees, then press OK. This will create the image: | ||
+ | |||
+ | http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/PhotonPB/g4_01_6000e.eps | ||
+ | |||
+ | The color in the images indicates the type of the particle. Photons are in green, electrons are in red and positrons are in cyan. | ||
== <span style="color:#000080"> Files </span> == | == <span style="color:#000080"> Files </span> == | ||
[[List of monoenergetic photon pencil beam files with brief description]] | [[List of monoenergetic photon pencil beam files with brief description]] |