Suppose we have computed the beam moment matrix $\Sigma_{ij}(s)$ around the ring.

Consider the normalized spatial distribution in $(x,y)$:

If we define the matrix

(2)the exponential could be written as

(3)with $\vec X = \pmatrix{x\cr y}$. Now, we have (see here for a reference)

(4)with

(5)We can thus derive that

(6)We have a family of ellipses, now, and we'd like to choose one to represent the electron beam.

Perhaps we may use

where the particle density has dropped by a factor of $\frac{1}{e}$

This is an ellipse with a rotation angle $\theta$ satisfying

(8)The equation for the ellipse may also be written in terms of the moments as

(9)First we find the positions we want to plot at:

dr278=findcells(ring_err,'FamName','DR_278….')

Then we can use the function

plotContours(ring,dr278(1:2:end))