Derivation for number of photons assigned to to an electromagnetic field amplitude I am trying to understand a derivation concerning the number of photons 
 associated with an electromagnetic field which is irradiated on some probe. The point is to get a expression that connects the field amplitude of an laser field to the number of photons per frequency but some steps seem wrong to me. The derivation goes like this and follows closely the derivation given in the book Introduction to Quantum Mechanics A Time Dependent Perspective, Chapter 13.3.2:
The energy U of an electromagnetic E field in vacuum in cgs units is given by 
$$
U = \frac{1}{8\pi}\int |\vec E(t)|^2 +|\vec B(t)|^2 dV = \frac{1}{4\pi}\int |\vec E|^2(t)dV
$$
assuming that the B-Field term contributes the same Energy as the E-field term.
The Volume element is now rewritten as $V=Acdt$ where $A$ is an area, $c$ is the speed of light in vacuum and $t$ is a time, assuming that the field is constant on the surface A(t). We obtain
$$
U = \frac{1}{4\pi}\int |\vec E(t)|^2 Acdt.
$$
Now we invoke Parsevals Theorem to obtain
$$
U = \frac{1}{4\pi}\int |\vec {\tilde{E}}(\omega)|^2 Acd\omega.
$$
where $\vec {\tilde{E}}(\omega)$ is the Fourier transform of $\vec E(t)$. Now we compare this with another expression for the energy, based on the knowledge that one photon at frequency $\omega$ holds the energy $\hbar \omega$.
We get
$$U = \int N(\omega)\hbar \omega d\omega $$
where $N(\omega)$ is the number of photons at a given frequency. Comparing both integrals over the frequency gives the identity
$$
N(\omega)\hbar \omega= \frac{1}{4\pi}|\vec {\tilde{E}}(\omega)|^2 Ac
$$
$$N(\omega) =  \frac{1}{4\pi \hbar \omega}|\vec {\tilde{E}}(\omega)|^2 Ac$$
My problem is that the Volume integral change to a "time" integral is actually still an integral over the position, i.e. $z(t)=ct$. The volume element in cartesian coordinates is then $dxdydz\rightarrow dxdy \ cdt$. The electric field if written with with all coordinates should look like this
$\vec E(x,y,z,t')\rightarrow \vec E(x,y,ct,t')$. The problem is now that the fouriert transform over $t$ is not the same as the fourier transform over $t'$. It holds only for a single plane wave of the type $\vec E(r,t)=E_0 \cos(\omega t - \vec k \cdot \vec r)$ in my opinion. 
This is where i need help. Is the derivation valid for other electromagnetic fields or only for single frequency fields ?   
 A: This derivation certainly assumes a plane wave. In general, the expression for the energy (in vacuum so $|\vec{E}|=|\vec{B}|$) would be an integral
\begin{equation}
U = \frac{1}{4\pi} \int {\rm d}V |\vec{E}(x,y,z,t)|^2
\end{equation}
and you would not be able to do the integrals over $x$ and $y$ to get a factor of the area $A$ trivially. However, physically this assumption seems fine, since you are interested in lasers; generating a plane wave with a single frequency is pretty much the point of a laser.
Still you might be interested, in a more general context, how to relate the number of photons per unit frequency, with the classical electromagnetic field. This is typically done via the spectral intensity $I_\omega$, which is the energy per unit area per unit frequency, averaged over time.
The total energy can be written in terms of the intensity as
\begin{equation}
U = \int {\rm d} \omega {\rm d} A I_\omega
\end{equation}
Matching with the expression you gave for the energy in terms of the number of photons
\begin{equation}
U = \int {\rm d} \omega \hbar \omega N(\omega)
\end{equation}
we find
\begin{equation}
N(\omega) = \frac{1}{\hbar \omega} \int {\rm d} A I_\omega
\end{equation}
For a plane wave, the spectral intensity is $I_\omega=c |\vec{\tilde{E}}(\omega)|^2/4\pi$, and thus we recover the result you have derived for $N(\omega)$. (Actually there's no magic here, you can interpret what you wrote as a derivation of $I_\omega$ for a plane wave). If you have "nice" boundary conditions (eg if your area is a plane), then knowing how to compute the intensity for a plane wave is enough, since you can simply add the intensities for each mode.
Finally, a word of caution. While we can associate the intensity of the electromagnetic field (roughly, the amplitude of the field) with a number of photons, we can't say that the field configuration is made of a given number $N$ of photons. The reason is that there is an uncertainty principle relating the phase of the field and the number of photons. Therefore if we know the number of photons exactly, we can't know the phase of the field, and vice versa. In practical/experimental terms, you will find that laser light at a given frequency has an associated shot noise, due to Poisson fluctuations in the number of photons.
