Home > pubtools > LatticeTuningFunctions > errors > errorsmanipulation > UniformGirderErrors.m

UniformGirderErrors

PURPOSE ^

function ring=UniformGirderErrors(ring)

SYNOPSIS ^

function [ring,mag_groups]=UniformGirderErrors(ring,mag_groups)

DESCRIPTION ^

 function ring=UniformGirderErrors(ring)

 makes all error in a section delimited by the markers GS and GE
 identical to the ones on the first element
 of the group. Groups are defined in the lattice by the MagNum Field

 BPM are moved with the girder setting the appropriate offset.
 
see also: getMagGroupsFromGirderIndex

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ring,mag_groups]=UniformGirderErrors(ring,mag_groups)
0002 % function ring=UniformGirderErrors(ring)
0003 %
0004 % makes all error in a section delimited by the markers GS and GE
0005 % identical to the ones on the first element
0006 % of the group. Groups are defined in the lattice by the MagNum Field
0007 %
0008 % BPM are moved with the girder setting the appropriate offset.
0009 %
0010 %see also: getMagGroupsFromGirderIndex
0011 
0012 if nargin<2
0013 mag_groups=getMagGroupsFromGirderIndex(ring);
0014 end
0015 
0016 for i=1:length(mag_groups)
0017     
0018     % group indexes
0019     ind=mag_groups{i};
0020     if length(ind)>1
0021         % uniform BPM offsets
0022         % find bpm
0023         bpmingroup=findcells(ring(ind),'Class','Monitor');
0024         if ~isempty(bpmingroup)
0025             % assign first bpm alignment and rotation errors to all other BPM
0026             offerrx=atgetfieldvalues(ring,ind(bpmingroup(1)),'Offset',{1,1});
0027             offerry=atgetfieldvalues(ring,ind(bpmingroup(1)),'Offset',{1,2});
0028             roterr=atgetfieldvalues(ring,ind(bpmingroup(1)),'Rotation',{1,1});
0029             indALL=ind(bpmingroup);
0030             ring=atsetfieldvalues(ring,indALL,'Offset'   ,offerrx,1,1);
0031             ring=atsetfieldvalues(ring,indALL,'Offset'   ,offerry,1,2);
0032             ring=atsetfieldvalues(ring,indALL,'Rotation' ,roterr,1,1);
0033         end
0034         
0035         % uniform magnet errors
0036         
0037         % get first element errors
0038         if isfield(ring{ind(1)},'T1')
0039             T1=ring{ind(1)}.T1;
0040         else
0041             T1=zeros(6,1);
0042         end
0043         
0044         if isfield(ring{ind(1)},'T2')
0045             T2=ring{ind(1)}.T2;
0046         else
0047             T2=zeros(6,1);
0048         end
0049         
0050         if isfield(ring{ind(1)},'R1')
0051             R1=ring{ind(1)}.R1;
0052         else
0053             R1=eye(6,6);
0054         end
0055         
0056         if isfield(ring{ind(1)},'R2')
0057             R2=ring{ind(1)}.R2;
0058         else
0059             R2=eye(6,6);
0060         end
0061         
0062         if isfield(ring{ind(1)},'DeltaS')
0063             DeltaS=ring{ind(1)}.DeltaS;
0064         else
0065             DeltaS=0;
0066         end
0067        
0068         if isfield(ring{ind(1)},'RotAboutS')
0069             RotAboutS=ring{ind(1)}.RotAboutS;
0070         else
0071             RotAboutS=0;
0072         end
0073         
0074         if isfield(ring{ind(1)},'RotAboutX')
0075             RotAboutX=ring{ind(1)}.RotAboutX;
0076         else
0077             RotAboutX=0;
0078         end
0079         
0080         if isfield(ring{ind(1)},'RotAboutY')
0081             RotAboutY=ring{ind(1)}.RotAboutY;
0082         else
0083             RotAboutY=0;
0084         end
0085         
0086         for isl=1:length(ind)
0087             
0088             % set all other slices to this value
0089             ring{ind(isl)}.T1=T1;
0090             ring{ind(isl)}.T2=T2;
0091             ring{ind(isl)}.R1=R1;
0092             ring{ind(isl)}.R2=R2;
0093             ring{ind(isl)}.DeltaS=DeltaS;
0094             ring{ind(isl)}.RotAboutS=RotAboutS;
0095             ring{ind(isl)}.RotAboutX=RotAboutX;
0096             ring{ind(isl)}.RotAboutY=RotAboutY;
0097             % ring{ind(isl)}.Offset=[T1(1) T1(3)];
0098             % ring{ind(isl)}.Rotation=-Tilt;
0099         end
0100     end
0101     
0102 end
0103 
0104 %ring=setBpmOffsetOnDipoleRef(ring);
0105 
0106 
0107 return

Generated on Thu 24-Aug-2017 18:47:33 by m2html © 2005