Formation of Temporally Shaped Electron Bunches for Beam-Driven Collinear Wakeﬁeld Accelerators

Beam-driven collinear wakeﬁeld accelerators (CWAs) that operate by using slow-wave structures or plasmas hold great promise toward reducing the size of contemporary accelerators. Sustainable acceleration of charged particles to high energies in the CWA relies on using ﬁeld-generating relativistic electron bunches with a highly asymmetric peak current proﬁle and a large energy chirp. A new approach to obtaining such bunches has been proposed and illustrated with the accelerator design supported by particle tracking simulations. It has been shown that the required particle distribution in the longitudinal phase space can be obtained without collimators, giving CWAs an opportunity for employment in applications requiring a high repetition rate of operation.


I. INTRODUCTION
In a beam-based collinear wakefield accelerator (CWA), a high-charge drive bunch generates an electromagnetic field passing through a slow-wave structure (a dielectric-lined or corrugated waveguide) or plasma. This field, called the wakefield, is used to accelerate a witness bunch propagating the structure in the same direction behind the drive bunch [1][2][3][4][5][6][7][8]. An important figure of merit for a CWA is the transformer ratio, R ≡ |E + /E − |, where E + is the maximum accelerating field behind the drive bunch, and E − is the maximum decelerating field within the drive bunch. For symmetric drive-bunch current distribution in time I(t), the transformer ratio is limited to R < 2 [9]. However, asymmetric I(t) can significantly enhance the transformer ratio [9], albeit at the expense of reduced E + and E − [10].
Bunch-shaping techniques investigated hitherto are photocathode-laser intensity shaping [11][12][13], transverseto-longitudinal phase-space exchange [14][15][16], and use of multi-frequency linacs [17]. Despite significant progress, they suffer either from their inability to deliver highly asymmetric bunches or from prohibitively large beam losses on collimators. Consequently, producing drive bunches with an asymmetric peak current profile while preserving most of the bunch electrons has been an active research topic.
Another important consideration for a drive bunch arises from its proneness to the transverse beam-break-up (BBU) instability caused by the strong transverse forces due to the transverse wakefield [18][19][20]. A possible BBUmitigation technique consists of imparting a large energy chirp along the drive bunch [21][22][23] and creating a current profile I(t) that stimulates a dynamic adjustment of this chirp concurrently with the wakefield-induced bunch * wtan1@niu.edu deceleration in the CWA [24].
The work reported in this paper was motivated by a design of a high repetition rate CWA for use in a freeelectron laser (FEL) facility described in Refs. [25,26]. This facility plans to employ up to ten FELs individually driven by a dedicated CWA. A single conventional accelerator delivers ∼ 1 GeV drive electron bunches with a highly asymmetric I(t) and a large energy chirp to the ten CWAs. Since the drive-bunch charge considered in [25,26] is up to 10 nC and the bunch repetition rate up to 500 kHz, the electron beam carries significant power. Therefore, using collimators to assist with the bunch shaping is prohibitive, and, consequently, preparing the drive bunches doing otherwise becomes a prime challenge.
To solve the problem, we undertook a new approach and distributed the task of obtaining the highly asymmetric I(t) over the entire drive bunch accelerator beginning from the photocathode electron gun and ending by the final bunch compressor. To the best of our knowledge, our work demonstrates for the first time a pathway to obtaining electron bunches with a highly asymmetric I(t), avoiding prohibitively large electron losses on collimators. The employed technique is rather generic and can be used for preparing the electron bunch peak current distribution with profiles different than those considered in this paper.
Although the main focus of the work was to obtain a drive bunch with the required distribution in the longitudinal phase space (LPS), an equally important additional objective, was to ensure the associated transverse emittances commensurate with the small CWA aperture.

