%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Script to process breakdown flash data and id220 efficiency curve
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% loading data file
data_noise = load('noise_long.dat');
data = load('processed_data.dat')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

wavelength = data(:, 2);
a2b = data(:, 5);
b2a = data(:, 8);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

eff = [0.0196143, 0.022945, 0.0256368, 0.0285486, 0.032787, 0.0387336,...
       0.0437783, 0.0485772, 0.0540273, 0.0606933, 0.0687214, 0.080776,...
       0.104069, 0.126553, 0.144722, 0.159669, 0.169364, 0.176183, 0.185075,...
       0.195001, 0.204982, 0.214091, 0.22335, 0.231481, 0.236305, 0.239019,...
       0.24003, 0.239651, 0.238997, 0.237158, 0.23184, 0.228141, 0.226229,...
       0.222946, 0.220358, 0.218806, 0.217586, 0.215602, 0.212946, 0.212886,...
       0.212823, 0.21042, 0.206757, 0.201999, 0.196432, 0.192572, 0.182363,...
       0.151804, 0.131998, 0.0994494, 0.0660486, 0.0372073, 0.0166149,...
       0.0052351, 0.00170216, 0.000628304]';
   
id220_eff_curve = [wavelength(1:length(eff)), eff*100];
dlmwrite('id220_efficiency_curve.dat', id220_eff_curve, ' ');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

plot(wavelength, a2b/max(a2b),...
    wavelength, b2a/max(b2a),...
    wavelength(1:length(eff)), eff/max(eff)),...
    grid;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%