High-accuracy wavefront sensing for x-ray free electron lasers

, Systematic understanding and real-time feedback capability for x-ray free electron laser (FEL) accelerator and optical components are critical for scientific experiments and instrument performance. Single-shot wavefront sensing enables characterization of the intensity and local electric field distribution at the sample plane, something that is important for understanding scientific experiments such as nonlinear studies. It can also provide feedback for alignment and tuning of the FEL beam and instrumentation optics, leading to optimal instrument performance and greater opera-tional efficiency. A robust, sensitive, and accurate single-shot wavefront sensor for x-ray FEL beams using single grating Talbot interferometry has been developed. Experiments performed at the Linac Coherent Light Source (LCLS) demonstrate 3 σ sensitivity and accuracy, both better than λ ∕ 100 , and retrieval of hard x-ray ( λ (cid:1) 0 . 13 nm , E (cid:1) 9 . 5 keV ) wavefronts in 3D. Exhibiting high performance from both unfocused and focused beams, the same setup can be used to systematically study the wavefront from the FEL output, beam transport optics, and endstation focusing optics. This technique can be extended for use with softer and harder x rays with modified grating configurations.


INTRODUCTION
The rapid evolution of hard x-ray FELs [1][2][3], with femtosecond pulse durations, has enabled a wide range of previously impossible dynamical studies of atoms, molecules, clusters, and materials in the physical and life sciences [4]. In addition to the photon energy, pulse duration, and spectral characteristics, it is important to have an accurate knowledge of the single pulse x-ray wavefront, which affects focal plane intensity and profile, spot size, and spatial resolution, as well as centroid location within the focal plane. Among techniques currently in use are the following: burn patterns that ablate material as a function of intensity across the focal plane [5,6]; Hartmann masks, which track localized wavefront vectors [7,8]; double grating interferometers, each grating having a two-dimensional checkerboard pattern, where the second grating produces a spatially downshifted Moiré pattern [9,10]; and x-ray speckle tracking techniques [11].
Ideally, an x-ray FEL wavefront sensor should provide high sensitivity and accuracy on a single-shot basis, be capable of measurements with both collimated and highly focused beams, survive in a high-power x-ray beam, be robust, and be compatible with in situ analysis and fast wavefront retrieval methods for real-time feedback. Furthermore, systematic understanding and control of the FEL wavefront require measurements at three positions along the beam path: at the undulator output, after the transport optics, and at the sample plane. To meet all the above criteria, we designed and implemented a wavefront imaging technique based on single grating Talbot interferometry.
Talbot interferometers and their variations, such as multilateral shearing interferometers or modified Hartmann mask interferometers, are widely used at visible [12][13][14][15] and infrared wavelengths [16]. A Talbot interferometer at hard x-rays can use a π-phase shift checkerboard pattern with pitch p as the imaging object. When illuminated by a plane wave with wavelength of λ, it forms sharp grid-like images with pitch p∕2 at a series of distances with Z T np 2 ∕8λ, where n 1, 3, 5… is the Talbot order. A nonplane-wave wavefront illumination will cause the Talbot image to change its pitch and/or deviate from the regularly spaced grid. From an interferometry point-of-view, Talbot images can be treated as interferograms formed by sheared copies of the original wavefront, in which the shear angle is θ S 2λ∕p. Therefore, Talbot images measure the phase gradient of the illumination wavefront. For hard x-rays, p needs to be micrometers or less to provide an adequate level of shearing to achieve good sensitivity. Choosing smaller p provides a larger shear, and thus, increases the signal level. However, common detectors cannot resolve the dense-pitched Talbot images if p is smaller than a few micrometers. To solve this problem, previous Talbot interferometers [9,10] use a second analyzer grating and detect the Moiré pattern. The analyzer, however, blocks most of the photons in the Talbot image. In our approach, we use a relatively large p, ∼20 μm, and detect the Talbot image formed on a scintillator using an optical microscope. Avoiding use of the analyzer grating not only simplifies the operational procedure and implementation, but also fully utilizes all x-ray photons. This allows recording of high-quality Talbot images on a single-shot basis with minimal photon shot noise, which in turn results in high sensitivity and accuracy.
Similar setups have been used to measure the wavefront of synchrotron radiation [17] and to perform imaging [18,19]. In this work we emphasize optimization for high performance of the sensor on a single-shot basis with an unattenuated full FEL beam, and its applications to systematic studies of FEL beam characteristics at different locations along the beam path.

