Open access peer-reviewed chapter - ONLINE FIRST

Monte Carlo and Medical Physics

By Omaima Essaad Belhaj, Hamid Boukhal and El Mahjoub Chakir

Submitted: May 19th 2021Reviewed: August 24th 2021Published: September 23rd 2021

DOI: 10.5772/intechopen.100121

Downloaded: 25


The different codes based on the Monte Carlo method, allows to make simulations in the field of medical physics, so the determination of all the magnitudes of radiation protection namely the absorbed dose, the kerma, the equivalent dose, and effective, what guarantees the good planning of the experiment in order to minimize the degrees of exposure to ionizing radiation, and to strengthen the radiation protection of patients and workers in clinical environment as well as to respect the 3 principles of radiation protection ALARA (As Low As Reasonably Achievable) and which are based on: -Justification of the practice -Optimization of radiation protection -Limitation of exposure.


  • Radioprotection
  • Monte Carlo
  • medical physics
  • simulation

1. Introduction

The monte Carlo method is a method of the family of algorithmic methods, it makes it possible to solve statistical problems and contribute to the analysis of data based on stochastic processes, thus it allows to evaluate the maturity risk and these probabilities thus the appointment of this method refers to the random side used at the casino of Monte Carlo located in MONACO.

The scope of the Monte Carlo method is very broad and covers all fields of nuclear medicine and particle transport, namely applications in radiotherapy-brachytherapy, scintigraphic imaging, shielding, dosimetry, PET, gamma camera, etc.

This choice of use of this method is not due to chance, but on the one hand because it allows to simulate the behavior of different particles and to deduce the average behavior of all particles according to the law of large numbers and the central limit theorem, so it can handle coupled and 3D problems with complex geometry and it can answer specific questions (average flow in a volume, Absorbed dose, Kerma, Hp(10), etc.), and its major advantages and determining the sources of errors, on the other hand, this method makes it possible to comply with the laws of ALARA (As Low As Reasonably Achievable) radiation protection which are:

  • Justification of the practice

  • Limitation of exposure

  • Optimization of radiation protection

All this through simulation and modeling of the experience by the Monte Carlo method before practicing it in order to be able to determine the limits of the doses absorbed by the staff and the patient, as well as to develop and determine the correction methods to improve the quantification images and results, as well as the design of radiation detection equipment.

Monte Carlo uses software and calculation codes requiring a better knowledge of the input data of the problem (source, energy, angle and distribution, spatial and temporal dependence), and of the geometry which must represent the real situation, as well. The materials constituting the system to be studied, type of calculation envisaged, criteria for stopping the simulation, these parameters are defined and entered by the operator, and the basic nuclear data will be taken directly from data libraries (effective diffusion section, adsorption, fission, etc.).

Among these codes we cite GEANT4, GAMOS, GATE, FLUKA, PENELOPE… generally written in the C ++ language. So, Monte Carlo is a reliable method and offers complete and very close to reality solutions, which cover all the needs in nuclear medicine.


2. Analogous simulation of photon transport by the Monte Carlo method

2.1 Generality of photons

Most visualization techniques exploit radiation, photonic or otherwise, the intensity of which can be measured in total flux, while gamma radiation used in nuclear medicine is exploited at the level of its smallest indivisible component, the “photon”, and to detect this gamma radiation, a scintillation detector is generally used, the sensitive cell of which is a crystal which has the property of producing a small burst of light when it is touched by a photon, a photomultiplier tube associated with this crystal transforms this spark into an electrical pulse whose amplitude is proportional to the energy of the radiation. The total number of photons detected during a given time interval, or count rate, is the measurement of the radioactivity present in the field of the detector. It’s this ability to count the number of individual photons that make medicine nuclear energy provides quantitative results [1].

So, photons (mphoton = 0, qphoton = 0), are electromagnetic radiations characterized by their energy and their origin, they can be produced by the following phenomena:

  • de-excitation of the nucleus following a modification of its structure;

  • de-excitation of the electronic procession;

  • bremsstrahlung production;

  • dematerialization or positron annihilation

