# Simulation of Bethe-Bloch equation for different particles and materials.

### 1. Theory

#### The Bethe-Bloch equation

In this project I wanted to plot the Bethe-Bloch equation using C++ code and root. The goal was to plot the equation for two different particles and several different materials.
The following equations were used as a basis to code the program:   The first equation gives a relation between the velocity of the particle v and beta, c is the speed of light. The second equation give the relation between gamma and beta. The last equation is the max energy transfer in a single collision between the particle and the material given as Tmax. Here me is the electron rest mass and M is the incident particles rest mass. Lastly, this is the Bethe-Bloch equation. K was set as a constant. Lower-case z is the charge of the incident particle. Upper-case Z is the charge number of the medium. A is the atomic mass of the medium. I is the mean excitation energy of the medium.

### 2. The program

The finished code can be found here: code

The code itself is set up in a simple way. First there are some declerations of variables, buttons, pads and such. Then there is a main function which controls everything, and calls upon different functions after the user has clicked on a button. The atomic_number and particle function changes the relevant values for different particles and materials. And lastly the draw_graph function uses the variables and iterates through different velocities v, up to the light speed c, feeds these velocities into the bethe_bloch function, and gets the output from the bethe_bloch function. The changing value Beta*Gamma is stored in a vecotor and used for the x-axis, while the y-axis is the output from the bethe-bloch funciton. At last the graph is drawn.
To run the program, simply run the code in Root.

### 3. The results

Here are the resulting graphs:

#### For the proton: Fig. 1: The proton going through iron, silver and gold.

#### For the alpha particle: Fig. 2: The alpha particle going through iron, silver and gold.

#### Alpha particle and proton: Fig. 3: A comparison between the three materials for both the alpha particle and the proton.

### 4. Conclusion

As we can see from the graphs, the change in energy over distance x in the material is more for the heavier particles coming into the material, and the change is also greater for less dense materials compared to the more dense materials.
This was my first time using both C++ and Root. I found both C++ and Root to be straight forward enough to use, what I had the most trouble with during the project was to get the values correct for the bethe-bloch function. I ended up spending way too much time before realising I had a mistake in one of the constants. Oh well.
In the end i am happy with the results, the graphs display correctly, and you can choose to draw more than one line at a time. If I was to improve the program I would consider looking into the TF1 Root class, seems like that could be a better choice for drawing the graph.
A problem with the program is that if it iterates too many times when getting the points for the graph, the program crashes. As the program is now it also informs of a crash occuring, but it doesn't seem to matter, the graphs still draw correctly