To prepare the molecules for sorting and weighing, a sample containing an unknown compound is first injected into the mass spectrometer through an inlet (see the first figure), and is then vaporized by heating it under a vacuum. The vaporized sample is then pushed by an inert gas into the "smasher," where the sample is clobbered and broken into little bits.
The molecular ion peak is the most important piece that's weighed by the mass spectrometer, because knowing the molecular weight of the unknown molecule is a very valuable piece of information when you're trying to determine its structure.
Some of the radical cations stay intact and lead to the molecular ion peak, but others break down spontaneously into smaller bits. Most commonly, the radical cations break into two pieces, one piece that's a neutral radical, and one piece that's a positively charged cation, as shown in the next figure. Only the charged cationic species is "seen" and weighed by the mass spectrometer. The neutral radicals are discarded and go undetected.
When charged particles move through a magnetic field, they're deflected (pulled off course) by the magnetic field. All uncharged fragments are not deflected by the magnet and simply run into the walls of the spectrometer, never to be seen again. Therefore, only charged particles can hit the detector.
With a larger magnetic field strength, larger particles will curve the right amount to hit the detector. By varying the magnetic field strength (which is proportional to the weight of the fragment), the weights of the fragments can be determined.