Atoms combine to form molecules, and molecules combine to form compounds. Mass spectrometry can determine the relative masses of atoms and molecules. It works by converting samples into ion beams, which are then deflected by electric and magnetic fields based on their mass-to-charge ratio. This allows scientists to determine molecular formulas by identifying molecular fragments and isotope abundances. Stoichiometry uses this information to calculate quantities of materials involved in chemical reactions.