\section{Introduction}
The trajectory of the injected beam through the fringe fields of the
ring magnet and inflector is computed. Transfer matrices about the
trajectory that can be used to propagate $\beta-$ functions are
calculated by tracking.
The results presented here are an updated and corrected vertsion of
those in GM2-doc-1109-v2. The net horizontal bend is 24.6 mrad. The field maps are symmetric about the horizontal midplane. 
The horizontal magnetic field is zero by symmetry and there is no vertical bend.

%---------------------------------------------------------------------------
\section{Magnetic Field}
\label{s:magneticfield}

The magnetic field is given by field tables provided by Wuzeng. There
is a map (calculated) along the 4.395m path beginning 30 cm upstream of the outer
surface of the backleg iron, then passing through the hole in the iron, between
the outer coils and into the gap where the field is at the nomnal
1.45T. The axis of the map is collinear with the axis of the inflector (this needs to be checked. There may be a 2.4 mrad angle between inflector axis and tangent line.)
and therefore parallel to the tangent to the ideal orbit in the
ring. It is displaced 77mm from the tangent. In addition there is map
of the field in the inflector. We here track through the summed fields
of the two maps. The $\vec B$-field along the trajectory is shown in
Figure \ref{f:bfieldy}. 
 
\begin{figure}[tb]
 \begin{center}
    \includegraphics*[width=0.45\textwidth,angle=0]{/Users/dlr10/lepp/g-2/magneticfield/bfield_along_injection_axis.pdf}
    \includegraphics*[width=0.45\textwidth,angle=0]{/Users/dlr10/lepp/g-2/magneticfield/bfield_total_along_injection_axis.pdf}
\caption[Magnetic field along injection line]
 {
(Left)Vertical component of the magnetic field along the trajectory through the hole
in the backleg iron, between the inner coils, through the fringe field
and finally along the axis of the inflector to the gap.(Right) Sum of inflector field and dipole fringe field.
 }
 \label{f:bfieldy}
 \end{center}
 \end{figure}

