[4] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
---|
| 2 | "http://www.w3.org/TR/REC-html40/loose.dtd"> |
---|
| 3 | <html> |
---|
| 4 | <head> |
---|
| 5 | <title>Description of linepass1turn</title> |
---|
| 6 | <meta name="keywords" content="linepass1turn"> |
---|
| 7 | <meta name="description" content="LINEPASS1TURN - Track particle forward or backwards in one turn of the ring"> |
---|
| 8 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
| 9 | <meta name="generator" content="m2html © 2003 Guillaume Flandin"> |
---|
| 10 | <meta name="robots" content="index, follow"> |
---|
| 11 | <link type="text/css" rel="stylesheet" href="../m2html.css"> |
---|
| 12 | </head> |
---|
| 13 | <body> |
---|
| 14 | <a name="_top"></a> |
---|
| 15 | <div><a href="../index.html">Home</a> > <a href="index.html">at</a> > linepass1turn.m</div> |
---|
| 16 | |
---|
| 17 | <!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td> |
---|
| 18 | <td align="right"><a href="index.html">Index for at <img alt=">" border="0" src="../right.png"></a></td></tr></table>--> |
---|
| 19 | |
---|
| 20 | <h1>linepass1turn |
---|
| 21 | </h1> |
---|
| 22 | |
---|
| 23 | <h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
| 24 | <div class="box"><strong>LINEPASS1TURN - Track particle forward or backwards in one turn of the ring</strong></div> |
---|
| 25 | |
---|
| 26 | <h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
| 27 | <div class="box"><strong>function [x, ATindex, LostBeam] = linepass1turn(x0, Family0, DeviceList0, Family, DeviceList) </strong></div> |
---|
| 28 | |
---|
| 29 | <h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
| 30 | <div class="fragment"><pre class="comment">LINEPASS1TURN - Track particle forward or backwards in one turn of the ring |
---|
| 31 | [x, ATIndex] = linepass1turn(x0, Family, DeviceList) |
---|
| 32 | [x, ATIndex] = linepass1turn(x0, ATIndex) |
---|
| 33 | |
---|
| 34 | INPUTS |
---|
| 35 | 1. x0 - 6-component column vector {Default: [.001 0 .001 0 0]'} |
---|
| 36 | Initial particle launch condition at the start of the ring (see ringpass) |
---|
| 37 | AT units are meters & radians. |
---|
| 38 | 2. Location to measure turns: Family / DeviceList {Default: 'BPMx'} |
---|
| 39 | or |
---|
| 40 | ATIndex |
---|
| 41 | |
---|
| 42 | NOTE: Family can be a MiddlyLayer family or AT family. |
---|
| 43 | If using at AT family, then DeviceList is an index array (see family2atindex). |
---|
| 44 | |
---|
| 45 | OUTPUTS |
---|
| 46 | 1. x - Single turn data (6 x BPM Number) |
---|
| 47 | 2. ATIndex - AT index vector |
---|
| 48 | |
---|
| 49 | EXAMPLES |
---|
| 50 | 1. Get the starting coordinates for a kick at HCM[7 1] |
---|
| 51 | x = linepass1turn([.001 0 .001 0 0 0]', HCM, [7 1], 1); |
---|
| 52 | |
---|
| 53 | See also <a href="getturns.html" class="code" title="function [xAllBPMs, ATindex, LostBeam] = getturns(x0, N, Family, DeviceList)">getturns</a> |
---|
| 54 | |
---|
| 55 | Note: this function is still under development!!! |
---|
| 56 | |
---|
| 57 | Written by Greg Portmann</pre></div> |
---|
| 58 | |
---|
| 59 | <!-- crossreference --> |
---|
| 60 | <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
| 61 | This function calls: |
---|
| 62 | <ul style="list-style-image:url(../matlabicon.gif)"> |
---|
| 63 | <li><a href="family2atindex.html" class="code" title="function [ATIndexList, ErrorFlag] = family2atindex(Family, varargin);">family2atindex</a> FAMILY2ATINDEX - Returns the AT index for a given family</li></ul> |
---|
| 64 | This function is called by: |
---|
| 65 | <ul style="list-style-image:url(../matlabicon.gif)"> |
---|
| 66 | </ul> |
---|
| 67 | <!-- crossreference --> |
---|
| 68 | |
---|
| 69 | |
---|
| 70 | <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
| 71 | <div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [x, ATindex, LostBeam] = linepass1turn(x0, Family0, DeviceList0, Family, DeviceList)</a> |
---|
| 72 | 0002 <span class="comment">%LINEPASS1TURN - Track particle forward or backwards in one turn of the ring</span> |
---|
| 73 | 0003 <span class="comment">% [x, ATIndex] = linepass1turn(x0, Family, DeviceList)</span> |
---|
| 74 | 0004 <span class="comment">% [x, ATIndex] = linepass1turn(x0, ATIndex)</span> |
---|
| 75 | 0005 <span class="comment">%</span> |
---|
| 76 | 0006 <span class="comment">% INPUTS</span> |
---|
| 77 | 0007 <span class="comment">% 1. x0 - 6-component column vector {Default: [.001 0 .001 0 0]'}</span> |
---|
| 78 | 0008 <span class="comment">% Initial particle launch condition at the start of the ring (see ringpass)</span> |
---|
| 79 | 0009 <span class="comment">% AT units are meters & radians.</span> |
---|
| 80 | 0010 <span class="comment">% 2. Location to measure turns: Family / DeviceList {Default: 'BPMx'}</span> |
---|
| 81 | 0011 <span class="comment">% or</span> |
---|
| 82 | 0012 <span class="comment">% ATIndex</span> |
---|
| 83 | 0013 <span class="comment">%</span> |
---|
| 84 | 0014 <span class="comment">% NOTE: Family can be a MiddlyLayer family or AT family.</span> |
---|
| 85 | 0015 <span class="comment">% If using at AT family, then DeviceList is an index array (see family2atindex).</span> |
---|
| 86 | 0016 <span class="comment">%</span> |
---|
| 87 | 0017 <span class="comment">% OUTPUTS</span> |
---|
| 88 | 0018 <span class="comment">% 1. x - Single turn data (6 x BPM Number)</span> |
---|
| 89 | 0019 <span class="comment">% 2. ATIndex - AT index vector</span> |
---|
| 90 | 0020 <span class="comment">%</span> |
---|
| 91 | 0021 <span class="comment">% EXAMPLES</span> |
---|
| 92 | 0022 <span class="comment">% 1. Get the starting coordinates for a kick at HCM[7 1]</span> |
---|
| 93 | 0023 <span class="comment">% x = linepass1turn([.001 0 .001 0 0 0]', HCM, [7 1], 1);</span> |
---|
| 94 | 0024 <span class="comment">%</span> |
---|
| 95 | 0025 <span class="comment">% See also getturns</span> |
---|
| 96 | 0026 <span class="comment">%</span> |
---|
| 97 | 0027 <span class="comment">% Note: this function is still under development!!!</span> |
---|
| 98 | 0028 <span class="comment">%</span> |
---|
| 99 | 0029 <span class="comment">% Written by Greg Portmann</span> |
---|
| 100 | 0030 |
---|
| 101 | 0031 |
---|
| 102 | 0032 <span class="keyword">global</span> THERING |
---|
| 103 | 0033 <span class="keyword">if</span> isempty(THERING) |
---|
| 104 | 0034 error(<span class="string">'THERING is not defined.'</span>); |
---|
| 105 | 0035 <span class="keyword">end</span> |
---|
| 106 | 0036 |
---|
| 107 | 0037 |
---|
| 108 | 0038 <span class="comment">% AT units meters & radians</span> |
---|
| 109 | 0039 <span class="keyword">if</span> nargin < 1 |
---|
| 110 | 0040 x0 = []; |
---|
| 111 | 0041 <span class="keyword">end</span> |
---|
| 112 | 0042 <span class="keyword">if</span> isempty(x0) |
---|
| 113 | 0043 <span class="comment">% 1 mm starting offset</span> |
---|
| 114 | 0044 x0 = [.001 0, 0.001, 0, 0, 0]'; |
---|
| 115 | 0045 <span class="keyword">end</span> |
---|
| 116 | 0046 |
---|
| 117 | 0047 x0 = x0(:); |
---|
| 118 | 0048 <span class="keyword">if</span> size(x0,1) == 4 |
---|
| 119 | 0049 x0 = [x0; 0; 0]; |
---|
| 120 | 0050 <span class="keyword">elseif</span> size(x0,1) ~= 6 |
---|
| 121 | 0051 error(<span class="string">'x0 must be a 4x1 or 6x1 vector.'</span>); |
---|
| 122 | 0052 <span class="keyword">end</span> |
---|
| 123 | 0053 |
---|
| 124 | 0054 <span class="keyword">if</span> nargin < 2 |
---|
| 125 | 0055 Family0 = []; |
---|
| 126 | 0056 <span class="keyword">end</span> |
---|
| 127 | 0057 <span class="keyword">if</span> isempty(Family0) |
---|
| 128 | 0058 Family0 = <span class="string">'BPMx'</span>; |
---|
| 129 | 0059 <span class="keyword">end</span> |
---|
| 130 | 0060 <span class="keyword">if</span> nargin < 3 |
---|
| 131 | 0061 DeviceList0 = []; |
---|
| 132 | 0062 <span class="keyword">end</span> |
---|
| 133 | 0063 |
---|
| 134 | 0064 <span class="keyword">if</span> nargin < 4 |
---|
| 135 | 0065 Family = []; |
---|
| 136 | 0066 <span class="keyword">end</span> |
---|
| 137 | 0067 <span class="keyword">if</span> isempty(Family) |
---|
| 138 | 0068 Family = <span class="string">'BPMx'</span>; |
---|
| 139 | 0069 <span class="keyword">end</span> |
---|
| 140 | 0070 <span class="keyword">if</span> nargin < 5 |
---|
| 141 | 0071 DeviceList = []; |
---|
| 142 | 0072 <span class="keyword">end</span> |
---|
| 143 | 0073 |
---|
| 144 | 0074 |
---|
| 145 | 0075 <span class="comment">% Get AT index</span> |
---|
| 146 | 0076 <span class="keyword">if</span> ischar(Family0) |
---|
| 147 | 0077 ATindex0 = <a href="family2atindex.html" class="code" title="function [ATIndexList, ErrorFlag] = family2atindex(Family, varargin);">family2atindex</a>(Family0, DeviceList0); |
---|
| 148 | 0078 <span class="comment">% Watch for split magnets</span> |
---|
| 149 | 0079 <span class="keyword">if</span> size(ATindex0,2) > 1 |
---|
| 150 | 0080 ATindex0 = ATindex0(:,1); |
---|
| 151 | 0081 <span class="keyword">end</span> |
---|
| 152 | 0082 <span class="keyword">if</span> ischar(Family) |
---|
| 153 | 0083 ATindex = <a href="family2atindex.html" class="code" title="function [ATIndexList, ErrorFlag] = family2atindex(Family, varargin);">family2atindex</a>(Family, DeviceList); |
---|
| 154 | 0084 <span class="comment">% Watch for split magnets</span> |
---|
| 155 | 0085 <span class="keyword">if</span> size(ATindex,2) > 1 |
---|
| 156 | 0086 ATindex = ATindex(:,1); |
---|
| 157 | 0087 <span class="keyword">end</span> |
---|
| 158 | 0088 <span class="keyword">else</span> |
---|
| 159 | 0089 <span class="comment">% AT index was input directly</span> |
---|
| 160 | 0090 ATindex = Family; |
---|
| 161 | 0091 <span class="keyword">end</span> |
---|
| 162 | 0092 <span class="keyword">else</span> |
---|
| 163 | 0093 <span class="comment">% AT index was input directly</span> |
---|
| 164 | 0094 ATindex0 = Family0; |
---|
| 165 | 0095 ATindex = DeviceList0; |
---|
| 166 | 0096 <span class="keyword">end</span> |
---|
| 167 | 0097 |
---|
| 168 | 0098 <span class="keyword">if</span> any(size(ATindex0) ~= [1 1]) |
---|
| 169 | 0099 error(<span class="string">'DeviceList0 must be one location.'</span>); |
---|
| 170 | 0100 <span class="keyword">end</span> |
---|
| 171 | 0101 |
---|
| 172 | 0102 |
---|
| 173 | 0103 ATindex = ATindex(:)'; |
---|
| 174 | 0104 <span class="keyword">if</span> isempty(ATindex) |
---|
| 175 | 0105 error(<span class="string">'AT index empty.'</span>); |
---|
| 176 | 0106 <span class="keyword">end</span> |
---|
| 177 | 0107 |
---|
| 178 | 0108 |
---|
| 179 | 0109 <span class="comment">% Propagrate single turn data around the ring</span> |
---|
| 180 | 0110 <span class="comment">% xAllBPMs (6 x BPM Number)</span> |
---|
| 181 | 0111 |
---|
| 182 | 0112 <span class="comment">% Find forward and backward BPMs</span> |
---|
| 183 | 0113 iForward = find(ATindex >= ATindex0); |
---|
| 184 | 0114 iBackward = find(ATindex < ATindex0); |
---|
| 185 | 0115 |
---|
| 186 | 0116 x = []; |
---|
| 187 | 0117 <span class="keyword">if</span> ~isempty(iForward) |
---|
| 188 | 0118 Index = ATindex(iForward) - ATindex0 + 1; |
---|
| 189 | 0119 x = linepass(THERING([ATindex0:ATindex(iForward(end))]), x0, Index); |
---|
| 190 | 0120 <span class="keyword">end</span> |
---|
| 191 | 0121 |
---|
| 192 | 0122 <span class="keyword">if</span> ~isempty(iBackward) |
---|
| 193 | 0123 <span class="keyword">if</span> x0(5)~=0 | x0(6)~=0 |
---|
| 194 | 0124 fprintf(<span class="string">' WARNING: x0(5) & x0(6) must be zero for propagating backwards in the ring to work correctly.\n'</span>); |
---|
| 195 | 0125 <span class="keyword">end</span> |
---|
| 196 | 0126 |
---|
| 197 | 0127 x0neg = x0; |
---|
| 198 | 0128 x0neg([2 4]) = -x0neg([2 4]); |
---|
| 199 | 0129 |
---|
| 200 | 0130 IndexBack = [ATindex(iBackward):ATindex0]-1; |
---|
| 201 | 0131 IndexBack(1) = []; |
---|
| 202 | 0132 |
---|
| 203 | 0133 <span class="comment">%Index = ATindex0-IndexBack;</span> |
---|
| 204 | 0134 ATIndexBack = ATindex(iBackward); |
---|
| 205 | 0135 Index = ATindex0 - ATIndexBack + 1; |
---|
| 206 | 0136 Index = Index(end:-1:1); |
---|
| 207 | 0137 |
---|
| 208 | 0138 xb = linepass(THERING(IndexBack(end:-1:1)), x0neg, Index); |
---|
| 209 | 0139 xb([2 4],:) = -xb([2 4],:); |
---|
| 210 | 0140 |
---|
| 211 | 0141 |
---|
| 212 | 0142 x = [xb(:,end:-1:1) x]; |
---|
| 213 | 0143 <span class="keyword">end</span> |
---|
| 214 | 0144</pre></div> |
---|
| 215 | <hr><address>Generated on Fri 18-May-2007 17:13:39 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address> |
---|
| 216 | </body> |
---|
| 217 | </html> |
---|