Quantitative powder diffraction using a (2+3) surface diffractometer and an area detector

X-ray diffractometers primarily designed for surface x-ray diffraction are often used to measure the diffraction from powders, textured materials, and fiber-texture samples in so-called $2\theta$ scans. Unlike high-energy powder diffraction only a fraction of the powder rings is typically measured and the data consists of many detector images across the $2\theta$ range. Such diffractometers typically scan in directions not possible on a conventional lab-diffractometer, which gives enhanced control of the scattering vector relative to the sample orientation. There are, however, very few examples where the measured intensity is directly used, such as for profile/Rietveld refinement, as is common with other powder diffraction data. Although the underlying physics is known, converting the data is time-consuming and the appropriate corrections are dispersed across several publications, often not with powder diffraction in mind. In this paper we present the angle calculations and correction factors required to calculate meaningful intensities for $2\theta$ scans with a (2+3)-type diffractometer and an area detector. We also discuss some of the limitations with respect to texture, refraction, and instrumental resolution, and what kind of information one can hope to obtain.


Introduction
Since the early studies by Debye & Scherrer (1916), powder x-ray diffraction (PXRD) has become a wellestablished characterization technique. It has proved to be a fundamental tool for phase identification and structure determination of materials. Quantitative analyses of PXRD data enables access to information such as size, strain and stress of the crystallites, the Spin the specimen during the measurement Rietveld refinement Use equation (1) and (2) for angle calculations. Correct intensity as in equation (14).

Experimental
Data treatment Analysis Peak profile analysis (IRF, size and strain) More crystallites will satisfy the Bragg condition.
A good powder will show uniform diffraction rings. number of different phases in multi-phases materials, atomic and unit lattice parameters. PXRD data quality improves significantly when synchrotron xray beams are employed, which provide: a high photon flux, enhanced collimation, tunable energies, and a superior angular resolution. In surface x-ray diffrac-tion (SXRD), an experimental setup composed of a (2+3) diffractometer, an area detector is used at some beamlines. The (2+3) diffractometer was presented by Vlieg (1997) and its combination with an area detector was explored by Schlepütz et al. (2005). Although this setup was originally designed for singlecrystal SXRD, it can also be used in PXRD and in grazing-incidence x-ray diffraction (GIXRD) by rotating the detector about the diffractometer center in longitudinal and equatorial 2θ scans, across the Debye-Scherrer cones. In this scenario, the major benefit of the (2+3) diffractometer is control over the orientation of the sample and of the detector (and thus of the scattering vector) which enables convenient investigations of specimen textures and preferred orientations. This experimental setup is thus well-suited for a wide range of sample types with an extended face, such as thin polycrystalline films on substrates. The control over the grazing-incidence angle and thus over the x-ray penetration depth enables the study of layered materials and buried interfaces. Furthermore, the relatively high resolution of the instrument (compared to bench-top diffractometers) enhances the study and the identification of multi-phase systems.
The phenomena involved in PXRD are well-known and have been extensively studied in the last century. A significant step forward in the analysis of PXRD data was the Rietveld method (Rietveld, 1966;Rietveld, 1967;Young, 1993;Laar & Schenk, 2018). Such refinement is usually performed on PXRD patterns where the intensity is plotted as a function of 2θ. Therefore, with the (2+3) setup at the I07 beamline Nicklin et al., 2016, it is necessary to integrate the two-dimensional data collected by the area detector into a one-dimensional pattern. Furthermore, a series of intensity corrections should be applied to the measured intensities, to obtain the structure factors that depend on the underlying crystallography of the sample.
Area detectors with fixed position have been used extensively in powder diffraction, e.g., in the mapping of grain boundaries (Poulsen et al., 2001) and in texture analysis (Wenk & Vasin, 2017). Furthermore, software meant for the analysis of 2dimensional diffraction data has been developed. For instance, Fit2D (Hammersley, 2016) and pyFAI (Kieffer & Wright, 2013) enable the integration of two-dimensional data to a one-dimensional pattern only for detectors with fixed position. The software BINoculars (Roobol et al., 2015;Drnec et al., 2014) is tailored toward the analysis of surface x-ray diffraction data and is used to assign the intensity detected by every single pixel of an area detector to a bin in the three-dimensional reciprocal space. This means that it is possible to reduce the powder diffraction data collected by a (2+3) diffractometer with this software although it is computationally expensive and requires a backend.
In this work, we present the calculations and the correction factors needed to extract quantitative information from 2θ scans with (2+3) diffractometers and area detectors. The calculations are part of a process intended for the characterization of crystalline materials, as illustrated by the flowchart in Fig. 1. We assessed the validity of the calculations and of the correction factors by refining a LaB 6 reference sample. Furthermore, we calculated the instrumental resolution function (IRF) of the setup and compared the integrated intensities collected at different experimental geometries, namely capillary in transmission, grazing-incidence and Bragg-Brentano.

