Adapted from the Matlab application by E. Prat.
The energy of the electron bunch is derived from two BPM (beam position monitor) readings in the beam dump (where the electrons are deflected vertically and we have dispersion). This is our measurement, essentially two scalars read out under two different conditions (lasing and no-lasing).
The no-lasing condition is achieved by detuning the undulators: we simply change the K values of adjacent undulators by alternating amounts positive and negative to completely avoid the build up of the FEL process (still some incoherent radiation but you have that also when lasing and it won't contribute to the FEL pulse).
The measurement consists of the following steps:
To have an idea of the stability, and to avoid outliers, the measurement is typically repeated a few times (the current default is five) and the results are averaged. We can also compare the two results from the two BPMs to check for systematic effects (broken BPM for instance).
In this application, the number of measurements is an adjustable parameter.