SINGLE GRATING WAVEFRONT SENSOR AND ITS PERFORMANCE AT LCLS
A capable metrology method requires both high sensitivity and accuracy. Sensitivity is determined by the signal-to-noise ratio (SNR) and limited by random noise. It can be improved by increasing signal level, reducing noise, or using a balance of the two. In the case of Talbot interferometry, the signal level can be improved by using higher-order Talbot planes. However, this will be limited by the available spatial coherence of the system being measured, corresponding signal to noise, and available experimental space. Our single grating approach achieved high sensitivity by minimizing the noise level. Accuracy is limited by systematic errors. In the case of Talbot interferometry, any imperfection in the sensor itself, for example patterning error in the grating, optics alignment, aberrations in the microscope, etc., that causes the Talbot image to deviate from a perfect grid could be mistaken as measured wavefront error. For high-accuracy measurements, a calibration scheme that can greatly reduce systematic errors is required.
In this section, we describe the Talbot wavefront sensor (WFS) with a design optimized for single-shot measurements at 9.5 keV. System noise level is measured by repeatability studies, and sensitivity is found to be λ∕110 at SNR 3. Using a reference beam generated by spatial filtering, the WFS is calibrated and systematic errors are essentially removed, with accuracy reaching λ∕100 in the calibrated results.
The WFS developed for these experiments consists of a silicon checkerboard π-phase shift grating, a 20 μm thick cerium-doped yittrium aluminum garnet (YAG:Ce) scintillator, and a visible light microscope [ Fig. 1(a)]. The 1000 μm × 1000 μm, 20 μm period checkerboard silicon phase grating was fabricated using electron beam lithography and reactive ion etching [see Section 5 (Methods)]. The choice of 1000 μm width is based on the beam size to be measured, ∼700 μm. The scintillator was placed at a Talbot plane to convert the x-ray Talbot images to visible wavelengths, which were then magnified and recorded by an optical microscope. Simulations demonstrated that a modest magnification (8-10×), paired with a CCD pixel size of 5 μm, would be sufficient to resolve a 10 μm period Talbot image without losing wavefront sensitivity. We fabricate the checkerboard grating on a 200 μm thick Si substrate. Absorption of x-ray photons and the loss of visible photons due to the limited collection angle of the microscope objective together ensure that we collected high counts from the CCD (typically 1/3-1/2 of the quantum well) without saturation when doing single-shot measurements with the full LCLS beam at pulse energy ∼1 mJ. The system design, therefore, enables recording of well-resolved Talbot images with minimal photon shot noise. We also note that the spatial resolution of the WFS with this design is not compromised by using a relatively large pitch grating. The spatial resolution of the Talbot interferometer is determined by the shearing amount, which is np∕4 when using nth Talbot plane [9]. Since we are operating in the third Talbot plane, the spatial resolution is 15 μm. For comparison, the hard x-ray WFS in Ref. [9] used a checkerboard grating with a pitch of ∼4 μm, but it has a spatial resolution of 33 μm since it operates in the n 33 Talbot plane.
We tested the performance of this WFS at the x-ray pump-probe (XPP) instrument at LCLS [20]. For the first set of experiments, (a) Wavefront sensor based on single grating Talbot interferometry and its possible insertion points along a FEL facility to perform systematic studies on beam wavefronts. In this paper we included results from points 2 and 3. The exit of undulator is defined as Z 0 m in this paper. The size and location of the end station, shown by dashed box, is not to scale in the z axis; it is approximately in the same location as point 2. (b) A sample Talbot image as recorded on the CCD of the imaging microscope and the retrieved 2D wavefront error from it. The scale bar has a length of 100 μm. The dashed white box is where a single column was chosen for detailed analysis that was then used to test the repeatability of phase retrieval results. (c) Retrieved aspherical phase terms from 40 randomly picked single shots. The solid line is the average result, and the error bars at each location indicate 1σ (standard deviation) of the 40 measurements. The overall variation of the measurements is found to be 2.98 × 10 −3 waves, or λ∕335.

