1. A computer-implemented method for inspection of a sample, comprising: defining a plurality of locations on a surface of the sample; irradiating the surface at each of the locations with a beam of X-rays and measuring an angular distribution of the X-rays that are emitted from the surface responsively to the beam, so as to produce a respective plurality of X-ray spectra; analyzing the X-ray spectra to produce respective figures-of-merit indicative of a measurement quality of the X-ray spectra at the respective locations; selecting one or more locations out of the plurality of locations responsively to the figures-of-merit; and estimating a property of the sample using the X-ray spectra measured at the selected locations.