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 getturns</title> |
---|
6 | <meta name="keywords" content="getturns"> |
---|
7 | <meta name="description" content="GETTURNS - Single particle tracking for multiple turns"> |
---|
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> > getturns.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>getturns |
---|
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>GETTURNS - Single particle tracking for multiple turns</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 [xAllBPMs, ATindex, LostBeam] = getturns(x0, N, 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">GETTURNS - Single particle tracking for multiple turns |
---|
31 | |
---|
32 | [x, ATIndex, LostBeam] = getturns(x0, N, Family, DeviceList) |
---|
33 | [x, ATIndex, LostBeam] = getturns(x0, N, ATIndex) |
---|
34 | |
---|
35 | INPUTS |
---|
36 | 1. x0 - 6-component column vector |
---|
37 | Initial particle launch condition at the start of the ring (see ringpass) |
---|
38 | AT units are meters & radians. {Default: getpvmodel('LaunchVector')} |
---|
39 | 2. N - Number of turns {Default: 1024} |
---|
40 | 3. Location to measure turns: Family / DeviceList {Default: gethbpmfamily} |
---|
41 | or |
---|
42 | ATIndex |
---|
43 | |
---|
44 | NOTE: Family can be a MiddlyLayer family or AT family. |
---|
45 | If using at AT family, then DeviceList is an index array (see family2atindex). |
---|
46 | |
---|
47 | OUTPUTS |
---|
48 | 1. x - Multiple turn data (BPM Number x N turns x 6) |
---|
49 | Note: 1. The initial condition is included in the first turn. |
---|
50 | 2. Use squeeze to reduce dimensions. Matlab automatically squeezes the last |
---|
51 | dimension, ie, x(:,:,BPMnumber) will be a 2-dim matrix if BPMnumber is a scalar. |
---|
52 | 2. ATIndex - AT index vector |
---|
53 | 3. LostBeam - 1 if particle is lost, else 0 |
---|
54 | |
---|
55 | EXAMPLES |
---|
56 | 1. Get 1024 turns at BPMx(1,2) and BPMx(1,4) and plot the horizontal position FFT for BPMx(1,2) |
---|
57 | [x, ATIndex, LostBeam] = getturns([.001 0, 0.001, 0, 0, 0]', 1024, 'BPMx', [1 2;1 4]); |
---|
58 | multiturnfft(x(1,:,1)); |
---|
59 | 2. Get 1024 turns at AT-index 1,2,10 |
---|
60 | [x, ATIndex, LostBeam] = getturns([.001 0, 0.001, 0, 0, 0]', 1024, [1 2 10]); |
---|
61 | 3. Get first turn at all AT indices |
---|
62 | [x, ATIndex, LostBeam] = getturns([.001 0, 0.001, 0, 0, 0]', 1, 'All'); |
---|
63 | |
---|
64 | Also see multiturnfft linepass |
---|
65 | |
---|
66 | Written by Greg Portmann</pre></div> |
---|
67 | |
---|
68 | <!-- crossreference --> |
---|
69 | <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
70 | This function calls: |
---|
71 | <ul style="list-style-image:url(../matlabicon.gif)"> |
---|
72 | <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><li><a href="getpvmodel.html" class="code" title="function [AM, tout, DataTime, ErrorFlag] = getpvmodel(varargin)">getpvmodel</a> GETPVMODEL - Get the model value</li></ul> |
---|
73 | This function is called by: |
---|
74 | <ul style="list-style-image:url(../matlabicon.gif)"> |
---|
75 | <li><a href="getpvmodel.html" class="code" title="function [AM, tout, DataTime, ErrorFlag] = getpvmodel(varargin)">getpvmodel</a> GETPVMODEL - Get the model value</li></ul> |
---|
76 | <!-- crossreference --> |
---|
77 | |
---|
78 | |
---|
79 | <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
80 | <div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [xAllBPMs, ATindex, LostBeam] = getturns(x0, N, Family, DeviceList)</a> |
---|
81 | 0002 <span class="comment">%GETTURNS - Single particle tracking for multiple turns</span> |
---|
82 | 0003 <span class="comment">%</span> |
---|
83 | 0004 <span class="comment">% [x, ATIndex, LostBeam] = getturns(x0, N, Family, DeviceList)</span> |
---|
84 | 0005 <span class="comment">% [x, ATIndex, LostBeam] = getturns(x0, N, ATIndex)</span> |
---|
85 | 0006 <span class="comment">%</span> |
---|
86 | 0007 <span class="comment">% INPUTS</span> |
---|
87 | 0008 <span class="comment">% 1. x0 - 6-component column vector</span> |
---|
88 | 0009 <span class="comment">% Initial particle launch condition at the start of the ring (see ringpass)</span> |
---|
89 | 0010 <span class="comment">% AT units are meters & radians. {Default: getpvmodel('LaunchVector')}</span> |
---|
90 | 0011 <span class="comment">% 2. N - Number of turns {Default: 1024}</span> |
---|
91 | 0012 <span class="comment">% 3. Location to measure turns: Family / DeviceList {Default: gethbpmfamily}</span> |
---|
92 | 0013 <span class="comment">% or</span> |
---|
93 | 0014 <span class="comment">% ATIndex</span> |
---|
94 | 0015 <span class="comment">%</span> |
---|
95 | 0016 <span class="comment">% NOTE: Family can be a MiddlyLayer family or AT family.</span> |
---|
96 | 0017 <span class="comment">% If using at AT family, then DeviceList is an index array (see family2atindex).</span> |
---|
97 | 0018 <span class="comment">%</span> |
---|
98 | 0019 <span class="comment">% OUTPUTS</span> |
---|
99 | 0020 <span class="comment">% 1. x - Multiple turn data (BPM Number x N turns x 6)</span> |
---|
100 | 0021 <span class="comment">% Note: 1. The initial condition is included in the first turn.</span> |
---|
101 | 0022 <span class="comment">% 2. Use squeeze to reduce dimensions. Matlab automatically squeezes the last</span> |
---|
102 | 0023 <span class="comment">% dimension, ie, x(:,:,BPMnumber) will be a 2-dim matrix if BPMnumber is a scalar.</span> |
---|
103 | 0024 <span class="comment">% 2. ATIndex - AT index vector</span> |
---|
104 | 0025 <span class="comment">% 3. LostBeam - 1 if particle is lost, else 0</span> |
---|
105 | 0026 <span class="comment">%</span> |
---|
106 | 0027 <span class="comment">% EXAMPLES</span> |
---|
107 | 0028 <span class="comment">% 1. Get 1024 turns at BPMx(1,2) and BPMx(1,4) and plot the horizontal position FFT for BPMx(1,2)</span> |
---|
108 | 0029 <span class="comment">% [x, ATIndex, LostBeam] = getturns([.001 0, 0.001, 0, 0, 0]', 1024, 'BPMx', [1 2;1 4]);</span> |
---|
109 | 0030 <span class="comment">% multiturnfft(x(1,:,1));</span> |
---|
110 | 0031 <span class="comment">% 2. Get 1024 turns at AT-index 1,2,10</span> |
---|
111 | 0032 <span class="comment">% [x, ATIndex, LostBeam] = getturns([.001 0, 0.001, 0, 0, 0]', 1024, [1 2 10]);</span> |
---|
112 | 0033 <span class="comment">% 3. Get first turn at all AT indices</span> |
---|
113 | 0034 <span class="comment">% [x, ATIndex, LostBeam] = getturns([.001 0, 0.001, 0, 0, 0]', 1, 'All');</span> |
---|
114 | 0035 <span class="comment">%</span> |
---|
115 | 0036 <span class="comment">% Also see multiturnfft linepass</span> |
---|
116 | 0037 <span class="comment">%</span> |
---|
117 | 0038 <span class="comment">% Written by Greg Portmann</span> |
---|
118 | 0039 |
---|
119 | 0040 |
---|
120 | 0041 <span class="keyword">global</span> THERING |
---|
121 | 0042 <span class="keyword">if</span> isempty(THERING) |
---|
122 | 0043 error(<span class="string">'THERING is not defined.'</span>); |
---|
123 | 0044 <span class="keyword">end</span> |
---|
124 | 0045 |
---|
125 | 0046 |
---|
126 | 0047 <span class="comment">% AT units meters & radians</span> |
---|
127 | 0048 <span class="keyword">if</span> nargin < 1 |
---|
128 | 0049 x0 = []; |
---|
129 | 0050 <span class="keyword">end</span> |
---|
130 | 0051 <span class="keyword">if</span> isempty(x0) |
---|
131 | 0052 x0 = <a href="getpvmodel.html" class="code" title="function [AM, tout, DataTime, ErrorFlag] = getpvmodel(varargin)">getpvmodel</a>(<span class="string">'LaunchVector'</span>); |
---|
132 | 0053 <span class="keyword">if</span> isempty(x0) |
---|
133 | 0054 <span class="comment">% 1 mm starting offset</span> |
---|
134 | 0055 x0 = [0 0 0 0 0 0]'; |
---|
135 | 0056 <span class="keyword">end</span> |
---|
136 | 0057 <span class="keyword">end</span> |
---|
137 | 0058 |
---|
138 | 0059 x0 = x0(:); |
---|
139 | 0060 <span class="keyword">if</span> size(x0,1) ~= 6 |
---|
140 | 0061 error(<span class="string">'x0 must be a 6x1 vector.'</span>); |
---|
141 | 0062 <span class="keyword">end</span> |
---|
142 | 0063 |
---|
143 | 0064 <span class="keyword">if</span> nargin < 2 |
---|
144 | 0065 N = []; |
---|
145 | 0066 <span class="keyword">end</span> |
---|
146 | 0067 <span class="keyword">if</span> isempty(N) |
---|
147 | 0068 N = 1024; |
---|
148 | 0069 <span class="keyword">end</span> |
---|
149 | 0070 |
---|
150 | 0071 <span class="keyword">if</span> nargin < 3 |
---|
151 | 0072 Family = []; |
---|
152 | 0073 <span class="keyword">end</span> |
---|
153 | 0074 <span class="keyword">if</span> isempty(Family) |
---|
154 | 0075 Family = gethbpmfamily; |
---|
155 | 0076 <span class="keyword">end</span> |
---|
156 | 0077 |
---|
157 | 0078 <span class="keyword">if</span> nargin < 4 |
---|
158 | 0079 DeviceList = []; |
---|
159 | 0080 <span class="keyword">end</span> |
---|
160 | 0081 |
---|
161 | 0082 |
---|
162 | 0083 <span class="comment">% Get AT index</span> |
---|
163 | 0084 <span class="keyword">if</span> ischar(Family) |
---|
164 | 0085 ATindex = <a href="family2atindex.html" class="code" title="function [ATIndexList, ErrorFlag] = family2atindex(Family, varargin);">family2atindex</a>(Family, DeviceList); |
---|
165 | 0086 <span class="comment">% Watch for split magnets</span> |
---|
166 | 0087 <span class="keyword">if</span> size(ATindex,2) > 1 |
---|
167 | 0088 ATindex = ATindex(:,1); |
---|
168 | 0089 <span class="keyword">end</span> |
---|
169 | 0090 <span class="keyword">else</span> |
---|
170 | 0091 <span class="comment">% AT index was input directly</span> |
---|
171 | 0092 ATindex = Family; |
---|
172 | 0093 <span class="keyword">end</span> |
---|
173 | 0094 ATindex = ATindex(:)'; |
---|
174 | 0095 <span class="keyword">if</span> isempty(ATindex) |
---|
175 | 0096 error(<span class="string">'AT index empty.'</span>); |
---|
176 | 0097 <span class="keyword">end</span> |
---|
177 | 0098 |
---|
178 | 0099 <span class="comment">% Get single turn data</span> |
---|
179 | 0100 <span class="keyword">if</span> N == 1 |
---|
180 | 0101 x = x0; |
---|
181 | 0102 LostBeam = 0; |
---|
182 | 0103 <span class="keyword">else</span> |
---|
183 | 0104 [x, LostBeam] = ringpass(THERING, x0, N-1); <span class="comment">% 'reuse' seems to cause errors</span> |
---|
184 | 0105 x = [x0 x]; |
---|
185 | 0106 <span class="keyword">if</span> LostBeam |
---|
186 | 0107 fprintf(<span class="string">' Beam was lost\n'</span>); |
---|
187 | 0108 xAllBPMs = []; |
---|
188 | 0109 <span class="keyword">return</span> |
---|
189 | 0110 <span class="keyword">end</span> |
---|
190 | 0111 <span class="keyword">end</span> |
---|
191 | 0112 |
---|
192 | 0113 |
---|
193 | 0114 <span class="comment">% Propagate single turn data around the ring</span> |
---|
194 | 0115 <span class="keyword">for</span> iturn = 1:size(x,2) |
---|
195 | 0116 <span class="comment">% if iturn == 1</span> |
---|
196 | 0117 <span class="comment">% xAllBPMs (BPM Number x N turns x 6)</span> |
---|
197 | 0118 [xAllBPMs(:,iturn,:)] = linepass(THERING, x(:,iturn), ATindex)'; |
---|
198 | 0119 |
---|
199 | 0120 <span class="comment">% xAllBPMs (6 x N turns x BPM Number)</span> |
---|
200 | 0121 <span class="comment">%[xAllBPMs(:,iturn,:)] = linepass(THERING, x(:,iturn), ATindex);</span> |
---|
201 | 0122 <span class="comment">% else</span> |
---|
202 | 0123 <span class="comment">% [xAllBPMs(:,iturn,:)] = linepass(THERING, x(:,iturn), ATindex, 'reuse');</span> |
---|
203 | 0124 <span class="comment">% end</span> |
---|
204 | 0125 <span class="keyword">end</span> |
---|
205 | 0126 |
---|
206 | 0127 |
---|
207 | 0128 |
---|
208 | 0129 |
---|
209 | 0130</pre></div> |
---|
210 | <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> |
---|
211 | </body> |
---|
212 | </html> |
---|