There are two types of photons:


  • Products during the rearrangements of the electronic procession, usually caused by the collision of electrons on atoms, [10 keV; 100 keV].

  • Produced by linear accelerators used in radiotherapy external, [6 MeV; 25 MeV].

Ray γ:

Gamma radiation generally accompany α and β decays, their energy ranges from 60 keV at 3 MeV.

Whatever the origin of the photon, its behavior in matter will be identical.

The photons interact directly with the electrons of matter, and then regenerate various effects depending on the disappearance or not of this one, we find the photoelectric effect, creation of pairs which are due to a disappearance of the photon, the coherent and incoherent diffusion due to the non-disappearance of the photon.

2.2 Simple flowchart

The method to generate histories is to query the probability distributions that describe the problem. This concept is called sampling. The method chosen for Sampling these probability distributions depends on the nature of the distribution [2].

Figure 1.

Flowchart of photon transport in Monte Carlo.

The analogous simulation of particle transport using the Monte Carlo method allows the particle to be followed in its actual path, and the particle is sampled by following the following steps ( Figure 1 ):

  1. Sampling of the “random distance” collision distance (average free path).

  2. transport of the particle to the point of interaction taking into account the constraints of geometry.

  3. Selection of the collided nucleus (heterogeneous environment).

  4. selection of the type of interaction.

2.2.1 Collision distance

This is the distance the particle traveled before it interacted. Or a particle that will undergo an interaction at a point x, at a distance l in a given volume.

The probability of interaction in dl:


The cumulative function is calculated by:


We draw a random number ε, and we look for L such that:




where μ() is the linear attenuation coefficient for the material at photon energy hν.

2.2.2 Selection of the collided nucleus

Which nuclide is subject to collision in the case of a mixture environment?

We must just generate a random number ε between 0 and 1 and compare it to the cumulative probabilities ( Figures 2 and 3 ).

Figure 2.

Density of probability.

Figure 3.

Inversion of the CDF for selection of the collided nucleus.

Example (H2O):

2.2.3 Choice of the type of interaction

The choice of the interaction type is done in the same way of choosing of the collided nucleus.

with σphotoelecric: cross section of photoelectric effect

σcoh: cross section of coherent scattering effect

σincoh: cross section of incoherent scattering effect

2.2.4 Choice of angle and scattering energy

In the case of photoelectric effect, the history of the photon ends, and the program begins with another sample, except if there is emission of a fluorescence X-ray in this case The direction of the emitted photon in the laboratory system is given by.

Ω=sinθ cosΦsinθ sinΦcosθE12

(θ and Φ, are polar and azimuthal angles, respectively), with the azimuthal angle sampled from,


and the polar angle sampled from,


with θmax = π

When the scattering is incoherent the energy hν’ of the scattered photon is taken as the Compton energy:



mec2: the energy equivalence of the electron rest mass (511 keV);

θ: scattering angle.

It is common to neglect sampling coherent scattering angles [3], this may be justified in many situations. However, in diagnostic radiology the neglect of coherent scattering is a poor approximation [4].

Sampling of scattering angles can be done with the rejection method, from the total (incoherent more coherent) scattering cross-section [5], or separately, through method of Klein-Nishina cross-section and the classical Thompson scattering cross-section and corrected for the use of incorrect scattering cross-sections by applying a weight factor to the photon [6], or with and the distribution function techniques.

2.2.5 Weight of particle

Ideally, every real particle in a physical problem should be simulated by a fictitious particle in monte Carlo, in fact, to limit the duration of the simulations and improve computational efficiency [7], a monte Carlo particle does not exactly simulate a physical particle but rather represents a number w of particles physical. The number w is the weight, this weight represents the importance that is assigned to a particle. By default, the weight of each particle is 1 and the energy deposited by a particle equals the product of its energy by its weight.

The benefit of giving weight to a particle is to favor certain physical processes over others. It is necessary to simulate more particle with a low weight to decrease the uncertainty, if we have a sample N of σ (uncertainty) and we want to decrease σ to σn,so we have to multiply N by √n2.


3. Monte Carlo code “GAMOS”