Research Article
the sensor was placed approximately 42 m downstream of a pair of flat mirrors [location 2 in Fig. 1(a)] used to direct the beam to the experimental hutches and to remove any high-energy spontaneous or Bremsstrahlung radiation greater than 25 keV. This is the hard x-ray offset mirror system (HOMS) [21]. The LCLS photon energy was tuned to 9.5 keV, or 0.13 nm. For a checkerboard grating period of 20 μm, the third Talbot plane was chosen for the location of the YAG scintillator, at a distance d 1.150 m. An example of the Talbot image and the retrieved 2D wavefront error are shown in Fig. 1(b). The wavefront error was obtained by removing an overall quadratic phase term from the retrieved wavefront. It is dominated by astigmatism caused by weak defocusing from the HOMS mirrors, which will be discussed in detail later. We first evaluated system sensitivity by checking the repeatability of the aspherical term measurement. Choosing the aspherical term for repeatability allows us to avoid known shot-to-shot FEL source location fluctuations, which will cause changes in the quadratic phase term. Figure 1(c) shows the retrieved aspherical phase residuals of 40 randomly picked single shots, each using only a single column [marked by the box in Fig. 1(b)] from the Talbot image. The profile covers 680 μm across the grating, approximately the 1∕e 2 full width of the x-ray beam. We obtained an averaged profile, and then computed the standard deviation of retrieved phases from the 40 runs at each of the 35 sampling points. As can been seen, the measurements were highly repeatable. The overall variation, characterized as the standard deviation of all measurements at all sampling points, is 2.98 × 10 −3 waves, or λ∕335. The sensitivity of the WFS, if using the convention of requiring SNR 3 for high confidence detection, is 9.0 × 10 −3 waves, or λ∕110. Note this assumed that there is no change in the beam itself and all variations in the results are caused by system noise. Therefore, the true stability and sensitivity of the sensor can be better than only the number reported herein given that FEL wavefronts are known to have fluctuations.
We then performed WFS calibration and improved its accuracy. The retrieved aspherical phase error in Fig. 1(c) is one example of a suspicious systematic error. It is stable in CCD coordinates but does not follow the shot-to-shot beam displacements. We expect that a real wavefront error in the x-ray beam should behave in the opposite way. We calibrated our system using a reference beam generated from using a combination of horizontal and vertical slits to form a small aperture located 17.30 m away from the grating, avoiding any optics between the slit and the WFS. The slits were sufficiently narrow (5-7 μm), so that the diffraction from them illuminated a 300 μm × 600 μm region of the grating, and their small sizes combined with the large distance from the exit of the undulators to the slits (>120 m) ensure a near-perfect reference beam. The use of such a small aperture compared to the size of the LCLS beam resulted in a reduction of ∼4 orders of magnitude in the number of photons/shot incident on the grating. Nevertheless, a reference Talbot image with similar photon counts to those measured with full beam was obtained by summing ∼4000 shots, albeit with a significantly increased background noise level. Using the recorded reference Talbot image [ Fig. 2(a)], we retrieved an aspherical phase error from the same column as that in Fig. 1(b) and compared the results. As shown in Fig. 2(b), the analysis confirmed that the aspherical phase errors previously retrieved in the full beam shots are indeed caused by systematic errors. After calibration, the residual phase error was reduced to λ∕330 root-mean-square (RMS), essentially to the noise floor. With calibration, we were able to improve the absolute accuracy on aspherical terms from λ∕14 peak to valley (p − v) to a range within λ∕100.
Calibration through a known, near perfect reference beam is also critical to achieve high accuracy in the quadratic phase term, which is directly linked to the equivalent axial source location and represents an important parameter to measure in wavefront sensing. The quadratic phase term manifests itself in a Talbot image as a change in the pitch of the grid [see Section 5 (Methods)]. While this pitch can be measured to high precision, it is prone to systematic errors. As an example, we retrieved the pitch of vertical grid lines from different horizontal locations across the ∼680 μm field of view. The result showed a relatively large variation [see Fig. 2(d)] of pitch y as a function of X , likely caused by objective lens distortion in the microscope. With the calibration images, such errors could be corrected. In the experiments, to increase the flux and shorten the image acquisition time, a vertically oriented slit was scanned in the X direction, and the recorded series of images were stitched together to form a single reference image that covered the full X extent of the CCD [ Fig. 2(c)]. We then compared, location by location, the pitch variations in the reference and raw images. As shown in Fig. 2(d), the reference calibration reproduced the distortion almost exactly. The correction reduced the pitch measurement variation across the field by approximately four, to 1 × 10 −4 , essentially eliminating this error. This high-accuracy measurement of pitch is critical for achieving high accuracy measurements of the source location, as discussed below.

