In the list of NucWik Simulation Exercises
there is an exercise that simulate a gamma-ray detector
, which allow you to investigate the details of how gamma rays are detected, i.e. the way gamma rays are absorbed in the detector crystal. This exercise can be expanded into a Computing in Science Education (CSE)
exercise where you write your own simulation program instead of using already written software. This will give you a more detailed feel for how the simulation works. In addition, you get training in how to use computers to simulate physical processes.
Here we will give you some tips on how to write such a simulation program. We assume you are familar with absorption of gamma rays. If this is not the case, then please review it in an appropriate textbook.
There are many ways to simulate a gamma-ray detector. Here, we will try to write a program that when running actually will look like an acqusition system collecting data from a real gamma-ray detector (e.g. a scintillation-type detector like NaI or a semiconductor detector like a HPGe-detector). We will keep it rather simple, ignoring some physical effects, in order to not make this exercise too complex. You can always add sophistication to the program at a later stage.
We want a program that:
- Detects radiation from a source emitting gamma rays with one, two or three distinct gamma-energies. The releative intensity between the different gamma-rays can be specified at will (0-100%).
- The simulated detector will either absorb electromagnetic radiation through the fotoelectric process (full energy absorption) or by the Compton process (an electron with part of the incident gamma-ray's energy and a new radiationn quantum with the remaining energy generated). We will disregard pair-formation at this stage (i.e. the program will only work correctly for gamma-ray energies below 1022 keV). The relative ratio between the different processes can be user selected or turned off (by setting it to 0%).
- The simulation can be started and stopped like a real detector system, and after starting the data will slowly accumulate in a intensity (counts per channel) vs energy (channels or histogram bins sorted according to increasing energy) spectrum. The spectrum can also be cleared, exactly like in an ordinary acquisition system.
- The detectors response function, which determine how precisly it will measure the absorbed gamma-ray energy, can be warried to illustrate how this property will affect the spectrum.
- The ratio between different absorption processes is in reality highly energy dependent. It would make the spectra more realistic, but we ignore it in this first version of the program.
- As already mentioned above, we ignore pair-formation.
- The random emission of gamma rays from a disintegrating source is ignored. Instead we allow the program to run in a loop generating events as fast we can. If your computer is very powerful (and/or you write very efficient code) you may need to slow things down a bit to get a reasonable spectrum build-up.
To simulate the random process of nuclear disintegration we will use a random generator to generate detector "events" at random times and with random energies. However, we will filter these randomly generated events in such a way that their distribution will obey the rules of gamma-ray absorption in matter. This filtering we will have to do for each single event, otherwise the data acquistion will not look like in a real detector.
An easy way to generate a random event stream which, when a large number has been collected, will build up show a specific distribution pattern ("spectrum"), is to "roll a dice" for each event (with a given energy) where the event is either accepted or rejected depending on the likelyhood of what will happen inside the detector when a gamma-ray with just that energy is absorbed.
At this stage you should understand that what a gamma-ray detector detects is the amount of the gamma-rays energy which has been transfered as kinetic energy to an latice-electron in the sensitive part of the detector. This electron's kintetic energy is measured by the detection system and will show up as a single "event" in the spectrum, i.e. the spectrum channel representing that energy increases it's number of counts by one. The visual picture is a histogram with columns that slowly build in height. If you are not familar with this we have a simple animation (to the right) that show how a spectrum is slowly being built up inside a "Multi Channel Analyzer (MCA)". (It's a MP4-format file, so your browser need to be able to play this format.)
Writing the Program
One way to code this simulation is as follows:
Make a main loop (e.g. a while loop) which when the detector is "switched on" will generate events. Each generated event is processed as follows:
Step 1: Determine which energy is emitted from the source
Determine which gamma (i.e. energy) should be generated, depending on the gamma's relative intensity. This step will always output one event. On a scale from 0 to 100 assign the three different gamma-energies a portion of the scale according to it's relative intensity. Get a random number between 0 and 100, and select the gamma that is represented within this part of the scale.
For example, if gamma-1 is emitted with a likelyhood of 10%, gamma-2 with 50% and gamma-3 with 40%, The scale would be divided like this: 0-10 represent gamma-1, 11-60 represent gamma-2 and 61-100 represent gamma-3. Then, if the random number turns out to be 56, gamma-2 will be selected. If it had been 76, it would have been gamma-3, etc.
Step 2: Select absorption mechanism
The gamma ray emitted from the source (in Step 1), how will it be absorbed? Determine if it should be either the photoeffect or the Compton effect (as already explained, pair formation is ignored, but you could add it here at a later stage).
If the absorption is by the Compton effect you need to randomly select an angle between the electron and the Compton quantum, as any of these angles is possible. The energy measured by the detector system will be the electron energy generated by the selected angle. As you should know (or read up on the Compton effect), there is a specific equation that give you the relationship between the initial gamma-energy and the energy of the generated new quantum (frequently wrongly called a new gamma-ray, which it is not since it originates from outside the nucleus). Not all energies between zero and the original gamma-ray energy is possible for the ejected
electron: there will be a maximum energy, which we refer to as the Compton edge. The distribution of electrons between zero energy and the Compton energy is not uniform, because each arc of angle cover different energy ranges. The distribution of Compton electrons will look like in the figure to the right, where we also have shown the foto-peak for comparision. You will get the right shape for the distribution by simply randomly selecting angles between 0 and 180-degrees.
Step 3: Apply the detector's response function
Apply the detectors response function, which will determine the width of the peaks in the spectrum. The response function is a gaussian like peak with a certain width (according the uncertainity the detector is able to measure with). In addition, it will have a small, but none-zero likelihood of generating a far too small response between anything from zero to the correct energy. This can be explained by wall effects or impurities in the detector crystall causing only a fraction of the kinetic energy on the electron actually produce a measureable signal. The shape of the function is shown to the right. You need to find an appropriate mathematical function to represent this.
For each loop (Step1 -> Step 2 -> Step 3) you increment the histogram that represent the spectrum with the new event. I.e. you increase the number of "counts" in the appropriate channel (histogram column) representing the given energy by 1 (see the video about the MCA spectrum above, if you have not already done so). Make sure you update the graph with the spectrum for each turn of the main loop, otherwise you will not get the impression of a live acquisition system.
That should be it! An example of a working program can be seen in the video below.
Development History and Contact Person
This simulation was conceived by Jon Petter Omtvedt (UiO
) and used for teaching in Nuclear Chemistry at University of Oslo since many years. It was included here at NucWik as part of the CINCH project
If you have comments, suggestions, examples of simulation software (in any computer language) or anything else relevant, please write in the comment page (use the NucWik page commenting tool, but you must be a registered user) or send your feed-back to NucWikemail@example.com. The teaching material for this particular simulation exercise is managed and updated by: Jon Petter Omtvedt. Feel free to contact me directly if you want to discuss this exercise or need help implementing it.