a, b, Start-to-end simulation for horizontal and vertical envelopes of the electron beam along the beamline with a beam energy of 475 MeV (blue), 490 MeV (red) and 505 MeV (black). c–e, Measured transverse profiles of the electron beam at the entrance of the undulator located 4-m downstream from the gas target without (c) and with (d) focusing and at the exit of the undulator located 9.5-m downstream from the gas target (e). With the quadrupoles installed, the measured r.m.s. size of the electron beam was reduced from approximately 0.8 mm to a minimum value of less than 0.1 mm in the horizontal and vertical directions. f–h, Shot-to-shot pointing distribution over 50 shots (f), and beam size statistics in the horizontal (g) and vertical (h) directions. The relative positions of the quadrupoles (green) and undulators (cyan) are shown in a and b.