II. THE DRIVE BUNCH AND THE WAKEFIELD
We define the longitudinal charge distribution in the electron bunch as q(z) and consider bunches localized on  [30]. The transformer ratio for the modified doorstep distribution shown in the plot is R = 5.6. the interval 0 ≤ z ≤ L, where z is the distance behind the bunch head. Therefore, we have where Q is the total bunch charge. Following [10], we use the Green's function G(z) consisting only of a fundamental mode G(z) = 2κ cos (kz)H(z) 1 , where κ is the loss factor of a point particle per unit length, k = 2π/λ is the wave vector, λ is the wavelength, H(z) is the Heaviside step function. The longitudinal electric field within the electron bunch can be written as [27,28] which is a Volterra equation of the first kind for the function q(z) with the trigonometric kernel cos [k(z − z)]. If we assume that E − (0) = 0 at the bunch head, then the solution of Eq. (2) is given by [29], where E − (z) is a known function, and its derivative is taken over z. Hence, q(z) is defined. In order to maintain the stability of the drive bunch in the CWA throughout its deceleration, we require the bunch's relative chirp to be constant while being decelerated by the wakefield E − (z), based on studies in [24]. This requirement is achieved by having a small linear variation in energy loss within the bunch, where head particles lose more energies than tail particles such that where E 0 (s) is the energy of the reference particle, and s is the distance propagated by the bunch in the CWA. This is accomplished by using the electron bunch producing E − with a linear variation in z. Similar to Ref. [9], we solve Eq. (3) considering q(z) to be constant in the range 0 ≤ z < ξ with ξ = 1 k arccos(χ/k), in which case the continuities of E − (z) and E − (z) are preserved over the entire bunch length Setting χ = 0, simplifies q(z) to one used in [9]. Figure 1 shows an example of a modified doorstep distribution with an associated wakefield calculated using L = λ and χ = − 1 10λ . In this example we considered a corrugated waveguide with radius a=1 mm and fundamental mode frequency f = 180 GHz, as discussed in Ref. [31]. The current profile has sharp features that are challenging to realize. Consequently, the distribution defined by Eq. (5) 1 It has been shown in [10] that a multi-mode Green's function is less effective in producing a high transformer ratio.
is used only as a starting point to construct a practically realizable distribution shown in Fig. 2 with similar final properties listed in Table I.

A. Basic considerations
A block diagram of the drive bunch accelerator is shown in Fig. 3. It utilizes a commonly used con-   [32,33]) and includes a photocathode-gun-based injector, three linac sections, and two bunch compressors. Linac sections L1 and L2 are based on 650 MHz superconducting (SRF) linac structures, and linac section L39 is based on 3.9 GHz SRF structures. It is used for linearization of the electron distribution in the longitudinal phase space (LPS). Two bunch compressors are labeled as BC1 and BC2. Here we take advantage of the requirement to prepare the drive bunch with the energy chirp seen in Fig. 2(b) and move BC2 to the end of the linac, since we do not need to use the linac to remove the energy chirp after bunch compression. Using the known LPS distribution Φ f (z f , E f ) at the end of the accelerator, we performed the one-dimensional (1D) backward tracking proposed in [11] to find the LPS distribution Φ i (z i , E i ) at the entrance of L1. We stopped at L1 where the beam energy is approximately 50 MeV considering that 1D tracking may not be reliable at lower energies where transverse and longitudinal space charge effects are stronger. The assumption is that at this point the backward tracking will produce a plausible Φ i (z i , E i ) that can be matched by the injector. Specifically, we constrained the peak current to I ≤ 300 A and sought Φ i (z i , E i ) with minimal high-order correlations.
A tracking program, twice [34], was developed for rapid prototyping of the longitudinal dynamics in the linac without accounting for a transverse motion. The program adopts an approach similar to that used in LiTrack [35]. An important feature of twice is its ability to perform backward tracking including time-reversal of the collective effect, see Appendix A.
The physics model implemented in twice includes the geometric wakefields in the accelerating sections, longitudinal space charge effects (LSCs), and coherent synchrotron radiation (CSR). The Green's functions needed for modeling of the geometric wakefield effects in the 650 MHz and 3.9 GHz linac sections were computed using the echo software and the empirical formula documented in Ref. [36].
The backward tracking was performed to define Fig. 2. The following constraints for the accelerator components were observed. First, the BBU-mitigation scheme implemented in the CWA requires a drive bunch with the negative chirp ∂E ∂z < 0, which implies that the longitudinal dispersions of BC1 and BC2 should be R 56 > 0, as we want to maintain a negative chirp throughout the entire accelerator. Second, a total energy gain of ∼950 MeV in the linac part after the injector is needed. Third, an overall compression factor of ∼ 10 is required from two bunch compressors.
In order to enforce all these constraints, twice was combined with the multi-objective optimization framework deap [37]. The optimization was performed by analyzing the LPS distributions upstream of BC1 and L1 to extract the central energy of the beam slices at every z-coordinate and to fit the slice-energy dependence on z with the polynomial where c i are constants derived from the fit. The optimizer was requested to minimize the ratio c 2 /c 1 in both locations.

