source: MML/trunk/mml/at/sextualign.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: 2.1 KB
Line 
1function sextualign(sx,sz)
2%QUADALIGN - Locates sextupoles in AO and apply random alignment
3%quadalign(sx,sz);  sx and sz are sigma values for randn;
4% units are meters
5%
6% INPUTS
7% 1. sx sigma for vertical plane
8% 2. sz sigma for horizontal plane
9%
10
11%
12% Written by SPEAR people
13% Modified by Laurent S. Nadolski
14
15cutoff = 3; % sigma
16
17if nargin<2
18    error('Error in quadalign - must supply alignment sigma values for both planes');
19end
20
21global THERING
22AO = getao;
23
24ATindx=[];   %indices of sextupoles
25mx=[];
26my=[];
27len = findspos(THERING,length(THERING)+1);
28
29
30SextuList = findmemberof('Sext');
31
32for ii = 1:length(SextuList)-2,
33   
34    Family = SextuList{ii};
35    indx=AO.(Family).AT.ATIndex;
36
37    %assign random alignment error to first magnet
38    mx=[mx; sx*randncut('CutOff',cutoff)];
39    my=[my; sz*randncut('CutOff',cutoff)];
40
41    % assign random error to rest of family
42    tol=1e-6; %tolerance for spacing between magnets
43    for jj=2:length(indx)
44        %check for split magnets
45        if AO.(Family).Position(jj)-THERING{indx(jj)}.Length - AO.(Family).Position(jj-1)<tol   %magnet split
46            disp(['   Split magnet ' AO{ii}.FamilyName ' found in function quadalign with index  ', num2str(indx(jj))]);
47            mx=[mx; -mx(end)];
48            my=[my; -my(end)];
49        else   %magnet not split
50            mx=[mx; sx*randn];
51            my=[my; sz*randn];
52        end
53
54    end
55
56    %check if first/last element split in THERING
57    if abs(AO.(Family).Position(1))  < tol  && ...    %first element near zero
58            abs((len - AO.(Family).Position(end) - THERING{indx(end)}.Length < tol))      %last element near end
59        disp(['   Split magnet ' AO.(Family).FamilyName ' found in function quadalign with index  ',...
60            num2str(indx(1)), ' ',num2str(indx(end))]);
61        mx(end)=-mx(end-length(indx)+1);       %error on last quad same as error on first quad in family
62        my(end)=-my(end-length(indx)+1);
63    end
64
65    ATindx=[ATindx; indx];
66end  %end loop over families
67
68% my=sz*randn(1,length(ATindx));
69% mx=sx*randn(1,length(ATindx));
70setshift(ATindx,mx,my);
71
Note: See TracBrowser for help on using the repository browser.