Magnetic spectrometer