A mass spectrometer (or mass spectrograph) is a device to determine the masses of molecules. The general method is to send ionized molecules through a magnetic field that give them a sideways push and measures their resulting trajectories, the heavier molecules being affected less and having straighter trajectories. Ratios of the counts of known molecules can be determined through measuring the number reaching two different areas. This practice is called mass spectrometry. The word spectrometer (or spectrograph) is used because the device's ability to measure molecules by mass is analogous to the measurement of visible light by wavelength.
To measure the amounts of rarer constituents (i.e., traces), a mass spectrometer may include an enrichment mode mechanism, allowing some compounds to be removed, typically by exposing the material to some chemical that will react with it, i.e., draw it out in some manner, it from the gas, after which the spectrometer is used to determine the relative amounts of the remaining constituents. This works best with some foreknowledge of the constituents and/or for measuring noble gases.
Mass spectrometers are included in space probes, to analyze material from dust or associated with solar system planets, moons, comets, or asteroids, either gathered by a lander, or collected from flying through the body's atmosphere or plume residue.