## Ghost-imaging-enhanced noninvasive spectral characterization of stochastic x-ray free-electron-laser pulses

### Spectral ghost imaging

Ghost imaging is an experimental technique, which uses statistical fluctuations of an incident beam to extract information about an object using a beam replica that has not physically interacted with the object^{34}. It can be used in the spatial^{35,36,37}, temporal^{18}, and spectral^{21,22} domains. Traditional ghost imaging requires a beamsplitter to separate the incident beam into two replicas, the object beam and the reference beam. The object beam interacts with the sample and a low-resolution detector is used to measure the signal whose intensity is proportional to the interaction and the incident beam. The reference beam is directly measured by a high-resolution detector to extract knowledge of the incident beam. The incident light source varies shot-by-shot and numerous measurements are carried out to calculate the correlation function between the two signals from the object and the reference beams. The correlation function of the measurements is analyzed to extract information about the sample. The advantage of ghost imaging is that the object beam does not necessarily need to be strong—thus protecting the samples from radiation damage. In addition, due to the fluctuations of the light source and correlation analysis, ghost imaging is robust to noise and background signals.

Ghost imaging essentially maps the high-resolution signal onto the low-resolution one, making it an ideal tool to calibrate devices with high resolution. The correlation function generated by ghost imaging contains information on the response of a device to the different incident signals. This extracted information can be further used to correct defects or discrimination present in a device. The ghost imaging calibration method reconstructs a high-quality signal that achieves resolution beyond the low-resolution instrumental limit. The stochastic nature of a SASE XFEL makes it well-suited for ghost imaging in the temporal and spectral domains. Here, ghost imaging is used to calibrate the eToFs of the PES array and obtain a response matrix, which is then applied to reconstruct a more accurate incident x-ray spectrum. One challenge for applying the ghost imaging method in the x-ray regime is the requirement of a beamsplitter. Although x-ray beamsplitters are available as mentioned above, the noninvasive gas-target measurement is suitable to replace the function of the beamsplitter.

### Experimental procedure