Research Article
An absolute determination of the quadratic term also requires an accurate knowledge of the "original" pitch p 0 when the WFS is illuminated by a plane wave. The true value of p 0 can be affected by many factors, including the true pitch of the fabricated grating, the exact magnification of the microscope including the distortion of the objective lens, the exact CCD pixel size, and the relative tilt of any optics including the grating, the YAG screen, and the CCD. All these sources of systematic errors are difficult to measure individually to the needed accuracy level, but the procedure described above also provides a single calibration step for absolute determination of the quadratic term. Assuming two wavefront measurements were done using the same sensor, one with a reference beam with known radius of curvature (ROC) of R ref , and the other with a test beam with unknown ROC of R test , we have where D is the distance from grating to Talbot  Thus, we determined the source ROC in the vertical direction, R y , to be 178 4 m, within which 2 m comes from the uncertainty of the Talbot image pitch determination, which has more contributions from noise in the reference image. We estimated the sensitivity, depending on the uncertainty of the pitch measurement of test images only, to be better than 1 m. For comparison, the Rayleigh length of the FEL source at this photon energy is ∼10 m, whereas a 4 m error at 178 m corresponds to an RMS wavefront error ∼λ∕100 across the beam up to its 1∕e 2 width. The accuracy and sensitivity we achieved here would be sufficient for nearly all practical use cases. From the same image, we also found the ROC in the horizontal direction, R x , to be 138 3 m. This large astigmatism could originate from a weak defocusing (with f −560 m on each of the two HOMS mirrors) by the newly installed HOMS mirrors [22]. The new HOMS mirrors are designed to sustain the heat load generated by a planned upgrade of LCLS to a higher repetition rate. The increased thermal load will generate a bump on the mirror surface, creating a convex surface. A bender, to compensate such induced curvature, is present on the new mirrors. The mirrors and the holder are designed to maintain the mirror surface as flat as possible. With an angle of incidence of 1.35 mrad, a convex radius of curvature of 830 km on the mirrors will generate the observed astigmatism.

SYSTEMATIC UNDERSTANDING OF THE LCLS BEAM
For an FEL user, accurate knowledge of the beam delivered to the sample at the interaction point (IP) is critical for planning experiments and interpreting the data collected. The beam at the IP can be affected by all upstream optics, and the FEL source itself. We designed the WFS to be capable of measuring both unfocused and focused LCLS beams. Together with its high sensitivity and accuracy on a single-shot basis, this WFS has been demonstrated to be a powerful and versatile tool for systematic understanding of the LCLS wavefront quality along its beam path. In this section, we report results obtained by this WFS, on three essential parts of the LCLS beam path: the undulator source, the impact of beamline transport optics-the HOMS mirrors, and aberrations of nanofocusing optics at the end station.

