Noninvasive THz spectroscopy for bunch current profile reconstructions at MHz repetition rates

X-ray free-electron lasers based on superconducting accelerator technology deliver ultrashort photon pulses with unprecedented peak brilliance at high repetition rates. Continuous and noninvasive monitoring of the current profile of the electron bunches is essential for the operation and control of the accelerator. Longitudinal diagnostics based on coherent radiation have already shown their potential at various free-electron laser facilities, and the multi-GeVelectron beams of x-ray free-electron lasers are powerful sources for the generation of broadband coherent diffraction radiation. We present noninvasive current profile measurements with a few femtoseconds resolution based on spectroscopy of coherent diffraction radiation in the frequency range 0.7 – 58 THz. The current profiles, reconstructed from the spectroscopic data with an advanced phase retrieval method, are compared with measurement results obtained with a transverse deflecting structure. For the first time, bunch-resolved current profiles have been recorded simultaneously to user operation at European XFEL for all bunches in the bunch train at MHz repetition rates.


I. INTRODUCTION
Single-pass x-ray free-electron lasers (XFELs) [1][2][3][4] require high-brightness electron beams with peak currents in the kiloampere range to start the self-amplification of spontaneous emission (SASE) process [5] in the undulators. Such high peak currents and the constant quest to produce ever shorter photon pulses push longitudinal bunch compression into a regime in which the formation of the current profile can be strongly affected by collective and nonlinear effects such as coherent synchrotron radiation or longitudinal space charge [6][7][8]. Hence, it is crucial for the preparation of the electron beam for XFEL user experiments as well as stable accelerator operation to monitor the current profile with femtosecond resolution. Furthermore, the new generation of high-repetition rate XFELs based on superconducting technology, such as European XFEL [4] or the future LCLS-II [9] and SHINE [10], require diagnostics with single-bunch resolution at kHz or even MHz repetition rates.
A powerful method for measuring the current profile directly in the time domain utilizes transverse deflecting structures (TDS) which map the longitudinal bunch distribution to a transverse plane for observation on a view screen. This method was first introduced at SLAC [11,12], while recent results can be found in [13][14][15][16]. However, damage thresholds of view screens, radiation limits for the emission of secondary particles and normal-conducting technology render single-bunch characterization at kHz repetition rates or more impossible.
Spectroscopy of coherent radiation is a complementary approach in the frequency domain which makes use of the fact that the spectral distribution is linked to the current profile of the electron bunches [17]. Noninvasive subpicosecond bunch length measurements have utilized coherent diffraction radiation (CDR) [18,19], Smith-Purcell radiation [20,21], synchrotron radiation and others [22,23]. Usage of intense and broadband coherent transition radiation (CTR), produced by electron bunches striking a screen or foil, has enabled bunch length diagnostics with time resolutions on the femtosecond scale [24,25]. However, generation of CTR is invasive to the electron beam, and similar limitations on the repetition rate apply as in the case of a TDS.
CDR, for example generated by an electron bunch passing through an open aperture in a screen, has the advantage of being noninvasive, but the spectral energy density exhibits a cutoff toward high frequencies depending on the electron beam energy. This is illustrated in Fig. 1, which shows the ratio of the spectral energy density of diffraction radiation compared to transition radiation for various beam energies. The results have been obtained with Eq. (13) from Ref. [26] by replacing the lower limit of the integral with the radius of the aperture. In this example the aperture diameter is 5 mm, the angle acceptance is 20 mrad in a distance of 0.5 m to the screen.
While the lack of spectral energy density above ≃10 THz hampers bunch length characterization on the femtosecond scale for electron beams with beam energies below a few GeV, CDR spectroscopy becomes a promising method for non-invasive current profile monitoring with femtosecond resolution at high-repetition rate XFELs with multi-GeV beam energy. Using DR the radiation emission is decoupled from the spectral decomposition and allows high flexibility in applying other spectroscopic diagnostic devices.
The spectral energy density scales quadratically with the number of electrons N e in the bunch and can be expressed by dU df where ½dU=df 1 is the spectral energy density of diffraction radiation emitted by a single electron. The complex form factor FðfÞ is described by the 3D-particle distribution of the electron bunch. At high electron beam energies, transverse beam size effects are strongly suppressed for the frequency ranges considered here, and it is appropriate to approximate FðfÞ by the longitudinal form factor F l ðfÞ, which is given by the Fourier transform of the normalized longitudinal current profile ρðtÞ: To obtain the current profile by Fourier transform methods with sufficient resolution over an adequate time interval, the longitudinal form factor needs to be measured over a wide range of frequencies. As a consequence the form factor must be known over almost two orders of magnitude from about 1 THz to several 10 THz to resolve typical electron bunches of SASE XFELs on the femtosecond scale (see Fig. 1). In addition, as only the modulus of the longitudinal form factor is experimentally accessible, phase retrieval algorithms have to be applied for the reconstruction of the current profile, see, e. g., Ref. [27].
In this paper, we present current profile measurements with a few femtoseconds resolution obtained at the European XFEL (EuXFEL) by combining CDR and a spectrometer capable of measuring at MHz repetition rates. Section II gives an overview on EuXFEL and its operation modes, and the experimental setup consisting of the CDR beamline, spectrometer, and readout electronics is described in Sec. III. The calibration of the spectrometer, comparison of reconstructed current profiles with TDS results, and current profile measurements at MHz repetition rates are presented in Sec. IV. Section V provides conclusions.

