MedLinac2: a GEANT4 based software package for radiotherapy


MedLinac2: un pacchetto software per la radioterapia basato su GEANT4



Barbara CacciaI; Claudio AndennaII; Giuseppe Antonio Pablo CirroneIII

IDipartimento di Tecnologie e Salute, Istituto Superiore di Sanità, Rome, Italy
IIILaboratori Nazionali del Sud, Istituto Nazionale di Fisica Nucleare, Catania, Italy

Address for correspondence




Dose distribution evaluation in oncological radiotherapy treatments is an outstanding problem that requires sophisticated computing technologies to optimize the clinical results (i.e. increase the dose to the tumour and reduce the dose to the healthy tissues). Nowdays, dose calculation algorithms based on the Monte Carlo method are generally regarded as the most accurate tools for radiotherapy. The flexibility of the GEANT4 (GEometry ANd Tracking) Monte Carlo particle transport simulation code allows a wide range of applications, from high-energy to medical physics. In order to disseminate and encourage the use of Monte Carlo method in oncological radiotherapy, a software package based on the GEANT4 Monte Carlo toolkit has been developed. The developed package (MedLinac2) allows to simulate in an adequate flexible way a linear accelerator for radiotherapy and to evaluate the dose distributions.

Key words: computer assisted radiotherapy, computer simulation, distributed system.


La valutazione della distribuzione di dose nei trattamenti in radioterapia oncologica richiede sistemi di calcolo avanzati per poter offrire le soluzioni migliori per la cura dei pazienti (rilasciare la dose di radiazione necessaria al tumore salvaguardando agli organi sani). Gli algoritmi di calcolo della dose basati su metodo Monte Carlo sono lo strumento più accurato attualmente disponibile per la radioterapia. La flessibilità del codice Monte Carlo GEANT4 (GEometry ANd Tracking) consente un'ampia gamma d'applicazioni: dalla fisica delle alte energie alla fisica medica. Per diffondere e incoraggiare l'uso di codici Monte Carlo in radioterapia oncologica è stato realizzato un pacchetto software (MedLinac2), basato sul toolkit GEANT4, che permette di simulare in modo flessibile un acceleratore lineare per radioterapia e calcolare le distribuzioni di dose.

Parole chiave: radioterapia assistita da computer, simulazione computerizzata, sistemi di calcolo distribuiti.




Radiotherapy represents one of the major treatment options in cancer care. About 52% of oncological patientsreceiveradiotherapyatleastonceduringthetreatment of their cancer [1]. Therefore radiotherapy plays an important role in the treatment of the patients, in association with other modalities such as surgery and chemotherapy. However, radiotherapy is defined as "a double-edged sword" [2], because patients treated with ionizing radiation have an increased risk of developing a second cancer in their lifetimes. As a consequence it is important to optimize every aspect of the treatment in order to reduce the radiation dose to the healthy tissues and maximizing the radiation dose to the tumour. For example, as reported by the AAPM [3], a 5% changes in radiation dose can result in 10%-20% changes in tumour control probability (TCP) or up to 20-30% changes in normal tissue complication probabilities (NCTP) in the steepest region of the dose-effect curves. Monte Carlo codes can provide dose calculation map with the high level of accuracy required by the innovative high-technology radiation techniques. This is important because, in radiotherapy treatment planning, the conventional deterministic dose algorithms may not accurately evaluate the effects of electron transport in heterogeneous patient tissues [3, 4].

An obstacle to the application of Monte Carlo methods to the clinical routine in radiotherapy departments is the heavy computational load needed for the dose calculation and the skill and expertise required to run the actual codes. However, the improvements in computer processor technology and the availability of computer architecture, such as cluster computing and grid technologies, have reduced calculation times and a number of Monte Carlo-based treatment planning systems (TPS) are commercially available today [4].

GEANT4 (GEometry ANd Tracking) - one of the most powerful Monte Carlo codes, largely used in high energy physics [5] - was first applied in 2004 to develop a software package (MedLinac) to simulate a medical linear accelerator for radiotherapy [6]. However, the MedLinac package had a low flexibility, especially in the implementation of different accelerators and in the production of output files.

GEANT4 and MedLinac2

To facilitate the use and to spread the knowledge of the Monte Carlo codes in medical applications we have developed a GEANT4 based package (called MedLinac2) with the purpose to overcome the cited problems of MedLinac in simulating a medical linear accelerator.

The MedLinac2 package was distributed with the GEANT4 release of December 2009 (Release GEANT4 9.3).