A. Beam Source Location Fluctuations in Undulator
One of the more fundamental parameters of an FEL beam line is the equivalent source location. The source locations are presented here using the LCLS undulator exit as the reference point, defined as Z 0 m. The WFS is located at 143.9 m away from the undulator exit, and we use Z yx 143.9 − ROC yx to convert the measured wavefront ROC to the location of the equivalent source. A negative Z means the source is inside (upstream) the undulator.
In the experiments, we used the WFS to monitor source location changes for three different undulator configurations. The LCLS consists of 32 undulator sections, each 4 m long. In addition to normal operation with full undulator length (where 30 of the 32 sections were used), two other configurations using only the first 22 sections or last 22 sections were used, albeit with different undulator tapering settings [ Fig. 3(a)]. We collected ∼10,000 shots for each of the three configurations, in 5.5 min of continuous FEL operation, and retrieved the source locations on a single-shot basis.
As seen in Fig. 3(b), the source locations shift upstream and downstream following the undulator change. Recall from the previous section that Z y is insensitive to aberrations in the upstream HOMS mirrors as they are positioned vertically and only steer the beam in the horizontal plane. Z x is altered by ∼40 m downstream by the HOMS mirrors. The total amount of shift, judging from Z y measurements is 27 m, close to the physical undulator displacements of 32 m. The small difference of 5 m might come from the effect of different tapering. Also as expected, both Z y and Z x measurements put the source location for the full-length undulator somewhere between the sources for the other two cases. The observed fluctuations of source location under any undulator configuration extend several meters, occasionally exceeding 10 m, especially in the full-length undulator case. A previous experiment at SACLA saw a similar, or larger, range of source location fluctuations [10]. As LCLS operates in a deep saturation regime, FEL simulations generally predict a smaller range of source location fluctuation under nominal operation parameters. The stability of the sensor would also not cause such a level of change due to experimental error.
The large amount of data we collected and the single-shot measurement capability allow us to perform data-mining on the results. As shown in Fig. 3(c), we observed an interesting correlation between source location and peak current of each electron bunch. The peak current instability during LCLS operation seems to contribute more to the source location fluctuation than the intrinsic randomness of the SASE process. If we select only shots with similar electron bunch properties, for example a narrow window near a given electron bunch peak current, the source location fluctuation will be reduced to less than ∼2 m. It is also observed that fluctuations are greater with the full-length undulator and that different undulator tapering also played a role. Further investigation to determine correlations between the wavefront properties and additional machine parameters, using larger datasets, are underway, utilizing the singleshot and high-sensitivity capabilities of the WFS.

Research Article B. Tuning of Transport Optics
Great efforts have been put into the fabrication, mounting, and metrology of the new LCLS HOMS mirrors to ensure minimal distortions to the wavefront, though it is extremely difficult to achieve true flatness. At shallow angle of incidence, even large radii of curvature, above 2-300 km, produce observable astigmatism. To monitor the impact of the HOMS mirrors on the beam wavefront, we performed a series of controlled measurements in which one of the two HOMS mirrors was bent by different amounts (0-3 mm stroke on the actuator. The zero position of the bender is very difficult to set, so the true zero position is likely somewhere between the 0 and 1 mm position) and introduces a weak focusing in the horizontal direction. At each bender setting, we collected multiple single-shot images, and retrieved the wavefronts and corresponding ROCs for the horizontal and vertical directions. The WFS detected the adjustments successfully. The source location Z x indeed moved gradually upstream [ Fig. 4(a)] as the bending partially compensated for the convex surface figure of the mirrors. Also, as expected, we did not observe noticeable Z y change. Bending the mirrors, while generating anticipated focusing, also introduces some higherorder aberrations in the beam [ Fig. 4(b)]. The high-order aberration was, actually, expected. This is due to a residual friction of the mirror's supports that are not compliant enough to prevent it. It has been also measured, in the metrology laboratory of LCLS, on an identical system. A new version of the supports, with higher compliance, has been developed and will be implemented soon on the HOMS mirrors.