Experimental setup
The experimental work was conducted at the beamline I07, a hard x-ray (8-30 keV) high resolution diffraction beamline at Diamond Light Source, UK (Nicklin et al., 2016). The x-ray beam had an energy of 20 keV and a size of 100 µm vertically and 200 µm horizontally. To record the powder diffraction intensities, a Huber (2+3) diffractometer (Vlieg, 1998) and a Pilatus 100K detector were used.
A schematic diagram of the Huber (2+3) diffractometer is shown in Fig. 2. The coordinate frame of reference depends on whether the sample geometry is horizontal (blue) or vertical (red). In both modes of operation the sample is mounted on a hexapod (Micos), which allows scanning of the sample translations and rotations for the initial alignment. The grazing-incidence angle of the synchrotron beam onto Figure 3: (a) Schematic representation of the angles γ, δ, 2θ and χ, subtended by the incoming beam wavevector k and a generic scattering wavevector k' and (b) diagram showing the offsets ∆x and ∆z from the detector center of a generic (i, j) pixel. The vector d (i.e., the distance of the pixel from the diffractometer center) subtends the angles δ p and γ p . the sample surface and the azimuth are given by the rotation of α h and φ h in the horizontal geometry, and by α v and φ v in the vertical geometry.
The three detector circles are fully independent of the two sample circles and allow for radial scans in the horizontal plane (γ) or out of the horizontal plane (δ), and rotation of the detector around its surface normal (ν).
The Pilatus 100K area detector consists of an array module of 487 × 195 pixels with size 172 µm × 172 µm, resulting in an active area of 83.8 × 33.5 mm and it can detect photons in an energy range of 3-30 keV with a dynamic range of 2 20 (Kraft et al., 2009).
Due to the size of the detector and to the energy range available in this experimental setup, the detection of whole Debye-Scherrer rings in image is not feasible. Therefore, the detector arm is usually scanned across the diffraction cones and small fractions of the Debye-Scherrer rings are detected.

Angle calculations
With the setup described above, the Debye-Scherrer rings are detected by scanning the detector arm along γ and δ. The sequence of detector images collected during a scan can be integrated and processed to obtain diffracted intensities as a function of the diffraction angle 2θ and the azimuthal angle χ, illustrated in Fig. 3 (a). A detailed derivation of these angles for every pixel of an area detector are given in Appendix. According to this, 2θ and χ are expressed as 2θ = arccos(cos δ cos γ), (1) χ = arctan tan δ tan γ .
(2) Fig. 3 (b) shows the angles γ p and δ p subtended by a generic detector pixel (i, j), located at a certain distance d from the diffractometer center. Once the coordinates (x p , y p , z p ) of this pixel are determined using the rotation matrices shown in Appendix, it is possible to calculate γ p and δ p as follows: Therefore, equations (3) and (4) can be substituted into equations (1) and (2) to produce some angle maps like those shown in Fig. 4, calculated for the case where γ=30°and δ=20°, assuming a detector distance of 897 mm, which is the distance at which the data were collected in this work.

Intensity correction factors
The intensity of a powder diffraction pattern can be expressed as where Φ 0 is the incident photon flux, M hkl is the multiplicity (i.e., the number of symmetry-equivalent reflections contributing to a single peak), F hkl is the structure factor, P (2θ) is the polarization factor, L(2θ) is the Lorentz factor and V is the sample volume from which the diffracted intensity arises. Deviations from this are often due to the presence of a preferred orientation or crystal texture.

