Analysis of CERN testbench data with Vcsel output split to 2 APDs. Scope inputs are:1)Inverse of pulser output into Vcsel 2)front 64mm^2 APD,3)back 64mm^2 APD,4)trigger to pulser and scope.

preamps are Wenteq with a nominal voltage gain of 100. DAQ is a Lecroy 1GHz scope sampling at 5 GSa/s. APD bias
voltage was 1800 volts.
SNW-Sept. 14, 2014

Below we find that we are close to that, (8mV), even before the data with least count reduced by a factor of 20.

SetDirectory["~bastian/Desktop/desy2015"]; 
Namelist=FileNames[]
Namelist//Length;
nfiles=%;

filename = Namelist[[11]]

scopedata=Import[filename,"csv"];

Dimensions[scopedata]

nevents=2000;
nbins=202;

t0=scopedata[[1,2]];
dt=scopedata[[1,3]]*10^9
time=Range[0,(nbins-4)]*dt;

v1=Table[Take[scopedata[[4*(i-1)+1]],-(nbins-3)],{i,nevents}];
v2=Table[Take[scopedata[[4*(i-1)+2]],-(nbins-3)],{i,nevents}];
(*v3=Table[Take[scopedata[[4*(i-1)+3]],-(nbins-3)],{i,nevents}];*)
(*v4=Table[Take[scopedata[[4*(i-1)+4]],-502],{i,8000}];*)

ListPlot[Transpose[{time,v1[[5]]}],Joined->True,PlotRange->{{0,3},{-.1,.1}}]
ListPlot[Transpose[{time,v2[[1]]}],Joined->True,PlotRange->{All,{-.1,1}}]

“iorder” specifies level of filtering. ie iorder=5 reduces 5 GSa/s to 1 GSa/s average of 5 pts.

inbase1=Table[Mean[Take[v1[[i]],30]],{i,nevents}];
innoise1=Table[RootMeanSquare[Take[v1[[i]],30]-inbase1[[i]]],{i,nevents}];
inbase2=Table[Mean[Take[v2[[i]],100]],{i,nevents}];
innoise2=Table[RootMeanSquare[Take[v2[[i]],100]-inbase2[[i]]],{i,nevents}];

GraphicsGrid[{{Histogram[inbase2,PlotLabel->"CH2 baseline"],Histogram[inbase1,PlotLabel->"CH1 baseline"]},{Histogram[innoise2,PlotLabel->"CH2 noise"],Histogram[innoise1,PlotLabel->"CH1 noise"]}},Frame->All,ImageSize->Large]

Print[Style[{" noise2= ",Mean[innoise2](*," noise2= ",Mean[innoise2]," noise3= ",Mean[innoise3]*)," volts"} ,Large, Red]]

time=Range[0,(nbins-4)]*dt;
iorder=1;

Dimensions[time]
Dimensions[v1[[1]]]

Manipulate[ListPlot[{Transpose[{MovingAverage[time,iorder],MovingAverage[0.25*(v1[[i]]-inbase1[[i]]),iorder]}],Transpose[{MovingAverage[time-9.6,iorder],MovingAverage[(v2[[i]]-inbase2[[i]]),iorder]}](*,Transpose[{MovingAverage[time-.6,iorder],MovingAverage[(v3[[i]]),iorder]}]*)},PlotRange->{{3,5},{-.2,1}},PlotStyle->Directive[AbsoluteThickness[1.8]],LabelStyle->Directive[Orange,Bold],PlotLabel->Style[CERN-bench,Large],AxesLabel->{nanosec,V},PlotStyle->{Red,Blue,Green},PlotLegends->Placed[{"Vcsel","Front","Back"},{0.85,0.85}],Joined->True,ImageSize->Large,Frame->True,FrameStyle->Black],{i,1,100,1},SaveDefinitions->True]

Manipulate[ListPlot[Transpose[{time,v1[[i]]}],PlotRange->{{3,5},{-.2,4}},PlotStyle->Directive[AbsoluteThickness[1.8]],LabelStyle->Directive[Orange,Bold],PlotLabel->Style[CERN-bench,Large],AxesLabel->{nanosec,V},PlotStyle->{Red,Blue,Green},PlotLegends->Placed[{"Vcsel","Front","Back"},{0.85,0.85}],Joined->True,ImageSize->Large,Frame->True,FrameStyle->Black],{i,1,100,1},SaveDefinitions->True]

