A single spatial mode whose associated harmonic oscillator is in its $n$th excited state unambiguously contains $n$ photons? I am reading the introduction to the textbook The Quantum Theory of Light, third edition, by Louden. When discussing the photon, the author says the following:

The idea of the photon is most easily expressed for an electromagnetic field confined inside a closed optical resonator, or perfectly-reflecting cavity. The field excitations are then limited to an infinite discrete set of spatial modes determined by the boundary conditions at the cavity walls. The allowed standing-wave spatial variations of the electromagnetic field in the cavity are identical in the classical and quantum theories but the time dependences of each mode are governed by classical and quantum harmonic-oscillator equations, respectively. Unlike its classical counterpart, a quantum harmonic oscillator of angular frequency $\omega$ can only be excited by integer multiples of $\hbar \omega$, the integers $n$ being eigenvalues of the oscillator number operator. A single spatial mode whose associated harmonic oscillator is in its $n$th excited state unambiguously contains $n$ photons.

This part isn't clear to me:

A single spatial mode whose associated harmonic oscillator is in its $n$th excited state unambiguously contains $n$ photons.

Why does the single spatial mode unambiguously contain $n$ photons? This is my first exposure to quantum optics, so I would greatly appreciate it if people would please take the time to explain this.
 A: The idea of a photons dates back to 1905, when Einstein discussed the photo-electric effect. According to Einstein a photon is a quantised light package, and therefore an elementary excitation of the electromagnetic field. However, it is not immediately clear how we could formulate this conceptional idea mathematically.
The mathematical description of a photon becomes much simple if we consider an optical cavity (two mirror). The mirrors impose boundary conditions similar to the ones given by an oscillating string fixed at both ends: The allowed energies becomes quantised. The different oscillation "types" are called spatial modes:

The important point here is that each of these spatial modes can be  thought of being occupied by "excitations of the electromagnetic field", and that these excitations are well-defined mathematical quantities. E.g. let's consider only the fourth mode. We can think of it to be ...

*

*not excited at all, $|0\rangle_4$

*excited once, $|1\rangle_4$,

*excited twice, $|2\rangle_4$,

*...

According to Einstein the electromagnetic excitations are called photons.
A: Actually, this is the rigorous definition of a photon in quantum field theory: the excitation of a mode (or, in the langauge of the cited book, the excitation of a harmonic oscillator associated with the mode).
The problem with this definition is that it is at odds with more intuitive notions of a photon as a particle. These are not without their merits: e.g., one may claim that, due to the energy-time uncertainty relation
$$\Delta E \Delta t \geq \frac{\hbar}{2}$$
one can never have a mode with a well defined energy/number of excitations, and thus any electromagnetic excitation is a wave packet.
A: The Hamiltonian of the quantum harmonic oscillator is given by $$ H = (N+\frac{1}{2}) \hbar \omega$$ N corresponds to the number operator and its eigen values corresponds to number of photons in the cavity. The author has ignored the zero point energy which is quite common thing to do. Hence the Hamiltonian becomes $$H = N \hbar \omega $$ Now consider an eigenstate of $N$ having n photons with frequency $\omega$ denoted by $|n \rangle $
$$ H|n \rangle = n\hbar \omega | n \rangle $$
which gives the energy $n \hbar \omega$ hence it has $n$ photons.
