## 3 Electron Beam Transport for Ideal Magnetic Elements  
The electron beam transport is modeled up to the second order with BETA [84], where using a multiparticle tracking code, based on sympletic mapping, the electron beam is tracked in a 6D phase space which describes position, momenta, and energy at any location along the line. The product of the different matrix elements of the line (drift, quadrupole, dipole, etc.) by a particle array gives the 6D phase space of the particle [72]. The code was benchmarked on COXINEL with ASTRA [73; 85], ELEGANT [86], and OCELOT [87]. The distribution of electron charge versus energy and the vertical divergence per energy slice are extracted and used as initial beam parameters for the transport code. \begin{table}
\begin{tabular}{c|c c c c|c c c c c} \hline  & \multicolumn{4}{c|}{**High Skew Term Case**} & \multicolumn{4}{c}{**Low Skew Term Case**} \\ \hline
**Magnetic Length** & \(\mathbf{a_{2}}\) & \(\mathbf{a_{6}}\) & \(\mathbf{b_{2}}\) & \(\mathbf{b_{6}}\) & **Angle (mrad)** & \(\mathbf{a_{2}}\) & \(\mathbf{a_{6}}\) & \(\mathbf{b_{2}}\) & \(\mathbf{b_{6}}\) & **Angle (mrad)** \\ \hline
26 mm & 0.073 & \(-\)0.003 & 10.951 & 0.192 & 3.3 & \(-\)0.007 & \(-\)0.01 & 10.947 & 0.186 & \(-\)0.3 \\ \hline
40.7 mm & \(-\)0.325 & \(-\)0.017 & 17.475 & 0.326 & \(-\)9 & 0.027 & \(-\)0 & 17.448 & 0.329 & 0.7 \\ \hline
44.7 mm & 0.362 & 0.012 & \(-\)19.181 & \(-\)0.363 & \(-\)9 & 0.003 & \(-\)0.004 & \(-\)19.148 & \(-\)0.357 & 0.05 \\ \hline \end{tabular}
\end{table} 
Table 2: Multipolar terms before (high skew terms case) and after (low skew terms case) correction. Figure 4: Skew quadrupolar term (\(a_{2}\)) measured with the stretched wire, before (\(\circ\)) and after (\(\bullet\)) correction, for the QUAPEVA triplet: 26 mm (**left**), 40.7 mm (**middle**), and 44.7 mm (**right**), \(r_{0}=4\) mm. Figure 3: (a) QUAPEVA magnetic design with different orientation of the cylindrical magnets: maximum (**left**), intermediate (**middle**), minimum gradient (**right**). (b) Mechanical shims applied to one of the QUAPEVAs to compensate for the skew terms. Transport simulations were tested with \(\epsilon_{x,i}\),\(\epsilon_{z,i}\) = 0.5 mm.mrad and \(\epsilon_{x,i}\),\(\epsilon_{z,i}\) = 1 mm.mrad, and the variations of the beam parameters are close to the simulations variations as well as for \(\sigma_{s,i}\) = 0.5 \(\upmu\)m and \(\sigma_{s,i}\) = 5 \(\upmu\)m.  
Figure 5 shows the optics configurations (Figure 5a-d) and the associated beam transverse shape observed on the screen located at the entrance, center, and exit of the undulator (Figure 5a-d3). The envelope is modeled using a 176 \(\pm\) 0.3 MeV flat-top energy distribution electron beam with \(\sigma^{\prime}_{z,i}\) = 2 mrad (RMS) and \(\sigma^{\prime}_{x,i}\) = 3.12 mrad (RMS), while the transverse shape on the screens is simulated for the low divergence beam case (see Figure 2, Table 1) and the magnetic elements settings given in Table 3. In Figure 5a (\"undulator\" optics), the focus is set for both axes in the undulator, while in Figure 5b (\"slit-undulator\" optics), the beam is first focused horizontally onto a slit and then both vertically and horizontally focused on the undulator center. In Figure 5c (\"undulator-entrance\" optics), the focus is set onto the screen located at the undulator entrance (the associated transverse distribution exhibits a tiny spot there, while the beam size increases at the undulator exit). In Figure 5d (\"undulator-exit\" optics), the beam is well focused at the exit of the undulator. Figure 5e presents the vertical aperture along the trasport line: 10 mm in the QUAPEVAs, 20 mm in the vacuum pipe, 5 mm in the undulator.