Pulse-to-pulse wavefront sensing at free-electron lasers using ptychography

The pressing need for the detailed wavefront properties of ultra-bright and ultra-short pulses produced by free-electron lasers (FELs) has spurred the development of several complementary characterization approaches. Here we present a method based on ptychography that can retrieve full high-resolution complex-valued wave functions of individual pulses. Our technique is demonstrated within experimental conditions suited for diffraction experiments in their native imaging state. This lensless technique, applicable to many other short-pulse instruments, can achieve diffraction-limited resolution.

complementary characterization approaches. Here we present a method based on ptychography that can retrieve full high-resolution complex-valued wave functions of individual pulses. Our technique is demonstrated within experimental conditions suited for diffraction experiments in their native imaging state. This lensless technique, applicable to many other short-pulse instruments, can achieve diffraction-limited resolution.

Introduction
Free-electron lasers (FELs) are opening the way to a number of new research paths. Within the field of microscopy, the highly coherent and short pulses produced by FELs are used to conduct diffractive imaging of individual particles, also called flash X-ray imaging (FXI), potentially down to atomic resolution (Neutze et al., 2000;Chapman et al., 2006;Seibert et al., 2011). Many other investigations exploit FEL tight focal spots to maximize fluence or improve spatial resolution (Willems et al., 2017;Vidal et al., 2017;Mincigrucci et al., 2018).
For all these applications, a reliable high-resolution characterization of the shot-to-shot focal spot is crucial. A number of beam diagnostics methods have been purposely designed for this task. However, with ultrashort pulses (down to femtoseconds) which can reach a flux sufficient to destroy or irreversibly damage most targets, these methods mostly provide only partial information about the wavefront, such as position, size, shape, intensity or curvature (Chalupsky et al., 2011;Vartanyants et al., 2011;Rutishauser et al., 2012;Loh et al., 2013;Sikorski et al., 2015;Keitel et al., 2016;Daurer et al., 2017). A recent gratingbased method can provide real-time wavefront distributions (Schneider et al., 2018;Liu et al., 2018), though away from the focal plane and with a resolution limited by the grating's manufacturing process.
Here we show that ptychography can be used to reliably reconstruct the wavefront of individual FEL pulses. Our approach requires no a priori information on either object or probes, and all individual wavefronts are allowed to vary, including their positions.
Unlike a previous application of ptychography at the FEL which filtered the pulses through additional optics (Schropp et al., 2013), our method retrieves wavefronts in the native imaging state, i.e. the same conditions in which the apparatus is used for imaging or diffraction experiments.

Methods
The experiment was carried out at the DiProI instrument of FERMI (see Appendix for details), a seeded FEL producing 10 µJ pulses, at a photon energy of 83 eV, equivalent to a wavelength of 15 nm. Figure 1 gives a schematic representation of the experimental setup. After attenuation by about 4 orders of magnitude to avoid damage, the beam was focused by a pair of perpendicular bendable Kirkpatrick-Baez (KB) mirrors to a focal spot size of under 10 × 10 µm 2 . The sample -positioned close the focal plane -was a gold test pattern featuring a 30 × 30 µm 2 Siemens star whose SEM image is represented in Fig. 2a. At 83 eV the sample behaves as a binary object since the gold-plated areas absorb completely the incident X-rays. Far-field diffraction patterns were detected with a CCD camera located 150 mm downstream from the sample. The ptychographic reconstruction was carried out using a single-pulse retrieval algorithm derived from the orthogonal probe relaxation ptychographic (OPRP) method (Odstrcil et al., 2016) which recovers a different probe for each diffraction pattern while keeping the problem over-constrained through dimensionality reduction. Individual probes are thus modeled as linear combinations of a number of dominant components (also called "modes" or "eigenprobes") recovered dynamically and without a priori information. As usual for ptychography, the object's transmission function is also retrieved without enforcing any prior knowledge. The essence of OPRP is compatible with any ptychographic reconstruc-tion algorithm and has been implemented within the PtyPy reconstruction suite (Enders & Thibault, 2016) for both difference map (DM) (Thibault et al., 2009) and maximum likelihood (ML) (Thibault & Guizar-Sicairos, 2012) algorithms. The reconstructions presented here were obtained using DM followed by ML refinement, both using a 10-component decomposition of the retrieved probes.

Results
The absolute value of the retrieved object transmission function is represented in Fig  Using the full stack of retrieved probes, it is possible to gather valuable statistical information, such as variations in intensity and beam pointing. Figure 5a illustrates the fluctuations of the total intensity found for each probe relative to the median total intensity, revealing significant variations, with a relative standard deviation of 0.4. Figure  We numerically propagated the main component -as it is the most representative part of all retrieved probes -downstream and upstream from object plane to investigate the region around the focal position. Sections of the propagated main component are shown in Fig. 6 and can be compared with the unpropagated reconstructed main component from Fig. 3a.
The dotted line in Fig. 6 indicates the sample plane; the focal plane has been estimated to be some 2 mm further upstream, as the plane at which the beam size is minimized.

