Monoenergetic photon pencil beam
From UCL HEP PBT Wiki
for
Monoenergetic photon pencil beam
Jump to:
navigation
,
search
== <span style="color:#000080"> Introduction </span> == 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. == <span style="color:#000080"> Setting up the environment </span> == ; Connect to HEP cluster and create folder PhotonPBFolder in your area <pre style="color: #800000; background-color: #dcdcdc"> ssh -X username@plus1.hep.ucl.ac.uk password: type your password here cd /home/username/ mkdir PhotonPBFolder cd PhotonPBFolder </pre> ; Setup your environment <pre style="color: #800000; background-color: #dcdcdc"> source /unix/pbt/software/dev/bin/pbt-dev.sh </pre> == <span style="color:#000080"> How to get the code </span> == ; Copy the code to your working directory and rename it <pre style="color: #800000; background-color: #dcdcdc"> cp -r /unix/pbt/tutorials/basic/PhotonPB . mv PhotonPB PhotonPB_source </pre> == <span style="color:#000080"> How to run the code </span> == ; Inside /home/username/PhotonPBFolder/ create a directory <pre style="color: #800000; background-color: #dcdcdc"> mkdir PhotonPB_build </pre> ; To compile the code enter this directory and run cmake and make <pre style="color: #800000; background-color: #dcdcdc"> cd PhotonPB_build cmake -DGeant4_DIR=/unix/pbt/software/dev /home/username/PhotonPBFolder/PhotonPB_source make </pre> ; Run macro gamma.mac. The macro generates 10000 events. <pre style="color: #800000; background-color: #dcdcdc"> ./photonPB gamma.mac </pre> == <span style="color:#000080"> How to analyze data </span> == The macro produces root file '''Gamma.root''' with a histogram showing the energy deposition in water box along the beam line. It also produces text files: '''DoseFile.txt''' with energy and dose deposited in each slice and '''PlotDose.txt''' with dose deposited in each slice. === <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'''. <pre style="color: #800000; background-color: #dcdcdc"> Layers : x[mm] Edep Edep/Ebeam[%] Dose Dose/MaxDose[%] layer 1: 10 513.656 MeV 0.428046 5.14354e-09 Gy 32.1047 layer 2: 20 800.659 MeV 0.667216 8.01749e-09 Gy 50.0432 layer 3: 30 996.867 MeV 0.830722 9.98223e-09 Gy 62.3066 layer 4: 40 1.23773 GeV 1.03144 1.23942e-08 Gy 77.3614 layer 5: 50 1.29582 GeV 1.07985 1.29758e-08 Gy 80.9917 layer 6: 60 1.43647 GeV 1.19706 1.43843e-08 Gy 89.7831 layer 7: 70 1.59565 GeV 1.32971 1.59782e-08 Gy 99.7318 layer 8: 80 1.59994 GeV 1.33328 1.60211e-08 Gy 100 layer 9: 90 1.53239 GeV 1.27699 1.53448e-08 Gy 95.7783 layer 10: 100 1.52627 GeV 1.27189 1.52834e-08 Gy 95.3955 layer 11: 110 1.49511 GeV 1.24592 1.49714e-08 Gy 93.4478 layer 12: 120 1.46007 GeV 1.21672 1.46206e-08 Gy 91.2579 layer 13: 130 1.44794 GeV 1.20662 1.44991e-08 Gy 90.4998 layer 14: 140 1.40362 GeV 1.16968 1.40553e-08 Gy 87.7295 layer 15: 150 1.44033 GeV 1.20028 1.44229e-08 Gy 90.0244 layer 16: 160 1.42336 GeV 1.18613 1.42529e-08 Gy 88.9634 layer 17: 170 1.28793 GeV 1.07327 1.28968e-08 Gy 80.4985 layer 18: 180 1.26477 GeV 1.05397 1.26649e-08 Gy 79.051 layer 19: 190 1.24786 GeV 1.03989 1.24956e-08 Gy 77.9945 layer 20: 200 5.30499e-307 eV 4.42082e-316 0 Gy 0 The run consists of 6000 gamma of 20 MeV through 20 cm of Water (density: 1 g/cm3 ) divided into 20 slices. Edep is the deposited energy in every slice. Total incident energy(Ebeam)= 120 GeV Total energy deposit= 25.169 GeV Dose is the deposited dose in every slice. MaxDose is the highest dose value from all slices. </pre> This is '''PlotDose.txt'''. These values can be directly imported in MATLAB. <pre style="color: #800000; background-color: #dcdcdc"> 10 32.1047 20 50.0432 30 62.3066 40 77.3614 50 80.9917 60 89.7831 70 99.7318 80 100 90 95.7783 100 95.3955 110 93.4478 120 91.2579 130 90.4998 140 87.7295 150 90.0244 160 88.9634 170 80.4985 180 79.051 190 77.9945 200 0 </pre> === <span style="color:#000080"> Root file </span> === Open '''Gamma.root''' file in the following way: <pre style="color: #800000; background-color: #dcdcdc"> root -l Gamma.root new TBrowser Select ROOT files and Gamma.root </pre> The histogram inside Gamma.root shows the energy deposition in water box: http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/PhotonPB/Edep_PhotonB.png 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"> cp /home/username/PhotonPBFolder/PhotonPB_source/PlotSimulation.C . </pre> Then run the script: <pre style="color: #800000; background-color: #dcdcdc"> root -l .x PlotSimulation.C </pre> This will create '''Simulation.root''' file. Open the root file: <pre style="color: #800000; background-color: #dcdcdc"> root -l Simulation.root 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/DoseDeposition.png === <span style="color:#000080"> Changes in macro gamma.mac </span> === You can change the physics process, incident photon energy, phantom material, number of slices etc. by modifying the macro gamma.mac. Use your favorite editor '''pico''', '''vi''', '''emacs''' etc. For example open the macro with editor pico: <pre style="color: #800000; background-color: #dcdcdc"> pico gamma.mac </pre> This is the content of the macro: <pre style="color: #800000; background-color: #dcdcdc"> # gamma.mac # /control/verbose 2 /run/verbose 2 /tracking/verbose 0 /run/particle/verbose 1 /run/particle/dumpList # # set geometry and material /photonPB/det/setMat Water #/photonPB/det/setMat Lead /photonPB/det/setSizeX 20 cm /photonPB/det/setSizeYZ 20 cm /photonPB/det/setSliceSizeYZ 4 cm /photonPB/det/sliceNumber 20 # # set physics process /photonPB/phys/addPhysics emstandard_opt0 #photonPB/phys/addPhysics emlivermore #/photonPB/phys/addPhysics empenelope # # production tresholds (range cut off- # not bigger than 10% of slice thickness) /photonPB/phys/setCuts 1 mm #/photonPB/phys/setGCut 1 um #/photonPB/phys/setECut 1 um #/photonPB/phys/setPCut 1 um # # initialize /run/initialize # # particle gun properties (type of #particle and energy) /gun/particle gamma #/gun/particle e- /gun/energy 20 MeV # # beam size #/photonPB/gun/rndm 3 mm # # step limit (not bigger than 5% of # slice thickness) /photonPB/stepMax 0.5 mm # /photonPB/event/printModulo 50 # # output root file /analysis/setFileName Gamma # # number of events /run/beamOn 6000 </pre> '''Change the physics process''' The default physics process is '''emstandard_opt0'''. This package is used in high energy experiments. In gamma.mac change <pre style="color: #800000; background-color: #dcdcdc"> /photonPB/phys/addPhysics emstandard_opt0 </pre> to <pre style="color: #800000; background-color: #dcdcdc"> /photonPB/phys/addPhysics emlivermore </pre> The process '''emlivermore''' is used in low energy physics experiments. '''Change the incident particle energy''' The default energy is 20 MeV. It is a typical energy used in radiotherapy. In gamma.mac you can change the value of 20 MeV <pre style="color: #800000; background-color: #dcdcdc"> /gun/energy 20 MeV </pre> to, for example, 10 MeV <pre style="color: #800000; background-color: #dcdcdc"> /gun/energy 10 MeV </pre> Keep in mind that the primary particle generation is done at /PhotonPB_source/src/PrimaryGeneratorAction.cc. This is part of the PrimaryGeneratorAction.cc: <pre style="color: #800000; background-color: #dcdcdc"> fParticleGun = new G4ParticleGun(1); G4ParticleDefinition* particle = G4ParticleTable::GetParticleTable()->FindParticle("proton"); fParticleGun->SetParticleDefinition(particle); fParticleGun->SetParticleEnergy(160*MeV); fParticleGun->SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.)); ... G4double x0 = -0.5*(fDetector->GetAbsorSizeX()); G4double y0 = 0.*cm, z0 = 0.*cm; ... fParticleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0)); </pre> The line <pre style="color: #800000; background-color: #dcdcdc"> fParticleGun = new G4ParticleGun(1); </pre> means that only one particle is generated, incident from (x0,y0,z0). The default number of events is set to 6000. Therefore, 6000 particles are incident to the water box. '''Change the diameter of the beam''' You can set the diameter of the beam with the command: <pre style="color: #800000; background-color: #dcdcdc"> /photonPB/gun/rndm 3 mm </pre> '''Change the material''' In this example we compute the energy deposition of photons in water box. However, there is an option to change the box material from water to lead. In gamma.mac change <pre style="color: #800000; background-color: #dcdcdc"> /photonPB/det/setMat Water </pre> to <pre style="color: #800000; background-color: #dcdcdc"> /photonPB/det/setMat Lead </pre> '''Change the type of incident particle''' In gamma.mac change the photon <pre style="color: #800000; background-color: #dcdcdc"> /gun/particle gamma </pre> to electron <pre style="color: #800000; background-color: #dcdcdc"> /gun/particle e- </pre> '''Change the number of slices''' You can change the number of slices. The default number is 20. Keep in mind that if you want to have bigger number of slices you need to modify the file DetectorConstruction.hh in /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=30. For example, if you want your box to be divided to 35 slices you need to set the value of MaxLayer to ,for example, 40 then in gamma.mac you need to change the number of slices: <pre style="color: #800000; background-color: #dcdcdc"> /photonPB/det/sliceNumber 35 </pre> Every time you modify files in directory PhotonPB_source you need to compile your code. In directory PhotonPB_build do <pre style="color: #800000; background-color: #dcdcdc"> make </pre> then run the macro <pre style="color: #800000; background-color: #dcdcdc"> ./photonPB gamma.mac </pre> === <span style="color:#000080"> Visualisation </span> === Under construction (problems with OpenGL installed on plus1) == <span style="color:#000080"> Files </span> == [[List of monoenergetic photon pencil beam files with brief description]]
Return to
Monoenergetic photon pencil beam
.
Views
Page
Discussion
View source
History
Personal tools
Log in
Navigation
Main page
Community portal
Current events
Recent changes
Random page
Help
Search
Toolbox
What links here
Related changes
Special pages