II. EUROPEAN XFEL
The EuXFEL [4] provides femtosecond x-ray pulses in the wavelength range 0.05-4.7 nm for research into ultrafast dynamics in matter with sub-Ångström spatial resolution. Bursts of up to 2700 x-ray pulses generated every 100 ms can be shared between three user experiments, which benefit drastically from the high rate of x-ray pulses [28][29][30]. The layout of the EuXFEL is depicted schematically in Fig. 2.
In order to achieve electron bunches with peak currents in the kA regime, the initially several picosecond long electron bunches, created at the photocathode gun with adjustable charges between 20 pC and 1 nC, are compressed gradually with three radio-frequency (rf) accelerating sections ðL 1 ; L 2 ; L 3 Þ followed by magnetic bunch compression chicanes ðBC 1 ; BC 2 ; BC 3 Þ [31]. For this, an energy chirp is imprinted along the longitudinal bunch coordinate by off-crest acceleration in L 1 , L 2 , and L 3 . The injector section L 1 comprises a third harmonic accelerating module which allows the energy chirp to be linearized. The 1.0 km-long main linac is operated on-crest and accelerates the electron bunches to their final beam energy of up to 17.5 GeV. The superconducting 1.3 GHz rf technology allows to fill the rf accelerating pulses with bunch trains of up to 2700 electron bunches at a repetition rate of up to 4.5 MHz. The bunches in each bunch train can be distributed individually on request by the user experiments to either of the three FEL beamlines SASE1, SASE2 or SASE3 [32].
An example of a timing pattern for the electron bunches and x-ray pulses is illustrated in Fig. 3. A fast kickerseptum arrangement with 4.5 MHz switching rate allows individual bunches (grey bars) out of the bunch train to be deflected into the local dump upstream of the SASE undulators (see Fig. 2), while blue, green, and red bars indicate bunches that are requested for the FEL beamlines SASE1, SASE2, and SASE3 respectively. A flat-top kicker-septum arrangement (brown line) is used to deflect electron bunches into the hard x-ray beamline SASE2. The rf accelerating pulses (purple line), which have a length of up to 600 μs and a repetition rate of 10 Hz, can be split into two flat-top regions (FT1 and FT2) for which the accelerating voltage, i.e., amplitude and phase, can be adjusted within certain limits for independent optimization of the bunch compression and x-ray pulse energy for the individual undulator beamlines.
The hard x-ray undulators of SASE1 are located in the straight beamline and are followed by the soft x-ray undulators of SASE3 downstream of a bending magnet that separates the electron beam from the hard x-rays. A fresh bunch technique [33] has been realized for an almost independent operation of SASE1 and SASE3. The SASE2 bunches can also be swapped with the SASE1/SASE3 bunches by shifting the timing of the SASE2 flat-top kicker to the first rf flat-top (FT1). Bunches that are accelerated during the time between the rf flat-tops, which is required for both adjustment of the accelerating voltage and rise or decay time of the SASE2 flattop kicker, are sent to the local dump upstream of the SASE undulators by the fast kicker-septum arrangement.