The energy spectrum of the incident x-ray beam was characterized noninvasively by photoionization of dilute neon gas at the center of an array of 16-eToFs, i.e., the PES array^{29} as shown in Fig. 1. The arrival times of Ne 1*s* photoelectrons were measured by the eToFs located in the plane perpendicular to the beam propagation direction (see Supplementary Note 1). The ion and electron optics program SIMION was used to carry out trajectory simulations given the drift tube length and retardation voltages and thus establish a traditional calibration between the electron time-of-flight and kinetic energy, *E*_{k}. The incident photon energy was derived by adding the Ne 1*s* binding energy, 870 eV, to the measured *E*_{k}. The spectrum obtained by the PES array for several random shots using this traditional method is shown in Fig. 1 as the object measurement. Under the present experimental conditions, the energy resolution achievable by the PES array was around 1 eV, which is not comparable to the high-resolution grating spectrometer measurement where 0.2 eV FWHM (Δ*E*/*E*) can be readily achieved.

After passing through the PES array, the same FEL beam was characterized by a spectrometer based on a VLS grating and a Ce:YAG screen as shown in Fig. 1 as the reference measurement. The PES array contains very dilute gas which does not attenuate or otherwise alter the x-ray beam. Thus, ideally, the same spectrum would be obtained from the electron (PES array) and photon (grating spectrometer) measurements. However, the measurement of a single random shot reveals differences. The grating spectrometer resolution is much higher than the resolution of the PES array, thus creating a large deviation between the two spectra. The use of ghost imaging to retrieve a response matrix which is then used to improve the performance of the PES array measurements is demonstrated in the following.

### Principle of reconstruction

Theoretically, the photoelectron signal *c* (after normalization to the gas density) is proportional to the incident photon spectrum *s* as measured by the spectrometer

where *A* relates the PES array signals to the incident photon spectrum, is an (*m* × *n*) matrix with the PES array time-of-flight (ToF) points *m* = 137 and the spectrograph pixels *n* = 1900 in the region of interest between 895 and 920 eV. This equation resembles the basic equation in ghost imaging and is usually used to obtain sample information by solving for *A*. However, in order to predict the incident spectrum based on PES array measurements, we formally write equation (1) as

where the response matrix *R* is related to matrix *A*. *R* maps the low-resolution PES array measurements to high-resolution grating spectrometer measurements. In other words, *R* is a calibration matrix that contains information on the characteristics of the eToFs. After retrieving the response matrix *R*, according to equation (2), it can be used to generate a high-resolution spectrum with the intrinsic defects and broadening of the PES array removed.

### Ghost imaging reconstructed spectrum

To solve equation (2), we take advantage of the *N* independent measurements obtained. Each shot gives a realization of *s*_{i} and *c*_{j} in equation \({s}_{i}=\mathop{\sum }\nolimits_{j = 1}^{m}{R}_{ij}{c}_{j}\) with *m* unknown variables *R*_{ij}. Combining all measurements gives *N* independent linear equations which can be solved to uniquely determine the unknown variables if *N* > *m*. Instead of directly solving these equations, the response matrix elements are determined by least square regression, i.e. by minimizing the quantity ∣*s* − *R**c*∣^{2}. Single-photon Ne 1*s* ionization exhibits a dipole angular distribution pattern due to the linear (horizontal) polarization of the x-rays and the spherical 1*s* electron orbital. To increase the signals, we combined six eToFs near the polarization direction which have strong 1s peaks, to form the PES array measurement vector *c* with dimension *m* = 6 × 137 = 822.

The calculated PES array response matrix using all shots (*N* = 15,337) is shown in Fig. 2. Compared with the traditional calibration function, which just maps ToFs onto kinetic energy, here we retrieved a matrix whose values represent the sensitivity of the PES array to photons of different energy. As expected, there are six different calibration lines connecting the eToFs to spectrograph pixels. The lineshape, with both positive and negative contributions, corrects the instrumental broadening. One eToF does not work well and gives relatively small signals. We tried different regression optimizers and got essentially the same response matrix, demonstrating the robustness of our method. As discussed below, the response matrix can be used to obtain a better spectrum. Note that one can quickly obtain the traditional calibration lines of eToFs, by fitting the lines within a nonconverged response matrix obtained by using only 1500 shots.

It is reasonable to assume the response matrix of the PES array does not change for given photon energy, gas target, photoelectron energy range, and PES array configuration (fixed retardation, bias voltage…); thus *R* can be used to predict the spectra of new shots. Higher-resolution electron spectra *s*_{r} can be reconstructed by multiplying the response matrix *R* by the PES array measurement *c* according to equation (2). As illustrated in Fig. 3, the peak profile and intensities of the PES array data (a) are changed after multiplying the matrix with the PES array measurement (b).

The photon spectrum in Fig. 3b was convolved with a Gaussian function with *σ* = 0.2 eV to compare with the ghost-imaging-reconstructed spectrum. The *σ* was derived by considering the number of data points in the PES array versus the spectrometer measurement. There are 1900/137 ≈ 14 spectrograph pixels between two eToF points; multiplying by the 0.013 eV/pixel dispersion of the spectrometer gives 0.2 eV which we take to be *σ*. One function of reconstruction is to remove instrumental broadening. Thus one observes the higher resolution of the reconstructed spectrum, which matches well with the convolved grating spectrometer measurement. This also indicates that in our case the resolution of the reconstructed spectrum is limited by the number of data points within the Ne 1s photoelectron peak of the PES array signal.

To quantify the performance of the reconstruction, we calculated the standard deviation of the difference signal between the electron-derived and the photon spectra *s*_{i}

$${{\Delta }}{\sigma }_{{{{{{{{\rm{e-p}}}}}}}}}=\sqrt{\frac{\mathop{\sum }\nolimits_{i = 1}^{n}| ({c}_{i}-{s}_{i})-(\bar{c}-\bar{s}){| }^{2}}{n}}$$

(3)

where \(\bar{s}\) and \(\bar{c}\) are the mean value of spectrometer and PES array measurement, respectively, *n* is the number of spectrometer pixels. Depending on the situation, the value of *c*_{i} is either interpolated PES array data of one eToF or the ghost imaging reconstructed spectrum. As shown in Fig. 4 the deviation Δ*σ*_{e-p} of the reconstructed spectrum drops to half of the original value, which indicates the improvement after reconstruction. In addition, the smaller fluctuation of the deviations means that the reconstructed spectrum is stable and more reliable than the raw electron-derived spectrum. The significantly better matching of the spectrum after ghost-imaging is further confirmed by a good correlation between reconstructed and photon spectrum i.e., averaging 0.72 Pearson correlation coefficient across the spectrum (see Supplementary Note 2).

### Predictive power and performance analysis

One of the most interesting aspects of the ghost-imaging method is its predictive power for future shots. This requires numerous “learning” shots to obtain a converged response matrix. Data from six eToFs were used and the response matrix learned from a different number of shots is then used to predict the spectra for 100 new shots that were not used in the regression. As shown in Fig. 5, when fewer shots are used, the deviation of the learning shots is small because the regression is under-determined. Meanwhile, the deviation for the new shots is large, indicating a poor predictive power of an unconverged response matrix. As the information from more shots are included in the regression process, the deviation of learning shots rises, whereas the deviation for the new shots decreases indicating the gain of predictive power. The regression converges when the deviation of learning and prediction meets around 8000 shots (roughly ten times the number of unknown variables i.e., PES array vector elements). It is important to note that as more shots are used the error bar for the prediction, which measures the fluctuation of the deviation, also decreases, which means the prediction becomes more stable.

Combining electron spectra from several eToFs increases the signal intensities and suppresses the noise. However, the eToF signals cannot be added on top of each other directly, due to the different calibrations of each eTOF. As mentioned before, we put the signals from different eToFs together to form a larger vector and differences in eToFs are automatically taken into account when calculating the response matrix. The upper panel and the lower panel of Fig. 6 show the spectrum of a random shot where one eToF with the strongest signal and six eToFs are used, respectively. Comparison with the Gaussian convolved spectrometer measurement clearly indicates the advantages of using six eToFs. The inset plot shows that the normalized deviation drops gradually from 1 for one eToF to 0.87 with six eToFs. The data from different eToFs complement each other and improve the correlation with the spectrometer measurement thus resulting in a better overall reconstructed spectrum.

Our analysis indicates that the performance of the ghost-imaging reconstruction depends on experimentally controllable parameters, the number of shots used and the number of eTOFs used. Ghost imaging is based on the correlation between the object measurement and the reference measurement, i.e., the sensitivity of the PES array signals to the fluctuations of the incident spectrum as measured by a grating spectrometer. Obtaining a better correlation function and reconstruction, i.e., response matrix and spectrum with higher resolution, requires more data points within the Ne 1s photoelectron peak as well as a high signal-to-noise ratio. More data points in the eTOF spectrum can be obtained by increasing the retardation voltages to slow the electrons, using larger drift length tubes, or, more simply by increasing the digitizer sampling rate which is presently 2 GHz. In addition, the increased detection sensitivity can be readily achieved by using more eToFs or by increasing the gas density to produce more photoelectrons and a higher signal-to-noise ratio (see discussion in Supplementary Note 3).