When a sample is irradiated with primary X-rays from an X-ray tube, electrons in the inner shells of the atoms are ejected. This creates vacancies, which are then filled by electrons from higher energy levels. The energy difference between these levels is released in the form of fluorescent X-rays. Detectors in the XRF instrument measure the energies and intensities of these emitted X-rays to provide information about the elemental composition of the sample.