Optical shaping of plasma cavity for controlled laser wakefield acceleration