v2fil=Table[Take[WienerFilter[(v2[[i]]-inbase2[[i]]),2,.2],{121,180}],{i,1,nevents}];
v1fil=Table[Take[WienerFilter[(v1[[i]]-inbase1[[i]]),2,.2],{31,90.}],{i,1,nevents}];
pk2=Table[Max[v2fil[[i]]],{i,nevents}];
pk1=Table[Max[v1fil[[i]]],{i,nevents}];

tfit=0.1*Range[60];
Dimensions[v2fil]
Dimensions[tfit]

ListPlot[Drop[Drop[v1fil[[1]],-37],7]]

tft=Range[16]*.1;
a=Table[Drop[Drop[v1fil[[i]],-37],7],{i,nevents}];
meana=Table[a[[i]].tft/Total[a[[i]]],{i,nevents}];

Histogram[meana]

ListPlot[{Transpose[{tfit,(v2fil[[1]])}],Transpose[{tfit,(v1fil[[1]])}]},Joined->True,PlotRange->{All,{-.1,4}}]

GraphicsRow[{Histogram[pk1],Histogram[pk2]},PlotLabel->"PH Distributions-Vcsel,APD",ImageSize->Large]

v2fit=Table[Transpose[{v2fil[[i]],tfit}],{i,1,nevents}];
v1fit=Table[Transpose[{v1fil[[i]],tfit}],{i,1,nevents}];

ListPlot[Take[v1fit[[1]],{9,13}]]
ListPlot[Take[v2fit[[1]],{10,24}]]

difftr=ConstantArray[0,5]

trig2=ConstantArray[0,nevents];trig3=ConstantArray[0,nevents];
tr2=ConstantArray[0,nevents];tr3=ConstantArray[0,nevents];
ithr=1;timethreshold={.075,.1,.15,.2,.25};
Do[
Clear[fun];
fun[x_]:=Evaluate[Fit[Take[v2fit[[i]],{10,24}],{1,x},x]];
tr2[[i]]=Evaluate[fun[0.9*pk2[[i]]]]-Evaluate[fun[0.1*pk2[[i]]]];
trig2[[i]]=Evaluate[fun[.5]];
,{i,nevents}];
Do[
Clear[fun];
fun[x_]:=Evaluate[Fit[Take[v1fit[[i]],{9,13}],{1,x},x]];
tr3[[i]]=Evaluate[fun[0.9*pk1[[i]]]]-Evaluate[fun[0.1*pk1[[i]]]];
trig3[[i]]=Evaluate[fun[1.5]];
,{i,nevents}];

GraphicsRow[{Histogram[tr2],Histogram[tr3]},Frame->All,ImageSize->Large]

ListPlot[Transpose[{trig2,meana}],PlotStyle->Directive[Black,PointSize[Medium]],AxesLabel->{"t(APD2)","t(Vcsel)"},LabelStyle->Directive[Blue,Bold,18],AxesStyle->Directive[Bold]]

{Histogram[trig2],Histogram[trig3]}

trigdif=(trig2-trig3);
Histogram[trigdif]

bc=BinCounts[trigdif,{0.34,.44,.005}];
Length[bc]

bins=Range[.34,.44-.005,.005]

bc1=Transpose[{bins,bc}];
ListPlot[bc1,Joined->True]

ff = FindFit[bc1, {amp1*s1*PDF[NormalDistribution[m1,s1],x],
 .34<m1<.44},{{m1,.40},{s1,.02},{amp1,150}},x]

fittedcurve = amp1*s1*PDF[NormalDistribution[m1,s1],x]/. ff

Plot[fittedcurve,{x,.34,.44},PlotStyle->Red,PlotRange->All]

slpp=Show[Histogram[trigdif,{.34,.44,.005},ChartElementFunction->"GradientScaleRectangle"],Plot[fittedcurve,{x,.34,.44},PlotStyle->Red,PlotLabel->"(Subscript[δ, t12])"],
PlotRange->All]

{mean,sig}={m1,s1}/. ff
m=N[mean,2];
s=N[sig,2];
pt = TableForm[{{m,s}},
TableHeadings->{{},{"<(Subscript[δ, t1 - t2])>","σ(nsec)"}}]

Show[slpp, Graphics[Inset[Style[pt,16],{.36,150},Background->LightGray],Frame->True],ImageSize->Large,Frame->True,FrameStyle->Directive[Black,16]]

GraphicsRow[{ListPlot[Transpose[{trig2,trig3}],PlotStyle->Directive[Black,PointSize[Medium]],AxesLabel->{"tVcsel(nsec)","tAPD(nsec)"},LabelStyle->Directive[Blue,Bold,18],AxesStyle->Directive[Bold]],Show[slpp, Graphics[Inset[Style[pt,16],{.36,150},Background->LightGray],Frame->True],Frame->True,FrameStyle->Directive[Black,16]]},ImageSize->Full,Frame->True]

