source: MML/trunk/machine/SOLEIL/StorageRing/diagnostics/mosteffectivecorrector2.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 11 years ago

Initial import--MML version from SOLEIL@2013

File size: 2.7 KB
Line 
1function [delcm corr_orbit MEC orbit_reduction] = mosteffectivecorrector2(orbit,correctors,RF)
2%MOSTEFFECTIVECORRECTOR - Correction using most effective corrector
3%
4%  INPUTS
5%  1. plane of correction - 1 {Default} means Horizontal plane
6%                           2 means vertical planes
7%
8%  OUTPUTS
9%  2. delcm - Corrector strengths from direct orbit correction
10%
11%  See Also setorbit
12
13%
14%  Written by Laurent S. Nadolski
15
16CMFamily  = {'HCOR', 'VCOR'};
17
18
19switch correctors
20    case {'HCOR','FHCOR'}
21        plane=1;
22    case {'VCOR','FVCOR'}
23        plane=2;
24end
25       
26
27%%
28switch correctors
29    case {'FHCOR','FVCOR'}
30        R0 = getbpmresp4FOFB('Struct');
31
32        R = R0(plane,plane).Data;
33        CORlist = R0(plane,plane).Actuator.DeviceList;
34        N_corr=50;
35    case {'HCOR','VCOR'}
36        R0 = getbpmresp('Struct');
37
38        R = R0(plane,plane).Data;
39        CORlist = R0(plane,plane).Actuator.DeviceList;
40        N_corr=57;
41end
42%%
43if RF
44    switch correctors
45        case{'FHCOR','HCOR'}
46            Eta = modeldisp('BPMx', 'Hardware');
47            RFWeight = 10 * mean(std(R)) / std(Eta);
48            R = [R0(1,1).Data RFWeight*Eta];
49            N_corr=N_corr+1
50    end
51end   
52%%   
53Rinv = pinv(R);
54
55
56
57X0 = orbit;
58
59X0std = std(X0);
60
61delcm = Rinv*(X0);
62
63X = X0(:,ones(N_corr,1));
64
65% get index of most effective corrector and reduction factor
66[val idx] = min(std(X-R*diag(delcm)));
67
68efficiency=val/std(X0)*100;
69
70orbit_diff=std(X-R*diag(delcm));
71for i=1:N_corr
72    if orbit_diff(i) >X0std
73        orbit_reduction(i)=0;
74    else
75        orbit_reduction(i)=(1-(orbit_diff(i)./X0std))*100;
76    end
77end
78efficiency_array=std(X-R*diag(delcm));
79
80% if DisplayFlag
81%     figure(2001)
82%     subplot(2,1,1)
83%     bar(delcm)
84%     xlabel('Corrector number');
85%     ylabel('Corrector Strength [A]');
86%     title(sprintf('Most effective corrector using %s Family',CMFamily{plane}));
87%     subplot(2,1,2)
88%     plot(X0,'b'); hold on;
89    theta = zeros(N_corr,1);
90    theta(idx) = delcm(idx);
91    corr_orbit=R*theta;
92%     plot(corr_orbit,'r'); hold off;
93%     xlabel('BPM number')
94%     ylabel(' Close orbit [mm]')
95%     legend('Before correction','Prediction')
96% end
97
98CORlist =  R0(plane,plane).Actuator.DeviceList;
99%  fprintf('Most effective corrector is %s [%d %d] (%f A): orbit reduction by %f mm rms\n', ...
100%     correctors, CORlist(idx,:), delcm(idx), X0std-val)
101if RF && idx==N_corr && plane==1
102    fprintf('Most effective corrector is %s RF (%f Hz): orbit reduction by %f percent\n', ...
103        correctors, delcm(idx), orbit_reduction(idx))
104    MEC='RF';
105 
106else
107    fprintf('Most effective corrector is %s [%d %d] (%f A): orbit reduction by %f percent\n', ...
108        correctors, CORlist(idx,:), delcm(idx), orbit_reduction(idx))
109    MEC=CORlist(idx,:);
110end
111
Note: See TracBrowser for help on using the repository browser.