Method to eliminate the impact of magnetic fields on the position of the electron beam during EBW