Dimensions[v2]

v1sum=Sum[v1[[j]],{j,1,533}];
v2sum=Sum[v2[[j]],{j,1,533}];
(*v3sum=Sum[v3[[j]],{j,1,533}];*)
Dimensions[v2sum]
time=Range[0,(nbins-4)]*dt;
Dimensions[time]

ListPlot[v2[[2]],PlotRange->Full]

ListPlot[{Transpose[{time,0.5*v1sum/533}],Transpose[{time,-v2sum/533}](*,Transpose[{time,-20*v3sum/533}]*)},PlotRange->{{8,18},{-.1,2}},Joined->True]

Leading edge slopes

timbin[t_]:=IntegerPart[t/dt];

timbin[74]
timbin[76.5]
timbin[55.5]
timbin[55.5-3]
timbin[59]
timbin[59-3]

Now look at peak amplitude on all 3 channels.

Clear[peak4,peak2,peak3];
peak4=Table[Max[Take[0.2(v4[[i]]-inbase4[[i]]),{247,280}]],{i,8000}];
peak2=Table[Max[Take[-(v2[[i]]-inbase2[[i]]),{262,295}]],{i,8000}];
peak3=Table[Max[Take[-(v3[[i]]-inbase3[[i]]),{264,297}]],{i,8000}];

GraphicsRow[{Histogram[peak2,{0.5,0.85,.01}],Histogram[peak3,{0.5,0.85,.01}],Histogram[peak4,{0.7,0.85,.01}]},ImageSize->Large]

Now try to improve things by fitting the leading edge over the same time range. Also adjust fixed phase differences
between channels and scale to simplify fitting. Phases of ch4, 2, 3 are - 3, 0., +.4 nsec. Vcsel trigger is ~5 times amplifier outputs. Polarity of signals is negative. Vcsel trigger is ~5* largerthan amp signals. We highlight the region from 52.5 to 55.5 nsec

(*sig4=Table[0.2*Take[(v4[[i]]-inbase4[[i]])/peak4[[i]],{247,267}],{i,1,8000}];*)
Clear[sig2,sig3]
sig2=Table[Take[-WienerFilter[(v2[[i]]-inbase2[[i]]),4,.1],{370,382}],{i,1,8000}];
sig3=Table[Take[-WienerFilter[(v3[[i]]-inbase3[[i]]),4,.1],{373,385}],{i,1,8000}];
Clear[timecut];
timecut=Range[370,382]*dt;

Dimensions[timecut]
Dimensions[sig2]
Dimensions[sig3]

iorder=1;
Manipulate[ListPlot[{(*Transpose[{MovingAverage[timecut,iorder],MovingAverage[sig4[[i]],iorder]}],*)Transpose[{MovingAverage[timecut,iorder],MovingAverage[sig2[[i]],iorder]}],Transpose[{MovingAverage[timecut,iorder],MovingAverage[sig3[[i]],iorder]}]},PlotRange->Full,PlotStyle->Directive[AbsoluteThickness[1.8]],LabelStyle->Directive[Orange,Bold],PlotLabel->Style[CERN-bench,Large],AxesLabel->{nsec,v},PlotStyle->{Red,Blue,Green},PlotLegends->Placed[{"Vcsel trigger","Front","Back"},{0.85,0.85}],Joined->True,ImageSize->Large,Frame->True,FrameStyle->Black],{i,1,200,1},SaveDefinitions->True]

We now fit with a linear fit, the regon of interest.

iorder=3
Dimensions[Take[timecut,{4,18}]]
timefit=MovingAverage[Take[timecut,{4,18}],iorder];
Dimensions[timefit]

points4=Table[Transpose[{MovingAverage[Take[sig4[[i]],{4,18}],iorder],timefit}],{i,1,8000}];
points2=Table[Transpose[{MovingAverage[Take[sig2[[i]],{4,18}],iorder],timefit}],{i,1,8000}];
points3=Table[Transpose[{MovingAverage[Take[sig3[[i]],{4,18}],iorder],timefit}],{i,1,8000}];

l=Fit[points3[[3]],{1,x},x]
p=Fit[points3[[3]], {1,x,x^2}, x]
Show[ListPlot[points3[[3]], PlotStyle->Red], Plot[{l, p}, {x,0,1}]]

difftr=ConstantArray[0,6]