B. Discussion of 1D simulation results
A list of optimized accelerator settings found with twice backward tracking is given in Table II and the Fig. 4(a,b). The forward tracking using this distribution recovers Φ f (z f , E f ), as seen in Fig. 4(c,d). The excellent agreement between Fig. 2(a,b) and Fig. 4(c,d) demonstrates the ability of twice to properly handle collective effects in both forward and backward tracking.
Each accelerator component serves a special role in obtaining the above-shown result. Linac section L1 provides energy gain and operates far from the crest acceleration to produce the required negative chirp. Linac section L39 corrects a second-order correlation between E and z imprinted on the bunch by the injector and L1   before it enters BC1. Linac section L2 operates even further off-crest to impart the necessary large chirp required for maintaining beam stability in the CWA. Both bunch compressors shorten the bunch lengths and impact the LPS distributions. The values of T 566 selected in both bunch compressors ensure achieving Φ f (z f , E f ) despite the large energy chirp. The use of a negative T 566 in BC1 and a positive T 566 in BC2 enables the generation of a doorstep-like initial distribution without giving rise to a current spike, where T 566 has the effect of shifting the peak of current [38,39]. In this paper, we adopt the convention that T 566 with a negative (resp. positive) sign shifts the peak of current distribution to the tail (resp. head). The result of the backward-tracking optimization provides only a starting point for obtaining a more realistic solution. For instance, the zigzag feature observed in the tail of the LPS distribution in Fig. 4(b) is challenging to create. In the following sections, we discuss how 1D backward tracking results guide the design of a photocathode-gun-based injector and the downstream accelerator lattice.

IV. INJECTOR DESIGN
Given the required initial LPS distribution obtained from the backward tracking, the next step is to explore whether such LPS distribution is achievable downstream of the injector; our approach relies on temporally shaping the photocathode laser pulse [40].
The injector beamline was modeled using the particlein-cell beam-dynamics program astra, which includes a quasi-static space-charge algorithm [41]. The program was combined with the deap multivariate optimization framework to find a possible injector configuration and the laser pulse shape that realize the desired final bunch distribution while minimizing the transverse-emittance downstream of the photoinjector.
The injector configuration consists of a 200 MHz quarter-wave SRF gun [42][43][44], coupled to a 650 MHz accelerator module composed of five 5-cell SRF cavities [45]. The gun includes a high-T c superconducting solenoid [46] for emittance control.
In the absence of collective effects, the photoemitted electron-bunch distribution mirrors the laser pulse distribution. In practice, image-charge and space-charge effects are substantial during the emission process and distort the electron bunch distribution. Consequently, devising laser-pulse distributions that compensate for the introduced deformities is critical to the generation of bunches with tailored current profiles. The laser pulse distribution is characterized by I(t, r) = Λ(t)R(r), where Λ(t) and R(r) describe the laser temporal profile and the transverse envelope, respectively. In our simulation, we assumed the transverse distribution to be radially uniform R(r) = H(r c − r), where H(r c − r) is Heaviside step function and r c is the maximum radius. The temporal profile is parameterized as where A is the normalization constant; and a, b c, d, f , g, and h are the parameters controlling the bunch shape. resembles a smoothed version of the door-step distribution. The laser-shape parameters introduced in Eq. (7), the laser spot size, the phase and accelerating voltage of all RF cavities, and the HTS solenoid peak magnetic field were taken as control parameters for the optimization algorithm. The beam kinetic energy was constrained not to exceed 60 MeV. In order to quantify the final distribution, we used the Wasserstein's distance [47] to quantify how close the shape of the simulated macroparticle distribution at the injector exit I (o) (z) was to the shape of the target macroparticle density distributions I (t) (z) obtained from backward tracking results. Specifically, the Wasserstein's distance is evaluated as where are the corresponding histograms of the macroparticles' longitudinal positions over the interval being the longitudinal bin size and N b the number of bins used to compute the histogram. Additionally, we need to have a small beam transverse emittance. Hence, the Wasserstein's distance and the beam transverse emittance were used as our objective functions to be minimized.
An example of the optimized injector settings is summarized in Table III, and the evolution of the associated  Fig. 6. The beam transverse phase space indicates some halo population. Ultimately, an alternative laser-shaping approach implementing a spatiotemporal-tailoring scheme could provide better control over the transverse emittance while producing the required shaped electron beams [40]. We also find, as depicted in Fig. 6, that the current distribution tends to have a peak current lower than that desired from the backward tracking result shown in Fig. 4. Although higher currents are possible, they come at the expense of transverse emittance. Consequently, the distribution generated from the injector was considered as an input to the one-dimensional forward tracking simulations. Iterations of one-dimensional forward tracking simulation studies were done to further cross-check accelerator parameters needed for the beam-shaping process. We especially found that the desired final bunch shape at 1 GeV can be recovered by altering the L39 phase and amplitude. Furthermore, the small slice rms energy spread σ E < 10 keV simulated from the injector [see Fig. 4(b)] renders the bunch prone to microbunching instability. Consequently, a laser heater is required to increase the uncorrelated energy spread.
The correspondingly revised diagram of the accelerator beamline shown in Fig. 8 was used as a starting point to investigate the performance of the proposed bunchshaping process with elegant tracking simulations taking into account the transverse beam dynamics.
Another challenge associated with the bunch formation pertains to the temporal resolution of the bunch shaping process. Ultimately, the laser pulse shape can only be controlled on a time scale δt ≥ 1/(2πδf L ) limited by the bandwidth of the photocathode laser δf L . Contemporary laser systems are capable to δt ≤ 150 fs (RMS) [48]. Additionally, the electron bunch shape is also affected by the time response of the photoemission process. Given the required charge of ∼10 nC, we consider a Cs 2 Te photocathode with temporal response numerically investigated in Ref. [49,50]. Recent measurements confirm that Cs 2 Te has a photoemission response time below 370 fs [51]. Figure 5 compares the optimized ideal laser pulse shape described by Eq. (7) with the cases when the photocathode response time and the laser finite bandwidth are taken into account. The added effects have an insignificant impact on the final distribution due to relatively slow temporal variations in the required peak current distribution.

