Self-modulation of a relativistic charged-particle beam as thermal matter wave envelope