Generation of Relativistic Electron Bunches with Arbitrary Current Distribution via Transverse-to-Longitudinal Phase Space Exchange

We propose a general method for tailoring the current distribution of relativistic electron bunches. The technique relies on a recently proposed method to exchange the longitudinal phase space emittance with one of the transverse emittances. The method consists of transversely shaping the bunch and then converting its transverse profile into a current profile via a transverse-to-longitudinal phase-space-exchange beamline. We show that it is possible to tailor the current profile to follow, in principle, any desired distributions. We demonstrate, via computer simulations, the application of the method to generate trains of microbunches with tunable spacing and linearly-ramped current profiles. We also briefly explore potential applications of the technique.


I. INTRODUCTION
Modern applications of particle accelerators generally rely on phase space manipulations within one or two degrees of freedom. These manipulations are necessary to tailor the phase space distributions to match the requirements of the front-end applications. Usually, phase space matching is done in a root-mean-square (rms) sense. However, there has been an increasing demand for more precise phase space control. In particular, electron bunches with tailored temporal distributions are often desired. For instance, in accelerator-driven shortwavelength light sources based on the free-electron laser (FEL) principle and using the so-called high gain harmonic generation (HGHG), a uniform current density is needed [1]. On the other hand the production of trains of microbunches with a given bunch-to-bunch separation is foreseen to pave the road toward compact light source operating in the super-radiant regime at wavelength comparable or larger than the typical microbunch length [2]. Finally, novel accelerator concepts based on beam-driven acceleration mechanisms, e.g. plasma or dielectric wakefield-based acceleration [3][4][5][6], would greatly benefit from linearly ramped or trapezoidal current profiles [7,8] to significantly increase the transformer ratio -the energy gain of the accelerated bunch over the energy loss of the driving bunch [3]. Furthermore the performance of the aforementioned acceleration schemes, could be significantly improved if driven by a train of microbunches to resonantly drive wakefields [9] or train of linearly ramped microbunches [10,11] to improve the transformer ratio.
To address these needs, several techniques aimed at tailoring the current profile of electron bunches have been explored. Linearly-ramped current profiles can be produced by imparting nonlinear distortions in the longitudinal phase space [12][13][14]. A successful experimental im-plementation of a nonlinear optical lattice was reported in Ref. [15]. The generation of a train of microbunches by shaping the temporal profile associated to a photocathode drive laser in a photoemission electron source were explored via numerical simulations [16][17][18]. An alternative method using an interceptive mask located in a dispersive section, first proposed in Reference [19], was experimentally demonstrated [20]. Tailoring of the current profile to enhance the operation of a FEL operating in the HGHG regime via an ad hoc temporal shaping of the drive-laser was discussed in Reference [21].
Each of these methods has limitations. The techniques based on shaping of the photocathode drive laser distribution are prone to the space-charge effects which are prominent at low energies and tend to smear the impressed shaping. Although it has been pointed out that the density modulation is indeed converted into an energy modulation and can be later recovered by a proper longitudinal phase space manipulation, the final bunching factor is significantly lower [22]. Similarly the techniques based on nonlinear transformations generally have a limited tunability.
In this paper we propose an alternative method to tailor the current distribution of relativistic electron bunches extending on our earlier work [23,24]. The technique relies on the transverse-to-longitudinal phase space exchange technique. After discussing the theoretical background for our proposal in Section II, we demonstrate the generation of various current profiles via computer modeling in Section III. We finally discuss a possible implementation and its applications in Section IV.

