We know that electric charges moving in magnetic fields feel a force, called the Lorentz force, which is a cross product: F = qv x B.
This force is always perpendicular to the motion and B-field, and because of this particles get pushed into circular paths. This means the centripetal force is determined by the magnetic force. No work is done, as the energy is unchanged, but just the direction of the particle is changed.
In order to get a mass spectrometer to work, we also need to know the velocity of the particles. We can use electric fields to create a velocity selector. Keep in mind there is a good ActivPhysics simulation for mass spectrometers, 13.10, you may want to check out, too.