


[kn, 1) estimated normal quad gradients from sext offsets, quad
errors in quadrupoles and sextupoles.
ks, 2) estimated skew quad gradients from sext offsets, quad
errors in quadrupoles, quadrupole rotation.
ind 3) indexes of locations at wich kn and ks are found
]=EquivalentGradientsFromAlignments6D(
r, 1) AT lattice structure with errors
inCOD
)
the function finds the closed orbit at sextupoles and converts it to
equivalent quadrupole and skew quadrupole gradients for the computation
of skew and normal quadrupole RDT
quadrupole rotations are also converted in skew quadrupole gradients.
it returns the complete list of normal (kn) and skew (ks) quadrupole
gradients at the given indexes (ind) ( not integrated, PolynomB)
see also:


0001 function [kn,ks,ind]=EquivalentGradientsFromAlignments6D(r,inCOD) 0002 %[kn, 1) estimated normal quad gradients from sext offsets, quad 0003 % errors in quadrupoles and sextupoles. 0004 % ks, 2) estimated skew quad gradients from sext offsets, quad 0005 % errors in quadrupoles, quadrupole rotation. 0006 % ind 3) indexes of locations at wich kn and ks are found 0007 % ]=EquivalentGradientsFromAlignments6D( 0008 % r, 1) AT lattice structure with errors 0009 % inCOD 0010 % ) 0011 % 0012 % the function finds the closed orbit at sextupoles and converts it to 0013 % equivalent quadrupole and skew quadrupole gradients for the computation 0014 % of skew and normal quadrupole RDT 0015 % quadrupole rotations are also converted in skew quadrupole gradients. 0016 % 0017 % it returns the complete list of normal (kn) and skew (ks) quadrupole 0018 % gradients at the given indexes (ind) ( not integrated, PolynomB) 0019 % 0020 % 0021 %see also: 0022 0023 % quadrupole and skew quadrupole errors are introduced via COD in 0024 % sextupoles 0025 indsext=find(atgetcells(r,'Class','Sextupole'))'; 0026 0027 b3=atgetfieldvalues(r,indsext,'PolynomB',{1,3}); 0028 0029 oin=findorbit6(r,indsext,inCOD);% orbit at entrance of sextupole DO NOT USE HERE findorbit6Err! 0030 oout=findorbit6(r,indsext+1,inCOD); % orbit at exit of sextupole 0031 0032 xmisal=cellfun(@(a)getT1(a,1),r(indsext)); 0033 ymisal=cellfun(@(a)getT1(a,3),r(indsext)); 0034 0035 Dx=(oout(1,:)+oin(1,:))/2; % orbit average in sextupole 0036 Dy=(oout(3,:)+oin(3,:))/2; % orbit average in sextupole 0037 0038 % quarupole errors in sextupoles 0039 kn_sext_err=cellfun(@(a)a.PolynomB(2),r(indsext)); 0040 ks_sext_err=cellfun(@(a)a.PolynomA(2),r(indsext)); 0041 0042 kn_sext=-2.*b3.*(-Dx+xmisal')'+kn_sext_err; 0043 ks_sext=-2.*b3.*(-Dy+ymisal')'+ks_sext_err; 0044 0045 % quadrupole rotations 0046 indquad=find(atgetcells(r,'Class','Quadrupole'))'; 0047 0048 kn2=atgetfieldvalues(r,indquad,'PolynomB',{1,2}); 0049 ks2=atgetfieldvalues(r,indquad,'PolynomA',{1,2}); 0050 srot=cellfun(@(a)getR1(a),r(indquad)); 0051 0052 kn_quad=(1-srot).*kn2; 0053 ks_quad=-srot.*kn2+ks2; 0054 0055 % all elements with PolynomB, not sextupoles or quadrupoles 0056 indPolB=find(atgetcells(r,'PolynomB') & ... 0057 ~atgetcells(r,'Class','Quadrupole') & ... 0058 ~atgetcells(r,'Class','Sextupole' ))'; 0059 0060 NpolB=cellfun(@(a)length(a.PolynomB),r(indPolB)); 0061 NpolA=cellfun(@(a)length(a.PolynomA),r(indPolB)); 0062 0063 indPolB=indPolB(NpolB>=2 & NpolA>=2 & ~ismember(indPolB,[indquad indsext])'); 0064 0065 kn_all=cellfun(@(a)a.PolynomB(2),r(indPolB));%-kn0_all; 0066 ks_all=cellfun(@(a)a.PolynomA(2),r(indPolB));%-ks0_all; 0067 0068 [ind,ord]=sort([indsext,indquad,indPolB]); 0069 0070 kn=[kn_sext;kn_quad;kn_all]; 0071 ks=[ks_sext;ks_quad;ks_all]; 0072 0073 % integrated strengths 0074 %L=cellfun(@(a)a.Length,r(ind)); 0075 0076 kn=kn(ord);%.*L; 0077 ks=ks(ord);%.*L; 0078 0079 0080 return 0081 0082 0083 function t1=getT1(a,ind) 0084 t1=0; 0085 if isfield(a,'T1') 0086 t1=-a.T1(ind); 0087 end 0088 return 0089 0090 0091 function r1=getR1(a) 0092 r1=0; 0093 if isfield(a,'R1') 0094 r1=asin(a.R1(1,3)); 0095 end 0096 return