C. Monitoring Nanofocusing Optics in Beamline Endstation
The WFS can be easily implemented at experimental endstations to optimize and monitor the quality of the focused beam. We tested its performance at the XPP instrument of LCLS to retrieve the full 3D electric field near the focus of a compound refractive Fig. 4. Bending of the LCLS HOMS mirror caused weak focusing of the beam. Four settings of the bender of one of the two HOMS mirrors were used, 0-3 mm, gradually making the mirror more concave. We randomly picked 26 single-shot Talbot images and retrieved the wavefronts. (a) Measured source locations (Z y and Z x ) under the four bender settings. Z x followed the adjustments and moved gradually upstream, as the weak focusing starts to compensate the convex shape of the mirror. Z y was not affected as the HOMS mirrors bend the beam in only a horizontal direction. (b) Measured phase changes (versus bender at 0 position) when the bender was at 1-3 mm. The average profile at each bender setting is used for this comparison. Changes as small as λ∕100 can be clearly detected in both phase profile and source location measurements. Here we show the statistics for ∼9,000 shots under each undulator configuration, binned into intervals of 100 A of electron bunch peak current. The error bars indicate standard deviation of Z y , centered at the average value of Z y within each bin. In all cases, there is a correlation between source locations and electron bunch peak current, for which systematic drift of source location due to change of peak current can account for large part of the observed source location fluctuation.
In the pink beam case, a CRL stack with an effective focal length of 3.85 m was inserted to achieve an approximately 1 μm focus at the XPP interaction point [20]. To measure at the first Talbot plane, the grating was placed 1.89 m from the nominal focal plane, and the scintillator was placed 0.48 m from the grating. Single-shot measurements of the Talbot pattern [ Fig. 5(a)] were taken and were used to retrieve the full electric field of the x-ray beam [amplitude and phase shown in Figs. 5(c) and 5(d)]. The retrieved electric field at the scintillator plane can then be back-propagated to the focus [ Fig. 5(b)] and other axial planes along the propagation path, as described in Section 5 (Methods).
In this case, the CRL aberrations were much larger than the WFS imperfection, so we found it unnecessary to perform the detailed calibration described above; we instead assumed a constant effective pixel size of 643 nm. There is an average astigmatism of 19 mm, with the horizontal focus downstream of the vertical focus [ Fig. 5(e)], calculated based on the retrieved Zernike coefficients for defocus and vertical astigmatism (indices 3 and 4 following the OSA/ANSI convention). This is roughly consistent with the astigmatism measured in the unfocused beam; the lensmaker's equation predicts an astigmatism of 25 3 mm.
The chromaticity of the CRLs plays a strong role in the focusing quality when using the full bandwidth of the x-ray FEL. While single-shot measurements do retrieve a 1 μm focus [ Fig. 5(b)], the focal length of the CRL stack changes with photon energy; jitter in the central photon energy translates to jitter in focus position. The result is that even with a relatively long Rayleigh range (>2 cm), the peak intensity of the x-ray spot varies by up to a factor of 2, as seen in Fig. 5(f ).
The second focus measurement was made using a CRL stack having 45 cm focal length at 9.5 keV (15 lenses with 50 μm ROC, identical to those described in Ref. [23]), with the XPP diamond monochromator inserted [24]. The use of the monochromator removes the chromaticity effect of the CRLs, with a tradeoff of reduced overall intensity as well as 100% intensity fluctuations due to the nature of the self-amplified spontaneous emission (SASE) spectrum. For this measurement the grating was placed 72 cm downstream of the nominal focus, and the detector was placed 80.3 cm downstream of the grating. In addition, the setup was made compatible with ptychography measurements (although not in parallel) for comparison purposes. The Talbot images again provide the full electric field of the x-ray beam on every shot, whereas the ptychography measurement represents the average of many shots and requires a test object to be scanned across the focus [25]. While the two techniques effectively measure the same thing (the complex electric field of the x-ray beam), the measurement mechanism is fundamentally different. In the Talbot WFS case, the Talbot image of the grating is used to measure the gradient of the wavefront far from the focus. In contrast, ptychography employs diffraction due to a nanofabricated test object placed near the focus, combined with iterative phase retrieval, to reconstruct the field at the plane of the object.
A comparison of the focus profiles retrieved using both techniques is shown in Figs. 6(a)-6(d), for a randomly chosen single shot in the Talbot WFS case. The measurements were made during a single shift, but 7 h apart. The profiles exhibit good qualitative agreement between the techniques, with the major difference being that the ptychography measurement retrieves a higher proportion of energy in the first-order side lobes at the focus than does the WFS. A further, more quantitative comparison can be made by projecting the retrieved wavefronts onto the Zernike basis, with the result shown in Fig. 6(e).  Fig. 3(a). The distance to focus is calculated relative to the position of the scintillator detector, and is based on the Zernike defocus and astigmatism coefficients. The e-beam energy is well-correlated with the photon energy; the chromaticity of the CRLs combined with photon energy jitter leads to jitter in the focus position. (f ) Calculated single-shot peak intensities at best focus for ∼9.49 keV. Shots with lower and higher photon energy focus upstream and downstream of this plane, respectively.

