1 | close all; clear all; clc |
---|
2 | load FFX.mat |
---|
3 | cd('./KK') |
---|
4 | |
---|
5 | for c=[2:10]%, 14:18 |
---|
6 | c |
---|
7 | % for c=1:20 |
---|
8 | SP=flip(Freq(3:end)); |
---|
9 | SS(c,:)=flip(FF(c,3:end))/9; |
---|
10 | % SSM(c)=max(SS); |
---|
11 | [RSP,ISP(c,:)]=SRf(SP,SS(c,:)); |
---|
12 | % |
---|
13 | |
---|
14 | % figure (1) |
---|
15 | % plot(SP,SS(c,:),'or') |
---|
16 | % hold on |
---|
17 | % plot(RSP) |
---|
18 | |
---|
19 | PhaseH=-(imag(hilbert(log(abs(RSP))))); |
---|
20 | RPH=real((ifft(RSP.*exp(1i.*(PhaseH))))); |
---|
21 | |
---|
22 | |
---|
23 | % figure(2) |
---|
24 | [mx,ps]=max(RPH) |
---|
25 | RPH= [zeros(1,80-ps), RPH(1:end-(80-ps))] |
---|
26 | % plot((1:length(RPH))*1e-9/length(RPH),RPH) |
---|
27 | |
---|
28 | Gauss=@(mu,sig,A,x)A.*exp(-(x-mu).^2/(2*sig^2)) |
---|
29 | % hold on |
---|
30 | %2.1e-12 |
---|
31 | Profile5=Gauss(ps*1e-9/length(RPH),2.1e-12,mx,(1:length(RPH))*1e-9/length(RPH)); |
---|
32 | % plot((1:length(RPH))*1e-9/length(RPH),Profile5,'r') |
---|
33 | FWHM(c-1)=sum(RPH>max(RPH)/2)*1e-9/length(RPH) |
---|
34 | FW01M(c-1)=sum(RPH>max(RPH)*0.1)*1e-9/length(RPH) |
---|
35 | FW09M(c-1)=sum(RPH>max(RPH)*0.9)*1e-9/length(RPH) |
---|
36 | |
---|
37 | |
---|
38 | PR(c-1,:)=RPH; |
---|
39 | sum(Profile5>max(Profile5)/2)*1e-9/length(Profile5) |
---|
40 | % figure(1) |
---|
41 | % plot(abs(fft(RPH)),'r') |
---|
42 | % plot(abs(fft(Profile5./sum(Profile5))),'k') |
---|
43 | |
---|
44 | end |
---|
45 | Bphase=sort([8.14, 8.09, 8.04, 7.94, 7.84, 7.74, 8.19, 8.24, 8.34, 8.44, 8.54, 8.64, 8.74, 8.84, 8.94, 9.04, 9.14, 9.24]); |
---|
46 | |
---|
47 | % ds=1:20; |
---|
48 | figure |
---|
49 | hold on |
---|
50 | plot(Bphase(2:10),FW01M(:)*1e+12,'->k','linewidth',2) |
---|
51 | plot(Bphase(2:10),FWHM(:)*1e+12,'->b','linewidth',2) |
---|
52 | plot(Bphase(2:10),FW09M(:)*1e+12,'->r','linewidth',2) |
---|
53 | |
---|
54 | set(gca,'fontsize',16) |
---|
55 | xlabel('\phi_B, [a.u.]') |
---|
56 | ylabel('Pulsewidth, [ps]') |
---|
57 | legend('FW0.1M','FWHM','FW0.9M','Orientation','horizontal') |
---|
58 | grid on |
---|
59 | title('Pulsewidth vs. Buncher phase') |
---|
60 | |
---|
61 | figure |
---|
62 | [hc hc]=contourf((1:length(RPH))*1e-9/length(RPH)*1e+12,Bphase(2:10),PR*500) |
---|
63 | colorbar |
---|
64 | set(hc,'LineStyle','none'); |
---|
65 | xlim([0 50]) |
---|
66 | set(gca,'fontsize',16) |
---|
67 | |
---|
68 | xlabel('Time, [ps]') |
---|
69 | ylabel('\phi_B, [a.u.]') |
---|
70 | title('Bunch profile') |
---|
71 | |
---|
72 | |
---|
73 | figure |
---|
74 | |
---|
75 | hold on |
---|
76 | plot(SP, SS(2,:),'ob','linewidth',2) |
---|
77 | plot(0:(length(ISP)-1), ISP(2,:),'-.b','linewidth',2) |
---|
78 | plot(SP, SS(4,:),'om','linewidth',2) |
---|
79 | plot(0:(length(ISP)-1), ISP(4,:),'-.m','linewidth',2) |
---|
80 | plot(SP, SS(6,:),'ok','linewidth',2) |
---|
81 | plot(0:(length(ISP)-1), ISP(6,:),'-.k','linewidth',2) |
---|
82 | plot(SP, SS(8,:),'og','linewidth',2) |
---|
83 | plot(0:(length(ISP)-1), ISP(8,:),'-.g','linewidth',2) |
---|
84 | plot(SP, SS(10,:),'or','linewidth',2) |
---|
85 | plot(0:(length(ISP)-1), ISP(10,:),'-.r','linewidth',2) |
---|
86 | |
---|
87 | set(gca,'fontsize',16) |
---|
88 | xlabel('Frequency, [GHz]') |
---|
89 | legend('\phi_B=7.84','','\phi_B=8.04','','\phi_B=8.14','','\phi_B=8.24','','\phi_B=8.44','') |
---|
90 | % 2 4 6 8 10 |
---|
91 | title('Form Factor (BGS=10 mm)') |
---|
92 | ylabel('Amplitude, [a.u.]') |
---|
93 | xlim([0, 200]) |
---|
94 | grid on |
---|
95 | |
---|
96 | figure |
---|
97 | |
---|
98 | hold on |
---|
99 | plot((0:(length(RPH)-1))*1e-9/length(RPH)*1e+12, PR(1,:)*500,'-.b','linewidth',2) |
---|
100 | plot((0:(length(RPH)-1))*1e-9/length(RPH)*1e+12, PR(3,:)*500,'-.m','linewidth',2) |
---|
101 | plot((0:(length(RPH)-1))*1e-9/length(RPH)*1e+12, PR(5,:)*500,'-.k','linewidth',2) |
---|
102 | plot((0:(length(RPH)-1))*1e-9/length(RPH)*1e+12, PR(6,:)*500,'-.g','linewidth',2) |
---|
103 | plot((0:(length(RPH)-1))*1e-9/length(RPH)*1e+12, PR(9,:)*500,'-.r','linewidth',2) |
---|
104 | |
---|
105 | set(gca,'fontsize',16) |
---|
106 | xlabel('Time, [ps]') |
---|
107 | legend('\phi_B=7.84','\phi_B=8.04','\phi_B=8.14','\phi_B=8.24','\phi_B=8.44') |
---|
108 | % 2 4 6 8 10 |
---|
109 | title('Reconstructed profile') |
---|
110 | ylabel('Amplitude, [a.u.]') |
---|
111 | xlim([0, 50]) |
---|
112 | grid on |
---|
113 | |
---|
114 | |
---|
115 | figure |
---|
116 | |
---|
117 | hold on |
---|
118 | plot((0:(length(RPH)-1))*1e-9/length(RPH)*1e+12, PR(5,:)*500,'-.b','linewidth',2) |
---|
119 | plot((0:(length(RPH)-1))*1e-9/length(RPH)*1e+12, PR(6,:)*500,'-.m','linewidth',2) |
---|
120 | plot((0:(length(RPH)-1))*1e-9/length(RPH)*1e+12, PR(7,:)*500,'-.k','linewidth',2) |
---|
121 | plot((0:(length(RPH)-1))*1e-9/length(RPH)*1e+12, PR(8,:)*500,'-.g','linewidth',2) |
---|
122 | plot((0:(length(RPH)-1))*1e-9/length(RPH)*1e+12, PR(9,:)*500,'-.r','linewidth',2) |
---|
123 | |
---|
124 | set(gca,'fontsize',16) |
---|
125 | xlabel('Time, [ps]') |
---|
126 | legend('\phi_B=8.14','\phi_B=8.19','\phi_B=8.24','\phi_B=8.34','\phi_B=8.44') |
---|
127 | % 2 4 6 8 10 |
---|
128 | title('Reconstructed profile') |
---|
129 | ylabel('Amplitude, [a.u.]') |
---|
130 | xlim([0, 50]) |
---|
131 | grid on |
---|
132 | |
---|
133 | |
---|
134 | time =(0:(length(RPH)-1))*1e-9/length(RPH)*1e+9;%ns |
---|
135 | Profile=PR(6,:)*500; |
---|
136 | |
---|
137 | save P6.mat time Profile |
---|
138 | |
---|
139 | |
---|
140 | |
---|
141 | |
---|
142 | |
---|
143 | |
---|
144 | |
---|
145 | |
---|
146 | |
---|
147 | |
---|
148 | |
---|
149 | |
---|
150 | |
---|
151 | cd('..') |
---|