% Display the some DARM noises.
%
% respDARM(f, offset)
% f - frequency vector for plots
% offDC - DARM offset (m) for DC readout
% offRF - DARM offset (m) for RF readout
%
% Example:
% f = logspace(0, 4, 200)';
% respDARM(f, 1e-11, 1e-13)

function DARMtest(f, offDC, offRF)

  f = f(:);
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % RF detection scheme
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  opt = optLIGOp;

  % names and numbers
  oprb = opt.probe;
  prbNames = {oprb.name};

  nRF = strmatch('ASp Q1', prbNames);	% which signal to use for RF
  nDC = strmatch('AS DC', prbNames);	% which signal to use for RF
  nFreq = getDriveIndex(opt, 'Source'); % phase modulation input
  nAM = getDriveIndex(opt, 'AM');
  nEX = getDriveIndex(opt, 'EX');
  nEY = getDriveIndex(opt, 'EY');
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % DC detection scheme
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  pos = zeros(opt.Noptic, 1);
  pos(nEX) = offDC / 2;
  pos(nEY) = -offDC / 2;

  % run the offset simulation for RF locking
  opt = optLIGOp;
  [sigDC, sigAC, mechTF, fDC] = compute(opt, pos, f);

  % hDC is from mirror position to sensor signal (W/m)
  hAX = squeeze(sigAC(nDC, nEX, :));
  hAY = squeeze(sigAC(nDC, nEY, :));
  hDC = (hAX - hAY);

  % intensity noise
  hAMDC = squeeze(sigAC(nDC, nAM, :));
  aAMDC = abs(hAMDC ./ hDC);

  % frequency noise
  hFreqDC = squeeze(sigAC(nDC, nFreq, :)) ./ (i * f);
  aFreqDC = abs(hFreqDC ./ hDC);

  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % Plots
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  mybodeplot(f,hDC);
  
  
return