GEANT4 is not a stand-alone program but a collection of libraries, written in C++ language and organized exploiting the power of the object oriented programming technology. Nowadays, GEANT4 is used in a huge number of physics experiments and research projects, as well as in a variety of application domains, from high-energy physics to medical physics and radiation protection. Its functionalities and modelling capabilities continue to be extended, while its performance is enhanced. GEANT4 is organized as a worldwide collaboration of scientists and software engineers whose goal is to develop, maintain and provide support for the GEANT4 toolkit. The collaboration has various working groups regarding different aspects of the code development. In order to spread the use of GEANT4 toolkit, the Advanced Examples Working Group develops realistic examples illustrating GEANT4 application in typical experimental environments. Advanced examples are developed in collaboration with user group's expert in the corresponding experimental domain.

A cluster map of the access to the web site of the GEANT4 advanced examples is shown in Figure 1: the large amount of visits underlines how large is the community of users and developers that collaborate in using and disseminating the advanced examples. Many advanced examples are related to medical and biological applications (brachytherapy, hadrontherapy [7], human phantom, medical linac, microdosimetry, and others), thus demonstrating the power and capability of GEANT4 in this field.

Inthispaper,themainfeaturesof theadvancedexample MedLinac2, developed in the context of GEANT4 collaboration, will be reported. This package simulates a typical linear accelerator used for intensity modulated radiation therapy (IMRT) and offers a structure where a medical physicist may easily simulate the linear accelerator available in hospital, by easily changing the description of the accelerator components.

A brief description regarding the use of the package is included in the advanced example distribution that can be freely downloaded together with the GEANT4 toolkit from the official website A more detailed description can be found in the GEANT4 advanced example website (



Since the GEANT49. 3 version released on December 2009, the Advanced Example MedLinac2 replaced MedLinac [7], which is not more maintained.

MedLinac2, even if developed on the solid basis of its precursor MedLinac, was specifically designed to be more flexible. In particular, MedLinac2 allows to easily choose among different accelerators/phantoms, as well as different irradiating beams. The solution adopted to obtain a high flexibility was to organize the package into separate code modules, regarding the physics, the geometry, the particle source, and the post elaboration. These modules will be shortly described below. Moreover, macro files, i.e. ascii files based on the GEANT4 macro syntax that the program loads to define the simulation, were used to manage and to select external parameters, avoiding the need to recompile the source code for any change, and thus contributing to the flexibility and usability of the package.

Physics module

Different physics software packages can be selected among those distributed with GEANT4 code (see the GEANT4 collaboration website, such as:

- Em Standard Physics, designed for high accuracy of electrons, hadrons and ion tracking without magnetic field,

- Em Livermore Physics, designed for low-energy electromagnetic processes for gamma, e-, hadrons and ions based on Livermore data sets.

- Em Penelope Physics, designed for low-energy electromagnetic processes for gamma, e-, hadrons and ions based on Penelope models.

This gives the possibility to properly simulate physical processes well suited to the range of energies and to the chosen particles. Furthermore, since the GEANT4 collaboration maintains these packages of physics, it is also guaranteed that the software is always updated in terms of physical data, processes and algorithms. In addition, the comparison among different physical processes and algorithms can be easily performed by launching the same simulation changing just one parameter in the proper macro file.

Geometry module

The geometry was planned to allow the user to add new accelerator/phantom in a quite easy way. The chosen programming strategy allows swapping from one component to another by changing the appropriate parameters values in the macro files, according the standard macro of GEANT4, to allow different accelerators to have their own parameters properly set. The MedLinac2 advanced example is based on a clinical linear accelerator structure, where the components are: the target, the primary collimator, the flattening filter, the mirror, four jaws and the multileaf collimator. The general scheme was based on the structure of the Varian Clinac 2100 accelerator (Varian Medical Systems, Palo Alto, CA, USA).

Particle source module

The particle source module was planned to give two choices to the user: 1) a standard random electron generator, representing the electron beam hitting the target of the medical linear accelerator whose energy, in terms of mean and standard deviation, and radius can be specified in the macro file; 2) a phase space file, which contains data related to the particles (position, direction of propagation, kinetic energy, type) crossing the chosen scoring plane.

The use of the phase space is a technique to reduce the computing time without affecting the computing accuracy. The phase space approach is based on the idea to divide the computation into two steps. During the first step, the data of all the particles hitting the scoring plane are recorded in some files from which they are recalled when the second step of the computation is performed. This approach considerably reduces the computing time because the same data can be used in different simulations avoiding the computation time of the first step. As stated above, two different simulations (for the same accelerator) can share the same phase space file given the same first step of the simulation. Particularly attention has to be paid to the amount of particles stored in the phase space file to avoid a lack of statistics.

