as a function of pulse duration for a constant photon energy (8 keV) and constant beam intensity ($5\times10^{20}$ W cm$^{-2}$). We see in Fig. \[fig:selfgating\_SNR\](a) that the signal level at 0.15 nm resolution steadily rises until it plateaus at a maximum value at around 20 fs. The signal at lower resolution accumulates for longer pulse times. Interestingly the noise due to radiation damage also rises non-linearly, accumulating at slower rate at longer pulse times. This is because the random distribution of ions in the sample has smaller variation when the bound electrons are almost entirely depleted from each ion. The signal-to-noise ratios, shown in Fig. \[fig:selfgating\_SNR\](b), show strikingly that shot-noise has a much greater effect than damage noise. Although $SNR_D(q)$ improves greatly for short pulses ($<$5 fs), $SNR_{D+N}(q)$ maximizes when the signal $B(q)$ maximizes at around 20 fs.

The results are interesting when there is trade-off experimentally between pulse duration and pulse energy. For example, the LCLS can produce 2 mJ pulses with pulse durations of 30–50 fs for hard x-rays [@LCLS]. Sub 5 fs pulses can be produced by the LCLS using a low charge method or a slotted foil method, but at the expense of around a factor 