Table of contents
The goal for this project is to make a program using root that will solve the Bethe Bloch formula. This formula expresses the energy loss of a charged particle through a medium. I wanted to make a project relevant to particle therapy as I find it fascinating and hope to take a master's in medical physics. Since I took inspiration in particle therapy, I chose the particles proton/hydrogen, alpha/helium and carbon. The medium is water as our bodies are a large part water and this will serve as an approximation.
The program is written in a single file bethe.C. It is based on the programmes buttonTest.C  and example.C  and modified to fit the desired functions. The program generates a graphical user interface where the user can choose between three different particles and energy levels. After the desired values are chosen the graph is plotted by pressing the "Draw" button. To exit the program the user simply must press the "Quit" button.
The Bethe Bloch formula  gives the mean energy loss per centimetres
travelled for a charged particle through a chosen material, and is given by:
The formula can be modified using the classical electron radius 
and β expressed with kinetic energy and mass of the particle
Where the different constants and variables are:
me= Electron mass
n= Electron density of water
z= Charge of ion
re= Classical electron radius
I= Ionization potential
Ek= Kinetic energy
m= Mass of particle
This is the formula used in my program.
The particles chosen were proton/hydrogen, alpha/helium and carbon ions with respective charges z=1, z=2 and z=6. The different masses for the particles were obtained form source  and converted to MeV. This gives the masses:
Proton/hydrogen: 938 MeV
Alpha/helium: 3728 MeV
Carbon: 11178 MeV
The ionization potential is given by the formula
where Z is the atomic number . Since Z= 10 for water the ionization potential equals
I was originally planning on using the Bethe Bloch formula expressed in
Introduction to Health Physics , but later discovered it was only valid
for electrons. I
therefore decided to use the formula from Wikipedia  instead.
The figures below show the plotted graphs for the highest energy for the three different particles.
By using a for loop the graph is adjusted for the reduced energy as the particle travels. For the proton particle the graph looks nice, however for the alpha and carbon graphs something clearly goes wrong. It plots correctly in the beginning, but below E=0 the remainder of points are plotted outside the frame. I believe this is do to the number n under void ButtonWindow::DoDraw(). n decides how many points of x and y values are created and needs to be large enough for the farthest travelling particle. However, for particles traveling shorter, there are points created after E=0 that have negative y values and therefore outside of the y-axis (these points are not relevant as the particle will stop at E=0 and cannot have negative energy). I have tried different if conditions to try and stop the for loop when E=0 but I have not been able to solve the problem. I have also asked for help about this issue but have not received an answer.
This was my very first time programming in C++ and root, even using a Linux operating system. Despite the graph not turning out the way I wanted, I am pleased with the overall result. I managed to create a functional GUI designed the way I envisioned and learned a lot from the hiccups along the way.
 Bethe formula (2020) Available at:
 Cern (2020) WritingGUI Available at: https://root.cern.ch/root/htmldoc/guides/users-guide/WritingGUI.html (Accessed: 12.06.20)
 Classical electron radius (2020) Available at: https://en.wikipedia.org/wiki/Classical_electron_radius (Accessed: 15.06.20)
 Huang, W.J. (2017) Atomic mass adjustment Available at: http://amdc.impcas.ac.cn/masstables/Ame2016/mass16.txt (Accessed: 10.04.20)
 Johnson, T. E. (2017) Introduction to Health Physics. Fifth edition Colorado: McGraw-Hill Education
 Onuchin, V. (2007) buttonTest.C File Reference Available at: https://root.cern/doc/master/buttonTest_8C.html (Accessed: 13.06.20)