Post-elaboration module

A basic level of post elaboration was implemented in order to facilitate the data analysis in different situations. In many situations, it is necessary to know the results in some specific voxels of the phantom, to verify the agreement with experimental data or to construct dose distributions along or transversally to the beam direction. In other situations, the calculation of the overall dose in the whole phantom, or in a subsection of it, is needed. To answer the former necessity we have introduced the possibility to compute the data in a defined array of voxels, passed to the program by an input file specified as a macro file. To this array of voxel it is also linked a simple convergence criterion, implemented to automatically terminate the program when a given number of events have been reached. The phantom voxelization, on the other hand, was used to record the dose in the whole volume realising a three dimensional image of the dose in the phantom. For each voxel of the phantom it was saved not only the cumulative dose but also the number of events and the square cumulative dose. The name of the volume to which the voxel belongs is recorded to filter the results for specific volumes of interest.



The code was subjected to several tests to be validated in a clinical context [8]. The first test was based on the simulation of a system based on a Varian Clinac 2100 accelerator and a cubic phantom filled with water (see Figure 2a) as detector. To test the behaviour of the code in a more critical situation different cubic phantoms were filled with a lungequivalent material of different densities and with the insertion, in the centre, of a cube of polymethylmethacrylate (PMMA, density of 1.22 g/cm3, 6 cm side) (see Figure 2b).



Different densities of polyurethane slabs (ρ = 0.03, 0.08 and 0.40 g/cm3) were chosen to simulate lungs under different breathing phases [8] or small air cavities present in other human anatomical districts. To simulate a lung-equivalent material with different densities we have used a polyurethane-based material, while for higher density lung tissue (0.40 g/cm3) a blend of cork and polyurethane was used [8]. Experiments were performed with a Clinac Varian 2100 with energy of 6 MV using different square fields, from 3x3 cm2 to 20x20 cm2. Data obtained from the simulation were compared against experimental data measured with radiochromic film dosimeters and against data calculated with commercial treatment planning systems [8], along the PDD (percentage of depth dose) curves and along transversal sections at three different depths in the phantom. The GEANT4 simulations results (qualitatively shown in Figure 3 for the density of 0.08 g/cm3) were in a good agreement with the experimental data.

It stems from Figure 3 that reducing the field size the dose given to the low density material both before and after the PMMA insert decreases while the dose at the central block remains the same. In fact the attenuation of photons per unit length is lower in low density lung-equivalent material compared with the density of PMMA (close to water density). This results make evidents the need to have treatment planning systems that make an adequate calculation of density-corrected doses in low density tissues, such as lungs. A comprehensive comparison among GEANT4 simulations, gafchromic dosimetry and some commercial treatment planning systems is on going and will be reported in a next publication.



The most severe obstacle for the application to clinical practice of Monte Carlo-based code for dose distribution calculation is the long time required. In fact, to achieve the required accuracy it is necessary to collect a high number of dose release events generated from a much higher number of primary histories. For example, in the cubic phantom simulating a lung-equivalent material, about 80 millions of primary particles at the phase space plane were used to obtain a good agreement verified with the gamma factor (distance to agreement 3 mm and dose distribution 3%).

The time needed to get enough data to be statistically acceptable depends on several parameters, such as the computing system, the desired accuracy, the voxels sizes, the field size and the phantom material and heterogeneity, and for not adequate computing systems, it can be quite long. In the above example, using the phase space, about 10 CPU hours were roughly necessary to get the result for each simulation. To reduce the computational load it is necessary to use a distributed computing approach. MedLinac2 was tested on different distributed computing systems [10].

Computing cluster approach

We have used a distributed solution using the Beowulf cluster of 50 diskless nodes maintained at the Technology and Health Department of the Istituto Superiore di Sanità (ISS). The ISS Beowulf Cluster consists of 14 nodes based on a Intel core2D CPU (2.4GHz, 2GB RAM) and the other 36 on a P4 Hyper Threading CPU (3.2GHz, 1GB RAM). For each simulation, several MedLinac2 processes were generally distributed to the nodes and the data collected [10]. This solution is a good compromise between costs and computation times. The good scalability of the Beowulf cluster allows both statistically significant accuracy and good time performances.

GRID approach

