function [stdt1,stdt2,stdt]=Tline_process(p);
% Get params
[tstep,trise,tfall,gain,NPE,Ishot,G,nadc,bw,tau,taus,T,R,fs,ts,apjit]=params();
% Read tek files
[x1,t]=readfiles(p,2); [x2,t]=readfiles(p,3);
% Clip to useful range
% figure(10); plot(t,x1(1,:)); hold; plot(t,x2(1,:),'r'); return
[mini,im]=min(x1(2,:)); % [min2,im2]=min(x2(2,:));
xx1=x1(:,im-20:im+90); 
xx2=x2(:,im-20:im+90);
% figure(31); plot(t(1:111),xx1(1,:)); hold; plot(t(1:111),xx2(1,:),'r'); return
% Build reference
tx1=sum(xx1(:,:))/p;  tx2=sum(xx2(:,:))/p;
dx1=[tx1(2:111)-tx1(1:110) 0]; dx2=[tx2(2:111)-tx2(1:110) 0];
ref1(1,:)=tx1; ref2(1,:)=tx2; ref1(2,:)=dx1; ref2(2,:)=dx2;
% figure(200)
% plot(ref1(1,:)); hold
% plot(ref2(1,:),'r');
% return
% figure(201)
% plot(ref1(2,:)); hold
% plot(ref2(2,:),'r');
% return
% Init variables for sampling_stat_mcp
snn=ones(p); t0=zeros(1,p); i01=max(abs(xx1'));i02=max(abs(xx2'));
% Run Cleland & Stern
[stda1,stdt1,mean_snn1,t1]=sampling_stat_mcp(xx1,ref1,snn,i01,t0,p);
[stda2,stdt2,mean_snn2,t2]=sampling_stat_mcp(xx2,ref2,snn,i02,t0,p);
t1(1:10)
t2(1:10)
t1(1:10)-t2(1:10) 
mean(t1)
stdt1
mean(t2)
stdt2
% Derive stdt
tt1=mean(t1)
tt2=mean(t2)
dt=tt1-tt2
% Colle pas !
return
