In 1919, Francis Aston improved on Thomson's methods and apparatus, leading to the first mass spectrometer -- a machine that literally weighs atoms and molecules. Aston used his spectrometer to study hundreds of naturally occurring isotopes. Today, chemists still use the mass spectrometer to measure the molecular weights of elements, isotopes and compounds. But they also use it to identify the chemicals in a sample, determine how much of each chemical is present in a sample and analyze the structure of complex molecules. Next, we'll take a closer look at what's going on inside a mass spectrometer.
In a mass spectrometer, the same thing is happening, except it's atoms and molecules that are being deflected, and it's electric or magnetic fields causing the deflection. It's also happening in a cabinet that can be as small as a microwave or as large as a chest freezer. The cabinet contains three basic parts: an ionization chamber, a mass analyzer and a detector. Here's how it all works
Chemists combine these two variables into a value called the mass-to-charge ratio, which is represented mathematically as m/z (or m/e). For example, if an ion has a mass of 18 units and a charge of 1+, its m/z value is 18. If an ion has a mass of 36 units and a 2+ charge, its m/z value is also 18. Most of the ions moving from the ionization chamber to the mass analyzer have lost a single electron, so they have a charge of 1+. That means the m/z value of most ions passing through a mass spectrometer is the same as the mass of the ion. The net result is that each ion follows a path dependent on its mass, as shown on the right. Ion stream A has the lightest particles and is deflected the most. Ion stream C has the heaviest particles and is deflected the least. The mass of the particles in ion stream B falls somewhere in between. Notice that only one of the ion streams actually passes through the mass analyzer and reaches the detection unit at the back of the device. The other two streams hit the side of the spectrometer and are neutralized. To analyze all of the ions, chemists simply adjust the intensity of the magnetic field until each stream hits the detector.
Urine drug testing is typically conducted by gas chromatography/mass spectrometry (GC/MS). Sometimes, more than one mass spectrometer is used in a technique called tandem mass spectrometry, which basically acts to break apart large ions into smaller ions for more detailed analysis. All of this is required because urine contains a large number of components, including naturally occurring steroids. Using GC/MS or GC/MS/MS detects more chemicals and yields more reliable results http://science.howstuffworks.com/mass-spectrometry4.htm