V. FINAL ACCELERATOR DESIGN
The strawman accelerator design developed with the help of 1D simulations provides guidance for the final design of the accelerator. project [52]. The linac L1 consists of two cryomodules, and L2 has eight cryomodules. Each cryomodule includes six cavities containing five cells. We assume that in CW operation each cavity provides up to 20 MV/m average accelerating gradients. The quadrupole magnet doublets are located between cryomodules and produce a pseudoperiodic oscillation of the betatron functions. The two cavities used in the 3.9 GHz L39 SRF linac are similar to the cavity described in Ref. [36]. b. Bunch compressors: We use an arc-shaped bunch compressor consisting of a series of FODO cells, where each cell contains two quadrupoles and two dipole magnets. The latter configuration nominally provides a positive R 56 [53][54][55][56] where θ total is the total bending angle, L total is the total path length, N cell is the total number of FODO cells, and ψ x is the horizontal phase advance per cell. The dipole magnet bending angles can be used to tune the R 56 . The bending angle or dipole polarity from cell to cell does not need to be identical, but the number of cells should be selected to realize a phase advance ψ x,total = 2nπ (with n integer) over the compressor to achieve the first-order achromat.
The second-order longitudinal dispersion produced by the bunch compressor is given by [57,58] where L is the length of the beamline, ρ is the bending radius, η 1,x (s) ≡ (E 0 2 /2)∂ 2 x(s)/∂E 2 is the second-order horizontal dispersion function, and η x (s) is the derivative of the dispersion function. We incorporate 12 sextupole magnets to control the T 566 and 12 octupole magnets to cancel the third-order longitudinal transfer-map element U 5666 computed over BC1. If needed, a non-vanishing value of U 5666 can enable higher-order control over the LPS correlation [38].
The sextupole and octupole magnets are also used to zero the chromatic transfer-map elements T 166 , T 266 , and U 1666 , resulting in the bunch compressors being achromatic up to the third order. Figure 9 displays the BC1 configuration along with the evolution of the betatron functions and relevant horizontal chromatic (η x , η 1,x , and η 2,x ) and longitudinal accumulated transfer-map elements (R 0→s 56 , T 0→s 566 , and U 0→s 5666 ) up to third order as a function of the beamline coordinate s. It has two arcs, one bending the beam trajectory by 22.92 • and another one bending it back. Each bending magnet has the bending angle θ = 2.865 • . This design eases the requirement on the sextupole-magnet strength required to provide a T 566 < 0; see Table II. The strengths of the sextupole magnets were optimized using elegant to achieve the required T 566 across BC1 while obtaining a second-order achromat by constraining T 166 = T 266 = 0. The three pairs of sextupole magnets in the second arc are mirror-symmetric to the first three pairs, with opposite-polarity magnet strengths. During the design process, the first pair of sextupole magnets was inserted close to the region of the first arc with the highest dispersion for tuning the desired T 566 ; its mirror symmetry pair was placed in the second arc and separated by 2π phase advance. Another two pairs of sextupole magnets were subsequently inserted for tuning T 166 . Similarly, their mirror symmetry pairs were separated by 2π phase advance. Finally, six pairs of octupole magnets were inserted to zero the overall U i666 i = 1, 2, 5 transfer-map elements, where the same design process was employed. The BC2 compressor requires both R 56 and T 566 to be positive, which is naturally provided by the arc bunch compressor introduced earlier. It has a total bending angle of 32.63°, and each dipole has a bending angle of 4.079°. Similar to BC1, we used sextupole-and octupole-magnet families to adjust both T 566 and U 5666 and produce the third-order achromat. The BC2 lattice appears in Fig. 10 along with the evolution of the betatron functions and relevant chromatic elements. Finally, the layout of the two bunch compressors is presented in Fig. 11. c. Matching sections: All accelerator components are connected using matching sections composed of quadrupole magnets and drift spaces.
The evolution of the betatron functions from the injector exit up to the end of BC2 appears in Fig. 12. Throughout the entire accelerator, the betatron functions are maintained to values β x,y < 30 m.