There are several Monte Carlo calculation codes in the field of nuclear medicine, among these codes there is the famous GEANT4 code which is a very powerful and flexible toolkit, for medical applications, but the use of this code does not is not easy, it requires strong knowledge of C ++ language, and details of GEANT4, Most GEANT4 users are researchers who always want to know what is going on in simulation.

The thing that drove Pedro Acre to develop an easy-to-use framework based on the GEANT4 code, allowing to deal with medical physics problems with minimal knowledge of GEANT4 and no need for C ++, thus it provides all the necessary functionalities. to deal with a subject of medical physics while avoiding complicated coding, it is the GAMOS code (Geant4-Based Architecture for Medicine-Oriented Simulation).

The minimum set necessary to compile a project is to select a geometry, a physics list and a generator, to run N events to do this, the geometry will be written in a (.geom) extension file, the name of the geometry, the choice of the physics list, the generators, and the other functionality will be written in an input file of .in extension, therefore output items will be displayed in a file with an .out extension and errors in a file with the gamos_error.log extension.

3.1 Installation Gamos 6.2.0 under Ubuntu

Tap on terminal:

3.2 Creation of geometry and input file

3.2.1 Geometry file

There are 3 ways to describe your geometry:

  • Using a text file.

  • Using one of the geometry examples provided by Gamos.

  • Using C ++.

In this case we will be concerned with the use of a geometry from a text file, the extension of this file must be (.geom), the 1st step is to create a mother volume that will generate all the other volumes, so that the particles do not escape from the mother volume, and to finish the history of the particles that will come out of this volume, then build the other volumes from the following tags:

  1. Materials

:ISOT:For isotopes

:ELEM:For elements

:ELEM_FROM_ISOT:For element composed of several isotopes Material mixtures by weight, volume or number of atoms

:MIXT:For material made of a mixture of elements or materials it can be:





:ISOT  Cs137(Name)  55(Z) 137(A) 136,907(atomic mass)

:ELEM Hydrogen(Name) H(Symbol) 1.( Z) 1.0078 (A).

:ELEM Water(Name) 1. (density) 2(Number of components).

    Hydrogen   2*1.0078/ (2*1.0078 + 15.999)

    Oxygene   1.0078/(2*1.0078 + 15.999)

Geant4 provides a list of predefined materials, whose compositions correspond to the definition of NIST. Among them you can find all the simple elements, you can use these materials when building a volume in GAMOS without needing to redefine them on your geometry file.

The elements can be found in ∼ / gamos-6.2.0 / GAMOS.6.2.0 / data / NIST_elements.txt

Materials consisting of a mixture of elements or materials can be found in ∼ / gamos-6.2.0 / GAMOS.6.2.0 / data / NIST_materials.txt

Other materials common in medical physics are also predefined in the files ∼ / gamos-6.2.0 / GAMOS.6.2.0 / data / NIST_materials.txt and /PET_materials.txt.

  1. Volume


For more details on List of solid parameters see the manual [8].

: PLACEmean the placement of the volume in relation to the parent volume, according to which rotation Matrix, and which coordinates x, y, z.

: PLACE_PARAMis the placement of several copies of a volume along a line.

  1. Rotation matrix

:ROTM, a rotation matrix is interpreted as the rotation that should be applied to the volume in the reference system, it can be defined in three ways:

3 rotation angles around X,Y,Z

6 theta and phi angles of X,Y,Z axis

9 matrix values (XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ)


:ROTM  R000  0.  0.   0.

:VOLU   world  BOX 400.  400. 400. G4_AIR

:VOLU  myvol BOX 200.  200. 200. G4_Pb

:PLACE  myvol 1   world R00 0.  0.   0.

There are other features offered by Gamos such as Visibility, Color and transparency, Check overlaps…. For more details return to manual.

3.2.2 Input file

The first lines of this file are to appeal to the geometry file using the following commands:

/ gamos / setParam GmGeometryFromText: FileName test.geom

/ gamos / geometry GmGeometryFromText

Then, determine one of the lists found on physical Gamos and functions adabpted to your problem, such as:

/ gamos / physicsList GmEMPhysics: for gammas, electrons and positrons, as well as for optical photons.

