Real-time complex amplitude reconstruction method for beam quality M2 factor measurement.