III. EXPERIMENTAL SETUP
The CDR beamline and spectrometer are located after the main linac but upstream of the kicker-septum distribution systems (see Fig. 2). Consequently, every single bunch inside the rf accelerating pulse (see Fig. 3) can be characterized regardless of whether it is sent to any of the SASE beamlines or the dump upstream of the undulators. A 3D model of the electron beamline section hosting the CDR beamline and spectrometer is depicted in Fig. 4. The spectrometer is the only longitudinal electron beam diagnostics at final beam energy. A normal-conducting S-band TDS [34] has been installed downstream of the last bunch compressor chicane BC 3 where the bunches are fully compressed at a beam energy of 2.4 GeV. The TDS is followed by a diagnostics section with view screens and a local dump where longitudinal phase space measurements with femtosecond resolution are possible with a special accelerator optic and single bunch operation.

A. CDR screen and beamline
The diffraction radiator has a vertical dimension of 80 mm and a transverse dimension of 32 mm. This screen is made out of 1 mm thick aluminium and is attached to a remotely-controllable linear motion vacuum feed-through, which is mounted on top of a vacuum chamber in the electron beamline (green part in Fig. 4). Both apertures of the screen, which have projected diameters of 5 mm and 7 mm, are separated by 32 mm and can be adjusted to the electron beam axis to serve as diffraction radiators. The solid section between the two apertures can be used to produce CTR at single bunch operation for characterization of the spectrometer. The screen is installed at an angle of 45°with respect to the electron beam axis, such that the radiation is emitted perpendicularly to the electron beam and is coupled into the CDR beamline (blue part in Fig. 4). During user operation, the screen is permanently set to the aperture with 5 mm diameter. This aperture yields sufficient intensity at the high frequency channels of the spectrometer while it is large enough to avoid radiation due to beam losses. Effects on accelerator or SASE performance have not been observed. A diamond vacuum window with a free aperture of 20 mm is used to decouple the ultrahigh vacuum of the electron beamline from the evacuated CDR beamline with an inner diameter of 150 mm. The diamond window provides an efficient transmission of CDR over a large frequency range [26], and its wedge shape suppresses etalon oscillations of the vertical polarization. The diamond window aperture does not introduce a low frequency cutoff in the spectral range of the spectrometer. A periscope, consisting of four gold-coated focusing mirrors inside the CDR beamline, translates the vertical polarization at the screen to the horizontal polarization which is dispersed by the gratings inside the spectrometer. The mirrors have a projected radius of 50 mm and are mounted on linear motion vacuum feed-throughs for remotely controllable alignment. Any possible background radiation from other locations is suppressed by the optical layout of the CDR beamline which images the radiation emitted at the screen onto the detectors in the spectrometer. The layout of the CDR beamline is well suited for the multi-GeV electron beam energies of XFELs, and a detailed description of the optical setup and overall transmission can be found in Ref. [35].