Conclusions
We have demonstrated the first fully pulse-to-pulse ptychographic wavefront reconstruction for a FEL instrument in its native imaging state. Our approach provides the complexvalued wavefront of each pulse directly at the sample plane, in its near-focus position. As a lensless microscopy technique, its achievable resolution is limited only by flux and detector numerical aperture.
The full set of 937 retrieved probes reveals pulse-to-pulse variations, providing statistical information on FEL beam fluctuations and direct insight into FERMI's performance. The retrieved probes also confirm the elongated shape of the beam at and around the focal position, as expected from previous experiments carried out at the same beamline .
Ptychographic wavefront characterisation brings some benefits compared to gratingbased methods (Schneider et al., 2018;Liu et al., 2018), which recover information far from the focal position, tend to underestimate the intensity in the tails of the power distribution and are limited by grating fabrication. The method has also proven effective even in the presence of significant setup vibrations -another advantage over Hartmann and grating-based wavefront sensing, which are mostly insensitive to beam position variations.
Pulse-to-pulse ptychography is primarily expected to benefit wavefront characterization experiments at FELs, contributing to the development of FEL and FEL-based science. Its application can be extended to other imaging experiments, which would benefit from the relaxation of the single-illumination probe constraint.

Appendix A Experimental setup
The ptychography experiment was carried out at the Diffraction and Projection Imaging (DiProI) beamline Capotondi et al., 2015) at FERMI, EUV and soft X-ray seeded FEL, using the FEL-2 line (Allaria et al., 2012;Allaria et al., 2013;Allaria et al., 2015). The vertical and horizontal bendable KB mirrors had a focal length of 1.75 m and 1.2 m, respectively . The sample (Xradia X30-30-2) was a 110 nm Si 3 N 4 membrane with a 200 nm thick Au test pattern deposited on top. A 3-axis translation stage was used to translate and scan the sample within a vacuum chamber. The in-vacuum CCD camera was a PI-MTE:2048B with 2048 × 2048 pixels, 13.5 µm each. To decrease readout time to 2 s, only the intensities collected by the central 1000 × 1000 pixels were recorded. As readout frequency was lower than the FEL's 10 Hz repetition rate, a fast shutter was used to prevent more than one pulse from contributing to each detector reading.
Due to further overhead, the acquisition rate was effectively reduced to 0.2 Hz, i.e. only one every 50 FEL pulses was recorded.
The beam was attenuated with a combination of attenuators. A 6 m long gas chamber was filled with 2.8 × 10 −2 mbar of N 2 and complemented with solid Zr (600 nm) and Al (200 nm) attenuators. Thus attenuated, pulses remained well below the sample's damage threshold, given by Au melting dose of 0.4 eV per atom .

Appendix B Data acquisition and processing
Ptychographic data were collected using three 25 × 25 µm 2 spiral scans in the x-y plane, with a step size of 2.5 µm for a total of 101 positions each. Five single-pulse diffraction patterns were collected at each scanning position, for a total of 1515 frames over the 3 spiral scans. The center of the last spiral scan was translated in y to extend the overall scanned area which is highlighted by the rectangles in Fig.s 7a,b. The collected diffraction patterns were binned by a factor of 2 and then padded to a size of 512×512 pixels in order to decrease computational cost. Each frame was then dark-subtracted. Detector counts were thresholded to a value of 0 in order to remove unphysical negative counts and converted into units of photon counts. A wide jitter of the photon beam position was found to have occurred throughout data acquisition. Ascribed to vibrations in the optics upstream from the experimental setup, the jitter was of such a large amplitude -tens of microns -that the scanning positions recorded by the sample motors were essentially unusable. Most known position refinement approaches within ptychographic algorithms (Guizar-Sicairos & Fienup, 2008;Maiden et al., 2012;Beckers et al., 2013;Zhang et al., 2013;Tripathi et al., 2014) have been designed to account for minor deviations from the expected positions, typically smaller than the scanning step size. Here, a customized approach was implemented to accommodate for such a wide jitter. Coarse positions were first obtained by cross-correlating the recorded diffraction patterns with simulations based on the interaction of a simulated probe and an object modelled from the available high-resolution image of the test pattern (cf Fig. 7a). The coarse positions were then further refined with a purposely-designed position refinement algorithm (Odstrčil et al., 2018). Diffraction patterns corresponding to positions far from the intended field-of-view were discarded, as well as others for which position refinement failed, effectively reducing the dataset to 937 frames. Given the experiment geometry and detector specifications, the achieved pixel size in the ptychographic reconstruction was 162 nm. The initial illumination function was produced by numerical back-propagation of the mean diffraction pattern. The initial object was assigned a uniform unit transmission function. The ptychographic algorithm ran 200 iterations of DM, followed by 800 of ML refinement.

Appendix C Reconstruction algorithm
The ptychographic wavefront characterization approach used within this work for singlepulse investigation is derived from OPRP (Odstrcil et al., 2016). It recovers a different probe P j for each of the N diffraction patterns I j recorded during a ptychographic scan, with the frame index j varying between 1 and N . The SVD step is added at the end of every iteration of the ptychographic reconstruction algorithm and generates the probes' main principal components or "modes".
Given the complex matrix P whose columns contain estimates of the individual probes P j , applying SVD to P leads to P = U ΣV * where V * denotes the Hermitian transposition of V and both U and V are unitary matrices such that U U * = U * U = I and V * V = V V * = I with I as the identity matrix. By multiplying P with its Hermitian transpose P * , one gets with P * P as a Hermitian matrix and (Σ * Σ) as a diagonal matrix. This is equivalent to the eigenvalue problem so that the non-zero elements on the diagonal of Σ correspond to the square roots of the eigenvalues of P * P .
The solution to this problem within the ptychographic algorithm is implemented as a truncated diagonalisation: the N eigenvalues and main k eigenvectorsV can be retrieved, with k < N andV denoting truncation of V . Applying this in the SVD step, a set of k orthogonal components M is generated via M = P nV = UΣV * V = UΣ where P n denotes the probe matrix P at the n-th iteration. The obtained component matrix M is then used to generate the updated probes P n+1 = MV * = UΣV * .
We are thankful to N. Mahne, M. Zangrando and L. Raimondi