ast=load('l0_test.ini.astra');
gpt=load('l0_test.ini.gpt');

c = 299792458;
e = 1.60217657e-19;
m = 9.10938291e-31;

mc2=m*c*c/abs(e);

xast=ast(2:end,1);
xgpt=gpt(:,1);

diffx=xast-xgpt;
%nnz(diffx)

yast=ast(2:end,2);
ygpt=gpt(:,2);

diffy=yast-ygpt;
%nnz(diffy)

zast=ast(2:end,3);
zgpt=gpt(:,3);

diffz=zast-zgpt;
%nnz(diffz)

pxast=ast(2:end,4);
pxgpt=mc2*gpt(:,4);

diffpx=pxast-pxgpt;
%nnz(diffpx)
mean(diffpx)/mean(pxast)

pyast=ast(2:end,5);
pygpt=mc2*gpt(:,5);

diffpy=pyast-pygpt;
%nnz(diffpy)
mean(diffpy)/mean(pyast)

pzast=ast(2:end,6);
pzgpt=mc2*gpt(:,6);

diffpz=pzast-pzgpt;
mean(diffpz)/mean(pzast);

tast=1e-9*ast(2:end,7);
tgpt=gpt(:,7);

difft=tast-tgpt;
mean(difft)/mean(tast)
nnz(difft)

[nast, cast]=hist(-tast,100);
[ngpt, cgpt]=hist(tgpt,100);

figure(1)
plot(cast,nast,cgpt,ngpt)

%figure(1)
%plot(xast,pxast,'.')
%figure(2)
%plot(xgpt,pxgpt,'.')
