%**************************************************************************
%This function gets the header information and the measurements from
%the input data file.
%
%Input:
%param, parameter structure
%
%Output:
%header, header information from data file
%zm, Z positions of the measurements in bench coordinates (m)
%bx, measured horizontal field component Bx (T)
%by, measured vertical field component By (T)
%
%Zachary Wolf
%12/23/05

function [header, zm, bx, by] = pid_anal_get_meas(param)

%Construct the input file
input_file = strcat(param.input_file_dir, param.input_file_name);

%Read the input file
if strcmp(param.input_file_type, 'ZVXYBXYH')
    [header, zm, bx, by] = read_meas_zvxybxyh(input_file);
%   [header, zm, bx, by] = read_meas_zvxybxyh_check_calib(input_file);
elseif strcmp(param.input_file_type, 'ZVXYBXYHT')
    [header, zm, bx, by] = read_meas_zvxybxyht(input_file);
elseif strcmp(param.input_file_type, 'ZBXYH')
%    [header, zm, bx, by] = read_meas_zbxyh(input_file);
    [header, zm, bx, by] = read_meas_zbyxh(input_file);
elseif strcmp(param.input_file_type, 'ZBXYZH')
    [header, zm, bx, by, bz] = read_meas_zbxyzh(input_file);
elseif strcmp(param.input_file_type, 'ZBYH')
    [header, zm, by] = read_meas_zbyh(input_file);
    bx = zeros(1, length(zm));
elseif strcmp(param.input_file_type, 'ZVYH')
    [header, zm, by] = read_meas_zvyh(input_file);
    bx = zeros(1, length(zm));
elseif strcmp(param.input_file_type, 'ZBYH_ANL')
    [header, zm, by] = read_meas_zbyh_anl(input_file);
    bx = zeros(1, length(zm));
elseif strcmp(param.input_file_type, 'ZBYH_DESY')
    input_file_x = [input_file(1 : length(input_file) - 1), 'Z'];
    [header, zm, bx] = read_meas_zbyh_desy(input_file_x);
    bx = bx / 1.e4;
    [header, zm, by] = read_meas_zbyh_desy(input_file);    temp = 0;
%    bx = zeros(1, length(zm));
else
    error('Unknown input file type.');
end

%Done