B. Spectrometer and read-out electronics
Radiation from the CDR beamline enters the multistage grating spectrometer (red part in Fig. 4) which is a replica of the coherent radiation intensity spectrometer (CRISP) described in detail in Ref. [24]. CRISP has been successfully applied at the soft x-ray FEL FLASH [27,36], however limited to single-bunch measurements at 10 Hz repetition rate due to the low electron beam energy of about 1 GeV which requires usage of CTR (see Fig. 1). Two remotely interchangeable sets of four consecutive gratings cover the frequency range from 0.7 THz to 6.6 THz and 6.8 THz to 58.3 THz (or correspondingly in wavelengths 438.1 μm to 45.4 μm and 43.8 μm to 5.1 μm).
The dispersed radiation is detected by four linear arrays consisting of 30 individual pyroelectrical detectors with LiTaO 3 crystals. Whereas the optical system and pyroelectric detectors are identical to Ref. [24], the detection and pulse shaping electronics have been modified to meet the requirements of MHz operation.
As shown in the block diagram of the detector electronics in Fig. 5, charge-sensitive preamplifiers inside the spectrometer convert the surface charge signal of each pyroelectric detector to an exponential steplike voltage signal with a time constant of 1.4 μs. The MHz repetition rate of the EuXFEL leads to a stepwise increase of the signal after the preamplifier until the baseline reaches a steady-state as soon as the influence of the first bunches is not significant anymore. Gaussian shaping amplifiers with a time constant of 0.1 μs are used as high-pass filters and resolve the induced pyroelectric signal of every bunch even at MHz repetition rates.
However, due to piezoelectric oscillations of the pyroelectric crystal, the influence of preceding bunches cannot be removed completely by the electronic pulse shaping. The influence of this pileup is discussed in detail in the Appendix where an algorithm is deduced which removes this effect and allows the pyroelectric detectors to operate at MHz repetition rates. Finally, the signals are digitized by four MicroTCA.4-compliant advanced mezzanine cards each comprising 32 analog-to-digital converters (ADC) with a sampling rate of 54 MHz, which is obtained by dividing the rf reference of the accelerator by a factor 24. The components used to realize the pulse shaping electronics are quoted in Fig. 5.

IV. EXPERIMENTAL RESULTS
The experimental results shown in this section have been obtained with the diffraction radiator with 5 mm aperture and an electron beam energy of 14 GeV. The measurements including comparisons with TDS profiles have been performed during dedicated beam time, whereas multibunch measurements have been carried out parasitically to user operation. The following subsection describes the calibration procedure of the spectrometer, so that precise form factor measurements can be carried out and used as input for current profile reconstructions in the subsections thereafter.

A. Beam-based calibration
For the sake of simplicity, the calibration is not given in relation to absolute units of the spectral energy density, but as R ref with respect to the form factor of an infinitely short bunch with a charge of 1 nC. In that case, for a bunch with charge Q, whose emitted radiation generates voltage signals v m for each central detector frequency f m , the form factor is simply given by The calibration function R ref of the spectrometer depends on the response of the pyroelectric detectors, radiation emission and transport through the beamline and spectrometer as well as optical reflectivities and influence of the pulse shaping electronics. As described in Ref. [24], the detectors have been experimentally calibrated and radiation emission and transport have been simulated based on the numerical approach described in Ref. [26]. The resulting calibration is denoted as "initial" in Fig. 6 and serves as a reference for a beam-based calibration. The eight different grating stages are clearly noticeable. The periodic pattern of minima, caused by the variation of solid angle acceptance along each detector array, results in a high sensitivity to the exact alignment and makes a beam-based calibration mandatory.
The beam-based calibration is carried out using a comparative TDS measurement and an ultrashort bunch with low charge. For the TDS comparison, the current profile is characterized using the TDS downstream of the last bunch compressor. Measurements are taken at both rf zero-crossings as described in the appendix of Ref. [27] and averaged over 5 rf pulses. The resulting current profile with a time resolution of 8 fs is shown in the inset of Fig. 7. Applying a Fourier transform to the current profile and correcting for the time resolution results in the form factor from the TDS measurement, which is depicted in Fig. 7 as a green line. The limitation to frequencies below 30 THz is due to the TDS time resolution, which distorts higher frequencies. The spectrometer data is averaged over 100 single shots at both grating sets. The form factor of the initial calibration is plotted as red dots together with the shot-to-shot fluctuations as error bars. It agrees with the overall shape of the TDS form factor but shows nonphysical wiggles. The calibration function is therefore adapted to fit the form factor from the TDS, which eliminates misalignment errors and corrects for nonperfect knowledge of the single spectrometer components as, e.g., the pyroelectric detectors [37]. The calibration of the remaining channels is based on an ultrashort bunch with a charge of 50 pC. The form factor of this bunch can be expected to be a smooth function of frequency and allows to adjust the spectrometer calibration accordingly. Using this combined beam-based calibration the spectrometer form factor (blue) evolves into a continuous function of frequency. Indicated by the gray area is the spectrometer noise floor given by 4σ of the ADC baseline signal.
The form factor of the used ultrashort bunch is shown in Fig. 8 together with the reconstructed current profile (inset). The reconstructed rms bunch duration amounts to 5.4 fs. Details on the reconstruction routine will be given in Sec. IV B. The final calibration function is illustrated as bright and dark blue dots in Fig. 6, which can be used for accurate form factor measurements of bunches with completely different longitudinal beam properties.