Polarization factor
The x-ray beam produced by the I07 undulator has a strong horizontal polarization (Nicklin et al., 2016) and therefore the scans in the horizontal plane (i.e., γ-scans) are more affected by this factor than the scans out of the horizontal plane (i.e., δ-scans). For this reason it is more convenient to express the polarization factor P as a function of (γ, δ) using the following expression that has been presented by several authors (Vlieg, 1997;Schlepütz et al., 2005) The polar plot in Fig. 5 (a) illustrates the variation of the polarization factor during an in-plane (γ) scan. Conversely, it will be less significant for an out-of plane (δ) scan, where the polarization factor will be fairly constant.
In high energy x-ray diffraction, where the beam energy is usually in the 60-80 keV range and the whole Debye-Scherrer rings are detected, this factor is often neglected. With high energies, although the beam polarization is almost entirely horizontal (e.g., 98%), the angular-dependent decay does not have a significant impact. Assuming a detector distance of 1.5 m and that a large flat panel detector is used (e.g., 40 × 40 cm), the highest q accessible has an absolute value of approximately 5.8Å −1 . If the beam energy is 80 keV, the corresponding 2θ angle will be 8.2°and the highest drop in intensity due to the polarization on the detector horizon can be calculated using equation (6) and equals 4%. This small drop in intensity becomes even less significant when the intensity is integrated over the whole Debye-Scherrer ring. When lower energies are used (e.g., 20 keV), the 2θ angle corresponding to a scattering vector of 5.8Å −1 is 33.2°. When the detector arm of a (2+3) diffractometer is scanned horizontally (i.e., δ = 0°) and reaches a γ value of 33.2°, the polarization has dropped by 31%. This decay must be taken into account especially since only a fraction of the Debye-Scherrer rings are detected.

Lorentz factor
A detailed derivation of the Lorentz factor was given by Buerger (1940), where it is defined to be proportional to the time that a reflection stays in the Bragg condition. The Lorentz factor depends on the type of experiment performed and especially on the scanning variable employed to detect reciprocal space (Vlieg, 1997). For instance, in single-crystal diffraction, the integrated intensity is measured by rotating the sample over the entire width of a reflection while the detector position is fixed, in a so-called rocking scan or Φ-scan. In that case, the measured intensities need to be corrected by a geometrical factor, i.e. the Lorentz factor, that expresses the relative time spent by each point in reciprocal space in the reflecting position during the Φ-scan. In PXRD, instead, the detector is rotated while the sample position is stationary, thus there is virtually no access to reciprocal space volume. However, due to the random orientation of the crystallites, a powder can be seen as a single crystal that is rotated along the Φ-axis and an axis orthogonal to the Φ rotation.
In PXRD, the Lorentz factor L is the product of three terms. The first term is the "Darwinian" single-crystal part (Darwin, 1922), that accounts for changes in integration volume as a function of 2θ: The second term is proportional to the fraction of diffraction ring detected for different 2θ values. If > Figure 5: Intensity correction factors calculated at a distance of 897 mm from the diffractometer center. Polar contours of polarization factor (a) and Lorentz factor (b), as a function of the diffraction and the azimuthal angles. Flat detector correction calculated for a Pilatus 100K with center pixel coordinates (c i , c j ) = (246, 100).
we express the radius of the base of a generic Debye-Scherrer cone as 2πk sin 2θ, the fraction recorded by the detector is k∆χ/2πk sin 2θ and therefore the second term will be proportional to where ∆χ is the range of azimuthal χ values accessible by the detector at a given γ and δ and it can be considered constant (Als-Nielsen & McMorrow, 2011). This effect is evident in Fig. 6, where the diffraction intensity from a borosilicate capillary containing NIST LaB 6 SRM 660c is plotted as a function of 2θ and χ. Here, the range of accessible χ values decreases significantly with the increase of 2θ.
The third term is proportional to the number of observable lattice points at the same time, and therefore to the circumference of the base-circle of the Debye-Scherrer cones. If we denote a particular reciprocal lattice vector with G hkl , this circumference is G hkl sin ( π 2 − θ)=G hkl cos θ. In the assumption that the crystallites and thus their reciprocal lattice points are homogeneously distributed on the Ewald sphere, this term is proportional to Note that L 3 is not proportional to the possible permutations of (h,k,l) since this is already accounted for by the multiplicity factor M hkl in equation (5). The Lorentz factor is given by the product L 1 L 2 L 3 as in equation (10), which is rearranged in equation (11): As shown in Fig. 5 (b), the Lorentz factor has a rather quick decay as a function of 2θ, regardless of the azimuthal angle χ. It is perhaps the most significant intensity correction that needs to be applied to experimental data, especially at small 2θ.