B. Tracking and optimization
The beam distribution obtained at the exit of the injector was used as input to elegant for tracking and optimization. We found that we need to increase the slice energy spread to ∼ 75 keV using the laser heater  to suppress the microbunching instability [59,60]. However, in this study, we numerically added random noise with Gaussian distribution to the macroparticles' energy using the scatter element available in elegant. Thus, Fig. 13 shows the actual LPS distribution used at the beginning of the accelerator in tracking studies. The accelerator settings obtained with twice were used as a starting point in the accelerator optimization including transverse effects. The fine-tuning of the abovedescribed accelerator components was accomplished using elegant. A multi-objective optimization was applied to determine the twelve accelerator parameters controlling the longitudinal dynamics, i.e., voltages and phases of L1, L2, L39, and values of R 56 , T 566 in two bunch compressors. The resulting beam distribution obtained downstream of BC2 was then used to compute the wakefield generated in a 180 GHz corrugated waveguide considered for the role of the wakefield accelerator in [31]. The resulting peak accelerating field and transformer ratio were then adopted as objective functions to be maximized with the accelerator parameters as control variables. The trade-off between peak accelerating field and transformer ratio was quantified in Eq. (30) of Ref. [10], hence providing a good measure to verify whether our optimization reaches the optimal Pareto front. The op-  Table IV. The LPS distribution at the end of the accelerator is shown in Fig. 14. We also calculated that the ∼ 1 GeV, 10 nC electron bunch having this distribution produces a peak wakefield of 94.26 MV/m with a transformer ratio of 5 propagating in a corrugated waveguide. Figure 15 demonstrates that our optimiza-  Figure 13. Current profile (a) and associated LPS (b) distributions simulated with Astra at the end of the photoinjector (see Fig. 6) with added uncorrelated fraction energy spread following a Gaussian distribution with RMS spread σE/E = 1.5 × 10 −3 . In plot (b) the red trace represents the slice RMS energy spread σE. tion has reached the optimal set of solutions, where the Pareto front closely follows the analytically calculated tradeoff curve [10]. The obtained current profile produces a wakefield amplitude ∼ 15% lower than the one expected from the ideal distribution for a transformer ratio R 5. Such an agreement gives confidence in our optimization approach based on the trade-off between peak accelerating field and transformer ratio. The simulations also indicate that the horizontal transverse emittance increases to ε nx = 31µm due to the CSR and chromatic aberrations in the electron bunch having large correlated energy variations. Although significant, this emittance dilution is still acceptable.
Our main result is shown in Fig. 16. It compares the final distribution and wakefield with that of the target distribution and wakefield from Fig. 2. A good agreement manifests that, indeed, the drive electron bunch with a highly asymmetric peak current profile can be obtained without employing the collimators.
A comparison of Tables III and IV indicates that  final accelerator settings optimized by elegant deviate less than 10% from those obtained with twice. It justifies the strategy taken in this study to solve the difficult problem of formation of temporally shaped electron bunches for a beam-driven collinear wakefield accelerator in two steps.
The nonlinear correlation observed in the tail of the LPS distribution downstream of BC2 [see Fig. 14(b, blue trace)] originates from the CSR. As the beam is compressed inside the bunch compressors, its tail experiences a stronger CSR force due to its peak current being higher than the rest of the bunch. It is worth noting that elegant uses a 1D projected model to treat the CSR effect. The applicability of such a 1D treatment is conditioned by the Derbenev's criterion [61], which suggests that projecting the bunch distribution onto a line-charge distribution may overestimate the CSR force, particularly when the bunch has a large transverse-to-longitudinal aspect ratio A(s) ≡ (σ x (s)/σ z (s)) (σ x (s)/ρ(s)). In our design, the condition A 1 was not rigorously followed (but rather the softer condition A < 1 was achieved), suggesting that the impact of CSR may be overestimated in some regions of the bunch compressors.
We also note that the final beam distribution exhibits significant longitudinal-horizontal (z−x) correlations due to CSR effects; see Fig. 17. Although the associated projected-emittance dilution is tolerable, the electrons in the longitudinal slices with the horizontal offsets seen in Fig. 17(c) will excite transverse wakefields in the CWA and ultimately seed the BBU instability. These offsets come from CSR-induced energy loss occurring in the BC2  Figure 15. Comparison of the Pareto front with the analytical trade-off curve between the peak field and transformer ratio described by Eq. (30) of Ref. [10]. Each blue dot represents a numerically simulated configuration with the red star representing the configuration with parameters listed in Table IV.

