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

GetExistingErrors

PURPOSE ^

this function retrives 6 vectors, for x, y,s misalignments,

SYNOPSIS ^

function [X,Y,S,T,R,P,bpmerrors]=GetExistingErrors(THERING,varargin)

DESCRIPTION ^

 this function retrives 6 vectors, for x, y,s misalignments,
 Tilts (rot about s), Roll (rot about x) and Pinch (rot about y)

 the vectors are length of THERING or of the optional second input

 in future also bpm errors and girder errors will be added.

see also: ApplyErrorRand SetExistingErrors

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [X,Y,S,T,R,P,bpmerrors]=GetExistingErrors(THERING,varargin)
0002 % this function retrives 6 vectors, for x, y,s misalignments,
0003 % Tilts (rot about s), Roll (rot about x) and Pinch (rot about y)
0004 %
0005 % the vectors are length of THERING or of the optional second input
0006 %
0007 % in future also bpm errors and girder errors will be added.
0008 %
0009 %see also: ApplyErrorRand SetExistingErrors
0010 
0011 if numel(varargin)==1
0012     indxerrors=varargin{1};
0013 else
0014     indxerrors=1:length(THERING);
0015 end
0016 
0017 if nargout>=2
0018     % X and Y misal
0019     X=zeros(size(indxerrors));
0020     Y=zeros(size(indxerrors));
0021     t1=findcells(THERING(indxerrors),'T1');
0022     if ~isempty(t1)
0023         X(t1)=-getcellstruct(THERING(indxerrors),'T1',t1,1);
0024         Y(t1)=-getcellstruct(THERING(indxerrors),'T1',t1,3);
0025     end
0026 end
0027 if nargout>=3
0028     % S misal
0029     S=zeros(size(indxerrors));
0030     s1=findcells(THERING(indxerrors),'DeltaS');
0031     if ~isempty(s1)
0032         S(s1)=-getcellstruct(THERING(indxerrors),'DeltaS',s1,1);
0033     end
0034 end
0035 if nargout>=4
0036     % tilt about s-axis
0037     T=zeros(size(indxerrors));
0038     tiltedelem=findcells(THERING(indxerrors),'RotAboutS');
0039     if ~isempty(tiltedelem)
0040         T(tiltedelem)=getcellstruct(THERING(indxerrors),'RotAboutS',tiltedelem);
0041         T(T<1e-7 & T>-1e-7)=0;
0042     end
0043 end
0044 if nargout>=5
0045     % roll about x-axis
0046     R=zeros(size(indxerrors));
0047     tiltedelem=findcells(THERING(indxerrors),'RotAboutX');
0048     if ~isempty(tiltedelem)
0049         R(tiltedelem)=getcellstruct(THERING(indxerrors),'RotAboutX',tiltedelem);
0050         R(R<1e-7 & R>-1e-7)=0;
0051     end
0052 end
0053 if nargout>=6
0054     % pinch about y-axis
0055     P=zeros(size(indxerrors));
0056     tiltedelem=findcells(THERING(indxerrors),'RotAboutY');
0057     if ~isempty(tiltedelem)
0058         P(tiltedelem)=getcellstruct(THERING(indxerrors),'RotAboutY',tiltedelem);
0059         P(P<1e-7 & P>-1e-7)=0;
0060     end
0061 end
0062 if nargout>=7
0063     tiltedelem=findcells(THERING,'Class','Monitor');
0064     bpmerrors.offsetx=zeros(size(tiltedelem));
0065     bpmerrors.offsety=zeros(size(tiltedelem));
0066     bpmerrors.rotation=zeros(size(tiltedelem));
0067     
0068     if ~isempty(tiltedelem)
0069         
0070 try
0071     ox=cell2mat(cellfun(@(a)a.Offset(1,1),THERING(tiltedelem),'un',0));
0072         oy=cell2mat(cellfun(@(a)a.Offset(1,2),THERING(tiltedelem),'un',0));
0073         or=cell2mat(cellfun(@(a)a.Rotation(1,1),THERING(tiltedelem),'un',0));
0074 catch
0075     ox=zeros(size(tiltedelem));
0076     oy=zeros(size(tiltedelem));
0077     or=zeros(size(tiltedelem));
0078     
0079 end
0080         ox(isnan(ox))=0;
0081         oy(isnan(oy))=0;
0082         or(isnan(or))=0;
0083         
0084         bpmerrors.offsetx=ox(:)';
0085         bpmerrors.offsety=oy(:)';
0086         bpmerrors.rotation=or(:)';
0087         
0088     end
0089 end
0090 return

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