0001 function plotdata = plotRDT(lindata,ring,dpp, varargin)
0002
0003 naddvar=length(varargin);
0004 chromatic=0;
0005 coupling=0;
0006 geometric1=0;
0007 geometric2=0;
0008 tuneshifts=0;
0009 OnlyFirst=0;
0010 if(naddvar>0)
0011
0012 switch varargin{1}
0013 case 'chromatic'
0014 chromatic=1;
0015 case 'coupling'
0016 coupling=1;
0017 case 'geometric1'
0018 geometric1=1;
0019 case 'geometric2'
0020 geometric2=1;
0021 case 'tuneshifts'
0022 tuneshifts=1;
0023 otherwise
0024 disp(['The first input must be one of these:']);
0025 disp('''chromatic'', ''coupling'', ''geometric1'', ''geometric2'', ''tuneshifts''');
0026 disp('your input will be considered ''geometric1''');
0027 geometric1=1;
0028 end
0029 if naddvar>1
0030 switch varargin{2}
0031 case 'OnlyFirstOrders'
0032 OnlyFirst=1;
0033 otherwise
0034 disp(['The second input can be only:']);
0035 disp('''OnlyFirstOrders''');
0036 disp('your second input will be ignored');
0037 end
0038 end
0039 else
0040 chromatic=0;
0041 coupling=0;
0042 geometric1=1;
0043 geometric2=0;
0044 tuneshifts=0;
0045 OnlyFirst=0;
0046 end
0047
0048 indSext=findcells(ring,'Class','Sextupole');
0049 indSext=unique(sort([ 1, length(ring),indSext+1]));
0050 indOct=findcells(ring,'Class','Octupole');
0051 indOct=unique(sort([1,length(ring),indOct+1]));
0052 indSO=unique(sort([indSext,indOct]));
0053 indQuad=findcells(ring,'Class','Quadrupole');
0054 indQuad=unique(sort([1,length(ring),indQuad+1]));
0055 indDip=findcells(ring,'Class','Bend');
0056 indDip=unique(sort([1,length(ring),indDip+1]));
0057 indTot=unique(sort([ indSext, indOct, indQuad, indDip ]));
0058 if(geometric1 || geometric2 || tuneshifts)
0059 if(geometric1)
0060 RDT=computeRDT(ring,indSO,'geometric1');
0061 else
0062 if OnlyFirst==1
0063 RDT=computeRDT(ring,indOct,varargin{1},'OnlyFirstOrders');
0064 else
0065 RDT=computeRDT(ring,indSO,varargin{1});
0066 end
0067 end
0068 else
0069 RDT=computeRDT(ring,indTot,varargin{1});
0070 end
0071
0072 Spos=findspos(ring,1:length(ring));
0073 if(chromatic)
0074 h11001=[]; h00111=[]; h20001=[]; h00201=[]; h10002=[];
0075 h11001p=abs(arrayfun(@(x)x.h11001,RDT));
0076 h00111p=abs(arrayfun(@(x)x.h00111,RDT));
0077 h20001p=abs(arrayfun(@(x)x.h20001,RDT));
0078 h00201p=abs(arrayfun(@(x)x.h00201,RDT));
0079 h10002p=abs(arrayfun(@(x)x.h10002,RDT));
0080 for(ii=1:length(indTot)-1)
0081 h11001=[h11001; repmat(h11001p(ii),indTot(ii+1)-indTot(ii),1)];
0082 h00111=[h00111; repmat(h00111p(ii),indTot(ii+1)-indTot(ii),1)];
0083 h20001=[h20001; repmat(h20001p(ii),indTot(ii+1)-indTot(ii),1)];
0084 h00201=[h00201; repmat(h00201p(ii),indTot(ii+1)-indTot(ii),1)];
0085 h10002=[h10002; repmat(h10002p(ii),indTot(ii+1)-indTot(ii),1)];
0086 end
0087 h11001=[h11001; repmat(h11001p(length(indTot)),2,1)];
0088 h00111=[h00111; repmat(h00111p(length(indTot)),2,1)];
0089 h20001=[h20001; repmat(h20001p(length(indTot)),2,1)];
0090 h00201=[h00201; repmat(h00201p(length(indTot)),2,1)];
0091 h10002=[h10002; repmat(h10002p(length(indTot)),2,1)];
0092
0093 plotdata(1).values=[ h11001 h00111 h20001 h00201 ];
0094 plotdata(2).values=[ h10002 ];
0095 plotdata(1).labels={ 'h11001','h00111','h20001','h00201' };
0096 plotdata(2).labels={'h10002'};
0097 plotdata(1).axislabel='absolute value of RDTs';
0098 plotdata(2).axislabel='absolute value of h10002';
0099 end
0100 if(coupling)
0101 h10010=[]; h10100=[];
0102 h10010p=abs(arrayfun(@(x)x.h10010,RDT));
0103 h10100p=abs(arrayfun(@(x)x.h10100,RDT));
0104 for(ii=1:length(indTot)-1)
0105 h10010=[h10010; repmat(h10010p(ii),indTot(ii+1)-indTot(ii),1)];
0106 h10100=[h10100; repmat(h10100p(ii),indTot(ii+1)-indTot(ii),1)];
0107 end
0108 h10010=[h10010; repmat(h10010p(length(indTot)),2,1)];
0109 h10100=[h10100; repmat(h10100p(length(indTot)),2,1)];
0110
0111 plotdata(1).values=[h10010 h10100];
0112 plotdata(1).labels={'h10010','h10100'};
0113 plotdata(1).axislabel='absolute value of RDTs';
0114 end
0115 if(geometric1)
0116 h21000=[]; h30000=[]; h10110=[]; h10020=[]; h10200=[];
0117 h21000p=abs(arrayfun(@(x)x.h21000,RDT));
0118 h30000p=abs(arrayfun(@(x)x.h30000,RDT));
0119 h10110p=abs(arrayfun(@(x)x.h10110,RDT));
0120 h10020p=abs(arrayfun(@(x)x.h10020,RDT));
0121 h10200p=abs(arrayfun(@(x)x.h10200,RDT));
0122 for(ii=1:length(indSO)-1)
0123 h21000=[h21000; repmat(h21000p(ii),indSO(ii+1)-indSO(ii),1)];
0124 h30000=[h30000; repmat(h30000p(ii),indSO(ii+1)-indSO(ii),1)];
0125 h10110=[h10110; repmat(h10110p(ii),indSO(ii+1)-indSO(ii),1)];
0126 h10020=[h10020; repmat(h10020p(ii),indSO(ii+1)-indSO(ii),1)];
0127 h10200=[h10200; repmat(h10200p(ii),indSO(ii+1)-indSO(ii),1)];
0128 end
0129 h21000=[h21000; repmat(h21000p(ii),2,1)];
0130 h30000=[h30000; repmat(h30000p(ii),2,1)];
0131 h10110=[h10110; repmat(h10110p(ii),2,1)];
0132 h10020=[h10020; repmat(h10020p(ii),2,1)];
0133 h10200=[h10200; repmat(h10200p(ii),2,1)];
0134 plotdata(1).values=[h21000 h30000 h10110 h10020 h10200];
0135 plotdata(1).labels={'h21000','h30000','h10110','h10020','h10200'};
0136 plotdata(1).axislabel='absolute value of RDTs';
0137 end
0138 if(geometric2)
0139 h22000=[]; h11110=[]; h00220=[]; h31000=[]; h40000=[]; h20110=[]; h11200=[]; h20020=[]; h20200=[]; h00310=[]; h00400=[];
0140 h22000p=abs(arrayfun(@(x)x.h22000,RDT));
0141 h11110p=abs(arrayfun(@(x)x.h11110,RDT));
0142 h00220p=abs(arrayfun(@(x)x.h00220,RDT));
0143 h31000p=abs(arrayfun(@(x)x.h31000,RDT));
0144 h40000p=abs(arrayfun(@(x)x.h40000,RDT));
0145 h20110p=abs(arrayfun(@(x)x.h20110,RDT));
0146 h11200p=abs(arrayfun(@(x)x.h11200,RDT));
0147 h20020p=abs(arrayfun(@(x)x.h20020,RDT));
0148 h20200p=abs(arrayfun(@(x)x.h20200,RDT));
0149 h00310p=abs(arrayfun(@(x)x.h00310,RDT));
0150 h00400p=abs(arrayfun(@(x)x.h00400,RDT));
0151 if (~OnlyFirst)
0152 for(ii=1:length(indSO)-1)
0153 h22000=[h22000; repmat(h22000p(ii),indSO(ii+1)-indSO(ii),1)];
0154 h11110=[h11110; repmat(h11110p(ii),indSO(ii+1)-indSO(ii),1)];
0155 h00220=[h00220; repmat(h00220p(ii),indSO(ii+1)-indSO(ii),1)];
0156 h31000=[h31000; repmat(h31000p(ii),indSO(ii+1)-indSO(ii),1)];
0157 h40000=[h40000; repmat(h40000p(ii),indSO(ii+1)-indSO(ii),1)];
0158 h20110=[h20110; repmat(h20110p(ii),indSO(ii+1)-indSO(ii),1)];
0159 h11200=[h11200; repmat(h11200p(ii),indSO(ii+1)-indSO(ii),1)];
0160 h20020=[h20020; repmat(h20020p(ii),indSO(ii+1)-indSO(ii),1)];
0161 h20200=[h20200; repmat(h20200p(ii),indSO(ii+1)-indSO(ii),1)];
0162 h00310=[h00310; repmat(h00310p(ii),indSO(ii+1)-indSO(ii),1)];
0163 h00400=[h00400; repmat(h00400p(ii),indSO(ii+1)-indSO(ii),1)];
0164 end
0165 h22000=[h22000; repmat(h22000p(ii),2,1)];
0166 h11110=[h11110; repmat(h11110p(ii),2,1)];
0167 h00220=[h00220; repmat(h00220p(ii),2,1)];
0168 h31000=[h31000; repmat(h31000p(ii),2,1)];
0169 h40000=[h40000; repmat(h40000p(ii),2,1)];
0170 h20110=[h20110; repmat(h20110p(ii),2,1)];
0171 h11200=[h11200; repmat(h11200p(ii),2,1)];
0172 h20020=[h20020; repmat(h20020p(ii),2,1)];
0173 h20200=[h20200; repmat(h20200p(ii),2,1)];
0174 h00310=[h00310; repmat(h00310p(ii),2,1)];
0175 h00400=[h00400; repmat(h00400p(ii),2,1)];
0176 else
0177 for(ii=1:length(indOct)-1)
0178 h22000=[h22000; repmat(h22000p(ii),indOct(ii+1)-indOct(ii),1)];
0179 h11110=[h11110; repmat(h11110p(ii),indOct(ii+1)-indOct(ii),1)];
0180 h00220=[h00220; repmat(h00220p(ii),indOct(ii+1)-indOct(ii),1)];
0181 h31000=[h31000; repmat(h31000p(ii),indOct(ii+1)-indOct(ii),1)];
0182 h40000=[h40000; repmat(h40000p(ii),indOct(ii+1)-indOct(ii),1)];
0183 h20110=[h20110; repmat(h20110p(ii),indOct(ii+1)-indOct(ii),1)];
0184 h11200=[h11200; repmat(h11200p(ii),indOct(ii+1)-indOct(ii),1)];
0185 h20020=[h20020; repmat(h20020p(ii),indOct(ii+1)-indOct(ii),1)];
0186 h20200=[h20200; repmat(h20200p(ii),indOct(ii+1)-indOct(ii),1)];
0187 h00310=[h00310; repmat(h00310p(ii),indOct(ii+1)-indOct(ii),1)];
0188 h00400=[h00400; repmat(h00400p(ii),indOct(ii+1)-indOct(ii),1)];
0189 end
0190 h22000=[h22000; repmat(h22000p(ii),2,1)];
0191 h11110=[h11110; repmat(h11110p(ii),2,1)];
0192 h00220=[h00220; repmat(h00220p(ii),2,1)];
0193 h31000=[h31000; repmat(h31000p(ii),2,1)];
0194 h40000=[h40000; repmat(h40000p(ii),2,1)];
0195 h20110=[h20110; repmat(h20110p(ii),2,1)];
0196 h11200=[h11200; repmat(h11200p(ii),2,1)];
0197 h20020=[h20020; repmat(h20020p(ii),2,1)];
0198 h20200=[h20200; repmat(h20200p(ii),2,1)];
0199 h00310=[h00310; repmat(h00310p(ii),2,1)];
0200 h00400=[h00400; repmat(h00400p(ii),2,1)];
0201 end
0202 plotdata(1).values=[h22000 h11110 h00220 h31000 h40000 h20110 h11200 h20020 h20200 h00310 h00400];
0203 plotdata(1).labels={'h22000','h11110','h00220','h31000','h40000','h20110','h11200','h20020','h20200','h00310','h00400'};
0204 plotdata(1).axislabel='absolute value of RDTs';
0205 end
0206
0207
0208