%**************************************************************************
%This function plots the field integrals.
%The filtered integrals are also plotted.
%
%Input:
%plt_file, plot file for results
%field_name, 'Bx' or 'By'
%z, position along the undulator (m)
%b, field value (T)
%b_filt, filtered field value (T) 
%int_b_dz, first integral of field (Tm)
%int_b_dz_filt, filtered first integral of field (Tm) 
%int_int_b_dz_dz, second integral of field (Tm^2)
%int_int_b_dz_dz_filt, filtered second integral of field (Tm^2) 
%
%Zachary Wolf, 12/24/05, 1/8/06

function [] = int_plot_b_int(plt_file, field_name, z, b, b_filt, int_b_dz, int_b_dz_filt, int_int_b_dz_dz, int_int_b_dz_dz_filt)
    
%Plot the field
figure;
subplot(3, 1, 1);
hold on;
plot(z, b, 'linewidth', 0.25);
title([field_name, ' Field Integrals']);
%title([field_name, ' vs Z']);
ylabel([field_name, ' (T)']);
grid on;
zoom on;

%Plot the lambda filtered field
plot(z, b_filt, 'linewidth', 3.);
hold off;

%Plot the first field integral
subplot(3, 1, 2);
hold on;
plot(z, int_b_dz, 'linewidth', 0.25);
%title(['\int ', field_name, ' dz vs Z']);
ylabel(['\int ', field_name, ' dz (Tm)']);
grid on;
zoom on;

%Plot the lambda filtered first integral
plot(z, int_b_dz_filt, 'linewidth', 3.);
hold off;

%Plot the second field integral
subplot(3, 1, 3);
hold on;
plot(z, int_int_b_dz_dz, 'linewidth', 0.25);
%title(['\int \int ', field_name, ' dz dz vs Z']);
ylabel(['\int \int ', field_name, ' dz dz (Tm^2)']);
xlabel('Z position (m)');
grid on;
zoom on;

%Plot the lambda filtered second integral
plot(z, int_int_b_dz_dz_filt, 'linewidth', 3.);
hold off;

%Write the figures to the plot file
util_print_fig(plt_file);

%Done
