A mass spectrometer operates by ionizing chemical compounds to generate charged molecules or molecule fragments and then measuring their mass-to-charge ratios. The process involves three key steps: ionization, mass analysis, and detection. In epidemiology, this helps in identifying specific biomarkers associated with diseases or outbreaks.