%Caluculate OMC DC PD transimpedance in RF

%% OMC Parameters
FSR = 261e6; %Hz
Fin = 390; %Dan Hoak's thesis page 63
x = (2*pi*3e6/FSR);
lambda = 1064e-9;
R = 0.858; %A/W

Pratio = 0.1;
%Pratio = 1/( 1+ ( (2*Fin/pi)*deg2rad(sin(2*pi*x)) )^2 ); %what's inside
%sin()?

I_cr = 13e-3; %A, no whitening
dark_offset = -0.00323e-3;
I_clf = (0.015958e-3-dark_offset)/15.85; %A, include 24dB whitening. Uncertainy +- 1 last digit
I_clf = I_clf*Pratio;

Z_dc = 400; %Use high Zhttps://alog.ligo-wa.caltech.edu/aLOG/index.php?callRep=17647

V_cr = I_cr*Z_dc; %power equivalent volt
V_clf = I_clf*Z_dc*Pratio;

V_rf = 148e-3/2; %V from RF in to avoide 23dB down. factor of 2 because of not 50Ohms at the scope
V_rf_rms = V_rf/(2*sqrt(2));

Z_rf = V_rf_rms/sqrt(I_clf*I_cr)
%Z_rf = 300;
% Koji's plot suggest 300Ohms https://dcc.ligo.org/LIGO-E1500358

%% Calculate loss
W_sqzt6 = 0.757e-6;
Icr = 20e-3;
V_ifo = 117.6e-3/2;
V_ifo_rms = V_ifo/(2*sqrt(2));

Iclf = (1/Icr)*(V_ifo_rms/Z_rf)^2 ;

Wclf = Iclf/R;

%W_cal = Iclf*R; %(1/W)
%W_cal = 1/W_cal;

Loss = (1-10*(Wclf/W_sqzt6)) %factor of 10 because we wan't loss before OMC not after.