trig4=ConstantArray[0,8000];trig2=ConstantArray[0,8000];trig3=ConstantArray[0,8000];
tr4=ConstantArray[0,8000];tr2=ConstantArray[0,8000];tr3=ConstantArray[0,8000];
ithr=6;timethreshold={.15,.2,.25,.35,.45,.55};
Do[
Clear[fun];
fun[x_]:=Evaluate[Fit[points4[[i]],{1,x},x]];
tr4[[i]]=Evaluate[fun[.9]]-Evaluate[fun[.1]];;
trig4[[i]]=Evaluate[fun[timethreshold[[ithr]]]];
,{i,8000}];
Do[
Clear[fun];
fun[x_]:=Evaluate[Fit[points2[[i]],{1,x},x]];
tr2[[i]]=Evaluate[fun[.9]]-Evaluate[fun[.1]];
trig2[[i]]=Evaluate[fun[timethreshold[[ithr]]]];
,{i,8000}];
Do[
Clear[fun];
fun[x_]:=Evaluate[Fit[points3[[i]],{1,x},x]];
tr3[[i]]=Evaluate[fun[.9]]-Evaluate[fun[.1]];
trig3[[i]]=Evaluate[fun[timethreshold[[ithr]]]];
,{i,8000}];

m=Mean[(trig2-trig3)]
sig=RootMeanSquare[(trig2-trig3)-m]

Now create an n - tuple wth information for studying timing.

Clear[tntuple]
tntuple=Transpose[{peak2,peak3,peak4,trig2,trig3,trig4,tr2,tr3,tr4}];