II. THEORETICAL BACKGROUND
The proposed method for producing beams with arbitrary current profile is illustrated in Figure 1. A transversely-shaped electron bunch with the transverse density distribution Φ ⊥ (x, y) is manipulated through a transverse-to-longitudinal emittance exchange (EEX) beamline to convert the corresponding horizontal profile P (x) = dyΦ ⊥ (x, y) into the longitudinal (temporal) coordinate; see Fig. 1. The backbone of our proposed scheme is the transverse-to-longitudinal phase space exchange. The emittance exchange was first proposed in the context of B-factory [25] as a way to achieve very small β * values at the interaction point. The scheme was later explored as a possible alternative for mitigating microbunching instability in bright electron beams [26] or for improving the performance of single-pass FELs [27]. There are several solutions capable of performing this phase space exchange [28,29]. The simplest solution devised to date consists of a horizontally-deflecting cavity, operating on the TM 110 mode, flanked by two identical horizontallydispersive sections henceforth referred to as "dogleg" [30]; see Fig. 1. An experiment conducted at the Fermilab's A0 photoinjector facility recently demonstrated the exchange of transverse and longitudinal emittances [31].
We first elaborate on the emittance exchange principle and analyze the single-particle dynamics in the four dimensional phase space (x, x ′ , z, δ), an initial electron with coordinate X 0 ≡ (x 0 , x ′ 0 , z 0 , δ 0 ) is mapped to its final coordinate X ≡ (x, x ′ , z, δ) accordingly to X = RX 0 wherein R is the 4 × 4 transport matrix; the stands for the transposition operator. In our notation underlined vectors belong to the four-dimensional trace space (x, x ′ , z, δ). The matrix of a dogleg composed of two rectangular bends of length L b and bending angle α separated by a drift space D has the form where the matrix elements are related to the machine parameters by the following: , with the short-handed notation (c, s) α = (cos, sin)α [32]. The transfer matrix associated to a deflecting cavity of length L c and deflecting strength κ is [26,33]: A complete emittance exchange requires κ = −1/η [30] and the total matrix becomes: where the elements of matrix A are all zero except has the same form as B but its diagonal elements are reversed, and D = Lc For a thin cavity (L c = 0), the matrices A and D vanish and the exchange is perfect [30]. In this latter case we have a direct mapping of the transverse to longitudinal coordinates and vice versa. In particular we have: In general, when including thick lens effects, the final beam matrix is Σ ≡ X X = M Σ 0 M is not block antidiagonal and the final geometric emittances are given to first order by [26] where ̺ 0 ≡ ε x,0 /ε z,0 is the initial transverse-tolongitudinal emittance ratio and λ 2 is given by [32] Here α i,0 and β i,0 are the Courant-Snyder (C-S) parameters associated to the horizontal (i = x) and longitudinal (i = z) degrees of freedom. The quantity λ 2 can be minimized by a proper choice of either longitudinal or transverse C-S parameters. Here we opt for minimizing λ with respect to the longitudinal C-S parameters. Since the bunch length (i.e. β z,0 ) is fixed by the upstream beamline and electron source settings for most of the cases discussed in this paper, λ is minimized with respect to α z,0 = − z0δ0 εz,0 , the optimum value isα z,0 = βz ξ corresponding to an incoming longitudinal phase space chirp C ≡ dδ dz 0 = − 1 ξ that produces a minimum bunch length at the cavity location.
In order to illustrate how this phase space exchange mechanism could be taken advantage of to tailor the longitudinal distribution of an electron bunch, we consider a beam with an initial six-dimensional Gaussian trace space distribution where X 0 ≡ (x 0 , x ′ 0 , y 0 , y ′ 0 , z 0 , δ 0 ), and Σ ≡ X 0 X 0 is the six-dimensional covariance matrix associated to the beam. We further assume the initial covariance matrix to be uncoupled, i.e. to have the form Σ 0 = diag(Σ x,0 , Σ y,0 , Σ z,0 ) with where the index i = x, y, z stands for the considered degree of freedom and γ i,0 ≡ (1 + α 2 i,0 )/β i,0 . We suppose the initial distribution function can be transversely shaped with a "transmission" function T (x 0 , y 0 ). The function T (x 0 , y 0 ) can model a mask [if so its value is either 1 (within the mask aperture) or 0 (elsewhere)] or be used to account for a transverse density that deviates from the Gaussian distribution. Therefore the four-dimensional trace space distribution upstream of the EEX beamline is and the longitudinal trace space is given by where N i,j are the elements of the matrix N ≡ R −1 . The latter equation describes a two-dimensional Gaussian distribution in (z, δ) modulated by the function τ .
Integration over δ provides the longitudinal profile downstream of the exchanger: If the mask has no y-dependence [y + (x) → +∞ and y − (x) → −∞ ], τ is a function of x only.
We first consider the case of τ ( is the Dirac function. This can be achieved, e.g., by intercepting the incoming beam with a series of vertical slits with center located at x i 0 . In such a case the longitudinal phase space is described by a twodimensional Gaussian distribution with C-S parameters (α z , β z ), emittance ε x0 , which is non-vanishing only at locations described by the family of lines with equation dinal coordinate z is representing a series of Gaussian microbunches each of length σ z,m ≡ ε x,0 N 2 16 /β z . The microbunches are longitudinally separated when 4σ z,m Even when the P (z) projection is not strongly modulated, the local correlations in the longitudinal trace space can be taken advantage of to enhance the modulation. This can be done by using a dispersive section downstream of the EEX beamline with its longitudinal dispersion ξ ′ matched to the chirp of the beamlets, i.e. ξ ′ = −N 15 /N 16 . A simple estimate of ξ ′ in the thin-lens approximation gives the required value to be In our convention [head of the bunch is at positive time (or z-coordinate)] the required value is of opposite sign of the value provided by, e.g., a standard four-bend magnetic chicane. Such a longitudinal dispersion can be generated by a four-bend chicane with quadrupoles inserted between the two first and two last dipoles [34].
We now consider the more general case of a mask with upper (y > 0) and lower (y < 0) boundaries respectively respectively described by the functions y + 0 (x 0 ) and y − 0 (x 0 ). In such case we have Taking The general form of the longitudinal bunch profile downstream of the EEX beamline is The latter equation provides some insight on the limitation of the discussed pulse shaping technique. For instance, the convolution-like integral indicates that current profiles with spectral components beyond the spatial frequency f x ∼ 1/[2π β z ε x,0 ] will be filtered out. Therefore the generation of pulses with sharp features would require the final longitudinal emittance and betatron function to be small.

III. VALIDATION OF THE METHOD VIA SINGLE-PARTICLE DYNAMICS SIMULATIONS
We first validate the technique proposed in the previous Section with the help of single-particle dynamics simulations. We consider an incoming beam with Gaussian distribution in the three degrees of freedom. The beam is intercepted by a mask with transverse transmission T (x, y) and then passes through the emittance exchanger.  Table. I. The green symbols indicate the axial locations of the four dipoles (shown as rectangles) and deflecting cavity (vertical line at s ≃ 3 m). The initial normalized emittance partition is (ε n x,0 , ε n y,0 , ε n z,0 ) = (1, 1, 10) µm.
The beamline geometric parameters are gathered in Table I and correspond to the proof-of-principle experiment being considered at the Argonne Wakefield Accelerator (AWA) facility [35]. The transversely-deflecting cavity consists of a 1/2-1-1/2 cell cavity optimized to minimize steering effects [36]. The numerical beam dynamics simu- lations presented in this section were performed with the particle tracking code elegant [37] and do not include any collective effects. The influence of collective effects is investigated in the next section when considering a realistic beamline configuration along with exploring practical applications of the pulse shaping technique.
In elegant the deflecting cavity was modeled by its thick-lens transfer matrix which was found to be in excellent agreement with the transfer matrix numerically devised by tracking macroparticles in the 3D electromagnetic field map computed with the microwave studio R eigensolver [38]; see Appendix A. An example of emittance evolution along the emittance exchanger with parameters tabulated in Table. I, is shown in Fig. 3.

A. Limiting effects in an emittance-exchange beamline
Before proceeding with validating the pulse shaping method described in the previous section, we explore the domain of perfect phase space exchange. Several sources can prevent a perfect emittance exchange. One of them, described in the previous section, is due to coupling introduced by the thick lens model of the deflecting mode cavity. Although minimizing this emittance dilution requires the chirp to be tuned to minimize the bunch length at the cavity location, the emittance is still diluted and the dilution term can be further minimized by selecting proper incoming horizontal C-S parameters as illustrated in Fig. 4. In the latter Figure we introduced the normalized emittances defined for relativistic beams as

B. Generation of stratified longitudinal phase spaces and train of microbunches
We first demonstrate the generation of a train of microbunches using an interceptive mask located upstream of emittance exchanger beamline. For these simulations the incoming Gaussian beam is intercepted by a 3 mm thick tungsten mask. The slits width is taken to be 100 µm and the edge-to-edge separation between the slits, δw, is variable. The simulations of the beam interaction with the mask, including scattering effects, is executed with shower [39] and the beam distribution downstream of the mask is then used in elegant to model the emittance exchanger beamline; see  A series of simulations were performed for three cases of incoming transverse-to-longitudinal emittance ratio ρ 0 . The horizontal C-S parameters were chosen for an optimum emittance exchange in accordance with Fig. 4 and the beam's Lorentz is γ = 30. The obtained current profiles were characterized by computing the modulation wavelength λ m , and the associated bunching factor and k m = 2π/λ m . The contrast ratio whereP ≡ max[P (z)] andP ≡ min[P (z)], was also calculated. The resulting values for λ m , b m and the corresponding contrast ratio χ m are presented in Figure 6. We also include the parameters computed after removal of the local correlations such to result in upright longitudinal trace space for the beamlets: the modulation wavelength λ M , associated bunching factor b M ≡ b ′ (k M ) (where k M ≡ 2π/λ M and b ′ is the bunching factor computed after the longitudinal phase space manipulation), and the contrast ratio χ M . When the final horizontal and longitudinal emittances are equal [(ε n x,0 , ε n z,0 )=(1,10) µm] or when the final longitudinal emittance is smaller than the horizontal one [(ε n x,0 , ε n z,0 )=(1,10) µm], a clear bunching is observed (for most of the cases b m > 0.1 and χ m 0.5). For the case when the final longitudinal emittance is larger [(ε n x,0 , ε n z,0 )=(10,1) µm], the bunching factor is small, i.e. b m 10 −2 but the longitudinal trace space is clearly stratified and the removal of the local correlations leads to strong bunching: the bunching factor becomes b M 0.5 and the contrast ratios for all cases are close to unity. The modulation wavelength for the considered cases was 0.1 ≤ λ m ≤ 0.2 mm and 0.035λ M ≤ 0.080 mm. In Section II, we briefly discussed the possible use of a properly designed dispersive section to remove the correlation and produce a train of microbunches. In fact, another scheme is to choose the proper initial horizontal C-S parameters upstream of the EEX beamline such that the final longitudinal trace spaces associated to each beamlet are uncorrelated downstream of the EEX beamline. For the sake of simplicity we consider a simple model for the EEX beamline where the deflecting cavity is described by its thin-lens approximation; see Eq. 4. Imposing the final longitudinal trace space associated to, e.g., the central beamlet to be uncorrelated ( zδ = 0) yields a condition between the beamlets horizontal C-S parameters (α s,0 and β s,0 ) upstream of the exchanger where ν ≡ (1 − η 2 )/(Lξ). For β s,0 to be real-positive the condition |α s,0 | > |1 + ν|/ √ ν needs to be fulfilled. Equation 20 represents a hyperbola in the (α s,0 , β s,0 ) space. The horizontal C-S parameters associated to a beamlet generated by intercepting a beam with initial parameters (α − , β − ) are α s,− = 0, β s,− = β − and the beamlet's emittance is ε s,− = w 2 /(12β − ) where w is the slit width. Therefore a set of quadrupoles would be needed between the mask and the EEX beamline to match the initial beamlet C-S parameters (α − , β − ) to the required values (α s,0 , β s,0 ) upstream of the EEX beamline. Doing so will also modify the C-S parameters of the entire beam and might result in a significant beam emittance dilution as discussed in Section III A. For the geometry considered in this paper (see Tab. I) and under the single-particle dynamics it is possible to tune the C-S parameters to get the beamlets' longitudinal trace space upright downstream of the EEX beamline without significantly diluting the emittances; see Fig. 7. In general, it is always possible to find a beamline configuration upstream of the EEX beamline to simultaneously provide upright trace space for the beamlets while matching the horizontal C-S parameters of the entire beam to values minimizing emittance dilution. This can be done by constructing a beamline that provides the following incoming beam parameter upstream of the slits: Therefore inserting the mask between two matching sections, each minimally composed of four quadrupoles, enables to control the beamlets longitudinal trace space correlation downstream of the EEX beamline while minimizing beam emittance dilution during transport through the EEX beamline.

C. Arbitrary current profiles
The generation of arbitrarily-shaped current profiles could be achieved using a mask technique as described in the previous section. As an illustrative example, we first consider the academic case of a transverse density following a uniform triangular distribution; see Fig. 8 (a). Such a distribution results in a linearly-ramped current profile downstream of the EEX beamline upon proper choice of C-S parameter; see Fig. 8 (d,e). The latter figure clearly demonstrates the inability of the pulse shaping technique to resolve the initial high-frequency features (in this case the hard edge associated to the triangular profile). As For realistic beams , a mask with suitable shape needs to be used. Taking the case of a initial Gaussian horizontal profile and imposing the horizontal profile downstream of the mask to be a linear function of z [P (x) ∝ x] results in the mask shape where g 0 and g 1 are constants that control the offset and steepness of the linear ramp. The mask profile along with the initial and final horizontal profiles are depicted in Fig. 9. For this particular case of an initial Gaussian distribution, only ∼ 19% of the incoming charge is transmitted through the mask thus making the masking technique highly inefficient. The case of an initial uniform circular distribution is more favorable but still results in excessive charge loss.
In principle any current profile can be synthesized with the proposed technique. The main disadvantage of using a mask being the substantial charge loss. An alternative method is to shape the beam using the technique discussed later in Section IV B.

IV. POSSIBLE APPLICATIONS IN LOW-ENERGY ACCELERATORS
In this Section we demonstrate, via start-to-end simulations, possible use of the current shaping technique described in this Paper. We use as a simulation platform the AWA facility shown in Fig. 10. The accelerator incorporates a photoemission source consisting of a 1+1/2 cell rf cavity operating at f = 1.3 GHz, henceforth referred to as rf gun. An ultraviolet (uv) laser beam impinges a magnesium photocathode located on the back plate of the rf gun half cell. The thereby photoemitted electron bunch exits from the rf gun with a maximum kinetic energy of approximately 8 MeV and is injected into a 10-cell standing wave normal conducting booster cavity operating on the π/2 mode at f = 1.3 GHz. The final beam energy can be up to ∼ 16 MeV. The rf gun is surrounded by three solenoidal magnetic lenses independently powered referred to as L1, L2 and L3; see Fig. 10.
The simulations of the EEX beamline presented in this Section were performed with the particle-in-cell (PIC) program impact-t which includes space charge effects by solving Poisson's equation in the bunch's rest frame using a three-dimensional quasi-static algorithm [40]. The deflecting mode cavity was simulated with microwavestudio R and the generated 3-D electromagnetic field maps were imported in impact-t; see Appendix A. The simulated magnetic field of the horizontally-bending rectangular dipoles was used to accurately model the dipoles in impact-t by representing the fringe field regions with eight-order Enge functions [41].

A. Terahertz radiation source
Terahertz (THz) radiation occupies a very large portion of the electromagnetic spectrum and has generated much recent interest due to its ability to penetrate deep into many organic materials without the damage associated with ionizing radiation such as x-rays. THz radiation is easily produced in laser-based method via optical rectification [42][43][44]. The radiation spectrum is generally broadband and the associated energy is of the order of nJ per pulse. Accelerator-based THz radiation sources present advantages in term of emitted power, frequency tunability and spectral bandwidth. The spectral fluence radiated by a bunch of N e electrons taken to follow a line-charge distribution is [45] dP where [ dP dωdΩ ] 1 is the single electron power density associated to the considered electromagnetic process and F (ω) ≡ |b(k = ω/c)| 2 is the bunch form factor (BFF). Considering a series of N b identical microbunches with normalized distribution Λ(t) we have S(t) = N −1 b N b n=1 Λ(t + nT ) (where T ≡ λ m /c is the period and λ m the density modulation wavelength defined earlier) giving |S(ω)| 2 = Ξ|Λ(ω)| 2 . The intra-bunch coherence factor Ξ ≡ N −2 b sin 2 (ωN b T /2)/[sin 2 (ωT /2)] describes the enhancement of radiation emission at resonance, i.e. for frequencies ω = 2πpc/λ m (where p is an integer).
In order to demonstrate the generation of a train of microbunch or modulated bunches using realistic distributions produced by a photoinjector, we modeled the AWA photoinjector from the photocathode up to downstream of the booster cavity with astra (up to z = 2.79 m in Fig. 10), a PIC program that incorporates a cylindricalsymmetric space charge algorithm [46]. The generated 1-nC bunch was collimated through a set of vertical slits thereby producing beamlets and its final horizontal C-S parameters upstream of the EEX beamline were matched to specific values using a set of four quadrupoles shown as Q1, Q2, Q3, and Q4 in Fig. 10. The tracking from z = 2.79 m up to z ≃ 6.4 m was performed with impact-t and includes space charge effects. The Nmacroparticles ensemble downstream of the EEX beamline was represented as a Klimontovich distribution along the longitudinal coordinate. The associated BFF is calculated as the summation Figure 11 depicts examples of modulated bunches (the charge is 300 pC downstream of the slits). The BFF associated are enhanced at the fundamental bunching and harmonic frequencies which can be varied by either changing the quadrupoles settings upstream of the EEX beamline or using different slits separations; see Fig.12. In this particular example the frequency can in principle be continuously varied from ∼ 0.6 to ∼ 2.2 THz (if we consider the fundamental bunching frequency only; higher frequencies can be obtained by proper filtering to select harmonics of the bunching frequency). We should note that the calculated BFF is representative of the radiation spectrum as long as the line charge distribution assumption is fulfilled, e.g. provided the longitudinal and transverse σ ⊥ rms bunch sizes satisfy σ z ≫ σ ⊥ /γ if the considered radiation process is transition radiation [47]. The generated train of microbunches can also be used to produce super-radiant undulator radiation [2].
FIG. 10: Overview of the photoinjector configuration used for realistic simulations of bunch shaping. The legend is "Di" dipole magnets, "Qi" quadrupole magnets, "Li" solenoidal lenses. The geometry of the EEX beamline is detailed in Table I. where δw and w are respectively the slit edge-to-edge separation and width in micrometers, and F is a scaling factor for the quadrupoles Q1, Q2, Q3, and Q4 (when F = 1 the quadrupoles are tuned to match the horizontal C-S parameter to (αx,0, βx,0) = (2, 12 m) upstream of the exchanger).

B. Ramped drive beams and bunch trains for beam-driven wakefield accelerators
Another application of pulse shaping we consider is the generation of beams with linearly-ramped current profiles. Ramped beams maximize the transformer ratio in collinear beam-driven acceleration schemes. A practical implementation using an intercepting mask seems highly inefficient as discussed in Section III C. Instead we explore the generation of such a beam by generating a beam with a suitable transverse distribution starting at The four traces correspond to four settings/configuration indicated in the legend as "δw − w − F" where δw and w are respectively the slit edge-to-edge separation and width in micrometers, and F is a scaling factor for the quadrupoles Q1, Q2, Q3, and Q4 (when F = 1 the quadrupoles are tuned to match the horizontal C-S parameter to (αx,0, βx,0) = (2, 12 m) upstream of the exchanger). the photocathode. Several types of distribution were considered for the initial laser transverse distribution and we found that a distribution with a dipole moment in provides the desired ramped horizontal profile upstream of the EEX beamline. We therefore consider laser transverse densities on the cathode described by [48] ρ(r, θ) where ρ 0 (r, θ) = 1 over a specified domain and 0 elsewhere, r c is the beam size on the photocathode, θ 0 is the initial rotation angle of the dipole pattern, and A is the amplitude of the perturbation. The symmetry axis of the laser distribution is rotated such that after propagation through the emittance-compensating solenoid the x − y coupling is removed. This is accomplished by choosing the rotation angle to be [49]: where B(r = 0, z) is the axial component of magnetic field experienced by the beam, γ the beam's Lorentz factor and β ≡ [1 − γ −2 ] 1/2 . Three types of distributions were considered: (1) an initial uniform triangle (ρ 0 = 1 inside a equilateral triangle and A = 0), (2) a circular distribution with a dipole moment (ρ 0 = 1 for r < r c and ∀θ and A = 1), and (3) a triangular-shaped distribution with a dipole moment (A = 1). For all cases the distribution on the cathode was centered w.r.t to its barycenter and the rms transverse sizes were forced to be 1 mm. These three types of distribution can be implemented using uv masks of variable transmission [50]. The laser density on the photocathode surface and the resulting 1-nC bunch at z = 2.79 m are shown in Fig. 13.  For the considered accelerator settings, the triangularshaped distribution with a dipole moment yields the best linearly-ramped horizontal profile that can be converted into a linearly-ramped current profile downstream of the EEX beamline as illustrated for a 1-nC bunch in Fig. 14.
The quadrupoles Q1, Q2, Q3, and Q4 were tuned to approximately provide C-S horizontal parameters upstream of the EEX beamline close to (2, 12 m) (the matching was done in the single-particle dynamics mode and the corresponding quadrupole settings were used in impact-t when tracking with space charge). The final normalized emittance partition (ε n x , ε n y , ε n z ) = (43.6, 5.8, 12.1) µm makes such a bunch suitable as a drive beam for beam-driven techniques based on asymmetric structures, e.g., dielectric slabs [51,52]. The final current distribution is used to estimate the achievable axial wakefield following Ref. [51]. We consider a slab structure with half gap a = 0.150 mm and dielectric thickness b − a = 0.150 mm We take the relative dielectric permittivity to be ǫ = 9.8 and compute the axial wakefield produced by the bunch as where is the Green's function for the i-th mode wakefield described by Eq. 2.6 in Ref. [51]. The indices i and j in the latter equation correspond respectively to the summations over the number of modes considered (we take n = 10) and the number of macroparticles (N = 2 × 10 5 ) representing the bunch (here we model the bunch as a Klimontovich distribution; see Eq. 24). The computed axial electric field is shown and compared with the electric field induced by a Gaussian beam with similar rms duration in Fig. 15 . The transformer ratio defined as the ratio of the maximum accelerating field to the maximum (in absolute value) decelerating field is found to be R ≃ 20.08/10.22 = 1.96 and R ≃ 22.05/6.13 = 3.60 for respectively the Gaussian and linearly-ramped bunch. If a round beam is desired downstream of the EEX beamline, the shaping technique would need to be combined with the flat beam technique [53,54].
Finally, a bunch with linearly-ramped horizontal profiles could also be intercepted with a series of slits to generate a train of bunch. This would result in a ramped bunch train and has application to resonantly excite wakefield in beam-driven acceleration schemes.

V. SUMMARY
We presented a general method for generating relativistic electron beams with arbitrary current profiles. The proposed method offers a very generic tool for precisely controlling the current distribution (and possibly the emittance partitions) to match the requirements imposed by the front end application. The technique takes advantage of the recently proposed transverse-to-longitudinal phase space exchange to map the horizontal profile associated to the electron bunch into its current profile. In principle any current profile can be produced by properly manipulating the bunch's transverse density to provide the desired horizontal profile upstream of the EEX beamline. We have considered special cases and showed how the method could be used to produce a train of microbunches with variable spacing and linearly-ramped bunch using start-to-end simulations of a realistic configuration in a ∼ 16 MeV photoinjector. The technique could also be applied to high-energy beams as discussed, for instance, in Ref. [55]. At high energies, the use of a thick mask to intercept the beam might be prohibited and instead a selection technique based on emittance spoiling using a thin foil might be preferable [56].
Note added in proof − Very recently an experiment conducted at the Fermilab's A0 photoinjector demonstrated some of the possibilities discussed in this paper [57] including the generation of a train of subpicosecond bunches with variable separation [58]. In this appendix we show that the transfer matrix of a deflecting cavity derived in Ref. [33] for an ideal pillbox cavity operating on the T M 110 accurately describes the matrix modeled numerically computed using the electromagnetic field obtained from microwave-studio R simulations.
FIG. 16: Geometry of the TM010-like deflecting mode cavity used for the simulation presented in this paper. The superimposed false-color pattern represents the value of the Ez field in the (x = 0, y, z) plane (the blue and red colors respectively correspond to the maximum and minimum values of the field).
We consider a cylindrical-symmetric pillbox cavity operating on the T M 110 at the zero-crossing phase. The corresponding electromagnetic field components in the paraxial approximation are given by E z (x, y, z, t) = E ′ 0 x cos(ωt) B y (x, y, z, t) = E ′ 0 ω sin(ωt), (29) where E ′ 0 ≡ ∂E x /∂x ≃ (2π/λ)E 0 (where E 0 is the peak electric field) and ω ≡ 2πf (f is the operating frequency). The thick-lens transfer matrix in (x, x ′ , z, δ) is given by Eq. 2 where κ ≡ 2π λ eE0 pc . The cavity used in our simulations is shown in Fig. 16. It operates at f = 1.3 GHz and consists of three cells of length (1/2 − 1 − 1/2) × λ/2. Two end pipes were added in the electromagnetic model to properly account for the fringe fields of the cavity.
Considering the cavity to consists of three uncoupled pillbox resonators of length λ/4, λ/2 and λ/4 we compute the transfer matrix to be where L c is the cavity length including the outer pipes; see Fig. 16.
To numerically evaluate the first order transfer matrix of the cavity, we track seven macroparticles in the cavity showed in Fig. 16. Six of the macroparticles are displaced by an infinitesimal small amount δX i with respect to the reference macroparticle along one of the phase space coordinates. This initial displacement is mapped downstream of the cavity as a displacement δX ′ j with respect to the final position of the reference macroparticle. The initial and final displacement are related via Inversion of the latter system of equations directly pro-vides the transfer matrix elements. The κ-dependent elements of the numericallycomputed transfer matrix are compared with those analytically calculated using Eq. 30 in Fig. 17. The agreement between the numerical and analytical models is excellent: the relative discrepancy is < 5% over κ ∈ [−5, 5] m −1 .