Optimization of the focal volume in programmable spatial beam shaping