\section*{Simulation of Efield and pitch contributions to $\omega_a$}

\begin{figure}[tb]
 \begin{center}
    \includegraphics*[width=0.8\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/QuadPlateMisalignment.pdf}
\caption{Quad plate voltage and alignment errors}
 \label{fg:QuadPlateMisalignment}
 \end{center}
 \end{figure}

In simulation, the electric field of each of the quad plates (inner, bottom, outer, top) is based on a field map.
The map for each plate is computed with OPERA, holding the other three plates at zero potential. The field of the
quadrupole is then a simple superposition of the four maps. The maps that are implemented in the code are 2D azimuthal slices of the full 3D map and
includes the curvature of the plates. End fringe fields are neglected. 

As indicated in Fig. ~\ref{fg:QuadPlateMisalignment}, the quad plates can be displaced and/or voltage errors introduced on each plate.
We explore the dependence of the contribution of the electric field, and pitch to $\omega_a$ on these alignment and field errors.

\begin{enumerate}
\item Implement the quad plate offsets and voltage errors in the BMAD model
\item Create a 'realistic' distribution
\item Track  the distribution through the injection channel and into the ring.
\item Track each muon until it decays.
\item For each muon
{\begin{itemize}
\item Integrate $\vec\beta\times \vec E$ along the trajectory to determine the electric field contribution to $\omega_a$
\item Integrate $(1-|\beta\times \vec B|)$ along the trajectory to determine the contribution from pitch
\item Compute radial closed orbit  $<x_e>$
\end{itemize}}
\item Use the 'measured' radial and vertical coordinates (positions and times) at the decay point to compute the betatron tunes for the distribution.
\item Use the 'measured' vertical coordinate (positions) at  the decay point to determine vertical distribution
\end{enumerate} The alignment of the plates is measured with an uncertainty of less than $\pm 1$mm. The uncertainty in voltage is estimated to be within $\pm$5\%.
A particular set of alignment and field errors defines a configuration. For each of the four plates there are two possible displacement errors ($\pm 1$mm),
and two possible voltage errors $\pm 0.05\% V$, for a total of $N_Q=2^8=256$ configurations for a single quad. 
Each configuration corresponds to a maximum set of misalignments and field errors.
There are eight quadrupoles and therefore $N_T=(2^8)^8$ configurations for all quads. There is significant repetition due to the geometric periodicity, but even so
there are far too many independent configurations to consider. In order to identify a managable number of configurations, each of the 256 permutations of the
alignment and voltage errors of the plates in quad Q2, Q3 and Q4 are correlated with errors in Q1, according to five distinct rules, as detailed in Figure~\ref{fg:configs}.

We compute the corrections for electric field and pitch for 1024 configurations. For each configuration, a distribution of muons is injected into the storage ring and each muon
tracked until it decays. The contributions to spin precession frequency from electric field and pitch are computed for each muon by integration along the trajectory, allowing calculation of the
average for the distribution, that is the truth. The 'measured' vertical distribution and vertical betatron frequency are then substituted into 
Equation~\ref{eq:pitchlinear} to give the 'measured' pitch contribution. The measurement of the time dependence of the vertical position with the trackers provides that data 
in the experiment. The 'measured' momentum distribution and horizontal betatron tune are substituted into Equation~\ref{eq:efieldlinear} to give the 'measured' electric field contribution.
The fast rotation analysis described above provides the momentum distribution and horizontal tune.
Finally, the 'measured' corrections are compared to the truth for each of the configurations.

 
 
\begin{figure}
\begin{center}
    \includegraphics*[width=0.8\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/d1s2s3s4V1s2s3s4/relative_quad_plate_voltage.pdf}
    \includegraphics*[width=0.8\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/d1s2a3a4V1s2a3a4/relative_quad_plate_voltage.pdf}
    \includegraphics*[width=0.8\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/d1a2s3a4V1a2s3a4/relative_quad_plate_voltage.pdf}
    \includegraphics*[width=0.8\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/d1a2s3a4V1s2a3a4/relative_quad_plate_voltage.pdf}
   \includegraphics*[width=0.8\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/d1a2a3a4V1a2a3a4/relative_quad_plate_voltage.pdf}
\end{center}
\caption{Alignment and voltage errors on the plates in quads Q2,Q3 and Q4 are correlated to the errors in Q1 as indicated in the sketch. (a) The plates on all of the
quads share the offsets and voltage errors of the plates in Q1.(b) The offsets and voltage errors on the plates in Q2 are the same as in Q1. The errors on the plates
in Q3 and Q4 are opposite to those in Q1. (c) Errors in Q1 are reproduced in Q3 and with opposte sign in Q2 and Q4. (d) The offsets in Q1 are reproduced in Q3 and
opposite in Q2 and Q4. The voltage errors in Q1 are reproduced in Q2 and opposite in Q3 and Q4. (e) The errors on Q2,Q3 and Q4 are all opposite errors those in Q1.}   
\label{fg:configs}
\end{figure}

