Home > pubtools > LatticeTuningFunctions > errors > atsetbpmerr.m

atsetbpmerr

PURPOSE ^

ATSETBPMERR sets the misalignment vectors

SYNOPSIS ^

function ring=atsetbpmerr(varargin)

DESCRIPTION ^

ATSETBPMERR sets the misalignment vectors

 RING=ATSETBPMERR(RING, ELEMINDEX, OX,OY, GX,GY, RX,RY, Rot) 
 sets the bpm errors of one element or a group of elements 
 
 ELEMINDEX contains indexes of elements to be misaligned [1xN]
 OX,OY, are reading offsets [1x1 (all identical) or 1xN]
 GX,GY, are gain errors     [1x1 (all identical) or 1xN]
 RX,RY, are resolution errors  [1x1 (all identical) or 1xN]
 Rot is the rotation of the BPM about the s-axis. [1x1 (all identical) or 1xN]

 ATSETBPMERR(ELEMINDEX, OX,OY, GX,GY, RX,RY, Rot) Uses the global variable THERING

 See also: ATSETTILT ATSETSHIFT

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function ring=atsetbpmerr(varargin)
0002 %ATSETBPMERR sets the misalignment vectors
0003 %
0004 % RING=ATSETBPMERR(RING, ELEMINDEX, OX,OY, GX,GY, RX,RY, Rot)
0005 % sets the bpm errors of one element or a group of elements
0006 %
0007 % ELEMINDEX contains indexes of elements to be misaligned [1xN]
0008 % OX,OY, are reading offsets [1x1 (all identical) or 1xN]
0009 % GX,GY, are gain errors     [1x1 (all identical) or 1xN]
0010 % RX,RY, are resolution errors  [1x1 (all identical) or 1xN]
0011 % Rot is the rotation of the BPM about the s-axis. [1x1 (all identical) or 1xN]
0012 %
0013 % ATSETBPMERR(ELEMINDEX, OX,OY, GX,GY, RX,RY, Rot) Uses the global variable THERING
0014 %
0015 % See also: ATSETTILT ATSETSHIFT
0016 
0017 global THERING
0018 if ~iscell(varargin{1})
0019     THERING=atsetbpmerr(THERING,varargin{:});
0020 else
0021     [ring,idx,ox,oy,gx,gy,rx,ry,rot]=deal(varargin{:});
0022     
0023     if length(ox) == 1
0024         ox=ox*ones(size(idx)); %#ok<*NASGU>
0025     elseif length(ox) ~= length(idx)
0026         error('AT:length','Vector lengths are incompatible: %i/%i.',length(idx),length(ox));
0027     end
0028     if length(oy) == 1
0029         oy=oy*ones(size(idx));
0030     elseif length(oy) ~= length(idx)
0031         error('AT:length','Vector lengths are incompatible: %i/%i.',length(idx),length(oy))
0032     end
0033 
0034     if length(gx) == 1
0035         gx=gx*ones(size(idx));
0036     elseif length(gx) ~= length(idx)
0037         error('AT:length','Vector lengths are incompatible: %i/%i.',length(idx),length(gx));
0038     end
0039     if length(gy) == 1
0040         gy=gy*ones(size(idx));
0041     elseif length(gy) ~= length(idx)
0042         error('AT:length','Vector lengths are incompatible: %i/%i.',length(idx),length(gy))
0043     end
0044 
0045     if length(rx) == 1
0046         rx=rx*ones(size(idx));
0047     elseif length(rx) ~= length(idx)
0048         error('AT:length','Vector lengths are incompatible: %i/%i.',length(idx),length(rx));
0049     end
0050     if length(ry) == 1
0051         ry=ry*ones(size(idx));
0052     elseif length(ry) ~= length(idx)
0053         error('AT:length','Vector lengths are incompatible: %i/%i.',length(idx),length(ry))
0054     end
0055     
0056     if length(rot) == 1
0057         rot=rot*ones(size(idx));
0058     elseif length(rot) ~= length(idx)
0059         error('AT:length','Vector lengths are incompatible: %i/%i.',length(idx),length(rot))
0060     end
0061     
0062         
0063     ring(idx)=cellfun(@(el,a,b)setfield(el,'Offset',[a,b]),ring(idx),num2cell(ox),num2cell(oy),'un',0);
0064     ring(idx)=cellfun(@(el,a,b)setfield(el,'Scale',1+[a,b]),ring(idx),num2cell(gx),num2cell(gy),'un',0);
0065     ring(idx)=cellfun(@(el,a,b)setfield(el,'Reading',[a,b]),ring(idx),num2cell(rx),num2cell(ry),'un',0);
0066     ring(idx)=cellfun(@(el,a)setfield(el,'Rotation',a),ring(idx),num2cell(rot),'un',0); %#ok<*SFLD>
0067     
0068     
0069 end

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