How dose the standard deviation of beam divergency work

Dear experts:
I am very confused about the standard deviation of the beam divergence angle. The beam divergence angle can be set using micro commands with the standard deviation:
/gps/ang/sigma_x DX
/gps/ang/sigma_y DY
In the Geant4 manual, it is described “Sets the standard deviation [default 0 rad] of beam directional profile in x-direction. The units can only be deg or rad.”

I found the implementation of those macro commands in the source code (In the G4SPSAngDistribution.cc, Geant4: G4SPSAngDistribution.cc Source File), and I got the following code:

Here two Gaussian angles are generated based on the input standard deviations. However, I cannot understand well why theta = sqrt(pxpx + pypy), and theta refers to which angle in the coordinate system, and why it satisfies this relationship with the angular deviations in the x and y directions?

I hope someone can provide an answer for me or offer some reference materials