C. Impact of errors
In order to validate the robustness of the proposed design, it is instructive to investigate the sensitivity of the proposed shaping technique to shot-to-shot jitters of the amplitude and phase of the accelerating field in the linac's structures. Consistent with LCLS-II specifications [62], we considered the relative RMS amplitude jitter of 0.01% and the phase jitter of 0.01 degree. For simplicity, we assume that the injector produced identical bunches, as shown in Fig. 6, and performed 100 simulations of the accelerator beamline (from the injector exit to the exit of BC2) for different random realizations of the phase and amplitude for linacs L1, L2, and L39. The errors in linac settings were randomly generated using Gaussian probability function with standard deviations of 0.01% and 0.01 • . Figure 18 presents the wakefield averaged over the 100 simulations and indicates that a stable transformer ratio 5.00 ± 0.05 can be maintained owing to the stable beam produced in the superconducting linac.
Likewise, we observe the impact of charge fluctuation on the shaping to be tolerable. Cathode-to-end simulations combining astra and elegant indicate that a relative charge variation of +2% (resp. -2%) yields a relative change in the transformer ratio of -2% (resp. +1%) and

VI. SUMMARY
We have presented the design of an accelerator capable of generating 1 GeV electron bunches with a highly asymmetric peak current profile and a large energy chirp required for a collinear wakefield accelerator. It has been achieved without the use of collimators. Our approach is based on ab-initio temporal shaping of the photocathode laser pulse followed by nonlinear manipulations of the electron distribution in the longitudinal phase space throughout the accelerator using collective effects and precision control of the longitudinal dispersion in two bunch compressors up to the third order. Finding the optimal design consisted of first implementing a simpli-fied accelerator model and using it for backward tracking of the longitudinal phase space distribution of electrons through the main accelerator to provide the longitudinal phase space distribution required from the injector. The program twice was developed to support such a capability and used to optimize the global linac parameters and time-of-flight properties of bunch compressors. Second, the simulation of the photo-injector using astra was performed to generate the required distribution. Third, the linac design was refined using elegant to account for the transverse beam dynamics. Finally, formation of longitudinally shaped drive bunches capable of producing in the collinear wakefield accelerator a transformer ratio of ∼ 5 and a peak accelerating wakefield close to 100 MV/m has been numerically demonstrated.
Although the proposed accelerator design is promising, we note that further work is required to investigate whether the same accelerator can accelerate the lowcharge, low-emittance "witness bunches" that would be accelerated to multi-GeV energies in the collinear wakefield accelerator and used for the generation of x-rays in the downstream free-electron laser. Discussion of this research is the subject of a forthcoming publication.
(RF) linac is given by where V , k, and ϕ are, respectively, the accelerating voltage, wave-vector amplitude, and off-crest phase associated with the accelerating section, and e is the electronic charge. In the latter and following equations the ± sign indicates the forward (+) and backward (-) tracking process detailed in Sec. A 0 c. Similarly, the transformation through a longitudinally dispersive section, such as a bunch compressor, is given by where E 0 is the reference-particle energy assumed to remain constant during the transformation, and R 56 ≡ E 0 are the first-and secondorder longitudinal-dispersion functions introduced by the beamline. It should be noted that, given our LPS coordinate conventions, a conventional four-bend "chicane" magnetic bunch compressor has a longitudinal dispersion R 56 > 0. The latter equation ignores energy loss, e.g., due to incoherent synchrotron radiation, occurring in the beamline magnets.