B. Single-bunch operation
As mentioned in the Introduction, spectroscopic measurements only yield the modulus of the form factor, whereas the phase, needed to obtain the current profile ρðtÞ via inverse Fourier transform [see Eq. (2)], remains unknown. However, there are several approaches to obtain a suitable phase function. An analytical approach is based on the Kramers-Kronig dispersion relation which was first applied to longitudinal form factor measurements by Lai, Happek and Sievers [17]. An iterative algorithm for the phase retrieval of the longitudinal form factor has been introduced in Ref. [38] and the advantages of combining analytical and iterative phase retrieval have soon been realized [39]. In this paper, we use a combination of an analytical and iterative phase retrieval by starting the Gerchberg-Saxton algorithm with the phase obtained by the Kramers-Kronig dispersion relation. The used method was introduced in Ref. [27] together with the data preparation and extrapolation routine for the CRISP spectrometer at FLASH (the results are compared in detail to TDS measurements and other phase retrieval algorithms).
The top part of Fig. 9 depicts two longitudinal form factors measured with different compression settings and a bunch charge of 250 pC. The compression was altered by changing the chirp (energy dependence on longitudinal position inside the bunch) in the accelerator section L 2 . This leads to significant differences in the behavior of the form factor in the frequency range of the spectrometer. For low frequencies, both form factors asymptotically approach one. While setting 1 decreases smoothly, the form factor of setting 2 shows several periodic minima toward high frequencies.
The bottom part presents the reconstructed current profiles (dashed lines) for the two settings together with the corresponding TDS measurements (green). Even though the rms bunch durations are comparable, the current profiles differ strongly. The substructure of the reconstructed current profile at setting 2 cannot be resolved with the 8 fs (rms) resolution of the TDS. After convolution with the TDS resolution (solid lines), both measurements agree very well with the TDS results. This corroborates that spectroscopy of CDR generated by multi-GeV electron beams is a powerful method for a current profile monitor with few-fs resolution.

