Objective: In this contribution we present a special Fano test for charged particles in presence of magnetic fields in the MC code TOPAS, as well as the determination of magnetic field correction factors kB for Farmer-type ionization chambers using proton beams.

Approach: Customized C++ extensions for TOPAS were implemented to model the special Fano tests in presence of magnetic fields for electrons and protons. The Geant4-specific transport parameters, DRoverR and finalRange, were investigated to optimize passing rate and computation time. The kB was determined for the Farmer-type PTW 30013 ionization chamber, and 5 custom built ionization chambers with same geometry but varying inner radius, testing magnetic flux density ranging from 0 to 1.0 T and two proton beam energies of 157.43 and 221.05 MeV.

Main results: Using the investigated parameters, TOPAS passed the Fano test within 0.39±0.15% and 0.82±0.42%, respectively for electrons and protons. The chamber response (kBMQ) gives a maximum at different magnetic flux densities depending of the chamber size, 1.0043 at 1.0 T for the smallest chamber and 1.0051 at 0.2 T for the largest chamber. The local dose difference cB remained ≤ 0.1% for both tested energies. The magnetic field correction factor kB, for the chamber PTW 30013, varied from 0.9946 to 1.0036 for both tested energy.

Significance: The developed extension for the special Fano test in TOPAS MC code with the adjusted transport parameters, can accurately transport electron and proton particles in magnetic field. This makes TOPAS a valuable tool for the determination of kB. The ionization chambers we tested showed that kB remains small (<0.7%). To the best of our knowledge, this is the first calculations of kB for proton beams. This work represents a significant step forward in the development of MRgPT and protocols for proton dosimetry in presence of magnetic field.