addpath C:\Users\sheila.dwyer\Documents\MATLAB\alm-master
close all
clear classes

lambda = 1064e-9;

%translate Z, Zr from Lee's plot Fig 19 (pg 32) of T1900649 to waist size and location for alm
designZr= 1.190;
waist_size = sqrt(designZr*lambda/pi);
designZ = -0.1618;
Dpath = beamPath;
Dpath.seedWaist(waist_size, designZ, lambda);
Dpath.addComponent(component.lens(0.222, 1.092, 'ROC +100mm d'))

meas_path = beamPath;  %start by making a beam with measured parmeters from Georgia's alog 60204
%I will put all distances from BS1
D_M2_actual = 0.335+0.390;  %distance from BS1 to D:M2 based on ruler measurements in chamber (not very precise)
meas_path.seedWaist(160e-6, D_M2_actual+ 0.5535, lambda);

%back propagate through the lens to see what beam we get
back_meas = meas_path.branchPath(1);
back_meas.addComponent(component.lens(0.222, D_M2_actual + 0.185,'ROC +100mm'))


%this seems like poor agreement between our measurement and the design.
%Alog 59333 seems to say that the mode matching of B path is good. 
zdomain = 0:.01:2;
figure(1)
meas_path;
hold on
%meas_path.plotBeamWidth(zdomain,'k')
back_meas.plotBeamWidth(zdomain,'r')
Dpath.plotBeamWidth(zdomain,'b')
back_meas.plotWaists(zdomain)
title('blue desigg, red measurement back propagated')
saveas(gcf, 'D_path_beam_propagation.png')