Flat detector corrections
In addition to the polarization and the Lorentz factor, the decrease of the subtended solid angle for the different pixels has to be taken into account. Two contributions normally describe this change. The first one is due to the fact that pixels away from the detector center are also further away from the diffractometer center, as depicted in Fig. 7. To account for this change in distance the measured intensities should be multiplied by C d is greater than unity for every pixel of the detector except the detector center C, where d = R. The second contribution is due to the non-normal incidence of the scattered beam owing to the flat detector surface and is given by Schlepütz et al. (2011) where ∆r = √ ∆x 2 + ∆z 2 . For a better visualization of these correction factors, the product C d × C i is plotted in Fig. 5 (c) for the same detector distance R. The correction becomes more significant close to the edges of the detector image, where it shows a maximum change of Figure 6: Diffracted intensity as a function of 2θ and χ originating from a NIST LaB 6 SRM 660c encapsulated in a 1 mm diameter borosilicate capillary. The data was collected in the Debye-Scherrer geometry by scanning the detector in the horizontal plane (γ-scan). about 0.35 % from the detector center. The significance of this correction increases as the detector distance decreases or as the detector size increases. C P Figure 7: The flat surface of the Pilatus 100K (blue rectangle) intersects a sphere centred in the diffractometer (orange frame) in the point C (the detector centre). A generic diffracted beam would impinge the point C normally and subtend a non-normal angle with any other generic point P.

Transmission corrections
The sample volume that gives rise to diffracted intensity depends on the geometry of the experiment and is often a function of the scattering angle 2θ, the incidence angle α and the angle between the sample surface and the diffracted beam γ = 2θ − α. The diffracting specimen volume is often modelled as an exponential aberration. Table 1 summarizes this correction for some common experimental geometries. As a general remark, the interaction volume is proportional to the area of illuminated sample, A, and is inversely proportional to the linear absorption coefficient, µ. Furthermore, it should be noted that refraction leads to a reduction of the penetration depth and thus the interaction volume when the incidence angle is below the critical value. This effect is welldescribed by Feidenhans'l (1989), in a formalism that considers evanescent waves and their penetration into surfaces.

Summary of intensity corrections
The corrected intensity is given by where I obs is the observed intensity.

Peak profile analysis
Analysis of the line-profile shape is useful for the determination of crystallite size and strain of a specimen. However, the width of a diffraction peak is a function of 2θ and it depends not only on specimen properties but also on experimental conditions and sample size. Furthermore, instrumental features such as monochromators, collimating and refocusing optics, slits, beam divergence and energy bandwidth influence the broadening of diffraction peaks (Gozzo et al., 2006). As the mentioned causes of broadening have either Gaussian or Lorentzian nature, the most used fitting function for PXRD peaks are based on Voigt or pseudo-Voigt line shapes. The full width at half maximum (FWHM) of the Voigt profile depends on the widths of the associated Gaussian and Lorentzian components Γ G and Γ L (Thompson, Cox, et al., 1987;Thompson, Reilly, et al., 1987).

