% Sweep DARM (differential arm length) and generate plots.
%
% [xPos, sigDC, fDC] = sweepDARM(Nsweep)
% see sweepDC for information about the parameters
%
% This displays some DC signals, and some demod signals, during
% a DARM sweep.  The AS_I2 and Q2 signals are used for DARM, but
% the phase at DC is only part of the story (see respDARM).

function [xPos, sigDC, fDC] = sweepDARM(Nsweep)

  % Check number of input arguments
  if nargin < 1
    Nsweep = 100;
  elseif nargin > 1
    error('Too Many Arguments!')
  end

  % prepare some variables
  sweepSetup

  % adding this to sweepSetup causes matlab to crash, so do it here
  nDC = [nREFL(1) nAS([1 4])' nPOX(1) nPOY(1) nTRX(1) nTRY(1)];

  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % DARM sweep
  pos = zeros(opt.Noptic, 1);
  pos(nEX) = 3e-11;
  pos(nEY) = -3e-11;
  
  [xPos, sigDC, fDC] = sweepDC(opt, -pos, pos, Nsweep);

  subplot(2, 1, 1)
  semilogy(xPos(nEX, :), sigDC(nDC, :))
  legend(prbNames(nDC))
  title('DARM sweep: DC signals')
  axis tight
  grid on

  subplot(2, 1, 2)
  plot(xPos(nEX, :), sigDC(nAS([1:3 5:6]), :))
  legend(prbNames(nAS([1:3 5:6])))
  title('DARM sweep: AS demod signals')
  axis tight
  grid on