%---------------------------------------------------------------------------
\section{Trajectory}
The trajectory is determined by integrating
through the fields using the BMAD\footnote{http://www.lepp.cornell.edu/~dcs/bmad/} code, and is shown in Figure \ref{f:trajectory}. In order
to clear the narrow aperture of the inflector, the beam enters
displaced horizontally 5.5 cm from the center of the hole and at an angle of
-24.6mrad with respect to the axis of the hole. The beam enters the
hole from 1.5 cm vertically below the center line at an upward angle
of 9 mrad. As can be seen in the Figure, fine tuning will be required
to center the beam on axis of the inflector. The total change in
horizontal and vertical angles from entering the hole to exiting the
inflector is 24.6 mrad horizontally.
  

\begin{figure}[tb]
\begin{center}
        \includegraphics*[width=0.7\textwidth,angle=0]{/Users/dlr10/lepp/g-2/magneticfield/trajectoryAndField20140707.pdf}
\caption[Injection trajectory]
{
Trajectory throught the magnetic field in \ref{f:bfieldy}.
The fringe field steers the beam (horizontally) towards the center of the ring by an
angle of 24.6 mrad. Here the beam is injected into the hole displaced
-5.5cm from the center with an angle of 24.6 mrad so that it will make
it through the 1.7m long inflector $\pm 9$mm horizontal aperture.}

\label{f:trajectory}
\end{center}
\end{figure}
%-------------------------------------------
\section{Transfer Matrices}
The linear map (transfer matrix) through the injection channel is
computed by tracking. (See for example GM2-doc-1109-v2.) The matrix that propagates the phase space
coordinates from the entrance in the iron through to the upstream end
of the
inflector is given in Equation \ref{eq:hole}. The matrix is based on
the field map <injec\_fld.dat>. The length of this ``element'' is 2.6m. 

\begin{eqnarray}
\vec x_{inflector} &=&M_{hole} \vec x_{entrance}\nonumber\\ \\
\begin{pmatrix} x\\ x^\prime \\ y \\ y^\prime \\l \end{pmatrix}_{inflector}
&=&\begin{pmatrix}
    1.24519 &  2.91325  &-0.11429&  -0.10574  & 0.00000 &  0.00470 \\
    0.08750 &  1.00372 & -0.04997 & -0.06431  & 0.00000  &-0.00193 \\
   -0.05971&   0.00112  & 0.78390 &  2.26523   &0.00000  & 0.00260  \\
   -0.05689&  -0.11585 & -0.35097&   0.23381 &  0.00000  &-0.00073\\
    0.00275&   0.01028 & -0.00088   &0.00147 &  1.00000   &0.00021  \\
\end{pmatrix}
\begin{pmatrix} x\\ x^\prime \\ y \\ y^\prime
  \\l\end{pmatrix}_{entrance}\label{eq:hole}
\end{eqnarray}
The two-by-two blocks correspond to horizontal and vertical
transport. It is evident on inspection that the matrices will horizontally defocus and
vertically focus as the $R_{2,1} > 0$ and $R_{3,4}< 0$. 
For the purposes of propagating twiss parameters and tracking with
garden variety magnetic optics codes, it is
convenient to identify a beam line constructed from standard optical
elements (quadrupoles, drifts, etc.) that has equivalent transfer
matrix.
For example,
drift-quadrupole-drift equivalent for $M_{hole}$ is
\begin{eqnarray}
M_{hole}&=& D(l^{hole}_1) Q(l^{hole}_q,k^{hole})  D(l^{hole}_2)\label{eq:hole}
\end{eqnarray}
 
Similarly, the matrix through the 1.7m long inflector (see Figure \ref{f.bfieldy})
\begin{eqnarray}
M_{inf}&=&\begin{pmatrix}
    1.90994 &  1.80371 &  0.02445 &  0.07657   &0.00000  &-0.01638\\
    0.69276 &  1.16911  &-0.03162 & -0.01965  & 0.00000 & -0.00006\\
   -0.26773&  -0.05969  & 0.22587 &  1.42829  & 0.00000  & 0.00672  \\
   -0.20778 & -0.07260  &-0.50334  & 0.78289  & 0.00000 &  0.00012 \\
   -0.01001 & -0.01721 & -0.00325  & 0.00475 &  1.00000 &  0.00019 \\
\end{pmatrix}
\end{eqnarray}
and
\begin{equation}
M_{inf} = D(l^{inf}_1)Q(l^{inf}_q,k^{inf})D(l^{inf}_2)
\end{equation}\label{eq:inf}

The last 0.095m of the channel corresponds to the main bending field
and is given by

\begin{eqnarray}
M_{exit} &=& \begin{pmatrix}
    1.90994&   1.80371  & 0.02445 &  0.07657   &0.00000  &-0.01638 \\
    0.69276  & 1.16911  &-0.03162 & -0.01965  & 0.00000 & -0.00006\\
   -0.26773 & -0.05969 &  0.22587 &  1.42829  & 0.00000  & 0.00672 \\
   -0.20778 & -0.07260 & -0.50334  & 0.78289  & 0.00000 &  0.00012\\
   -0.01001 & -0.01721&  -0.00325  & 0.00475  & 1.00000 &  0.00019\\
\end{pmatrix}\\
&=& D(l^{end}_1)Q(l^{end}_q,k^{end})D(l^{end}_2)\label{eq:end}
\end{eqnarray}

A summary of drift lengths, and lengths and strengths of quadrupoles
for the beam line equivalents is given in Table \ref{t:ql}.
\begin{table}[htdp]
\caption{Drift lengths, and quad lengths and strengths of for
  transport equivalent to matrices $M_{hole}$ (Equation
  \ref{eq:hole}), $M_{inf}$ (Equation \ref{eq:inf}) and $M_{end}$
  (Equation \ref{eq:end}).}
\begin{center}
\begin{tabular}{|c|c|c|c|c|}
\hline
Element & $l_1$[m]&$ l_q$[m] & k [m$^{-2}$] & $l_2$[m]\\ \hline
hole &  & & & \\
inflector& & & & \\
end& & & & \\ \hline
\end{tabular}
\end{center}
\label{t:ql}
\end{table}%

Finally, the transfer matrix through the 4.395 m long injection
channel is given by
\begin{eqnarray}
M&=& M_{end}M_{inf}M_{hole}
\end{eqnarray} 
