Optical spectroscopy of (001) GaAs and AlAs under molecular-beam epitaxy growth conditions