source: MML/trunk/machine/SOLEIL/StorageRing/bpm/bpm2sext.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 10 years ago

Initial import--MML version from SOLEIL@2013

File size: 1.7 KB
Line 
1function [SEXTFamilyOutput, SEXTDevOutput, DeltaSpos] = bpm2sext(BPMFamily, BPMDev)
2%BPM2SEXT - Returns the nearest sextupole to the specified BPM
3%  [SEXTFamily, SEXTDeviceList, DeltaSpos] = bpm2sext(BPMFamily, BPMDeviceList)
4%
5%  INPUTS
6%  1. BPMFamily - BPM family (1 family only (row string))
7%  2. BPMDeviceList - BPM device list
8%
9%  OUTPUTS
10%  1. SEXTFamily
11%  2. SEXTDeviceList
12%  3. DeltaSpos - Distance from the BPM to the Quad 
13%
14%  Written by Greg Portmann
15
16
17if nargin < 1
18    BPMFamily = [];
19end
20if isempty(BPMFamily)
21    BPMFamily = gethbpmfamily;
22end
23if nargin < 2
24    BPMDev = [];
25end
26if isempty(BPMFamily)
27    BPMDev = [1 1];  %family2dev(BPMFamily);
28end
29
30
31% Get all the sext families
32SEXTFamilyList = getfamilylist;
33[tmp, i] = ismemberof(SEXTFamilyList, 'SEXT');
34if ~isempty(i)
35    SEXTFamilyList = SEXTFamilyList(i,:);
36else
37    SEXTFamilyList = ['SF','SD'];
38end
39
40
41% Find the Quad next to the BPM
42SEXTFamilyOutput = [];
43for k = 1:size(BPMDev,1)
44    BPMspos  = getspos(BPMFamily, BPMDev(k,:));
45   
46    Del = inf;
47    for j = 1:size(SEXTFamilyList,1)
48        Family = deblank(SEXTFamilyList(j,:));
49        SEXTDevList = getlist(Family);
50        SEXTspos  = getspos(Family);
51       
52        i = find(abs(SEXTspos-BPMspos)==min(abs(SEXTspos-BPMspos)));
53        SEXTDev{j} = SEXTDevList(i,:);
54       
55        if abs(SEXTspos(i)-BPMspos) < Del
56            SEXTFamilyMin = Family;
57            SEXTDevMin = SEXTDev{j};       
58            Del = abs(SEXTspos(i)-BPMspos);
59            DelwithSign = SEXTspos(i)-BPMspos;
60        end
61    end
62   
63    SEXTFamilyOutput = strvcat(SEXTFamilyOutput, SEXTFamilyMin);
64    SEXTDevOutput(k,:) = SEXTDevMin;       
65    DeltaSpos(k,1) = DelwithSign;
66end
67
Note: See TracBrowser for help on using the repository browser.