Commit 51eb82bf authored by ncarmignani's avatar ncarmignani
Browse files

some graphic improvements

parent d8d2f52b
......@@ -8,18 +8,13 @@ ErrorsH=nan(size(indexes));
ErrorsV=nan(size(indexes));
for ii=1:length(indexes)
pause(2);
ErrorsH(ii)=obj.CheckPolOneSteerer(indexes(ii),'H');
pause(2);
ErrorsV(ii)=obj.CheckPolOneSteerer(indexes(ii),'V');
disp(['~~~~~~~~~~~ Steerer ' num2str(indexes(ii)) ': '])
disp(['H error = ' num2str(ErrorsH(ii)) ', V error = ' num2str(ErrorsV(ii)) ]);
disp('~~~~~~~~~~~')
[ErrorsH(ii), ErrorsV(ii)]=obj.CheckPolOneSteerer(indexes(ii));
end
figure;
plot(indexes,ErrorsH,'DisplayName','Horizontal')
plot(indexes,ErrorsH,'.-','LineWidth',2,'DisplayName','Horizontal')
hold on; grid on;
plot(indexes,ErrorsV,'DisplayName','Vertical')
plot(indexes,ErrorsV,'.-','LineWidth',2,'DisplayName','Vertical')
xlabel('steerer number');
ylabel('Error')
legend('Location','NorthEast')
......
function Error = CheckPolOneSteerer(obj,index,plane)
function [ErrorH, ErrorV] = CheckPolOneSteerer(obj,index)
%CHECKPOLONESTEERER checks the polarity of steerer of index 'index'
%
% Error = CheckPolOneSteerer(index)
......@@ -9,87 +9,122 @@ function Error = CheckPolOneSteerer(obj,index,plane)
%
% see also: CheckPolArraySteerers
obj.n_acquisitions=3;
% hor=false;
if plane=='H'
sst=obj.sHst(index);
indplane=1;
hor=true;
else
sst=obj.sVst(index);
indplane=2;
hor=false;
end
% if plane=='H'
% sst=obj.sHst(index);
% indplane=1;
% hor=true;
% else
% sst=obj.sVst(index);
% indplane=2;
% hor=false;
% end
%% plane H
sst=obj.sHst(index);
bpmafter=find(obj.sBPM>sst);
if hor
v_zero=obj.getHSteerersValues();
else
v_zero=obj.getVSteerersValues();
end
v_zero=obj.getHSteerersValues();
%measurements of trajectories with steerer index at 0, +kick and -kick
traj_zero_Meas=obj.measuretrajectory;
%measurements of trajectories with steerer index at +kick and -kick
v=v_zero;
v(index)=v(index)+obj.kick_rad;
if hor
obj.setHSteerersValues(v);
else
obj.setVSteerersValues(v);
end
pause(2)
traj_pos_Meas=obj.measuretrajectory;
tra_p_Meas=obj.measuretrajectory;
v=v_zero;
v(index)=v(index)-obj.kick_rad;
if hor
obj.setHSteerersValues(v);
else
obj.setVSteerersValues(v);
end
pause(2)
traj_neg_Meas=obj.measuretrajectory;
if hor
tra_n_Meas=obj.measuretrajectory;
obj.setHSteerersValues(v_zero);
else
obj.setVSteerersValues(v_zero);
end
plane='H';indplane=1;
%simulations of trajectories with steerer index at +kick, 0 and -kick
tra_p_Sim=obj.SimulateTrajectoryKick(index,obj.kick_rad,plane);
% tra_z_Sim=obj.SimulateTrajectoryKick(index,0,plane);
tra_n_Sim=obj.SimulateTrajectoryKick(index,-obj.kick_rad,plane);
% compute dtraj_pos and dtraj_neg measured and simulated
dtra_Meas_H=tra_p_Meas(indplane,:)-tra_n_Meas(indplane,:);
%dtra_n_Meas=tra_n_Meas(indplane,:)-traj_zero_Meas(indplane,:);
dtra_Sim_H=tra_p_Sim(indplane,:)-tra_n_Sim(indplane,:);
%dtra_n_Sim=tra_n_Sim(indplane,:)-traj_zero_Sim(indplane,:);
indbpmafter=bpmafter(1:obj.nbpm_after);
ErrorH=100*rms(dtra_Meas_H(indbpmafter)-dtra_Sim_H(indbpmafter))/rms(dtra_Sim_H(indbpmafter));
%% plane V
sst=obj.sVst(index);
bpmafter=find(obj.sBPM>sst);
v_zero=obj.getVSteerersValues();
%measurements of trajectories with steerer index at 0, +kick and -kick
% tra_z_Meas=obj.measuretrajectory;
v=v_zero;
v(index)=v(index)+obj.kick_rad;
obj.setVSteerersValues(v);
pause(2)
tra_p_Meas=obj.measuretrajectory;
v=v_zero;
v(index)=v(index)-obj.kick_rad;
obj.setVSteerersValues(v);
pause(2)
tra_n_Meas=obj.measuretrajectory;
obj.setVSteerersValues(v_zero);
plane='V';indplane=2;
%simulations of trajectories with steerer index at +kick, 0 and -kick
traj_pos_Sim=obj.SimulateTrajectoryKick(index,obj.kick_rad,plane);
traj_zero_Sim=obj.SimulateTrajectoryKick(index,0,plane);
traj_neg_Sim=obj.SimulateTrajectoryKick(index,-obj.kick_rad,plane);
tra_p_Sim=obj.SimulateTrajectoryKick(index,obj.kick_rad,plane);
tra_n_Sim=obj.SimulateTrajectoryKick(index,-obj.kick_rad,plane);
% compute dtraj_pos and dtraj_neg measured and simulated
dtraj_pos_Meas=traj_pos_Meas(indplane,:)-traj_zero_Meas(indplane,:);
dtraj_neg_Meas=traj_neg_Meas(indplane,:)-traj_zero_Meas(indplane,:);
dtraj_pos_Sim=traj_pos_Sim(indplane,:)-traj_zero_Sim(indplane,:);
dtraj_neg_Sim=traj_neg_Sim(indplane,:)-traj_zero_Sim(indplane,:);
dtra_Meas_V=tra_p_Meas(indplane,:)-tra_n_Meas(indplane,:);
dtra_Sim_V=tra_p_Sim(indplane,:)-tra_n_Sim(indplane,:);
indbpmafter=bpmafter(1:obj.nbpm_after);
Error=rms([(dtraj_pos_Meas(indbpmafter)-dtraj_pos_Sim(indbpmafter)),...
(dtraj_neg_Meas(indbpmafter)-dtraj_neg_Sim(indbpmafter))])/...
rms([dtraj_pos_Sim(indbpmafter), dtraj_neg_Sim(indbpmafter)]);
ErrorV=100*rms(dtra_Meas_V(indbpmafter)-dtra_Sim_V(indbpmafter))/rms(dtra_Sim_V(indbpmafter));
% rms([(dtraj_pos_Meas(indbpmafter)-dtraj_pos_Sim(indbpmafter)),...
% (dtraj_neg_Meas(indbpmafter)-dtraj_neg_Sim(indbpmafter))])/...
% rms([dtraj_pos_Sim(indbpmafter), dtraj_neg_Sim(indbpmafter)]);
if(obj.plot)
figure;
subplot(2,1,1)
plot(dtraj_pos_Meas(indbpmafter),'DisplayName','Measured');
plot(dtra_Meas_H(indbpmafter),'.-','LineWidth',2,'MarkerSize',12,'DisplayName','Measured');
hold on; grid on;
plot(dtraj_pos_Sim(indbpmafter),'DisplayName','Simulated');
legend('Location','NorthWest');
ylabel('\Delta traj pos')
plot(dtra_Sim_H(indbpmafter),'.-','LineWidth',2,'MarkerSize',12,'DisplayName','Simulated');
l=legend('Location','NorthWest');
title(l,['Hor err=' num2str(ErrorH,'%1.1f') '%']);
ylabel('\Delta traj H')
subplot(2,1,2)
plot(dtraj_neg_Meas(indbpmafter),'DisplayName','Measured');
plot(dtra_Meas_V(indbpmafter),'.-','LineWidth',2,'MarkerSize',12,'DisplayName','Measured');
hold on; grid on;
plot(dtraj_neg_Sim(indbpmafter),'DisplayName','Simulated');
ylabel('\Delta traj neg')
plot(dtra_Sim_V(indbpmafter),'.-','LineWidth',2,'MarkerSize',12,'DisplayName','Simulated');
ylabel('\Delta traj V')
xlabel(['bpm number after steerer ' num2str(index) ])
legend('Location','SouthWest');
l=legend('Location','SouthWest');
title(l,['Ver err=' num2str(ErrorV,'%1.1f') '%']);
end
disp('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
disp(['Steerer number ' num2str(index) ]);
disp(['H error = ' num2str(ErrorH,'%1.1f') '%']);
disp(['V error = ' num2str(ErrorV,'%1.1f') '%']);
disp('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
end
......@@ -58,7 +58,7 @@ classdef SteerersPolarity < RingControl
%this function checks the polarity a single steerer
Error=CheckPolOneSteerer(obj,index,plane);
[ErrorH,ErrorV]=CheckPolOneSteerer(obj,index);
%this function checks the polarity an array of steerers
Errors=CheckPolArraySteerers(obj,indexes);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment