Mass spectrometry is an analytical technique that produces spectra of the masses of atoms and molecules in a sample. It works by ionizing the sample molecules and separating the resulting ions based on their mass-to-charge ratio. Common components include an ion source, mass analyzer, and detector. Common ionization methods are electron impact, chemical ionization, electrospray ionization, and matrix-assisted laser desorption/ionization. Common mass analyzers are the quadrupole and time-of-flight analyzer, which separate ions based on stability in oscillating electric fields or flight time. Mass spectrometry is used to determine molecular structure and composition.