C. MHz Operation
The combination of CDR as a noninvasive radiation source and a single-shot spectrometer with MHz read-out capability can be applied, in principle, to all bunches in the bunch train at EuXFEL (see Fig. 3) for current profile reconstructions. However, mechanical oscillations, induced by the absorption of CDR in the pyroelectric detectors and its transformation into heat, also occur at frequencies around the bunch repetition rate of 1 MHz. This leads to a signal distortion of the subsequent bunches which cannot be filtered out by the electronic amplification chain and manifests in a pileup effect. We have developed an algorithm for the determination and correction of the pileup effect which is described in detail in the Appendix. This pileup correction is a prerequisite for pyroelectric detectors at MHz operation and has been applied to all results presented in this subsection.
As described in Sec. II, the EuXFEL serves several SASE beamlines for which individual bunch compressions may be set by introducing different rf flat-tops. During such FEL operation with a bunch charge of 250 pC, we recorded the form factor of all bunches in the train simultaneously. Figure 10 shows the pileup corrected ADC signals sampled with the bunch repetition rate of 2.2 MHz along the bunch train for three spectrometer channels at low, moderate and high frequency. The signals are averaged for each bunch over 50 bunch trains. After the first bunch of the train, the behavior of low and high frequency channels is very different along the first 50 bunches. Afterwards in the first rf flat-top (FT1) with ∼360 bunches, the intensity at low frequencies stays constant, while it slightly decreases at higher frequencies. The transition region between the two rf flat-tops covering ∼100 bunches is clearly observable, followed by slight variations along rf flat-top 2 (FT2), especially at high frequencies and the end of the bunch train at sample 1090. The form factors of one bunch from each rf flat-top are shown in Fig. 11 together with the reconstructed current profiles in the inset. The effect of the different compression settings can clearly be seen in frequency and time domain.
The rms bunch duration of all reconstructed current profiles along the bunch train is presented in Fig. 12. The first 50 bunches show a steep decrease in bunch duration. During user operation, these bunches are usually sent to the dump upstream of undulator beamlines (see Fig. 3) as this time is needed to stabilize the accelerator and the fast feedbacks [32]. The rms bunch duration increases during FT1, whereas it stays constant along FT2. In order to estimate the relative uncertainty of the current reconstruction algorithm based on the spectrometer data, the rms bunch duration is assumed not to change on short (bunch-to-bunch) timescales. In that case an upper limit of the uncertainty is given by the standard deviation from a linear fit to each rf flat-top. This results in an accuracy of 1.5 fs along FT1 and 0.8 fs along FT2. The averaged rms bunch durations for FT1 and FT2 are 24.6 fs and 20.4 fs, respectively.
The peak currents from the reconstructed current profiles along the train are shown in the top of Fig. 13. The peak current increases by roughly 1.5 kA between the rf flattops, which is the result of empirical tuning to maximize the SASE intensity for SASE1=3 (FT2) and SASE2 (FT1) independently. To gain more insight into the evolution of the bunch profile along the train, the asymmetry of the bunch profile is depicted in the bottom of Fig. 13. The asymmetry is defined as the ratio of distance from the peak for the two points at half maximum. The current profile changes very dynamically before a stable state of the accelerator is reached and during the transition time between FT1 and FT2. Along the two rf flat-tops the shape of the profile stays approximately constant.

V. CONCLUSION
First noninvasive current profile measurements with a few femtoseconds resolution have been realized by combining CDR and the four staged-grating spectrometer CRISP [24] at the superconducting accelerator EuXFEL. The CDR screen does not influence accelerator operation and can be used simultaneously to user operation. The CDR intensity at a beam energy of 14 GeV is sufficient to perform form factor measurements up to frequencies of 60 THz, and electron bunches with reconstructed rms bunch durations as short as 5.4 fs have been characterized.
An iterative phase retrieval algorithm [27] has been applied to reconstruct current profiles from form factors, and comparative measurements with a TDS show excellent agreement. CDR spectroscopy has the advantage that the intensity at high frequencies increases with higher electron beam energies and shorter electron bunches, whereas this diminishes the time resolution in TDS measurements. Hence, CDR spectroscopy represents a potent diagnostic for current profile monitoring at XFELs with multi-GeV electron beams.
The knowledge and control of the current profile of each bunch producing x-rays is essential for the operation of the EuXFEL accelerator and provides valuable information for user experiments [14]. The read-out electronics have been adapted to meet the requirements for MHz repetition rates using the MicroTCA.4 crate standard. A pileup correction algorithm (see Appendix) has been developed which removes signal oscillations induced by the piezoelectric effect of the pyroelectric detectors and enables form factor measurements and therefore current profile reconstructions of every bunch in the bunch train at repetition rates of up to 2.2 MHz. The form factor at the low-frequency grating set is described by a smooth function of frequency and can be well extrapolated from the high-frequency grating set data (for a discussion of the extrapolation to low frequencies see Ref. [27]). This allows for online monitoring of the current profile with only the high-frequency grating set.
Variations of bunch length, peak current and asymmetry of the current profile along the first rf flat-top and in the transition region have been observed, which revealed dynamic changes before steady-state operation of the accelerator is reached. In future, feedbacks for the rf system could use this information to remove variations along the rf flat-tops. Machine learning algorithms may use the online form factor measurements for the optimization of the current profile or SASE photon pulse energy.

