function viewref
if(~exist('dcinj.ref.001','file'))
    error('cannot find ref file')
end

X = load('dcinj.ref.001');

if (isempty(findobj('Tag','ref')))
   scrsz = get(0,'ScreenSize');
   figure('Position',[scrsz(3)/3 1 scrsz(3)/1.6 scrsz(4)/1.2], 'Tag', 'ref', 'Name', 'viewref');
else
    figure(findobj('Tag', 'ref'));
end

subplot(3,2,1)
plot(X(:,1),X(:,3),'-b');
xlabel('z (m)');
ylabel('p_z (MeV/c)');
subplot(3,2,2)
plot(X(:,1),X(:,4),'-b');
xlabel('z (m)');
ylabel('dE/dz (MeV/m)');
subplot(3,2,3)
plot(X(:,1),X(:,5),'-b');
xlabel('z (m)');
ylabel('\theta_{Larmor} (rad)');
subplot(3,2,4)
plot(X(:,1),X(:,6),'-b');
xlabel('z (m)');
ylabel('x (mm)');
subplot(3,2,5)
plot(X(:,1),X(:,7),'-b');
xlabel('z (m)');
ylabel('y (mm)');
subplot(3,2,6)
plot(X(:,6),X(:,7),'-b');
xlabel('x (mm)');
ylabel('y (mm)');
axis square
xmax = max([X(:,6); X(:,7)]);
xmin = min([X(:,6); X(:,7)]);
axis([xmin xmax xmin xmax]);
