source: MML/trunk/mml/at/quadroll.m

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

Initial import--MML version from SOLEIL@2013

File size: 1.7 KB
Line 
1function quadroll(sr)
2%locate quadrupoles in AO and apply random roll about s-axis
3%function quadroll(sr);  sr is the sigma value for randn;
4%units are radians
5
6if nargin<1
7    disp('Error in quadroll - must supply alignment spreads');
8    return
9end
10
11global THERING
12AO = getao;
13
14ATindx=[];   %indices of quadrupoles
15mr=[];
16len=findspos(THERING,length(THERING)+1);
17
18QuadList = findmemberof('Quad');
19
20for ii=1:length(AO)
21    Family = QuadList{ii};
22    indx=AO.(Family).AT.ATIndex;
23
24    %assign random roll error to first magnet
25    mr=[mr; sr*randn];
26
27    % assign random error to rest of family
28    tol=1e-6; %tolerance for spacing between magnets
29    for jj=2:length(indx)
30
31        %check for split magnets
32        if AO.(Family).Position(jj)-THERING{indx(jj)}.Length - AO.(Family).Position(jj-1)<tol   %magnet split
33            disp(['   Split magnet ' AO.(Family).FamilyName ' found in function quadroll with index  ', num2str(indx(jj))]);
34            mr=[mr; -mr(end)];
35        else   %magnet not split
36            mr=[mr; sr*randn];
37        end
38
39    end
40
41    %check if first/last element split in THERING
42    if abs(AO.(Family).Position(1))  < tol  && ...    %first element near zero
43            abs((len - AO.(Family).Position(end) - THERING{indx(end)}.Length < tol))      %last element near end
44        disp(['   Split magnet ' AO.(Family).FamilyName ' found in function quadroll with index  ',...
45            num2str(indx(1)), ' ',num2str(indx(end))]);
46        mr(end)=-mr(end-length(indx)+1);       %error on last quad same as error on first quad in family
47    end
48
49    ATindx=[ATindx; indx];
50end  %end loop over families
51
52% my=sy*randn(1,length(ATindx));
53% mx=sx*randn(1,length(ATindx));
54settilt(ATindx,mr);
55
Note: See TracBrowser for help on using the repository browser.