cuttrig2=Select[tntuple,(#[[1]]>0.7)&][[All,4]];
cuttrig3=Select[tntuple,(#[[1]]>0.7)&][[All,5]];
ListPlot[Transpose[{cuttrig2,cuttrig3}]]

mtrig=Mean[(cuttrig2-cuttrig3)]
jitter=RootMeanSquare[(cuttrig2-cuttrig3-mtrig)]
difftr[[ithr]]=jitter;

ListPlot[Transpose[{timethreshold,difftr/Sqrt[2]}],PlotLabel->"Difference time jitter/Sqrt[2]-linear,iorder=3,no CF vs. trigger level",AxesLabel->{V,nsec},Frame->True]

ListPlot[Transpose[{timethreshold,difftr/Sqrt[2]}],PlotLabel->"Difference time jitter/Sqrt[2]-linear,iorder=3 vs. trigger level",AxesLabel->{V,nsec},Frame->True]

ListPlot[Transpose[{timethreshold,difftr/Sqrt[2]}],PlotLabel->"Difference time jitter/Sqrt[2]-linear,iorder=2 vs. trigger level",AxesLabel->{V,nsec},Frame->True]

ListPlot[Transpose[{timethreshold,difftr/Sqrt[2]}],PlotLabel->"Difference time jitter/Sqrt[2]-quadratic vs. trigger level",AxesLabel->{V,nsec},Frame->True]

ListPlot[Transpose[{timethreshold,difftr/Sqrt[2]}],PlotLabel->"Difference time jitter/Sqrt[2]-linear vs. trigger level",AxesLabel->{V,nsec},Frame->True]

Risetimes cutting off low side tail.

cuttr2=Select[tntuple,(#[[1]]>0.7)&][[All,7]];
cuttr3=Select[tntuple,(#[[1]]>0.7)&][[All,8]];
cuttr4=Select[tntuple,(#[[1]]>0.7)&][[All,9]];
GraphicsRow[{Histogram[cuttr2,{1,4,.02},PlotLabel->"APD1 risetime"],Histogram[cuttr3,{1,4,.02},PlotLabel->"APD2 risetime"],Histogram[(cuttr4),{1,4,.02},PlotLabel->"trigger risetime"]},ImageSize->Full,Frame->True]

mtrig=Mean[(trig2-trig3)]
jitter=RootMeanSquare[(trig2-trig3-mtrig)]
difftr[[ithr]]=jitter;

ListPlot[Transpose[{trig2,trig3}],PlotLabel->"APD2 vs. APD3 time(nsec)",Frame->True]

difftr

ListPlot[Transpose[{timethreshold,difftr/Sqrt[2]}],PlotLabel->"Difference time jitter/sqrt[2] vs. trigger level",AxesLabel->{V,nsec},Frame->True]

Switch to method using Wiener filter of waveform and time Interpolation function to filtered data rather than linear or quadratic fit.

Arrays of points in the leading edge region.

Clear[points2,points3];
points2=Table[Transpose[{sig2[[i]],timecut}],{i,8000}];
points3=Table[Transpose[{sig3[[i]],timecut}],{i,8000}];
(*ListPlot[{points2[[1]],points3[[1]]},Joined->True]*)

Manipulate[ListPlot[{points2[[i]],points3[[i]]},PlotRange->{{0,.7},{74,76.5}},PlotStyle->Directive[AbsoluteThickness[1.8]],LabelStyle->Directive[Orange,Bold],PlotLabel->Style[CERN-bench,Large],AxesLabel->{nsec,v},PlotStyle->{Red,Blue,Green},PlotLegends->Placed[{"Front","Back"},{0.85,0.85}],Joined->True,ImageSize->Large,Frame->True,FrameStyle->Black],{i,1,200,1},SaveDefinitions->True]

difftr=ConstantArray[0,6];

trig2=ConstantArray[0,800];trig3=ConstantArray[0,800];
tr2=ConstantArray[0,800];tr3=ConstantArray[0,800];
ithr=5;timethreshold={.15,.2,.25,.35,.45,.55};

Interpolation[points3[[82]],timethreshold[[1]]]

points3[[82]]=points3[[81]];

Actually computing risetime as   14 %  to 86 %

Do[
trig2[[i]]=Interpolation[points2[[i]],timethreshold[[ithr]]];
tr2[[i]]=Interpolation[points2[[i]],.6]-Interpolation[points2[[i]],.1];
trig3[[i]]=Interpolation[points3[[i]],timethreshold[[ithr]]];
tr3[[i]]=Interpolation[points3[[i]],.6]-Interpolation[points3[[i]],.1];
,{i,800}];

{Histogram[{tr2},{1.3,2,.05}],Histogram[{tr3},{1.3,2,.05}]}
{Histogram[trig2],Histogram[trig3]}

mtrig=Mean[(trig2-trig3)]
jitter=RootMeanSquare[(trig2-trig3-mtrig)]
difftr[[ithr]]=jitter

ListPlot[Transpose[{trig2,trig3}],PlotLabel->"APD2 vs. APD3 time(nsec)",Frame->True]

ListPlot[Transpose[{timethreshold,difftr/Sqrt[2]}],PlotLabel->Style[Framed["((∂t (1 - 2))/(Sqrt[2])) vs. threshold"],10,Blue,Background->Lighter[Yellow]],AxesLabel->{"V","nsec"},LabelStyle->Directive[Blue,Bold],Frame->True]

GraphicsRow[{ListPlot[Transpose[{peak1,peak2}]],ListPlot[Transpose[{peak1,peak3}]],ListPlot[Transpose[{peak2,peak3}]]},Frame->All,PlotLabel->"Raw Correltions (1 vs.2, 1 vs. 3, 2 vs.3 )",ImageSize->Full]

Now create an nTuple with the 3 peak values for each event.

peakntup=Transpose[{peak1,peak2,peak3,area3}];
GraphicsGrid[{{Histogram[Select[peakntup, (#[[3]]>.8 &&#[[2]]>0.05)&][[All,1]],{0,1.5,.02}],
Histogram[Select[peakntup, (#[[3]]>.050 &&#[[3]]<.8)&][[All,1]],{0,1.5,.02}]},
{Histogram[Select[peakntup, (#[[3]]>.8 &&#[[3]]<1)&][[All,2]],{0,1.5,.02}],
Histogram[Select[peakntup, (#[[3]]>.050 &&#[[1]]>0.05)&][[All,2]],{0,1.5,.02}]}},Frame->True,PlotLabel->"Ch1 with ch3 peak cut and complement, then same for ch2",ImageSize->Full]

peakcut=Select[peakntup, (#[[1]]>.050 &&#[[2]]>.050&&#[[4]]>5&&#[[4]]<15)&];
Dimensions[peakcut]

{p1,p2,p3,a3}=Transpose[peakcut];

Histogram[{(*area3,*)a3},{-5,20,.1},PlotLabel->"ch3 area after cleanup"]

GraphicsRow[{Histogram[{p1,p2},{0,0.8,.02},AxesOrigin->{0,0}],PairedHistogram[p1,p2,{0,0.6,.02},AxesOrigin->{0,0}]},Frame->True,PlotLabel->"Compare ch1 and ch2 Amplitudes, difference most likely due to preamp gain diff.",ImageSize->Full]

ListPlot[Transpose[{p1,p2}],ImageSize->Large,PlotLabel->"Front vs. Back APD after cleanup",Frame->True]

End of Notebook so far