ACKNOWLEDGMENTS
The authors are grateful to P. Peier, J. Roever, and K. Ludwig for their assistance with the construction of the CDR beamline, P. Smirnov and L. Petrosyan for their contributions to the MHz readout electronics, R. Brabants for his help in commissioning the spectrometer and M. J. Garland for his constructive criticism of the manuscript. The authors would like to thank the entire EuXFEL operations team that made these measurements possible, especially W. Decking and D. Nölle for their support for beamtime, and B. Beutner for his assistance during the TDS measurements.

APPENDIX: SIGNAL PILEUP CORRECTION
As mentioned in Sec. III B, the thermal expansion of the pyroelectric LiTaO 3 crystal leads to mechanical oscillations, which result in oscillatory signals due to the piezoelectric properties of the crystal [40]. The characteristic frequency in the MHz-range causes a ringing of the signal with a decay time of several tens of microseconds even after the pulse shaping electronics. An example of the ringing after the signal of one electron bunch at t ¼ 0 μs is shown in Fig. 14. In the signal processing, the sampling rate is reduced from the ADC sampling rate of 54 MHz to the bunch repetition rate (red).
FIG. 14. Normalized signal of one pyroelectric detector of the CRISP spectrometer for a single bunch accelerated within the rf flat-top. Sampled with the ADC sampling rate (blue line) and reduced to the bunch repetition rate of 2.2 MHz (red points). The inset shows the entries of the correction matrix.
An example for the measured signal of a bunch train containing more than a single bunch is given by the blue line in Fig. 15. The nonvanishing signal components of previous bunches distort the measured signal. This finally results in a nonvanishing signal after the end of the bunch train at sample 1090. As the ringing and thereby the influence of the previous electron bunches is phase-stable, the measured signal at the nth sampling position s Ã n can be mathematically described as the superposition s Ã n ¼ s n þ r 1 · s n−1 þ r 2 · s n−2 þ Á Á Á þ r n · s 0 ; ðA1Þ where r i is the influence on the subsequent electron bunches and can be extracted from a normalized single bunch measurement as shown in Fig. 14. This can also be expressed in matrix formalism with vectors for the measured and undisturbed signals along the sampling positions with a total of (N þ 1) samples as By inverting the response matrix R the undisturbed signal s can be calculated from the measured signal s Ã as As the response matrix is a half-infinite triangular Toeplitz matrix, its inverse, the correction matrix C, is also a triangular Toeplitz matrix whose elements can be calculated by an iterative algorithm [41] c 0 ¼ 1; r k−j c j ðk ¼ 1; …; NÞ: ðA4Þ The entries c k of the correction matrix for the given example are shown in the inset of Fig. 14, and the corrected signal is presented by the red line in Fig. 15. The vanishing signal after the bunch train indicates a successful pileup removal. The signal pileup equals the mathematical description of a finite impulse response filter in digital signal processing [42] and also allows pileup removal for accelerators operating in continuous mode instead of pulsed mode. It should be noted that the response of each detector channel is slightly different due to fabrication tolerances and the pileup correction has to be determined individually. Any possible remaining influence of the pileup effect is estimated by the maximum signal after the bunch train. This estimated error is quadratically added to the shot-to-shot fluctuations. If the estimated pileup error exceeds the shotto-shot baseline fluctuations this spectrometer channel is excluded from the further analysis.