Purpose: To develop a stand-alone code to make any application coded with the GEANT4 (GEometry ANd Tracking, version 4) toolkit capable of reading and writing phase-space (phsp) files in the format created by the IAEA (International Atomic Energy Agency), so that the exchange of phsp files between other validated Monte Carlo (MC) codes and GEANT4 is possible.
Methods: We present a stand-alone code, written in C++ object-oriented language, developed in a way that ensures the compatibility with future versions of the IAEA phsp format. The aim of the reader part is to get the information from a given IAEA phsp file and create the primary particles in a GEANT4 user application. On the other hand, the writer part of the code is the responsible for writing the IAEA phsp files during a run of the GEANT4 application.
Results: A testing simulation was written with GEANT4 to verify the performance of this code, with satisfactory results. An example of use in a GEANT4 application which simulates the treatment head of a radiotherapy linear electron accelerator (linac) is also shown, comparing dose calculations with experimental data.
Conclusions: This stand-alone package, which can be used in any GEANT4 application, allows the exchange of validated phsp files between different MC codes and the use of phsp data from many different accelerators and fields in dosimetry studies. Furthermore, it also offers additional utilities of interest in medical applications.