Gaussian and Lorentzian broadening
The Gaussian widths contain information on the instrumental resolution function (IRF) and on the sam- - (Cheary et al., 2004) (Egami & Billinge, 2003) Flat-plate asymmetric (grazing incidence) (Toraya et al., 1993) (James, 1967) Flat-plate with finite thickness t = thickness. Symmetric geometry when α = γ (Egami & Billinge, 2003) Capillary in transmission (Debye-Scherrer) et al., 1998) ple strain. An analytical description of the IRF was given by Caglioti et al. (1958): Specimen contributions to the Gaussian widths are the expression of crystal defects, dislocations and deformation of the unit cells, in what is known as inhomogeneous strain broadening: where the root mean square strain ǫ is a coefficient that depends on the elastic compliance and the mechanical properties of the specimen. Since this contribution is proportional to tan θ, some authors merged the strain contribution into equation (15). For example, Thompson, Cox, et al. (1987) enclosed the coefficient ǫ into the constant V, while Wu et al. (1998) into the constant U. In this work we adopt the solution presented by Thompson, Reilly, et al. (1987), where the Gaussian width broadening is expressed as The Lorentzian widths Γ L take into account the spectral bandwidth of the source and the sample crystallite size through the following equation (Cox, 1991): The X coefficient depends on the monochromating optics and it is in the order of magnitude of 10 −4 for most of the synchrotron beamlines where Si (111) crystals are employed. The dependence of the bandwidth term on tan θ can be derived by differentiating Bragg's law. The second term in equation (18) is the Scherrer crystallite size contribution. Here, Y = Kλ/D where K is a dimensionless shape factor (generally close to unity), λ is the wavelength of the x-ray radiation, and D is the crystallite size. One should remember that the use of equation (18) relates to the size of the coherent diffraction domains rather than the size of the crystallites per se (Scherrer, 1912;Patterson, 1939;Hargreaves, 2016).
Equation (18) can be rearranged as Plotting Γ L cos θ against sin θ in equation (19) would produce a line where the intercept depends on the crystallite size while the slope depends on the beam spectral bandwidth. Such a plot is known as a Williamson-Hall plot (Williamson & Hall, 1953) and an example of such analysis is given in §6.1.

