Mass spectrometry is an analytical technique that measures the mass-to-charge ratio of ions. It involves converting the sample into gaseous ions, separating the ions based on their mass-to-charge ratio, and detecting the relative abundance of each ion. There are four key stages: ionization, acceleration, deflection according to mass-to-charge ratio, and detection. Different types of peaks in a mass spectrum provide information about the molecule, including the molecular ion peak, which indicates the molecular mass, and fragment ion peaks, which result from fragmentation of the molecular ion. Rules like the nitrogen rule and rule of 13 can help determine molecular formulas from mass spectrometry data.