source: MML/trunk/mml/sext2bpm.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.6 KB
Line 
1function [BPMFamilyOutput, BPMDevOutput, DeltaSpos] = sext2bpm(SEXTFamily, SEXTDev)
2%SEXT2BPM - Returns the nearest BPM to the specified sextupole
3%  [BPMFamily, BPMDeviceList, DeltaSpos] = sext2bpm(SEXTFamily, SEXTDev)
4%
5%  INPUTS
6%  1. SEXTFamily - Quadrupole family (1 family only (row string))
7%  2. SEXTDeviceList - Quadrupole device list
8%
9%  OUTPUTS
10%  1. BPMFamily
11%  2. BPMDeviceList
12%  3. DeltaSpos - Distance from the Quad to the BPM   
13%
14%  Written by Greg Portmann
15
16
17if nargin < 1
18    SEXTFamily = 'SF';
19end
20if nargin < 2
21    SEXTDev = family2dev(SEXTFamily);
22end
23
24
25
26% Get all the BPM families
27BPMFamilyList = getfamilylist;
28[tmp, i] = ismemberof(BPMFamilyList, 'BPM');
29if ~isempty(i)
30    BPMFamilyList = BPMFamilyList(i,:);
31else
32    BPMFamilyList = ['BPMx','BPMy'];
33end
34
35
36% Find the BPM next to the Quad
37BPMFamilyOutput = [];
38for k = 1:size(SEXTDev,1)
39    SEXTspos  = getspos(SEXTFamily, SEXTDev(k,:));
40   
41    Del = inf;
42    for j = 1:size(BPMFamilyList,1)
43        Family = deblank(BPMFamilyList(j,:));
44        BPMDevList = getlist(Family);
45        BPMspos    = getspos(Family);
46       
47        i = find(abs(BPMspos-SEXTspos)==min(abs(BPMspos-SEXTspos)));
48        BPMDev{j} = BPMDevList(i,:);
49       
50        if abs(BPMspos(i)-SEXTspos) < Del
51            BPMFamilyMin = Family;
52            BPMDevMin = BPMDev{j};       
53            Del = abs(BPMspos(i)-SEXTspos);
54            DelwithSign = BPMspos(i)-SEXTspos;
55        end
56    end
57   
58    BPMFamilyOutput = strvcat(BPMFamilyOutput, BPMFamilyMin);
59    BPMDevOutput(k,:) = BPMDevMin;       
60    DeltaSpos(k,1) = DelwithSign;
61end
Note: See TracBrowser for help on using the repository browser.