Radiotherapy is one of three principal methods available to treat cancer patients. It uses ionizing radiation to destroy tumor cells, and it has been proven to be an effective treatment method for a variety of tumors. There are two ways to deliver radiation to the location of the cancer, an external beam or internal radioactive source. External radiation beam is produced by Linac aiming high-energy rays to the tumor location. The use of Linac is the most common approach in the clinical setting.
In order to implement those treatment methods, advanced treatment-planning and calculations are required for medical dosimetry. Monte Carlo method is well-suited for radiation transport in general and particularly for these kinds of problems. The Monte Carlo method can be used to model any statistical process that can be described by probability distributions. In radiation transport, electron and photon showers are created by compiling a large number of repetitions of physical processes that follow probability distributions. The Monte Carlo method is using machine-generated random numbers in order to sample probability distributions governing the physical processes involved. By simulating a large number of histories, information can be obtained about average values of macroscopic quantities, such as energy deposition.
There are several general-purpose Monte Carlo code systems for simulating radiation transport . The EGS5 code  and the EGSnrc code    are based on the fourth version of the EGS (Electron Gamma Shower) code, EGS4 , and were used in different studies that dealt with simulations of electron beams and Linac modelling   .
The EGS is a Monte Carlo transport code which grew out of the need to model electron-photon transport at high energies for the research conducted at the Stanford Linear Accelerator Centre (SLAC). The fourth revision of the code, EGS4, includes the PRESTA algorithm for electron step corrections   . This algorithm treats the lateral deflection of the condensed history electron step, during the transport simulation and also includes a more accurate prescription for relating the straight line transport distance to the actual path length. There are two major drawbacks to the PRESTA method. First, in situations where an electron is traveling close to a region boundary, translating its lateral distances perpendicular to its initial direction can sometimes result in moving it across the boundary and into a region with different material properties. Thus, PRESTA required computationally expensive interrogation of the problem geometry and sometimes resulted in very small steps when particles were traveling roughly parallel to nearby region boundaries. Second, PRESTA is not adept for backscattering modelling. The PRESTA algorithm tends to overestimate the penetration prior to the large-angle backscatter event, which can lead to significant errors in computations of energy distributions of backscattered electrons, among other quantities .
Numerous of improvements have been implemented to the radiation transport of EGS5 and EGSnrc   . The most notable improvements were new transport mechanism to address these shortcomings of the PRESTA algorithm . In the EGS5, the new transport mechanism is based on the dual hinge methodology  . In this methodology, instead of transporting the particle a distance and then displacing the particle horizontally and vertically followed by updating its direction according to the sampled scattering angles, the electron step is treated by randomly splitting it into two segments, and a scattering hinge is applied in between them .
The energy-loss calculation accuracy was improved by the EGSnrc. The improved energy-loss accuracy is mainly due to the replacement of the original algorithm for the condensed history electron step, PRESTA, with PRESTA-II . PRESTA-II improved the lateral and longitudinal corrections for elastic scattering by reproducing first and second order spatial moments, which are based on Lewis theory .
EGSnrc package includes the BEAMnrc code   and the DOSXYZnrc code  . BEAMnrc was designed to allow users to model Linac treatment heads by breaking the geometry down into independent blocks, referred to as component modules (CMs). Each component module (CM) is designed to model a particular geometric shape of the linear accelerator. BEAMnrc code produces phase-space files containing all the necessary information characterizing every particle at a specified scoring plane. DOSXYZnrc code can use the phase space files as an input in order to calculate dose distributions in water phantoms or in CT-based phantoms. Another program, DOSRZnrc, can simulate the passage of an electron or photon beam in a finite, right cylindrical geometry.
In a recent work in our group a comparison between the simulation results obtained using EGS5 with the EGSnrc simulation results was carried out . In order to compare between those two codes, the first part was modelling of the geometrical components of the radiation treatment head. Schematic diagram of Elekta Precise Linac treatment head is illustrated in Figure 1. The next step was to simulate percentage depth dose curves (PDD) and lateral profiles for three different electron beam energies from Elekta Precise Linac with a standard 14 × 14 cm2 applicator. Simulation EGSnrc and EGS5 codes results as well as measurements were performed. The results of the PDDs and lateral profiles have shown conformity between calculation results for EGS5 and EGSnrc codes as well as the measured. However, the calculation run-times were significantly different.
An example of PDD calculated with EGSnrc and EGS5 codes as well as the measured results is presented in Figure 2 . As can be seen from the results
Figure 1. ELEKTA Precise Linac schematic geometry for a 6 MeV beam as defined in BEAMnrc.
Figure 2. PDD curve for the 6 MeV beam, applicator 14 × 14 cm2 .
presented in Figure 2, the good conformity between normalized dose results of EGS5 and of EGSnrc codes were within 1%/1 mm. The calculation durations performed with EGSnrc code (the sum of BEAMnrc and DOSXYZnrc columns), and with EGS5 code are presented in Table 1.
From these results, it was shown that the EGSnrc based simulations are significantly faster than EGS5 based simulations (almost three times). The purpose of this study was to explore the reason for these run-times differences.
2. Materials and Methods
The differences between those two codes were examined thorough investigation of the parameters that affect the calculation time and the accuracy of the calculation for various cases. Characterization of the problem was done by simplifying the problem and focusing on several levels.
2.1. Computational Differences
Simulation of an air chamber cylinder (1 mm × 2 mm) irradiated with a parallel 6 MeV mono-energetic photon beam was prepared for EGS5, and the same for EGSnrc. All simulations were performed on the same computer, with the same operating system (Intel i5-4570 CPU 3.4 GHz, 8 GB RAM, Windows 8.1 pro 64 bit), in order to eliminate differences that may arise from the way those codes were running on different operating systems or computing conditions. Since the two codes differently output the results, we chose to calculate the absolute dose in a simple case, a small cavity placed in a water phantom, to assure absolute dose results agreement.
The EGS5 Dose in Air:
The EGSnrc Dose in Air:
The two calculated dose results in Equation (1) and Equation (2) are within 0.1% difference, therefore can be considered as identical.
2.2. Transport Differences
Several studies showed that many problems require more stringent criteria of
Table 1. The simulations run-times hours by EGS5 and by EGSnrc codes. Tthe run-time of the EGSnrc code is the sum of the two last columns .
electron tracks than just using an average length. In EGS5 code, a numerical model for automatically selecting electron energy-loss sub-steps was developed and implemented. However, in the EGSnrc code, the transport mechanism for electron step-size is still based on user intervention by choosing the fractional energy-loss per step: the ESTEPE parameter. To amplify the different method employed in the above codes, we designed a test case simulation with strong step-size dependency.
An iron martial body, that represented an ion-chamber component, was placed inside a water cylinder phantom, 5 cm radius and 5 cm length. The phantom was irradiated with a parallel 6 MeV mono-energetic photon beam incident toward the flat side of the phantom. The size of the chamber was 2 mm length with 1 mm radius, and it was placed inside the water phantom at depth of 2.5 cm. By simulating a small chamber inside a large homogenous medium, we challenged the algorithm performance. Choosing large steps will cause a lower dose inside the chamber, due to the fact that the steps could miss the chamber, and vice versa, choosing small steps lead to a higher dose inside the chamber. In order to emphasize our findings, we chose to take a case where a full 2-mm layer of iron was placed in front of the beam. The thick layer was placed at three different heights. The first case was at the upper side of the phantom, for the second case at the middle and in the last case, and for the third case the layer was placed at the bottom side of the phantom.
3. Results and Discussion
The iron chamber cylinder (1 mm × 2 mm) inside a water cylinder phantom, 5 cm radius and 5 cm length, was irradiated by a parallel 6 MeV mono-energetic photon beam. This case was run by the EGS5 code for 105 to 108 histories. The same iron chamber cylinder case was run with the same histories using the EGSnrc code with different ESTEPE percentages values.
In Table 2, the small chamber case results both from the EGS5 and from the EGSnrc runs are listed. A comparison was made by taking different ESTEPE values for each of the EGSnrc results compared to the EGS5 results, for each number of histories. The number of histories was changed in order to obtain different precisions and run-times. It was shown that by choosing ESTEPE- equal-1% for the EGSnrc, as recommended and necessary for this type of calculation , led to about 5.5% slower run-time compared to the EGS5 run-time.
Table 2. Simulations run-time (in seconds) versus number of histories for the small chamber case: EGS5 simulation and EGSnrc simulations with several ESTEPE values.
The EGS5 relative dose results were divided by the EGSnrc (with ESTEPE of 1% dose) results for the small chamber case are presented in Figure 3. It was shown that the ratio between the two codes results could be considered identical since the difference is less than 0.25%.
The graph in Figure 3 shows the results for the optimal ESTEPE value of 1% fractional energy-loss per step. Smaller values of ESTEPE have elevated the dose estimation, while higher values than 1% ESTEPE have decreased the estimated dose. The run-time increases significantly with the use of smaller ESTEPE values. For example, simulating one million histories with 2.5% ESTEPE takes about 108 seconds, almost five times longer than simulating the same number of histories with 25% ESTEPE.
A set of three different cases with a full 2-mm layer of iron were simulated with different ESTEPE values using the EGSnrc and the EGS5. The layer was placed in three different heights. The first case was at the upper side of the phantom in front of the beam, the second case at the middle, and in the last case, the layer was placed at the bottom side of the phantom. Setting a revealed structure in the geometry was performed in order to omit difficulty to find the iron layer by optimizing the ESTEPE value in the EGSnrc.
Table 3 summarized the run-times for different cases and number-of-histories: the EGSnrc with different values of ESTEPE were compared to the EGS5 run-time, for the three different layer cases. Dose results are summarized in Figure 4 to present the differences in EGSnrc with ESTEPE of 25% in small chamber case results, and in the thick layer case results. These results were obtained from the dose of each specific run divided to the dose expectation value, which was obtained by using ESTEPE of 0.25% with 108 histories.
These dose results indicated (Figure 4) that for large structure geometries, the ESTEPE dependence in EGSnrc would be less effective, hence choosing appropriate parameters in EGSnrc is less substantial. In this large structures geometry case, we were “helping” the EGSnrc electron-step algorithm to find the iron layer, and therefore in this case the EGSnrc was indeed efficient.
In this study, we presented a comparison between the EGS5 and the EGSnrc
Figure 3. Relative dose from the EGS5 and from the EGSnrc in a small iron chamber. For EGSnrc, ESTEPE of 1% was used. The ratio between the two codes results can be considered as identical.
Figure 4. Dose results from EGSnrc with ESTEPE of 25% in a small chamber case compared to the thick layer case results. The results were obtained from the dose of each specific run divided to the dose to expectation value, which was obtained by using ESTEPE - 0.25% and 108 histories.
Table 3. Simulations run-time (in seconds) versus number of histories for three different cases: thick layer at the upper side of the phantom, at the middle and at the bottom side of the phantom the small chamber case: EGS5 simulation and EGSnrc simulations with several ESTEPE values.
electron-step algorithms results. In some cases, the EGSnrc appeared to be faster only while default parameters were used without matching the parameters to the case. In the EGSnrc, where parameters were needed to be modified by the user, the EGSnrc became slower compared to the EGS5. PRESTA-II, the electron step algorithm in EGSnrc, requires an expert user intervention to set the proper electron step-sizes parameters in most cases, while in EGS5, the step-size parameters are automatically computed only just by relating them to the simulation’s geometry dimensions.
In conclusion, some cases that were tested in this study on the EGS5 and on the EGSnrc showed that the EGS5 is the more accurate, faster and fluent to use between these two codes.