\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.
Curvature of the plates is modeled correctly. 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. 
 

\begin{figure}[tb]
 \begin{center}
    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/d1s2s3s4V1s2s3s4/efield-truth.pdf}
    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/d1a2s3a4V1s2a3a4/efield-truth.pdf}
    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/d1s2a3a4V1s2a3a4/efield-truth.pdf}
    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/d1a2s3a4V1a2s3a4/efield-truth.pdf}
    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/d1a2a3a4V1a2a3a4/efield-truth.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}