Beam footprint
The beam footprint on the sample causes a broadening that affects the instrumental resolution. This is especially true for grazing-incidence geometries, where the beam spills over the sample and illuminates it over its whole length. A depiction of this geometric effect is shown in Fig. 8. Assuming that every volume element illuminated by the beam scatters, all intensity occurring at the diffraction angle 2θ is spread out into a radial range β on the detector. The angular spread for in-plane scans (Fig. 8 (a) and for out-of-plane scans (Fig. 8 (b) are respectively given by where w is the sample width and R is the sampleto-detector distance. Fig. 8 (c) shows a simulated intensity profile of an Au(311) peak at 20 keV (2θ = 29.1996°), for different sample widths, assuming a scan out-of-plane and a grazing-incidence angle of 0.1°. The simulated peaks were calculated as Voigt profiles where the Lorentzian and Gaussian components were determined by the IRF of the I07 beamline at Diamond Light Source (see §6.1). The β o broadening was calculated using equation 21 and summed to the Gaussian component of the Voigt profile as follows: A more insightful way to account for the beam footprint is to determine the peak profile change induced by specimen absorption. Equations (20) and (21) work on the assumption that the intensity of the incoming beam does not change significantly through the whole sample width w. This is not always true since the intensity decays exponentially as described by Beer-Lambert's law (Swinehart, 1962). Therefore, a change in diffraction peak profile due to absorption can be modelled as an exponential function. Such effects are well-described for several diffraction geometries in the work of Rowles & Buckley (2017). Once the transmission profile function has been modelled, it can be convoluted with a Voigt or pseudo-Voigt profile in a refining algorithm. This approach not only works for correcting the beam footprint effect, but also accounts for possible peak asymmetries.
The beam footprint broadening can be limited by engaging the guard slits between the sample and the detector. If the aperture is small enough, the diffraction originating from a limited region of the sample is detected and the peak broadening is no longer angledependent, but it is rather defined by the slit aperture width. A description of the geometry involving detector slits is available in Appendix.

Rietveld refinement
Rietveld refinement (also known as "profile refinement", (Laar & Schenk, 2018)) is a well-established analysis method for PXRD data and it is widely employed in the characterisation of polycrystalline materials (Rietveld, 1966;Rietveld, 1967;Young, 1993; Figure 8: Schematic depiction of the geometric broadening due to the beam footprint at grazingincidence: top view of a γ-scan (a) and side view of a δ-scan(b). Simulation of an Au(311) peak at 20 keV, at a grazing angle of 0.1°, scanned out-of-plane, for increasing sample widths (c).
Loopstra & Rietveld, 1969;Laar & Yelon, 1984). This method consists of fitting the experimental data with a calculated intensity profile which is based on the structural parameters of the material. A nonlinear least-squares algorithm (or other optimization strategy) finds the parameters for a theoretical profile that best matches the experimental intensities. The Rietveld method can be used to find unit cell parameters, phase quantities, crystallite size and strain, atomic coordinates and texture. Furthermore, it is possible to model texture and preferred orientations for example using spherical harmonics (Whit-field, 2009), although this is outside the scope of the present article.
The quality of the data and having a good starting model are what mainly determines the success of the refinement. For a good PXRD measurement the x-ray beam size should be comparatively larger than the crystallite size. In this way, the statistical significance of the detected intensity is maximised due to a larger interaction volume, which leads to the formation of homogeneously continuous diffraction rings. In common PXRD setups the sample is spun to facilitate the measurement of uniform rings and this is also possible with (2+3)-type diffractometers by rotating the φ h in the horizontal geometry or φ v in the vertical geometry.
To perform Rietveld analysis, software like Full-Prof (Rodriguez-Carvajal, 1993), GSAS-II (Toby & Von Dreele, 2013) and DIFFRAC. SUITE TOPAS (Coelho et al., 2011) has been developed. In our somewhat unconventional case, where the data has been manually corrected by Lorentz and polarization factors, e.g. by using equation (14), it is possible to disable FullProf from applying further instrumental corrections by selecting Lorentz Polarization not performed as the diffraction geometry. However, we could not determine how to disable the instrumental corrections in GSAS-II without modifying the Python code making such corrections. We did not test if this was possible in TOPAS. Another option would be to multiply the corrected data by the inverse Lorentz-polarization factors used in software such as GSAS and TOPAS. In this way, it should be possible to use these programs for Rietveld refinement of data collected on a (2+3) diffractometer.
In absence of preferred orientations, equation (5) describes the proportionality between the intensity of a diffraction pattern and the square modulus of the structure factor. Any deviations from this proportionality can be attributed to preferred orientations and refined in software like FullProf. These deviations due to preferred orientations can be modelled by, e.g., the so-called modified March's function (Dollase, 1986). More complex models involve the generalized spherical-harmonic description (Sitepu, 2002). In order to find further evidence of preferred orientations, one could plot the intensity as a function of 2θ and χ, as in Fig. 6. This complete view of all the data gathered in a detector scan enables the search for qualitative evidence of preferred orientations, such as intensity variations along the Debye-Scherrer rings. Based on the orientation of the scattering vector, it should be possible to quantify the preferred orientation.

Refinement of a NIST LaB 6 reference
The LaB 6 powder is a standard reference material commonly used in powder diffraction for the calibration of diffraction line positions and shapes. A sample of this powder was encapsulated in a borosilicate capillary of 0.5 mm radius, mounted vertically (i.e., with the capillary axis parallel to the z-axis) and measured in a series of γ radial scans in a range of 5°to 60°. In order to measure continuous powder rings, the capillary was rotated by 0.5°along the zaxis (i.e., increasing φ h in Fig. 2) between each scan. A total of 135 γ-scans were combined, each one at a different φ h .
The angle calculations presented in §3 were used to plot intensity against 2θ in the 1-dimensional pattern shown in Fig. 9 and to correct the data by Lorentz-polarization factor, flat detector effects and interaction volume from a capillary in transmission geometry (see Table 1). Therefore the corrected data are proportional to the squared module of the structure factors and the multiplicity of each diffraction peak. Since the LaB 6 standard has very well-defined unit cell parameters, the position of the diffraction peaks were used to calibrate the sample-to-detector distance and the nominal position of the γ and δ motors.
The good agreement of the calculated model to the observed data is indicated by fairly low residuals (see Fig. 9). This shows that the setup and data processing employed in this work can be used not only to investigate lattice parameters and phases, but also to record meaningful intensities proportional to structure factors and symmetry multiplicity. Deviations from this proportionality are a clear sign of texture and preferred orientation.
Rietveld refinement of a standard material thin film measured at grazing-incidence would be an interesting topic of discussion. However, the fabrication of such thin films often leads to sample morphology with prohibitive roughness. A film of LaB 6 on a silicon wafer was produced in this work (the fabrication is described in § 6.2). Due to the high roughness of this film, the control over the incidence angle, the interaction volume and the refraction effect was limited. The fact that Rietveld refinement was not feasible for this particular sample, does not exclude the possibility that it would be possible with a smooth polycrystalline film. In this case, it is recommended to select a grazing-incidence angle α above from the critical angle of the substrate, in order to avoid diffraction generated by the reflected beam, which would lead to two overlapping diffraction patterns with a shift of 2α. 0.799x10 -1 Figure 9: Rietveld refinement of a NIST LaB 6 SRM 660c PXRD pattern, measured with a 20 keV x-ray beam, performed with Fullprof using the pseudo-Voigt line shape. Before the refinement, the data was corrected by: Lorentz and polarization factors, flat-detector corrections and interaction volume of x-rays with a capillary. The background was subtracted by fitting a Chebychev polynomial (16 coefficients).

Further examples
The pattern in Fig. 9 was used to determine the IRF of the I07 beamline at Diamond Light Source. Furthermore, a different LaB 6 powder sample (Sigma-Aldrich, grain size 10 µm), prepared by spin coating on a Si substrate, were measured in grazing-incidence and in Bragg-Brentano geometry.

Instrumental resolution function of the I07 beamline
As discussed in §5.1, the peak widths contain instrumental as well as specimen-related information.
Although software like FullProf and GSAS-II have built-in options to refine such parameters, a precise knowledge of the IRF is required to obtain significant information. In this work, we processed the data from the NIST LaB 6 standard described in the previous section to calculate the IRF. All the peaks in Fig. 9 were fitted one by one with a Voigt profile. The FWHM reported in Fig.  10 (a) shows a broadening that has both Gaussian and Lorentzian contributions. The Gaussian and Lorentzian FWHMs of the peak widths were extracted and reported in Fig. 10 in the form of a Caglioti function (a) and a Williamson-Hall plot (b). The dominance of Gaussian component in the broadening can be explained by the large average crystallite size i.e., above 1 µm as certified by NIST. Due to such a large crystallite size, the Scherrer contribution to the Lorentzian broadening is negligible and outside the limits imposed by coherent scattering do-  (Miranda & Sasaki, 2018). Furthermore, since the unit cell of LaB 6 is not known to show inhomogeneous strain features, we can assume that Γ s in equation (17) is zero and that the Gaussian broadening in Fig. 10 (b) is only due to instrumental contributions. Therefore, fitting the Gaussian widths with the Caglioti function will produce a triplet of U, V and W values which describe the IRF. It should be noted that the result of the fitting is affected by the choice of the units expressing the angle. In this work, the Gaussian FWHMs were expressed in degrees. Furthermore, the Williamson-Hall plot in Fig.  10 (a), based on equation (19), provides the X and Y values which are characteristics of the x-ray beam bandwidth and the specimen grain size, respectively. All these fitting parameters are reported in Table 2 with their respective standard errors.

Refraction at grazing-incidence
A sample of LaB 6 spin-coated on a Si(100) substrate was measured in Bragg-Brentano and grazingincidence geometries, using a beam energy of 20 keV. The sample was prepared by mixing 500 mg of a LaB 6 powder (Sigma-Aldrich, nominal grain size = 10 µm) with 10 mg of ethyl cellulose (Sigma-Aldrich, 48.0-49.5 % (w/w) ethoxyl basis) as a binding agent, in 2 mL of ethanol. The mixture was spin-coated on a 6 mm square of Si(100) at 800 rpm. Fig. 11 shows the LaB 6 (211) peak a for the different geometries employed in this work, namely Debye-Scherrer (taken from the capillary data in §5.3), Bragg-Brentano and GIXRD at fixed grazing-incidence of 0.1°and 0.2°. The plots exhibit a shift in the peak position from the theoretical diffraction angle, 2θ calc , which can be explained by refraction of light in the LaB 6 film covering the Si substrate. For small incidence angles and a thin film with material constant δ, Lim et al. (1987) modelled this shift as follows: ∆2θ = δ sin 2θ calc × 2 + sin α sin 2θ calc + sin 2θ calc sin α .
The positions of the peaks in Fig. 11 for α h =0.1°a nd 0.2°were calculated in terms of center of mass and used to calculate the experimental peak shift by subtracting 2θ calc =21.0467°for LaB 6 (211). The experimental shift is reported against the theoretical shift calculated using equation (23) in Table 3. The discrepancy between the two set of values can be explained by density inhomogeneities in the LaB 6 film, which also contains ethyl cellulose for the practical purpose of consolidating the film. Furthermore, the LaB 6 used for this layered sample is not a standard and it could have a slightly varied lattice parameter from what reported in literature after the dissolution in ethanol. Although this kind of sample is not recommended for calibration of XRD setups, it could be used as a reference sample to determine instrumental broadening at grazing-incidence. In order to calibrate the detector distance and the motor positions accurately, a well-calibrated standard is always recommended. Equation (23) provides a way of correcting the data which is especially significant in strain analysis. In fact, homogeneous strain ǫ is calculated as the relative deviation of the atomic spacing d in the strained material from the atomic spacing d 0 in the ideally un-strained material: This means that a polycrystalline strained material measured in grazing-incidence geometry will diffract at 2θ angles that slightly deviate from the values predicted by Bragg's law not only because of refraction, but also because of strain. If the strain of such material needs to be determined, equation (23) helps to correct for refraction peak shifts.

Conclusions
The angle calculations presented in this work describe how to convert data measured by a (2+3) diffractometer equipped with an area detector into a 1dimensional XRD pattern, more familiar to the chemistry and material science communities. We also collected some dispersed knowledge on the phenomena contributing to the peak widths and on the intensity corrections. Since the calculations and the corrections are energy-independent, they can be applied to data collected at beamlines operating with hard xrays (8-30 keV) as well as with high energies (40-150 keV). The Python code used in this work for such corrections and angle calculations is available on Github (github.com/giuseppe-abbondanza/pyLjus). Quantitative PXRD using surface diffractometers is not often done. This work should however facilitate quantitative studies using such instruments, including for example in situ studies under grazing incidence conditions. Furthermore, the calculations presented in this work can be modified to apply to diffractometers with other geometries (e.g., (2+2), 4-circle and 6-circle) and they can even apply to setups where the detector is not mounted on a motor and therefore has a fixed position, facing the direct beam. In this configuration, one can assume that effectively γ=δ=0°.
Let us denote the coordinates of the detector center found in equation (31) with (c x , c z ). A pixel with coordinates (i, j) has an offset (∆x, ∆z) from the detector center given by: where w x and w z are the width of the pixel along the x and z directions, respectively (for a Pilatus 100K detector w x = w z = 172 µm). Fig. 3 (b) illustrates the typical offsets in pixel position described above. Here we assign the (0,0) coordinates to the upper left detector pixel. When the detector is at the zero position, the position of a generic (i, j) pixel in the laboratory coordinates is simply For non-zero detector angles, the new (x p , y p , z p ) coordinates of the (i, j) pixel are found by rotating the vector (∆x, R, ∆z) by γ, ν and δ around the z, y and x axes, respectively. Therefore, the pixel position in the laboratory frame of reference becomes where Γ, ∆ and N are the matrices describing the rotations around the z, x and y axes, defined as follows: Since the y-component has not changed, the equation for the 2θ angle is the same as in equation (29). The equation for the χ angle (30) is also the same in both geometries. The rotation matrices, however, are different in this frame of reference and are given by As in the case of horizontal geometry, equation (35) applies to the calculation of pixel coordinates.