/ gamos / physicsList HadrontherapyPhysics: this list relates to hadron-therapy.

/ gamos / physicsList GmEMExtendedPhysics: this list concerns subatomic particles, besons, leptons, mesons, barions, ions.

/ gamos / physicsList GmDNAPhysics: This physics list defines the physical processes and models to simulate the interactions of very low energy electrons (down to 7 eV) in water.


Then, you have to determine your generator by writing the following command.

/ gamos / generator GmGenerator

The generator allows you to choose the type of particle and combine any number of single particles or isotopes decaying into e +, e-, g, as well as choosing which distributions of time, energy, position and direction by the following commands: Particle source

For a single source particle:

/gamos/generator/addSingleParticleSource SOURCE_NAME PARTICLE_NAME ENERGY.

For an isotope source:

/ gamos / generator / addIsotopeSource SOURCE_NAME ISOTOPE_NAME ACTIVITY. Time distributions

There are 3 choices, Constant time, Time changing at constant interval, Decay time:

/ gamos / generator / timeDist SOURCE_NAME GmGenerDistTimeConstant TIME .

/gamos/generator/timeDist SOURCE_NAME GmGenerDistTimeConstantChange TIME_INTERVAL TIME_OFFSET.

/gamos/generator/ timeDist SOURCE_NAME GmGenerDistTimeDecay ACTIVITY LIFETIME. Energy

It can be, Constant, BetaDecay, Gaussian, RandomFlat…

/gamos/generator/energyDist SOURCE_NAME GmGenerDistEnergyConstant ENERGY.

/ gamos / generator / energyDist SOURCE_NAME GmGenerDistEnergyBetaDecay.

/ gamos / generator / energyDist SOURCE_NAME GmGenerDistEnergyGaussian MEAN SIGMA.

/ gamos / generator / energyDist SOURCE_NAME GmGenerDistEnergyRandomFlat MIN_ENERGY MAX_ENERGY. Position

It can be, at point, in a Geant4 volume, in a user defined volume, in steps along a line,in square, in a disc, in the voxels of a phantom(materials, structure…)….

/gamos/generator/positionDist SOURCE_NAME GmGenerDistPositionPoint POS_X POS_Y POS_Z.

/gamos/generator/positionDist SOURCE_NAME GmGenerDistPositionInG4Volumes LV_NAME1 LV_NAME2.

/gamos/generator/positionDist SOURCE_NAME GmGenerDistPositionInUserVolumes POS_X POS_Y POS_Z ANG_X ANG_Y ANG_Z SOLID_TYPE SOLID_DIMENSIONS.

/gamos/generator/positionDist SOURCE_NAME GmGenerDistPositionLineSteps POS_X POS_Y POS_Z DIR_X DIR_Y DIR_Z STEP.

/gamos/generator/positionDist SOURCE_NAME GmGenerDistPositionSquare HALF_WIDTH POS_X POS_Y POS_Z DIR_X DIR_Y DIR_Z.

/gamos/generator/positionDist SOURCE_NAME GmGenerDistPositionDisc RADIUS POS_X POS_Y POS_Z DIR_X DIR_Y DIR_Z.

/gamos/generator/positionDist SOURCE_NAME GmGenerDistPositionPhantomVoxels.

It is also possible to create distributions where several of the four variables, are generated at the same time, so that they are related.

By using this minimum of commands described above we can run an example and also visualize the geometry by VRML, OpenGL and ASCII with this command:

/control/execute PATH_TO_MY_GAMOS_DIRECTORY/examples/

The main way to extract information of what is happening and modify the running conditions is user action,

/gamos/userAction MyUserAction

This user action feature allows you to add filters, and classifier in order to follow and focus on the particles as well as the processes you are interested in with this command:

For filters



For classifiers


/gamos/scoring/assignClassifier2Scorer CLASSIFIER_NAME SCORER_NAME

Next step consiste of attaching a sensitive detector to a volume, which used to creating hits (deposits of energy) each time a track traverses a sensitive volume and loses some energy.