Research Article
The comparison is made at the WFS detection plane. The ptychography reconstruction was performed by selecting single shots at each scan position with pulse energy closest to a level of 2 V as measured on an x-ray intensity monitoring diode [26], corresponding to about half the pulse energy of the most intense shots. Thus, for this comparison the WFS measurements were filtered to include only shots with diode voltages between 1.8 and 3 V. Figure 6(e) shows quantitative agreement between the two measurements. The most dominant aberrations, which include oblique astigmatism (Z3), vertical astigmatism (Z5), and primary spherical (Z12), display good agreement between the two techniques. There are a variety of potential reasons for the small disagreements between the WFS and ptychography: imperfect ptychography reconstruction due to beam position jitter (mostly compensated for in software [27]), systematic error in the WFS measurements, and, not least, measurements made 7 h apart. Nevertheless, the comparison lends confidence that the WFS provides accurate information about the focus quality on a shot-by-shot basis.
As mentioned above, the use of a monochromatic beam eliminates the focus position jitter in favor of intensity jitter. This fact can be used to further quantify the sensitivity of the wavefront measurement. Figure 6(f ) shows the correlation between pulse energy and the corresponding distance to focus. As can be seen from the figure, the spread in the calculated focus location is minimized at intermediate intensities. The standard deviation of the focus position for the shots with 30%-80% of maximum intensity is 70 μm, which is only 0.005% of the distance to focus. This high shot-to-shot sensitivity will prove important in cases of high-NA focusing. For example, a 9.5 keV x-ray focus with 100 nm spot size has a Rayleigh range of 240 μm. If the wavefront sensor detector is located on order of 1 m away from focus, the device described here should be capable of distinguishing changes in focus position on the order of 20% of the Rayleigh range, corresponding to a peak intensity accuracy of approximately 5%.

SUMMARY
We have demonstrated single-shot, high-sensitivity, highaccuracy, 2D wavefront measurements of the LCLS hard x-ray FEL beam using single grating Talbot interferometry. The single grating design not only allows robust and simplified operation but also results in a low level of noise in the measurements. With calibrations, we achieved high levels of sensitivity and absolute accuracy, both at the level of λ∕100. Applying the WFS at different positions along the FEL beam path, we monitored shot-toshot undulator source fluctuations and observed a correlation between the source location fluctuation and the peak current of the electron beam. We were also able to detect expected curvature changes and undesired high-order aberrations when bending the transport optics. Finally, the through-focus light field near the interaction point of a nanofocus endstation was fully characterized with peak intensity accuracy of 5%.
The WFS can be easily adopted at lower and higher photon energies. For soft x rays, binary gratings (transmitting holes on opaque substrates) can be used. For harder x rays, gratings with deeper etching depths are needed to reach a π-phase shift. The fabrication techniques for both modifications are readily available. We expect this type of WFS will find its use at a wide range of FEL and synchrotron facilities in the future.

