Terahertz-based retrieval of the spectral phase and amplitude of ultrashort laser pulses