SIMS works by directing a primary ion beam, typically composed of ions like Cs+, Ga+, or O2+, onto the sample surface. This bombardment causes the emission of secondary ions from the sample, which are then collected and analyzed by a mass spectrometer. The mass spectrometer separates the ions based on their mass-to-charge ratios, allowing for the identification and quantification of the elements and molecules present on the sample surface.