Finally you can creat a score to calculate many quantities with or without error, in one or several volumes, for each scored quantity one of several filters can be used, only particles in a given volumen, and results can be displayed in a file or as a histogram.

3.3 Application

3.3.1 Attenuation study for photons of different energy (shielding)

To strengthen radiation protection, nuclear activities must be carried out in accordance with the fundamental principles to ensure the protection of man and the environment against the harmful effects of exposure to ionizing radiation, and since we are talking about medical nuclear medicine, The use of ionizing radiation for medical purposes contributes significantly to the exposure of the population. After natural exposure, this practice presents the first source of exposure of artificial origin, it is therefore recommended to control the doses, and to minimize the time, it is suggested to simulate the experiment before the practice.

We will be interested in the photon, in a midst, the fluence of photons decreases exponentially with the thickness of the material crossed. So, we have:


As the Kerma is at any point proportional to the fluence of photons:


For against, the absorbed dose is proportional to the photon fluence that when the electronic equilibruim is achieved in the material medium. In this case:


Therefore the dose rate decreases exponentially with the thickness of the material traversed, so to protect ourselves from external exposure we must move far from the source and protect ourselves with shielding, where the role of simulation comes in determining the thickness necessary to attenuate these photons.

The attenuation study of a parallel beam of photons of diffetent energy which moves away from a distance of 1 m from the plate of material with Gamos is made by this user action: /gamos/userAction SHNthValueLayerUA, and we must stopped secondary particle, so that they will not be counted as particles coming out of the shield layers by this command /gamos/userAction GmKillAtStackingActionUA GmSecondaryFilter. This commands, allows us to studying penetration, and to establish the role of the shielding.

3.3.2 For photons of 150 Kev

Figures 4 and 5 .

Figure 4.

Attenuation of E = 150 Kev photons by Pb.

Figure 5.

Attenuation of E = 150 Kev photons by Cu.

3.3.3 For photon of 511 Kev

Figures 6 and 7 .

Figure 6.

Attenuation of E = 511 Kev photons by Pb.

Figure 7.

Attenuation of E = 511 Kev photons by Cu.

3.3.4 For photon of 2 Mev

Figures 8 and 9 .

Figure 8.

Attenuation of E = 2Mev photons by Pb.

Figure 9.

Attenuation of E = 2Mev photons by Cu.

3.3.5 Interpretation

( Figures 4 9 ).

From the curves we can see that the element suitable for attenuating and absorbing photons is lead (you can try other materials than Cu), because it is less expensive, and it allows to have an optimal thickness compared to other materials, as well as for the facility of its control of the parameters of aquatic chemistry.

We can also Make an histogram of the energy spectrum of photons of energy 1 Mev and other types of particles that traverse the plate by using Gamos filters, and classifiers, with GmClassifierByParticle:DataList FinalKineticEnergy( Figures 10 13 ).

Figure 10.

Energy spectrum of photons that traverse the plate.

Figure 11.

Energy spectrum of electron.

Figure 12.

Number and type of processes that occur when a number N = 10 4of photons passes through the material.

So we can remove the number of interactions that occur along the path of the particle in the material with this command /gamos/userAction GmCountProcessesUA

Shielding calculations made by hand are often approximations, the most accurate are those performed by simulation, The thickness of the shielding needed depends on: Radiation Energy, the shield material, and Radiation intensity, So the lower the energy of the gamma rays, the easier it is to shield of them, and high energy gamma rays sometimes determine shielding requirements.

For gamma rays, the higher the atomic number of the shield material, the greater the attenuation of the radiation.

3.4 PET scanner

PET imaging combined with CT scanning allows two examinations to be performed simultaneously: the PET examination studies the biological activity of organs, while the CT examination studies the anatomy and morphology of organs. The objective of this examination is to detect anomalous organic activities, by injecting the patient with low-level radioactive glucose, the radiation dose is very low, and does not represent a risk for the patient and his entourage. The injected product is a weakly radioactive marker (derived from glucose marked by Fluorine 18), which will be fixed on the organs, with a preference for the organs that work more, the radioactive marker to highlight the biological activity. This examination is performed on a hybrid machine consisting of two devices:

  • PET scanner that records the radiation emissions of the injected product.

  • X-ray CT which allows to obtain anatomical images

