laser pulses and, consequently the electron beam microbunching, are always characterized by phase variations in time and space (wavefront distortions). We will therefore extend analytical description of EEHG scheme in [@EEHG2], following the line of derivations in that reference, to the time dependent case and account for finite duration and transverse size of the electron bunch.

To this aim, we assume that the temporal profile of the electron beam can be modeled as a Gaussian, and that the initial electron beam distribution can be factorized as a product of energy, $f_{0p}(p)$, and density, $f_{0\zeta}(\zeta)$ distributions as

$$\begin{aligned}
f_0(\zeta,p)= f_{0p}(p) f_{0\zeta}(\zeta) = \frac{N_0}{2\pi
\sigma_\zeta} \exp\left[-\frac{p^2}{2}-\frac{\zeta^2}{2
\sigma_\zeta^2}\right]~. \label{f0new}\end{aligned}$$

Here $p=(E-E_0)/\sigma_E$ is the dimensionless energy deviation of a particle from the average energy $E_0$, and the rms spread is given by $\sigma_E$. Similarly, $\zeta = \omega_l t$ is the dimensionless time, with $\omega_l$ the laser frequency, assumed to be the same in both stages, and $\sigma_\zeta$ is the rms spread of the density distribution. Finally $N_0$ is the total number of particles in the beam. The longitudinal phase space is described by the variables $(\zeta,p)$. Passing through the first modulator and dispersive section the phase space variables transform to $(\zeta',p')$, which are given 