b. Collective effects
In twice, we implemented collective effects as an energy kick approximation using the transformation where ∆E(z) represents the energy change associated with the considered collective effect. The treatment of collective effects is modeled as a z-dependent energy kick ∆E(z) taken downstream of beamline elements as specified for the forward and backward tracking with the diagram shown in Fig. 20. The implemented collective effects include wakefields modeled after a usersupplied Green's function, one-dimensional steady-state coherent synchrotron radiation (CSR), and longitudinal space charge (LSC) described via an impedance. The collective effects require the estimation of the beam's charge density, which is done in twice either using a standard histogram binning method with noise filtering or via the kernel-density estimation technique [63].
In order to model the impact of a wakefield, the charge distribution q(z) is directly used to compute the wake potential given a tabulated Green's function  Figure 20. Treatment of collective effects as energy kicks downstream of beamline elements. In forward (resp. backward) tracking, transformations of beamline elements (resp. energy kicks) were applied, followed by energy kicks (resp. beamline elements).
The change in energy is computed as ∆E(z) = LW (z), where L is the effective length where the beam experiences the wakefield.
The LSC is implemented using a one-dimensional model detailed in [64], where the impedance per unit length is where ξ b ≡ kr b /γ; I 1 and K 1 are modified Bessel functions of the first and second kind, respectively; and k, Z 0 and r b are, respectively, the wave-vector amplitude, impedance of free space and a user-defined transverse beam radius, and γ is the Lorentz factor. Given the charge density, the Fourier-transformed current densitỹ I(k) is derived fromĨ with F representing the Fourier transform. The change in energy is computed as where F −1 is the inverse Fourier transform, and L is the effective distance along which the LSC interaction occurs. In order to account for LSC during acceleration, γ is replaced by the geometry average √ γ i γ f of the Lorentz factors computed at the entrance γ i and exit γ f of the linac section. Finally, CSR energy kicks are applied downstream of the dispersive beamline elements. For instance, a CSR energy kick can be applied after a dispersive element with user-defined length and angle described by R 56 and T 566 . The effect of CSR is described using a one-dimensional model commonly implemented in other beam-dynamics program [65]. To simplify the calculation, only the steady-state CSR is considered in twice. The energy loss associated with CSR is obtained from [ with the integral kernel defined as I csr (z, z ) = 4u(u 2 + 8) (u 2 + 4)(u 2 + 12) , where θ is the angle, m e c 2 is the electron rest mass energy, r e is the classical electron radius and the variable u is the solution of γ 3 (z−z ) ρ = u 3 24 + u 2 . CSR introduces an energy loss strongly dependent on the bunch length, which varies within the dispersive sections used to compress the bunch. Consequently, the longitudinally dispersive beamlines are segmented into several elements with individual (R 56 , T 566 ) parameters. A CSR kick is ap-plied after each of the elements. A conventional chicanetype bunch compressor is usually broken into two sections (two mirror-symmetric doglegs) but can in principle be divided into an arbitrary number of segments to improve the resolution at the expense of computational time.

c. Backward tracking
An important feature of twice is its capability to track the beam in the forward or backward directions (indicated by the ± sign in Eqs. (A2) and (A3)) in the presence of collective effects [so far LSC, CSR, and wakefield effects are included]. The effects of LSC and wakefield are straightforward to implement as they only involve a change in energy, while handling of the CSR requires extra care since the particles' positions also change throughout the dispersive section. Therefore, an energy kick is applied after the beamline element in the forward-tracking mode and before the beamline element in backward-tracking mode, as shown in Fig. 20. Although the treatment of CSR is not exact, it nonetheless provides a good starting point to account for the effect.