Pair Creation and Reference Frames Ok, so I have a question about an example problem in my textbook (its long but not difficult to follow. My question is at the bottom after I outline the problem). Consider the situation below in frame $S$. A gamma ray encounters an electron, disappears and creates an electron-positron pair, then the two electrons and single positron move off together with speed $u = 0.8c$

From conservation of energy and momentum:
$$E_i = E_{\gamma} + mc^2 = E_f$$
$$p_i = \frac{E_{\gamma}}{c} = p_f$$
Now consider a frame $S'$  that moves with speed $v = 0.8c$ so that the three particles after the pair creation are at rest. In this frame, we know that the invariant rest energy of the system equals the sum of the rest energies of the constituent particles since the particles are not moving relative to one another in $S'$. My book places a big emphasis on the fact that 
$$(mc^2)^2 = E^2 - (pc)^2$$
the rest energy in the above formula is not the sum of the rest energies of the particles that form the system. Only when the particles are not moving relative to one another (as in $S'$), can you say that $mc^2$  is $\Sigma_i = m_ic^2$.
Anyways, so in $S'$ after the pair creation, $mc^2 = 3mc^2$ since electrons and positrons have the same mass. My book then goes on to write,
$$(3mc^2)^2 = E^2 - (pc)^2 \\
9(mc^2)^2 = (E_{\gamma} + mc^2)^2 - (\frac{E_{\gamma}c}{c})^2$$
My Question: In the above formula, for $E$ we substituted $E_{\gamma} + mc^2$ from the conservation laws written earlier. However, this energy was determined in frame $S$. Why didn't my book use the transformation:
$$E' = \gamma(E - vp'_x)$$
Since we are in the $S'$ frame? I have the same question for momentum. Why didn't we use the Lorentz transformation for momentum?
By the way: This was a problem specifically looking at what the energy of the photon $E_{\gamma}$ has to be in order for this particular electron-positron pair to be created. However, my main problem is with the reference frames since summing the rest energies requires us to be in $S'$. Then, $E$ and $p$, in $(mc^2)^2 = E^2 - (pc)^2$ need to be the energy and momentum in $S'$ as well?
 A: The point your book is trying to make is that the magnitude squared of the momentum four vector is invariant under a Lorentz transformation.  In other words, it has the same value no matter what frame you're in.  I'm writing the momentum four vector as
$\left(E, pc\right)$, in this case since the y and z momenta are zero in both frames.  
Keeping in mind that Minkowski space time is hyperbolic we have to write down the squared magnitude of the vector as $\left\vert\mathbf P^2 \right\vert = E^2-p^2c^2$ instead of as $\left\vert\mathbf P^2 \right\vert = E^2+p^2c^2$.  In other words, the Pythagorean theorem for calculating magnitudes in hyperbolic space contains a difference of the square of the sides instead of the sum of the square of the sides it contains in Euclidean space.  This geometrically explains the minus in your formula above.
Now that we know the quantity is invariant with respect to the velocity of the frame, we choose the easiest two frames to calculate the necessary energy of the photon.  In the frame at rest with respect to the produced particles, we get $\left\vert\mathbf P^2 \right\vert = \left(3mc^2\right)^2$.  In the frame where the initial electron was at rest, we get, as you noted above, $\left\vert\mathbf P^2 \right\vert = \left(E_\gamma + mc^2\right)^2 - \left(\frac{E_\gamma c}{c}\right)^2$.  Setting these two terms equal to each other and solving for $E_\gamma$ gives $E_\gamma = 4mc^2$.
I don't have the book, but I believe the point of the exercise was to show that using the invariance of the momentum four vector results in an easier calculation, both conceptually and mathematically, compared to using the associated Lorentz transforms between frames.
