Quantum-mechanical description of optical beams