Quantitative reconstruction of PET (Positron emission tomography) data with GAMOS (Monte Carlo) needs to have knowledge of the scanner geometry ( Figure 13 ). Both typical clinical and preclinical scanners use a block-type geometry. Many rectangular blocks of crystals are arrayed in regular polygons. Some of these polygons are arranged along the axis of the scanner, and Monte Carlo simulation remains an essential tool to help design new medical imaging devices, and to know what is happening in the simulation.

Figure 13.

Geometry realized by GAMOS. Three-dimensional (3D) acquisition with block description, and 18F source.

With this user action we can obtain information about the physics process that occur in a PET scanner with all particle:

/gamos/userAction GmCountTracksUA

/gamos/userAction GmCountProcessesUA

/gamos/userAction GmHistosGammaAtSD

/gamos/analysis/histo1Max *Energy* 1*MeV

/gamos/analysis/histo1Max *Pos* 200*mm

/gamos/userAction GmTrackDataHistosUA GmPrimaryFilter

We will obtain results about track ( Figure 14 ) and procces that occur for each particle in terminal and we can save them in file, for example

Figure 14.

Information about track of the job in interactive running.

/gamos/userAction GmHistosGammaAtSD, this command give us an idea about the interaction of original gammas in the sensitive detector ( Figure 15 ).

Figure 15.

Final position X ,Y,Z obtain with GAMOS.

So we have 901 total number of events:

55.66% of ‘original’ gammas reaching one sensitive detector,

94.21% with photoelectric interaction in SD,

37.67%with photoelectric interaction and no Compton interactions,

38,51, with photoelectric interaction and one Compton interaction,

16.29% with photoelectric interaction and two Compton interaction,

6.7% with photoelectric interaction and more than two Compton interaction,

31,03% with no photoelectric interaction and no Compton interaction.

Also we can get more details from the histrograms for examples:

Figures 16 20 show the different parameters and details after reaction generated by Gamos based on random number generator (Section 2.2.4).

Figure 16.

Accumulated Energy deposit.

Figure 17.

Accumulated energy lost.

Figure 18.

Accumulated energy lost.

Figure 19.

Information about interaction of gammas in the sensitive detector.

Figure 20.

Informations about Compton effect.


4. Conclusion

To conclude, Monte Carlo simulation facilitates the experiment and minimizes the time to process the phenomena, so we can go as far as studying the treatment using proton therapy because if we use a cancer treatment with photons, there will be the maximum amount of X-rays, so there will be a maximum dose delivered to the area to be treated (tumor volume), but also there will be a certain level of dose around this volume which are the organs at risk, and which are the tissues that should not be irradiated and which are, so the great advantage of protons is to have a delicate dose, almost zero once the target is reached, because the protons deposit their energy locally, so they generate less complication, and allows to decrease the risk of having a radiation-induced carcinogenesis. Proton therapy has an extremely important indication, which makes it possible to prevent proton therapy, and the Monte Carlo method remains a very powerful tool that makes it possible to improve research in this field by going as far as microdosimetry.


chapter PDF

© 2021 The Author(s). Licensee IntechOpen. This chapter is distributed under the terms of the Creative Commons Attribution 3.0 License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

How to cite and reference

Link to this chapter Copy to clipboard

Cite this chapter Copy to clipboard

Omaima Essaad Belhaj, Hamid Boukhal and El Mahjoub Chakir (September 23rd 2021). Monte Carlo and Medical Physics [Online First], IntechOpen, DOI: 10.5772/intechopen.100121. Available from:

chapter statistics

25total chapter downloads

More statistics for editors and authors

Login to your personal dashboard for more detailed statistics on your publications.

Access personal reporting

We are IntechOpen, the world's leading publisher of Open Access books. Built by scientists, for scientists. Our readership spans scientists, professors, researchers, librarians, and students, as well as business professionals. We share our knowledge and peer-reveiwed research papers with libraries, scientific and engineering societies, and also work with corporate R&D departments and government entities.

More About Us