% master.m
clear

makec2

load mcJ0.dat  % --> [r, R(r)]. 
mcJx = mcJ0;
load mcF0.dat  % --> z, r, F(z,r). 
mcFx = mcF0;

%%% extract flux J(r), excluding overflow bin
N = length(mcJx)-1;
u = (1:N)';
r = mcJx(u,1);
J = mcJx(u,2);
%%% extract fluence rate F(z,r), excluding overflow bins
[Nr Nc] = size(mcFx);
z = mcFx(2:Nr-1,1);
F = mcFx(2:Nr-1, 2:Nc-1);

%%% create F2(z,r2) for drawing vs +/- r
F2               = zeros(N, 2*N);
F2(1:N, N+1:2*N) = F;
F2(1:N, 1:N)     = F(:,N:-1:1);
r2               = zeros(2*N, 1);
r2(1:N)          = -r(N:-1:1);
r2(N+1:2*N)      = r;

%%%%%
% Fluence rate distribution, F
%%%%%
figure(1);clf
imagesc(r2,z,log10(F2))
set(gca,'fontsize',18)
xlabel('r [cm]')
ylabel('z [cm]')
axis('equal')
title('log_1_0( F(z,r) [W/cm^2/W] )','fontsize',18)
colormap(c2)
colorbar
set(colorbar,'fontsize',18)

%%%%%
% Escaping flux, J
%%%%%
figure(2);clf
semilogy(r,J,'r-')
hold on
semilogy(-r,J,'r-')
title('Escaping flux [W/cm^2/W]','fontsize',18)
set(gca,'fontsize',18)
xlabel('r [cm]')
ylabel('J(r) [cm]')
