%**************************************************************************
%Shim_Param
%This file contains parameters required by the shimming program.
%
%Zachary Wolf
%1/13/06

%Input file information
INPUT_FILE_DIR = 'C:\Magdata\SN09_Run002\';     %Directory where data is located, results go there also
INPUT_FILE_NAME = 'pid_anal.mat';                %Name of data file to analyze

%Set gap shim parameters
SETGAP_SHIM_RANGE = 20.E-6;  %(m)
SETGAP_SHIM_BIN_SIZE = 5.E-6;  %(m)

%Trajectory Shim Parameters
%Number of segments in the segmented trajectory
TRAJ_NUM_SEG = 40;
%Maximum trajectory shift when move shim (m)
TRAJ_SHIFT_MAX = 0.3e-6;
%Maximum trajectory shift accumulation before a shim is added (m)
TRAJ_SHIFT_ACCUM_MAX = 0.7e-6;
%End shims, use pole number < 1 for no end shims -- only undulator center shims
%Give pole number at entrance, exit pole assumed symmetric
X_TRAJ_END_SHIM_POLE_NUM = 0;
Y_TRAJ_END_SHIM_POLE_NUM = 0;
%Experimental parameters
%Let s = desired trajectory slope change (dimensionless)
%Let d = distance between the shim and the pole (m)
%d = p1 * s^2 + p2 * s + p3
%Parameter matrix order [type, slope_min, slope_max,     p1, p2, p3]
%Type -n shims are reserved for shims in the end pole region
X_TRAJ_SHIM_PAR = [-1, 1.00e-7, 1.00e-5,     0.000e0, -2.180e3, 0.000e00;...
                    1, 1.00e-6, 6.60e-6,     4.212e7, -3.283e3, 2.061e-2;...
                    2, 6.60e-6, 1.70e-5,     4.085e7, -1.833e3, 1.921e-2];
Y_TRAJ_SHIM_PAR = [-1,       0, 1.00e+9,           0,        0,        0;...
                    1,       0, 1.00e+9,           0,        0,        0];

%Phase Shim Parameters
%Number of segments in the segmented trajectory
PHASERR_NUM_SEG = 40;
%Maximum positive phase error change before a shim is added
PHASERR_POS_DELTA_MAX = 2 * pi / 180;  %2 degrees
%Maximum negative phase error change before a shim is added
PHASERR_NEG_DELTA_MAX = 6 * pi / 180;  %6 degrees
%Gap shim width
PHASERR_GAP_SHIM_WIDTH = 0.2;  %effective width in meters
%Nominal undulator gap, for gap shim (m)
PHASERR_GAP_SHIM_NOM_GAP = 0.0068;
%Experimental parameters
%A gap shim does not create a uniform gap change in practice
%Use a multiplicative gap change correction factor to compensate
PHASERR_GAP_SHIM_CORR_FACT = 1.;
%Let c = desired phase error change, absolute value (rad)
%Let t = shim thickness (m)
%t = p1 * c^2 + p2 * c + p3
%Parameter matrix order [type, c_min, c_max,     p1, p2, p3]
PHASERR_PHASE_SHIM_PAR = [1, 0, .253,     0, 1.58e-3, 0];

%K Shim Parameters
K_SHIM_CANT_ANGLE = 4.5e-3;

%Overwrite previous parameters if running from C
RUN_FROM_C = false;
if RUN_FROM_C == true
    INPUT_FILE_DIR = evalin('base','INPUT_FILE_DIR');
    FIG_VIS = evalin('base','FIG_VIS'); 
end