The systematic contribution to the measured spin precession frequency due to the electric field for each of the 1024 configurations of quad plate misalignments and voltage errors
is shown in Figure~\ref{fg:efield_truth} and for the pitching vertical motion in Figure~\ref{eq:pitch_truth}. The quad plate misalignments and voltage errors do indeed
alter the corrections. 
Those same misalignments and voltage errors similarly alter the momentum distribution, the vertical distribution and the betatron tunes which are the basis of the 'measured' corrections.
It is the difference between the true correction and the measured correction that ultimately limits our estimate. That difference is shown in
Figures~\ref{fg:efield_truth_linear} and ~\ref{eq:pitch_truth_linear} for the electric field and pitch respectively.


\begin{figure}
 \begin{minipage}[c]{0.45\linewidth}
    \includegraphics*[width=\linewidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/all_permutations/efield_truth_all.pdf}
\caption{Distribution of contribution of electric field to $\omega_a$ for four distinct sets of permuatations}
 \label{fg:efield_truth}
 \end{minipage}
\hfill
\begin{minipage}[c]{0.45\linewidth}
    \includegraphics*[width=\linewidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/all_permutations/pitch_truth_all.pdf}
\caption{Distribution of contribution of electric field to $\omega_a$ for four distinct sets of permuatations}
 \label{fg:pitch_truth}
 \end{minipage}
 \end{figure}

\begin{figure}
 \begin{minipage}[c]{0.45\linewidth}
    \includegraphics*[width=\linewidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/all_permutations/efield_truth_linear_all.pdf}
\caption{The difference between the true contribution from the electric field and the 'measured' contribution for 1024 configurations}
 \label{fg:efield_truth_linear}
 \end{minipage}
\hfill
 \begin{minipage}[c]{0.45\linewidth}
    \includegraphics*[width=\linewidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/all_permutations/pitch_truth_linear_all.pdf}
\caption{The difference between the true pitch contribution and the 'measurement' for 1024 configurations.}
 \label{fg:pitch_truth_linear}
\end{minipage}
 \end{figure}

\begin{figure}[tb]
 \begin{center}
    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/d1s2s3s4V1s2s3s4/efield_truth_linear.pdf}
    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/d1a2s3a4V1s2a3a4/efield_truth_linear.pdf}
    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/d1s2a3a4V1s2a3a4/efield_truth_linear.pdf}
    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/d1a2s3a4V1a2s3a4/efield_truth_linear.pdf}
    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/d1a2a3a4V1a2a3a4/efield_truth_linear.pdf}
\caption{Distribution of contribution of electric field to $\omega_a$ for four distinct sets of permuatations }
 \label{fg:d1s2s3s4V1s2s3s4}
 \end{center}
 \end{figure}


%\begin{figure}[tb]
% \begin{center}
%    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/d1s2s3s4V1s2s3s4/pitch-truth.pdf}
%    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/d1a2s3a4V1s2a3a4/pitch-truth.pdf}
%    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/d1s2a3a4V1s2a3a4/pitch-truth.pdf}
%    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/d1a2s3a4V1a2s3a4/pitch-truth.pdf}
%    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/d1a2a3a4V1a2a3a4/pitch-truth.pdf}
%\caption{Distribution of contribution from pitch to $\omega_a$ for four distinct sets of permulations. }
% \label{fg:d1s2s3s4V1s2s3s4}
% \end{center}
% \end{figure}

%\begin{figure}[tb]
% \begin{center}
%    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/all_permutations/efield-truth.pdf}
%    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/all_permutations/pitch-truth.pdf}
%    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/all_permutations/efield_convolve-truth.pdf}
%    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/all_permutations/efield_linear-truth.pdf}
%    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/all_permutations/pitch_linear-truth.pdf}
%    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/all_permutations/index-effective.pdf}
%\caption{Distribution of contribution from pitch to $\omega_a$ for all permutations. }
% \label{fg:allpermuatations}
% \end{center}
% \end{figure}

We assign a systematic uncertainty of $\sigma_p = 1.3$ppb, (namely the width of the distribution in Fig.~\ref{fg:pitch_truth_linear} to the measurement of the contribution from pitching motion due to misalignment and voltage errors of the quad plates. The distribution of the 'measurement' errors of the electric field contribution 
is non gaussian and the standard deviation may underestimate the uncertainty. Indeed we find that the error distribution has a strong dependence on the
nature of the misalignment/field error correlation configuration. The distributions for each of the five correlation types are shown
in Figure~\ref{fg:d1s2s3s4V1s2s3s4}. The systematic uncertainty in the measurement of the contribution from the electric field due
to field errors and misalginment is chosen to be the width of distribution for correlation type (a) errors, $\sigma_E=8.7$ppb. 