A. Grating Fabrication
A 7 nm titanium adhesion layer was electron beam evaporated onto a 200 μm thick silicon wafer. Then 900 nm of hydrogen (e) Comparison between Zernike coefficients for both ptychography and Talbot WFS measurements, up to fourth order. The defocus term (Z4) is outside the range of the vertical axis since the comparison is made at the WFS detector plane (∼1.5 m downstream of focus). Note that the ptychography scan produced a single reconstruction, whereas the wavefront sensor measurements were made on a single-shot basis. The coefficients from single shots were averaged to produce what is shown in the plot, with error bars representing the standard deviation. Note the good agreements on the dominating aberrations Z3, Z5, and Z12. (f ) Correlation plot between calculated focus position and relative pulse energy (as measured on the scintillator detector) in the monochromatic case, with histograms at right. The light blue histogram results from only accepting shots having between 30% and 80% of the maximum pulse energy. The standard deviation of the focus position when the data is filtered in this way is only 70 μm, corresponding to a sensitivity of 0.005%.
Research Article silsesquioxane (HSQ), an electron beam resist, was spun onto the wafer. Patterning was performed using electron beam lithography and developed in a solution of 25 wt.% tetramethylammonium hydroxide (TMAH) for 1 min and 40 s at room temperature. The HSQ pattern was then used as a mask to etch 12 μm deep into the silicon substrate, corresponding to a π-phase shift at 9.5 keV photon energy.

B. Phase Retrieval from Talbot Images
Analyses of Talbot images characterize wavefronts by retrieving the following information: (a) the overall image shift; (b) the quadratic phase term, corresponding to the radius of curvature; and (c) higher-order (n > 2) residuals, corresponding to aberrations. We followed the standard procedure for analyzing two beam interferograms (including the Talbot images in our studies) based on the Fourier transformation technique [28]. Item (a) is obtained by retrieving the overall phase shift, (b) is obtained from linear phase slopes in the Fourier domain, and (c) is obtained from cumulative integration of phase residuals after removing (a) and (b).
Item (b) is also equivalent to precise determination of the pitches of Talbot images. When a Talbot grating is illuminated by an incoming wave with a ROC of R, the pitch of the Talbot image is magnified (or demagnified, depending on the sign of R ) to where D is the distance from grating to Talbot image and P 0 is the original pitch of the phase grating. Thus, R can be determined from the measurement of P t as R D∕P t ∕P 0 − 1: Once R is determined, the quadratic phase term is then exp−iπx 2 ∕λR. The extension to 2D adds a complication in that, unless each gradient component is strictly a function of its corresponding dimension, the two components cannot be integrated independently. Here we choose to integrate the gradient by projecting it onto a complete basis set. In the case of CRLs, the Zernike basis is an appropriate choice. For the measurements shown in this paper, the Zernike basis was generated up to 32nd order, corresponding to 561 independent basis vectors. The procedure is as follows: (1) The overall quadratic phase in each direction is found first, as described for the 1D case above.
(2) The gradient of the high-order phase is found by isolating the first-order Fourier peaks and subtracting the linear terms of the gradient found in (1), similarly to the 1D case.
(3) An orthonormal basis for the gradient is formed as described in Ref. [29], using a decomposition of the Cartesian gradient of the Zernike polynomials [30].
(4) The gradient from (2) can then be projected directly onto the basis described in (3), and the Zernike coefficients are found using the transformation matrix relating the Zernike gradients to the basis [29].
(5) The results of (1) and (4) can be combined by adding the quadratic phase back in, corresponding to Zernike indices 3 and 4 (defocus and vertical astigmatism). The resulting Zernike coefficients define the wavefront at the detection plane. (6) The amplitude of the x-ray beam at the detection plane is found by simply applying a low-pass filter to the Talbot image, and taking its square root since the measurement is made in intensity.
(7) With (5) and (6), we fully define the electric field of the x-ray beam, which can then be free space propagated to the plane of interest.