The distributed architecture of the grid allows to split one single, time-consuming, simulation into several small submissions; each submission is typically sent to a different computing resource. The results of each sub-simulation are eventually recombined into a single statistics, providing then a result with the same accuracy it would have had if the simulation would has been unique. Test performed with GEANT4 code simulation using the Grid resource of Cometa consortium (see website have shown a significant reduction of the computation time without have the need to modify the code [11].



The MedLinac2 package was recently released within the December 2009 GEANT4 official distribution, in the Advanced Example category, and it started to be used by different researchers in medical physics community. The package is currently under further validation using new experimental data. Moreover, situations critical for the commercial TPS, such as small fields and/or phantoms with high differences in the materials densities, will be investigated. Finally, the package will be improved introducing new features of interest for clinical applications, such as the possibility to rotate the accelerator and/or the phantom, actually under testing.


We are indebted to Lidia Strigari, Giuseppe Iaccarino, Valeria Landoni and Antonella Soriani for all the experimental tests on our MedLinac2. We thank Gianluca Frustagli and Stefano Valentini for the technical support in using the Beowulf cluster of the Department of Technology and Health of the Italian National Institute of Health (Istituto Superiore di Sanità). This work has been supported by the INFN V Commission.

Conflict of interest statement

There are no potential conflicts of interest or any financial or personal relationships with other people or organizations that could inappropriately bias conduct and findings of this study.



1. Delaney GP, Jacob S, Featherstone C, Barton NB. The role of radiotherapy in cancer treatment: estimating optimal utilisation from a review of evidence-based clinical guidelines. Cancer 2005;104:1129-37.         

2. Xu X G, Bednarz B, Paganetti H. A review of dosimetry studies on external-beam radiation treatment with respect to second cancer induction phases. Phys Med Biol 2008;53: R193-R241.         

3. Chetty IJ et al. Report of the AAPM Task Group No.105: issues associated with clinical implementation of Monte Carlo-based photon and electron external beam treatment planning. Med Phys 2007;34(12):4818-53.         

4. Spezi E, Lewis G. An overview of Monte Carlo treatment planning for radiotherapy. Rad Prot Dos 2008;131(1):123-9.         

5. GEANT4 Collaboration. GEANT4 developments and applications. IEEE Transactions on Nuclear Science 2007;53(1): 270-8.         

6. Foppiano F, Mascialino B, Pia MG, Piergentili M. GEANT4 simulation of an accelerator head for intensity modulated radiotherapy. In: Proceedings of The Monte Carlo method: versatility unbounded in a dynamic computing world; Chattanooga, Tennessee, April 17-21, 2005. [CDROM]. LaGrange Park, IL: American Nuclear Society; 2005.         

7. Cirrone GAP, Cuttone G, Guatelli S, Lo Nigro S, Mascialino B, Pia MG, Raffaele L, Russo G, Sabini MG. Implementation of a new Monte Carlo - GEANT4 simulation tool for the development of a proton therapy beam line and verification of the related dose distributions. IEEE Transactions on Nuclear Science 2005;52(1):262-5.         

8. Caccia B, Frustagli G, Mattia M, Andenna C, Strigari L, Iaccarino G, Landoni V, Soriani A. Lung densities in different respiratory phases: a dosimetric study based on GEANT4 simulation and GafChromic films. Proceedings of the Second European Workshop on Monte Carlo Treatment Planning, 19-21 October 2009, Cardiff (UK), p. 86-8.         

9. Fogliata A, Vanetti E, Albers D, Brink C, Clivio A, Knoos T, Nicolini G, Cozzi L. On the dosimetric behaviour of photon dose calculation algorithms in the presence of simple geometric heterogeneities: comparison with MonteCarlo calculations. Phys Med Biol 2007;52:1363-85         

10. Caccia B, Mattia M, Amati G, Andenna C, Benassi M, d'Angelo A, Frustagli G, Iaccarino G, Occhigrossi A, Valentini S. Monte Carlo in radiotherapy: experience in a distributed computational environment. JPhys Conference Series 2007;73:1-9.         

11. Ardizzone V, Barbera R, Cirrone GAP, et al. Dose distribution verifications in medical physics: the results obtained using GEANT4 and GRID technology. Proceedings of final workshop of grid projects, 10-12 February 2009, Catania (Italy), p. 460-7. Available from:         



Address for correspondence:
Barbara Caccia
Dipartimento di Tecnologie e Salute, Istituto Superiore di Sanità
Viale Regina Elena 299
00161 Rome, Italy

Received on 29 March 2010.
Accepted on 10 May 2010.

Istituto Superiore di Sanità Roma - Rome - Italy