A method for X-ray analysis of a sample includes aligning an optical radiation
source with an X-ray excitation source, so that a spot on the sample that is irradiated
by an X-ray beam generated by the X-ray excitation source is illuminated with optical
radiation generated by the optical radiation source. Optical radiation that is
reflected from the sample is used to generate a first signal, which is indicative
of an alignment of the spot on the sample. The X-ray beam is aligned, responsively
to the first signal, so that the spot coincides with a target area of the sample.
X-ray photons received from the spot on the sample, after aligning the X-ray beam,
are used in generating a second signal that is indicative of a characteristic of
the target area.