%+
% Name:
%   ape_spec_4.10.tex
%
% Processing:
%   1. Only have two options for processing (where appropriate):
%       . doing something (e.g. CTI adjustment)
%       . not doing something (e.g. no CTI adjustment)
%      Do not have a ``copy'' option
%   2. Only error out where the wrong input will cause a subsequent failure
%
% Format of spec:
%   1. Concise, descriptive section titles
%   2. Nest ifs
%   3. Notation:
%       - c_{}        for constants
%       - \Delta_{}   for adjustments
%       - \epsilon_{} for random numbers
%       - h_{}        for HDU
%       - i           for event no.
%       - j           for event island element
%       - k           for arbitrary vector element
%       - r           for row no.
%
% History:
%   2015 Mar 25, Multiplied the \Delta Y edser adjustment by timedel for cc
%     mode in the section about pix_adj (v3.6), Glenn E. Allen
%   2015 Mar 25, Added more comments about what to do during bad time
%     intervals to the section about time and chipy_adj (v3.7), GEA
%   2015 Mar 26, Added TIME_min and TIME_max and used them in 1.5.3.11(a)ii
%     (v3.8), GEA
%   2015 Apr 01, Fixed a typo in the section about pha_ro (v3.9), GEA
%   2015 Apr 03, Fixed a typo in 1.5.3.14(a)v to change c'_{x}[j] to c'_{y}[j]
%     (v3.10), GEA
%   2015 Apr 03, Removed chipy_adj = chipy from the pix_adj section (v3.11),
%     GEA
%   2015 Apr 08, Added explicit comments about corners=0 to the section
%     about pha (v3.12), GEA
%   2015 Apr 17, Changed the validation of badpixfile, added obs_mode
%     (v3.20), GEA
%   2015 Apr 28, Fixed a sign error in the time-dependent gain section
%     (v3.21), GEA
%   2015 May 08, Add the sub-pixel adjustment to chipy for cc mode (v3.22),
%     GEA
%   2015 May 12, Fixed a problem with TIME_RO being 0 in the input file
%     (v3.23), GEA
%   2015 May 20, Fixed a problem with the GTIs (v3.24), modified the sections
%     about the tdet, det, and sky coordinates, GEA
%   2015 May 21, Changed the time/chipy_adj section about pointing cc mode
%     with ACIS-I grating data to clarify what time should be compared to
%     the gtis, changed the items about the tdet, det, and sky coordinates
%     to separate the gratings and non-gratings cases (v3.25), GEA
%   2015 Jun 09, switch the initialization of chipy_zo_med, etc. and
%     time_min, time_max, etc., check for chipy_tg = NaN on input, add an
%     explicit note about what asol data and times to use during Level 1 and
%     Level 1.5 processing, add gti and NULL/NaN to the tdet, det, sky, and
%     sky_1d coordinates (v3.26), GEA
%   2015 Jun 20, fixed a problem with the conditions for a grating source
%     event not in the gtis (v3.28), GEA
%   2015 Jun 28, added chipy_zo != null in the tdet, det, sky, and sky_1d
%     sections (v3.29), GEA
%   2015 Jul 02, changed so that time_min and time_max are computed for all
%     modes, changed a few chipy_tg=NaN to chipy_tg=NULL, and changed a few
%     chipy_zo=NaN to chipy_zo=NULL (v3.30), GEA
%   2015 Jul 09, ??? (v3.31), GEA
%   2015 Jul 22, added fltfile error checking, made the time_min and
%     time_max tests for the tdet, det, sky, and sky_1d coordinates
%     conditional on the specification of acaofffile, made the gti tests for
%     for the tdet, det, sky, and sky_1d coordinates conditional on the
%     specification of the fltfile, (v3.32), GEA
%   2015 Jul 24, dropped chipy_zo_med, ra_c, dec_c, time_c, ra_adj_i,
%     dec_adj_i, ra_adj_s, and dec_adj_s; added chipy_targ_med; added
%     initialization of chipx_adj; added chipy_targ for every event; rewrote
%     the computation of time/chipy_adj; modified the section about pix_adj;
%     reordered the computation of the sky, sky_1d, det, and tdet coordinates;
%     changed how these coordinates are computed (chipy_adj for tdet and
%     detx, chipy_targ for sky and sky_1d); rewrote the section about the
%     keyword time_adj (v3.33), GEA
%   2015 Aug 04, fixed a few typos in section 1.5.3.12(a)ii.A, .B, and .E
%     (v3.34), GEA
%   2015 Aug 07, changed chipy_targ_med to chipy_targ_acaoff,med; changed
%     chipy_targ to chipy_targ_evt; made the initialization of chipx_adj its
%     own section; added the computation of chipy_targ_eff (v3.37), GEA
%   2015 Aug 14, hacked to deal with the inability of pix_chip_to_fpc to
%     handle negative chipy values (v3.38), GEA
%   2015 Aug 15, fixed a typo (v3.39), GEA
%   2015 Aug 18, fixed chipy_adj for the case with t < t_min or t_max <= t so
%     that is works for acis-i as well as acis-s (v3.40), GEA
%   2015 Aug 19, added conditions that energy > 0 and energy != NaN for the
%     edser adjustment (v3.41), GEA
%   2015 Aug 20, fixed a typo by changing TGEVT to TGEVT1; removed a hack for
%     off-chip sources; added a test that CONTENT != TGEVT1 to avoid resetting
%     the NaNs and NULLs using times based upon chipy_tg instead of chipy_targ;
%     dropped the fltfile (v3.42), GEA
%   2015 Aug 22, changed datamode to datamode_in in the places where it was
%     just datamode, added tgaincor to the error checking section about the
%     infile, modified the description of the computation of pha_ro (v4.00),
%     GEA
%   2015 Aug 24, changed the error-checking conditions for ccdx, chipx, ccdy,
%     trow, and chipy; changed the conditions used to set the values of chipx
%     and chipy (v4.01), GEA
%   2015 Aug 25, changed the error-checking on the value of content in the
%     acaofffile; changed the error-checking conditions for pix_adj=edser
%     (v4.02), GEA
%   2015 Aug 26, fixed a problem with how the NULLs and NaNs are set after
%     the second pass (v4.03), GEA
%   2015 Aug 27, changed the error-checking on the value of content in the
%     alignmentfile (v4.04), GEA
%   2015 Aug 31, moved the section about time_ro to be immediately before
%     the section about chipx_targ, chipy_targ, and chipy_targ_eff (v4.05),
%     GEA
%   2015 Sep 09, changed behavior for stop if obs_mode != pointing (v4.06),
%     GEA
%   2015 Dec 14, dropped chipyzo and updated the TBD items (v4.07), GEA
%   2016 Jan 05, change obsfile=NONE to obsfile=none, use OBS_MODE_in instead
%     of OBS_MODE, change OBS_MODE=POINTING to OBS_MODE=pointing, change
%     OBS_MODE=SECONDARY to OBS_MODE=secondary, change acaofffile=NONE to
%     acaofffile=none (v4.08), GEA
%   2016 Feb 02, use chipy_tg=NaN instead of chipy_tg=NULL, set tdetx =
%     tdety = NULL only for continuous-clocking mode data (v4.09), GEA
%   2016 Feb 02, compute median(chipx_targ_acaoff) and
%     median(chipy_targ_acaoff) only for continuous-clocking mode
%     observations (v4.10), GEA
%-

\documentclass{article}

\usepackage{/nfs/inconceivable/d0/src/latex/sty/cxo_memo_logo}
\usepackage{/nfs/inconceivable/d0/src/latex/sty/enumitem}
\usepackage{epsfig}
\usepackage{pstricks}

\newrgbcolor{blue}{0 0 1}
\newrgbcolor{red}{1 0 0}

\newcommand{\acaofffile}{{\tt acaofffile}}
\newcommand{\acisprocessevents}{{\tt acis\_\-process\_\-events}}
\newcommand{\alignmentfile}{{\tt alignmentfile}}
\newcommand{\applycti}{{\tt apply\_cti}}
\newcommand{\applytgain}{{\tt apply\_tgain}}
\newcommand{\badpixfile}{{\tt badpixfile}}
\newcommand{\calculatepi}{{\tt calculate\_pi}}
\newcommand{\cbd}{{\tt CBD10001}}
\newcommand{\ccdid}{{\tt CCD\_ID}}
\newcommand{\ccdx}{{\tt CCDX}}
\newcommand{\ccdy}{{\tt CCDY}}
\newcommand{\checkvfpha}{{\tt check\_vf\_pha}}
\newcommand{\chipx}{{\tt CHIPX}}
\newcommand{\chipxadj}{{\tt CHIPX\_ADJ}}
\newcommand{\chipxhi}{{\tt CHIPX\_HI}}
\newcommand{\chipxlo}{{\tt CHIPX\_LO}}
\newcommand{\chipxmax}{{\tt CHIPX\_MAX}}
\newcommand{\chipxmin}{{\tt CHIPX\_MIN}}
\newcommand{\chipxoffset}{{\tt CHIPX\_OFFSET}}
\newcommand{\chipxtarg}{{\tt CHIPX\_TARG}}
\newcommand{\chipy}{{\tt CHIPY}}
\newcommand{\chipyadj}{{\tt CHIPY\_ADJ}}
\newcommand{\chipyhi}{{\tt CHIPY\_HI}}
\newcommand{\chipylo}{{\tt CHIPY\_LO}}
\newcommand{\chipymax}{{\tt CHIPY\_MAX}}
\newcommand{\chipymin}{{\tt CHIPY\_MIN}}
\newcommand{\chipyoffset}{{\tt CHIPY\_OFFSET}}
\newcommand{\chipytarg}{{\tt CHIPY\_TARG}}
\newcommand{\chipytg}{{\tt CHIPY\_TG}}
\newcommand{\clobber}{{\tt clobber}}
\newcommand{\content}{{\tt CONTENT}}
\newcommand{\corners}{{\tt CORNERS}}
\newcommand{\cornpha}{{\tt CORN\_PHA}}
\newcommand{\cticonverge}{{\tt cticonverge}}
\newcommand{\ctifile}{{\tt ctifile}}
\newcommand{\datamode}{{\tt DATAMODE}}
\newcommand{\dec}{{\tt DEC}}
\newcommand{\decnom}{{\tt DEC\_NOM}}
\newcommand{\decpnt}{{\tt DEC\_PNT}}
\newcommand{\dectarg}{{\tt DEC\_TARG}}
\newcommand{\deltpha}{{\tt DELTPHA}}
\newcommand{\detx}{{\tt DETX}}
\newcommand{\dety}{{\tt DETY}}
\newcommand{\doevtgrade}{{\tt doevtgrade}}
\newcommand{\dtheta}{{\tt DTHETA}}
\newcommand{\dy}{{\tt DY}}
\newcommand{\dz}{{\tt DZ}}
\newcommand{\energy}{{\tt ENERGY}}
\newcommand{\epoch}{{\tt EPOCH}}
\newcommand{\eventdef}{{\tt eventdef}}
\newcommand{\expno}{{\tt EXPNO}}
\newcommand{\fltgrade}{{\tt FLTGRADE}}
\newcommand{\fptemp}{{\tt FP\_TEMP}}
\newcommand{\frctrlx}{{\tt FRCTRLX}}
\newcommand{\frctrly}{{\tt FRCTRLY}}
\newcommand{\gainfile}{{\tt gainfile}}
\newcommand{\geompar}{{\tt geompar}}
\newcommand{\grade}{{\tt GRADE}}
\newcommand{\gradefile}{{\tt gradefile}}
\newcommand{\infile}{{\tt infile}}
\newcommand{\maxctiiter}{{\tt max\_cti\_iter}}
\newcommand{\mtlfile}{{\tt mtlfile}}
\newcommand{\nodeid}{{\tt NODE\_ID}}
\newcommand{\npoints}{{\tt NPOINTS}}
\newcommand{\obsfile}{{\tt obsfile}}
\newcommand{\obsmode}{{\tt OBS\_MODE}}
\newcommand{\outfile}{{\tt outfile}}
\newcommand{\pha}{{\tt PHA}}
\newcommand{\pharo}{{\tt PHA\_RO}}
\newcommand{\phas}{{\tt PHAS}}
\newcommand{\phasadj}{{\tt PHAS\_ADJ}}
\newcommand{\pibinwidth}{{\tt pi\_bin\_width}}
\newcommand{\pinumbins}{{\tt pi\_num\_bins}}
\newcommand{\pinv}{{\tt PI}}
\newcommand{\pixadj}{{\tt pix\_adj}}
\newcommand{\pixadjkey}{{\tt PIX\_ADJ}}
\newcommand{\randpha}{{\tt rand\_pha}}
\newcommand{\ra}{{\tt RA}}
\newcommand{\randsky}{{\tt RAND\_SKY}}
\newcommand{\ranom}{{\tt RA\_NOM}}
\newcommand{\rapnt}{{\tt RA\_PNT}}
\newcommand{\ratarg}{{\tt RA\_TARG}}
\newcommand{\roll}{{\tt ROLL}}
\newcommand{\simy}{{\tt SIM\_Y}}
\newcommand{\simz}{{\tt SIM\_Z}}
\newcommand{\skyoned}{{\tt SKY\_1D}}
\newcommand{\start}{{\tt START}}
\newcommand{\status}{{\tt STATUS}}
\newcommand{\stp}{{\tt stop}}
\newcommand{\subpixfile}{{\tt subpixfile}}
\newcommand{\tctix}{{\tt TCTIX}}
\newcommand{\tctiy}{{\tt TCTIY}}
\newcommand{\tdetx}{{\tt TDETX}}
\newcommand{\tdety}{{\tt TDETY}}
\newcommand{\tgaincor}{{\tt TGAINCOR}}
\newcommand{\tgainfile}{{\tt tgainfile}}
\newcommand{\tgm}{{\tt TG\_M}}
\newcommand{\threshfile}{{\tt threshfile}}
\newcommand{\tim}{{\tt TIME}}
\newcommand{\timeadj}{{\tt TIME\_ADJ}}
\newcommand{\timedel}{{\tt TIMEDEL}}
\newcommand{\timepixr}{{\tt TIMEPIXR}}
\newcommand{\timero}{{\tt TIME\_RO}}
\newcommand{\timestop}{{\tt TIME\_STOP}}
\newcommand{\trow}{{\tt TROW}}
\newcommand{\tstart}{{\tt TSTART}}
\newcommand{\volumex}{{\tt VOLUME\_X}}
\newcommand{\volumey}{{\tt VOLUME\_Y}}
\newcommand{\x}{{\tt X}}
\newcommand{\y}{{\tt Y}}

\renewcommand*{\thefootnote}{\fnsymbol{footnote}}

\setcounter{secnumdepth}{5}

\begin{document}

% 1. Header

\memobasic{
   Jonathan McDowell, SDS Group Leader }{
   Glenn E.\ Allen, SDS }{
   \acisprocessevents\ spec }{
   4.10 }{
   http://space.mit.edu/CXC/docs/docs.html\#ape }{
   /nfs/inconceivable/d0/sds/specs/acis\_process\_events/ape\_spec\_4.10.tex }

% 2. Tool name

\section{\acisprocessevents}

This spec, which is incomplete, describes some of processing steps for
continuous-clocking mode data.

% 3. Description

\subsection{ Description }

% 4. Input

\subsection{ Input }

% 5. Output

\subsection{ Output }

% 6. Parameters

\subsection{ Parameters }

% 7. Processing

\subsection{ Processing }

\subsubsection{ Error checking }

The following steps are performed once prior to the processing of the data
for each input ACIS event.

\begin{enumerate}

  \item
    {\obsfile}:
    %
    \begin{enumerate}

      \item
        {Validation}:
	%
        \begin{enumerate}

          \item
	    If
            %
            \begin{eqnarray}
              \obsfile & = & {\rm NONE},
            \end{eqnarray}
	    %
	    then \obsfile\ is changed to ``none''.
	    
          \item
	    {Existence}: \\
	    %
            If
            %
            \begin{eqnarray}
              \obsfile & \ne & {\rm none}
            \end{eqnarray}
	    %
            and the \obsfile\ does not exist, then \obsfile\ is changed to
	    ``none'' and \acisprocessevents\ produces a warning message.

          \item
	    {Permission}: \\
	    %
            If
            %
            \begin{eqnarray}
              \obsfile & \ne & {\rm none}
            \end{eqnarray}
	    %
            and the file permissions do not allow the \obsfile\ to be read,
	    then \obsfile\ is changed to ``none'' and \acisprocessevents\
	    produces a warning message.

          \item
	    {\obsmode}: \\
	    %
            If
            %
            \begin{eqnarray}
              \obsfile & \ne & {\rm none} 
            \end{eqnarray}
	    %
	    then
	    %
	    \begin{enumerate}

	      \item
	        %
                If the \obsfile\ does not include the keyword \obsmode, then
		${\obsmode}_{\rm in}$ is set to ``none''.

	      \item
	        %
                If the \obsfile\ includes the keyword \obsmode\ then
		${\obsmode}_{\rm in}$ is set to \obsmode.
		
	      \item
	        %
                If
	        %
                \begin{eqnarray}
                  \obsmode_{\rm in} & = & {\rm POINTING},
                \end{eqnarray}
		%
		then ${\obsmode}_{\rm in}$ is set to ``pointing''.
		
	      \item
	        %
                If
	        %
                \begin{eqnarray}
                  \obsmode_{\rm in} & = & {\rm SECONDARY},
                \end{eqnarray}
		%
		then ${\obsmode}_{\rm in}$ is set to ``secondary''.
		
	      \item
	        %
                If
	        %
                \begin{eqnarray}
                  \obsmode_{\rm in} & \ne & {\rm none\ and} \\
                  \obsmode_{\rm in} & \ne & {\rm pointing\ and} \\
                  \obsmode_{\rm in} & \ne & {\rm secondary},
                \end{eqnarray}
	        %
	        then $\obsmode_{\rm in}$ is set to ``none'' and
		\acisprocessevents\ produces a warning message. 
	      
	    \end{enumerate}

        \end{enumerate}

    \end{enumerate}

  \item
    {\acaofffile}:
    %
    \begin{enumerate}

      \item
        {Validation}: \\
	%
        If
	%
        \begin{eqnarray}
          \obsmode_{\rm in} & = & {\rm pointing},
        \end{eqnarray}
        %
        then
        %
        \begin{enumerate}

          \item
            If
	    %
	    \begin{eqnarray}
	      \acaofffile & = & {\rm NONE},
	    \end{eqnarray}
	    %
	    then \acaofffile\ is set to ``none.''
	    
          \item
	    {Setting}: \\
	    %
            If
	    %
	    \begin{eqnarray}
	      \acaofffile & = & {\rm none},
	    \end{eqnarray}
	    %
	    then \acisprocessevents\ produces a warning message.

          \item
	    {Existence}: \\
	    %
            If
	    %
	    \begin{eqnarray}
	      \acaofffile & \ne & {\rm none}
	    \end{eqnarray}
	    %
	    and the \acaofffile\ does not exist, then \acisprocessevents\
	    produces a warning and \acaofffile\ is set to ``none.''

          \item
	    {Permission}: \\
	    %
            If the \acaofffile\ exists and the file permissions do not allow
	    it to be read, then \acisprocessevents\ produces a warning
	    message and \acaofffile\ is set to ``none.''

          \item
	    {\content}: \\
	    %
            If the \acaofffile\ does not have an HDU $h_{\rm acaoff}$ with
	    the keyword
	    %
	    \begin{eqnarray}
	      \content & = & {\rm ASPSOL\ or} \\
	      \content & = & {\rm OBCSOL},
	    \end{eqnarray}
	    %
	    then \acisprocessevents\ produces a warning message and
	    \acaofffile\ is set to ``none.''

          \item
	    {Keyword}: \\
	    %
            If HDU $h_{\rm acaoff}$ of the \acaofffile\ does not include the
	    keyword \tstart, then \acisprocessevents\ produces a warning
	    message and \acaofffile\ is set to ``none.''

          \item
	    {Columns}: \\
	    %
            If HDU $h_{\rm acaoff}$ of the \acaofffile\ does not include the
	    columns \tim, \ra, \dec, and \roll\ then \acisprocessevents\
	    produces a warning message and \acaofffile\ is set to ``none.''
	    Hereafter, these columns are referred to as $\tim_{\rm acaoff}$,
	    $\ra_{\rm acaoff}$, $\dec_{\rm acaoff}$, and $\roll_{\rm
	    acaoff}$.

          \item
	    {Sequential}: \\
	    %
            If more than one valid \acaofffile\ is specified and the the
	    values \tstart\ are not in increasing order, then
	    \acisprocessevents\ produces a warning message and \acaofffile\
	    is set to ``none.''

        \end{enumerate}

    \end{enumerate}

  \item
    {\alignmentfile}:
    %
    \begin{enumerate}

      \item
        {Validation}: \\
	%
        If
	%
        \begin{eqnarray}
          \obsmode_{\rm in} & = & {\rm pointing},
        \end{eqnarray}
	%
        then
        %
        \begin{enumerate}

          \item
            If
	    %
	    \begin{eqnarray}
	      \alignmentfile & = & {\rm NONE},
	    \end{eqnarray}
	    %
	    then \alignmentfile\ is changed to ``none.''
	  
          \item
	    {Setting}: \\
	    %
            If
	    %
	    \begin{eqnarray}
	      \alignmentfile & = & {\rm none},
	    \end{eqnarray}
	    %
	    then \acisprocessevents\ produces a warning message.

          \item
	    {Existence}: \\
	    %
            If
	    %
	    \begin{eqnarray}
	      \alignmentfile & \ne & {\rm none} 
	    \end{eqnarray}
	    %
	    and the \alignmentfile\ does not exist, then \acisprocessevents\
	    produces a warning message and \alignmentfile\ is set to
	    ``none.''.

          \item
	    {Permission}: \\
	    %
            If the \alignmentfile\ exists and the file permissions do not
	    allow it to be read, then \acisprocessevents\ produces a warning
	    message and \alignmentfile\ is set to ``none.''.

          \item
	    {\content}: \\
	    %
            If the \alignmentfile\ does not have an HDU $h_{\rm alignment}$
	    with the keyword
	    %
	    \begin{eqnarray}
	      \content & = & {\rm ASPSOL\ or} \\
	      \content & = & {\rm OBCSOL},
	    \end{eqnarray}
	    %
	    then \acisprocessevents\ produces a warning message and
	    \alignmentfile\ is set to ``none.''.

          \item
	    {Keyword}: \\
	    %
            If HDU $h_{\rm alignment}$ of the \alignmentfile\ does not
	    include the keyword \tstart, then \acisprocessevents\ produces a
	    warning message and \alignmentfile\ is set to ``none.''.

          \item
	    {Columns}: \\
	    %
            If HDU $h_{\rm alignment}$ of the \alignmentfile\ does not
	    include the columns \dy, \dz, and \dtheta\ then
	    \acisprocessevents\ produces a warning message and
	    \alignmentfile\ is set to ``none.''.

          \item
	    {Sequential}: \\
	    %
            If more than one valid \alignmentfile\ is specified and the
	    values \tstart\ are not in increasing order, then
	    \acisprocessevents\ produces a warning message and
	    \alignmentfile\ is set to ``none.''.

        \end{enumerate}

    \end{enumerate}

  \item
    {\infile}:
    %
    \begin{enumerate}

      \item
        {Existence}: \\
        %
	If the \infile\ does not exist, then \acisprocessevents\ exits with
	an error message.

      \item
        {Permission}: \\
        %
	If the \infile\ exists and the file permissions do not allow it to
	be read, then \acisprocessevents\ exits with an error message.

      \item
        {Validation}:
	%
	\begin{enumerate}

          \item
            {\obsmode}: \\
            %
	    If $\obsmode_{\rm in} = {\rm none}$ and HDU $h_{\rm in}$ of the
	    \infile\ includes the keyword \obsmode, then
	    %
	    \begin{enumerate}

	      \item
	        %
		$\obsmode_{\rm in}$ is set to \obsmode.

	      \item
	        %
                If
	        %
                \begin{eqnarray}
                  \obsmode_{\rm in} & = & {\rm POINTING},
                \end{eqnarray}
		%
		then ${\obsmode}_{\rm in}$ is set to ``pointing''.
		
	      \item
	        %
                If
	        %
                \begin{eqnarray}
                  \obsmode_{\rm in} & = & {\rm SECONDARY},
                \end{eqnarray}
		%
		then ${\obsmode}_{\rm in}$ is set to ``secondary''.
		
	      \item
	        %
                If
	        %
                \begin{eqnarray}
                  \obsmode_{\rm in} & \ne & {\rm none\ and} \\
                  \obsmode_{\rm in} & \ne & {\rm pointing\ and} \\
                  \obsmode_{\rm in} & \ne & {\rm secondary},
                \end{eqnarray}
	        %
	        then $\obsmode_{\rm in}$ is set to ``none'' and
		\acisprocessevents\ produces a warning message. 
	    
	    \end{enumerate}

          \item
            {\datamode}: \\
            %
	    The \datamode\ is read from the HDU $h_{\rm in}$ keyword of the
	    same name. If the HDU $h_{\rm in}$ does not include the keyword
	    \datamode\ or if
	    %
	    \begin{eqnarray}
              \datamode & \ne & {\rm CC33\_FAINT}\ {\rm and} \\
              \datamode & \ne & {\rm CC33\_GRADED}\ {\rm and} \\
              \datamode & \ne & {\rm FAINT}\ {\rm and} \\
              \datamode & \ne & {\rm FAINT\_BIAS}\ {\rm and} \\
              \datamode & \ne & {\rm GRADED}\ {\rm and} \\
              \datamode & \ne & {\rm VFAINT},
	    \end{eqnarray}
	    %
	    then \acisprocessevents\ exits with an error message. Hereafter,
	    the value of this keyword is referred to as $\datamode_{\rm
	    in}$.

	  \item
            {\content}: \\
            %
	    If the \infile\ does not have an HDU $h_{\rm in}$ with the keyword
	    %
	    \begin{eqnarray}
	      \content & = & {\rm EVT0\ or} \\
	      \content & = & {\rm EVT1\ or} \\
	      \content & = & {\rm TGEVT1\ or} \\
	      \content & = & {\rm EVT2},
	    \end{eqnarray}
	    %
	    then \acisprocessevents\ exits with an error message. Hereafter,
	    the value of this keyword is referred to as $\content_{\rm in}$.

          \item
            {\tim}: \\
            %
	    If HDU $h_{\rm in}$ of the \infile\ does not include the column
	    \tim, then \acisprocessevents\ exits with an error message.
	    Hereafter, this column is referred to as $\tim_{\rm in}$.

          \item
            {\timero}: \\
            %
	    If
	    %
	    \begin{eqnarray}
              \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm CC33\_GRADED}
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \content_{\rm in} & = & {\rm EVT1}\ {\rm or} \\
	      \content_{\rm in} & = & {\rm TGEVT1}\ {\rm or} \\
	      \content_{\rm in} & = & {\rm EVT2}
	    \end{eqnarray}
	    %
	    and HDU $h_{\rm in}$ of the \infile\ does not include the column
	    \timero, then \acisprocessevents\ exits with an error message.
	    Hereafter, this column is referred to as $\timero_{\rm in}$.

          \item
            {\expno}: \\
            %
	    If HDU $h_{\rm in}$ the \infile\ does not include the column
	    \expno, then \acisprocessevents\ exits with an error message.
	    Hereafter, this column is referred to as $\expno_{\rm in}$.

          \item
            {\ccdid}:
	    %
	    \begin{enumerate}

	      \item
	        If
	        %
	        \begin{eqnarray}
	          \content_{\rm in} & = & {\rm EVT0}
	        \end{eqnarray}
	        %
	        and HDU $h_{\rm in}$ of the \infile\ does not include the
		keyword \ccdid, then \acisprocessevents\ exits with an error
		message.  Hereafter, this keyword is referred to as
		$\ccdid_{\rm in}$.

	      \item
	        If
	        %
	        \begin{eqnarray}
	          \content_{\rm in} & = & {\rm EVT1}\ {\rm or} \\
	          \content_{\rm in} & = & {\rm TGEVT1}\ {\rm or} \\
	          \content_{\rm in} & = & {\rm EVT2}
	        \end{eqnarray}
	        %
	        and HDU $h_{\rm in}$ of the \infile\ does not include the
		column \ccdid, then \acisprocessevents\ exits with an error
		message.  Hereafter, this column is referred to as
		$\ccdid_{\rm in}$.

	    \end{enumerate}

          \item
            {\ccdx}:
	    %
	    \begin{enumerate}

	      \item
	        If 
	        %
	        \begin{eqnarray}
	          \content_{\rm in} & = & {\rm EVT0}
	        \end{eqnarray}
	        %
		and HDU $h_{\rm in}$ of the \infile\ does not include the 
		column \ccdx\ and does not include the column \chipx, then
		\acisprocessevents\ exits with an error message.  Hereafter,
		these columns are referred to as $\ccdx_{\rm in}$ and
		$\chipx_{\rm in}$, respectively.
		
	    \end{enumerate}

          \item
            {\chipx}:
	    %
	    \begin{enumerate}
	    
	      \item
	        If
	        %
	        \begin{eqnarray}
	          \content_{\rm in} & = & {\rm EVT1}\ {\rm or} \\
	          \content_{\rm in} & = & {\rm TGEVT1}\ {\rm or} \\
	          \content_{\rm in} & = & {\rm EVT2}
	        \end{eqnarray}
	        %
	        and HDU $h_{\rm in}$ of the \infile\ does not include the
		column \chipx, then \acisprocessevents\ exits with an error
		message. Hereafter, this column is referred to as
		$\chipx_{\rm in}$.

	    \end{enumerate}

          \item
            {\ccdy}:
	    %
            \begin{enumerate}

	      \item
	        If
	        %
	        \begin{eqnarray}
                  \content_{\rm in} & = & {\rm EVT0}
	        \end{eqnarray}
	        %
		and
		%
	        \begin{eqnarray}
                  \datamode_{\rm in} & = & {\rm FAINT}\ {\rm or} \\
                  \datamode_{\rm in} & = & {\rm FAINT\_BIAS}\ {\rm or} \\
                  \datamode_{\rm in} & = & {\rm GRADED}\ {\rm or} \\
                  \datamode_{\rm in} & = & {\rm VFAINT}
	        \end{eqnarray}
		%
	        and HDU $h_{\rm in}$ of the \infile\ does not include the
		column \ccdy\ and does not include the column \chipy, then
		\acisprocessevents\ exits with an error message.  Hereafter,
		these columns are referred to as $\ccdy_{\rm in}$ and
		$\chipy_{\rm in}$, respectively.

            \end{enumerate}

          \item
            {\trow}:
	    %
            \begin{enumerate}

	      \item
	        If
	        %
	        \begin{eqnarray}
                  \content_{\rm in} & = & {\rm EVT0}
	        \end{eqnarray}
	        %
		and
		%
	        \begin{eqnarray}
                  \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
                  \datamode_{\rm in} & = & {\rm CC33\_GRADED}
	        \end{eqnarray}
	        %
	        and HDU $h_{\rm in}$ of the \infile\ does not include the
		column \trow\ and does not include the column \chipy, then
		\acisprocessevents\ exits with an error message.  Hereafter,
		these columns are referred to as $\trow_{\rm in}$ and
		$\chipy_{\rm in}$, respectively.

            \end{enumerate}

          \item
            {\chipy}:
	    %
            \begin{enumerate}

	      \item
	        If
	        %
	        \begin{eqnarray}
	          \content_{\rm in} & = & {\rm EVT1}\ {\rm or} \\
	          \content_{\rm in} & = & {\rm TGEVT1}\ {\rm or} \\
	          \content_{\rm in} & = & {\rm EVT2}
	        \end{eqnarray}
	        %
	        and HDU $h_{\rm in}$ of the \infile\ does not include the
		column \chipy, then \acisprocessevents\ exits with an error
		message.  Hereafter, this column is referred to as
		$\chipy_{\rm in}$.

	    \end{enumerate}

          \item
	    {\timedel}: \\
	    %
            If
            %
            \begin{eqnarray}
              \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm CC33\_GRADED}
            \end{eqnarray}
            %
            and HDU $h_{\rm in}$ of the \infile\ does not include the
	    keyword \timedel, then \acisprocessevents\ exits with an error
	    message. Hereafter this keyword is referred to as $\timedel_{\rm
	    in}$.

          \item
	    {\ratarg, \dectarg, \ranom, \decnom, \rapnt, \decpnt, \chipytg,
	    and \tgm}: \\
	    %
            If
            %
            \begin{eqnarray}
              \obsmode_{\rm in} & = & {\rm pointing}
            \end{eqnarray}
            %
            and
            %
            \begin{eqnarray}
              \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm CC33\_GRADED},
            \end{eqnarray}
            %
            then
            %
            \begin{enumerate}

              \item
	        {\ratarg, \dectarg, \ranom, \decnom, \rapnt, \decpnt}: \\
	        %
                If HDU $h_{\rm in}$ of the \infile\ does not include the
		keywords \ratarg, \dectarg, \ranom, \decnom, \rapnt, and
		\decpnt, then \acisprocessevents\ exits with an error
		message. Hereafter these keywords are referred to as
		$\ratarg_{\rm in}$, $\dectarg_{\rm in}$, $\ranom_{\rm in}$,
		$\decnom_{\rm in}$, $\rapnt_{\rm in}$, and $\decpnt_{\rm
		in}$, respectively.

              \item
	        {\chipytg\ and \tgm}: \\
	        %
                If
                %
                \begin{eqnarray}
	          \content_{\rm in} & = & {\rm TGEVT1}
	        \end{eqnarray}
	        %
	        and HDU $h_{\rm in}$ of the \infile\ does not include the
		columns \chipytg and \tgm, then \acisprocessevents\ exits
		with an error message. Hereafter these columns are referred
		to as $\chipytg_{\rm in}$ and $\tgm_{\rm in}$, respectively.

	    \end{enumerate}

          \item
	    {\tgaincor}: \\
	    %
            If HDU $h_{\rm in}$ of the \infile\ does not include the keyword
	    \tgaincor, then this keyword is set to zero (i.e. FALSE).
	    Hereafter, this keyword is referred to as $\tgaincor_{\rm in}$.

	\end{enumerate}

    \end{enumerate}

  \item
    {\stp}:
    %
    % Must be before \acaofffile, \alignmentfile, and \pixadj
    %
    \begin{enumerate}

      \item
        {Lowercase}: \\
	%
        The parameter string is converted to contain only lower case
	letters.

      \item
        {Validation}:
	%
	\begin{enumerate}

	  \item
	    {Setting}: \\
	    %
	    If
	    %
	    \begin{eqnarray}
	      \stp & \ne & {\rm none}\ {\rm and} \\
	      \stp & \ne & {\rm chip}\ {\rm and} \\
	      \stp & \ne & {\rm tdet}\ {\rm and} \\
	      \stp & \ne & {\rm det}\ {\rm and} \\
	      \stp & \ne & {\rm tan}\ {\rm and} \\
	      \stp & \ne & {\rm sky},
	    \end{eqnarray}
	    %
	    then \stp\ is changed to ``none'' and \acisprocessevents\
	    produces a warning message.

	  \item
	    {\obsmode}: \\
	    %
            If
	    %
            \begin{eqnarray}
              \obsmode_{\rm in} & \ne & {\rm pointing\ and} \\
	      \stp & \ne & {\rm none}\ {\rm and} \\
	      \stp & \ne & {\rm chip}\ {\rm and} \\
	      \stp & \ne & {\rm tdet},
	    \end{eqnarray}
	    %
	    then \stp\ is changed to ``tdet'' and \acisprocessevents\
	    produces a warning message.

	  \item
	    {\acaofffile}: \\
	    %
            If
	    %
            \begin{eqnarray}
              \obsmode_{\rm in} & = & {\rm pointing\ and} \\
	      \acaofffile & = & {\rm none\ and} \\
	      \stp & \ne & {\rm none}\ {\rm and} \\
	      \stp & \ne & {\rm chip}\ {\rm and} \\
	      \stp & \ne & {\rm tdet},
	    \end{eqnarray}
	    %
	    then \acisprocessevents\ produces a warning message and \stp\ is
	    changed to ``none.''

	  \item
	    {\alignmentfile}: \\
	    %
            If
	    %
            \begin{eqnarray}
              \obsmode_{\rm in} & = & {\rm pointing\ and} \\
	      \alignmentfile & = & {\rm none\ and} \\
	      \stp & \ne & {\rm none}\ {\rm and} \\
	      \stp & \ne & {\rm chip}\ {\rm and} \\
	      \stp & \ne & {\rm tdet},
	    \end{eqnarray}
	    %
	    then \acisprocessevents\ produces a warning message and \stp\ is
	    changed to ``none.''

	\end{enumerate}

    \end{enumerate}

  \item
    {\doevtgrade}:
    %
    % Must be above apply_cti
    %
    \begin{enumerate}

      \item
        {Lowercase}: \\
        %
        The parameter string is converted to contain only lower case letters.

      \item
        {Validation}: \\
        %
	If
	%
	\begin{eqnarray}
	  \doevtgrade & \ne & {\rm yes}\ {\rm and} \\
	  \doevtgrade & \ne & {\rm no},
	\end{eqnarray}
	%
	then \acisprocessevents\ exits with an error message.

    \end{enumerate}

  \item
    {\applycti}:
    %
    \begin{enumerate}

      \item
        {Lowercase}: \\
        %
        The parameter string is converted to contain only lower case letters.

      \item
        {Validation}:
	%
	\begin{enumerate}

	  \item
	    {Setting}: \\
	    %
	    If
	    %
	    \begin{eqnarray}
	      \applycti & \ne & {\rm yes}\ {\rm and} \\
	      \applycti & \ne & {\rm no},
	    \end{eqnarray}
	    %
	    then \acisprocessevents\ exits with an error message.

          \item
            {\phas}: \\
	    If
	    %
	    \begin{eqnarray}
	      \applycti & = & {\rm yes}
	    \end{eqnarray}
	    %
	    and the \infile\ does not include the column \phas, then
	    \applycti\ is changed to ``no'' and \acisprocessevents\ produces
	    a warning message.

          \item
            {\doevtgrade}: \\
	    If
	    %
	    \begin{eqnarray}
	      \applycti & = & {\rm yes}\ {\rm and} \\
	      \doevtgrade & = & {\rm no},
	    \end{eqnarray}
	    %
	    then \applycti\ is changed to ``no'' and \acisprocessevents\
	    produces a warning message.

	\end{enumerate}

    \end{enumerate}

  \item
    {\badpixfile}:
    %
    \begin{enumerate}

      \item
        {Validation}:
	%
        \begin{enumerate}

          \item
	    If
            %
            \begin{eqnarray}
              \badpixfile & = & {\rm NONE},
            \end{eqnarray}
	    %
	    then \badpixfile\ is changed to ``none.''
	    
          \item
	    {Existence}: \\
	    %
            If
            %
            \begin{eqnarray}
              \badpixfile & \ne & {\rm none}
            \end{eqnarray}
	    %
            and the \badpixfile\ does not exist, then \badpixfile\ is
	    changed to ``none'' and \acisprocessevents\ produces a warning
	    message.

          \item
	    {Permission}: \\
	    %
            If
            %
            \begin{eqnarray}
              \badpixfile & \ne & {\rm none}
            \end{eqnarray}
	    %
            and the file permissions do not allow it to be read, then
	    \badpixfile\ is changed to ``none'' and \acisprocessevents\
	    produces a warning message.

          \item
	    {\content}: \\
	    %
            If
            %
            \begin{eqnarray}
              \badpixfile & \ne & {\rm none}
            \end{eqnarray}
	    %
            and the \badpixfile\ does not have one or more HDUs $h_{\rm
	    badpix}$ with the keyword
            %
	    \begin{eqnarray}
	      \content & = & {\rm BADPIX}\ {\rm or} \\
	      \content & = & {\rm CDB\_ACIS\_BADPIX},
	    \end{eqnarray}
	    %
            then \badpixfile\ is changed to ``none'' and \acisprocessevents\
	    produces a warning message.

          \item
	    {Keyword}: \\
	    %
            If
            %
            \begin{eqnarray}
              \badpixfile & \ne & {\rm none} 
            \end{eqnarray}
	    %
	    and the HDU(s) $h_{\rm badpix}$ of the \badpixfile\ do not
	    include the keyword \ccdid, then \badpixfile\ is changed to
	    ``none'' and \acisprocessevents\ produces a warning message.
	    Hereafter this keyword is referred to as $\ccdid_{\rm badpix}$.

          \item
	    {Columns}: \\
	    %
            If
            %
            \begin{eqnarray}
              \badpixfile & \ne & {\rm none} 
            \end{eqnarray}
	    %
	    and the HDU(s) $h_{\rm badpix}$ of the \badpixfile\ do not
	    include the columns \chipx, \chipy, \tim, \timestop, and
	    \status, then \badpixfile\ is changed to ``none'' and
	    \acisprocessevents\ produces a warning message. Hereafter these
	    columns are referred to as $\chipx_{\rm badpix}$, $\chipy_{\rm
	    badpix}$, $\tim_{\rm badpix}$, $\timestop_{\rm badpix}$, and
	    $\status_{\rm badpix}$, respectively.

	\end{enumerate}

    \end{enumerate}

  \item
    {\ctifile}:
    %
    \begin{enumerate}

      \item
        {Validation}: \\
	%
        If
        %
        \begin{eqnarray}
          \ctifile & \ne & {\rm caldb\ and} \\
          \ctifile & \ne & {\rm CALDB},
        \end{eqnarray}
        %
        then
        %
        \begin{enumerate}

          \item
	    {Existence}: \\
	    %
            If the \ctifile\ does not exist, then \applycti\ is changed to
	    ``no'' and \acisprocessevents\ produces a warning message.

          \item
	    {Permission}: \\
	    %
            If the \ctifile\ exists and the file permissions do not allow it
	    to be read, then \applycti\ is changed to ``no'' and
	    \acisprocessevents\ produces a warning message.

          \item
	    {\content}: \\
	    %
            If the \ctifile\ does not have one or more HDUs $h_{\rm cti}$
	    with the keyword
            %
	    \begin{eqnarray}
	      \content & = & {\rm CDB\_ACIS\_CTI},
	    \end{eqnarray}
	    %
	    then \applycti\ is changed to ``no'' and \acisprocessevents\
	    produces a warning message.

          \item
	    {Columns}: \\
	    %
	    If the first such HDU of the \ctifile\ does not include the
	    columns \ccdid, \chipxlo, \chipxhi, \chipylo, \chipyhi, \pha,
	    \volumex, \volumey, \frctrlx, \frctrly, \tctix, and \tctiy, then
	    \applycti\ is changed to ``no'' and \acisprocessevents\ produces
	    a warning message.

	\end{enumerate}

    \end{enumerate}

  \item
    {\clobber}:
    %
    \begin{enumerate}

      \item
        {Lowercase}: \\
        %
        The parameter string is converted to contain only lower case letters.

      \item
        {Validation}:
        %
	\begin{enumerate}

	  \item
	    {Setting}: \\
	    %
	    If
	    %
	    \begin{eqnarray}
	      \clobber & \ne & {\rm yes}\ {\rm and} \\
	      \clobber & \ne & {\rm no},
	    \end{eqnarray}
	    %
	    then \clobber\ is changed to ``no'' and \acisprocessevents\
	    produces a warning message.

          \item
            {Permission}: \\
            %
	    If
	    %
	    \begin{eqnarray}
	      \clobber & = & {\rm yes}
            \end{eqnarray}
	    %
            and the \outfile\ exists and the file permissions of the
	    \outfile\ do not allow it to be overwritten, then
	    \acisprocessevents\ exits with an error message.

          \item
            {Don't overwrite}: \\
            %
	    If
	    %
	    \begin{eqnarray}
	      \clobber & = & {\rm no}
	    \end{eqnarray}
	    %
	    and the \outfile\ exists, then \acisprocessevents\ exits with an
	    error message.

	\end{enumerate}

    \end{enumerate}

  \item
    {\pixadj}:
    %
    % Must be before \subpixfile
    %
    \begin{enumerate}

      \item
        {Lowercase}: \\
	%
        The parameter string is converted to contain only lower case
	letters.

      \item
        {Validation}:
	%
	\begin{enumerate}

	  \item
	    {Setting}: \\
	    %
            If
            %
            \begin{eqnarray}
              \pixadj & \ne & {\rm centroid}\ {\rm and} \\
              \pixadj & \ne & {\rm edser}\ {\rm and} \\
	      \pixadj & \ne & {\rm none}\ {\rm and} \\
	      \pixadj & \ne & {\rm randomize},
	    \end{eqnarray}
	    %
	    then \pixadj\ is changed to ``none'' and \acisprocessevents\
	    produces a warning message.

	  \item
	    {\obsmode}: \\
	    %
	    If
	    %
            \begin{eqnarray}
              \obsmode_{\rm in} & \ne & {\rm pointing\ and} \\
	      \pixadj & \ne & {\rm none},
	    \end{eqnarray}
	    %
	    then \pixadj\ is changed to ``none'' and \acisprocessevents\
	    produces a warning message.

          \item
            {\stp}: \\
	    %
	    If
	    %
	    \begin{eqnarray}
	      \pixadj & = & {\rm centroid}\ {\rm or} \\
	      \pixadj & = & {\rm edser}\ {\rm or} \\
	      \pixadj & = & {\rm randomize}
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \stp & \ne & {\rm sky},
	    \end{eqnarray}
	    %
	    then \pixadj\ is changed to ``none'' and \acisprocessevents\
	    produces a warning message.

          \item
            {\phas}: \\
            %
	    If
	    %
	    \begin{eqnarray}
	      \pixadj & = & {\rm centroid}
            \end{eqnarray}
            %
	    and the \infile\ does not include the column \phas, then
	    \pixadj\ is changed to ``none'' and \acisprocessevents\ produces
	    a warning message.

          \item
            {\fltgrade}: \\
            %
	    If
	    %
	    \begin{eqnarray}
	      \pixadj & = & {\rm edser}
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
              \datamode & = & {\rm CC33\_GRADED}\ {\rm or} \\
              \datamode & = & {\rm GRADED}
	    \end{eqnarray}
	    %
	    and the \infile\ does not include the column \fltgrade, then
	    \pixadj\ is changed to ``none'' and \acisprocessevents\ produces
	    a warning message.

	\end{enumerate}

    \end{enumerate}

  \item
    {\subpixfile}:
    %
    \begin{enumerate}

      \item
	If
	%
	\begin{eqnarray}
	  \pixadj & = & {\rm edser},
	\end{eqnarray}
	%
	then
	%
	\begin{enumerate}

	  \item
	    {Existence}: \\
	    %
	    If the \subpixfile\ does not exist, then \pixadj\ is changed to
	    ``none'' and \acisprocessevents\ produces a warning message.

	  \item
	    {Permission}: \\
	    %
	    If the \subpixfile\ exists and the file permissions do not allow
	    it to be read, then \pixadj\ is changed to ``none'' and
	    \acisprocessevents\ produces a warning message.

	  \item
	    {Validation}:
	    %
	    \begin{enumerate}

	      \item
	        {\content}: \\
	        %
	        If the \subpixfile\ does not have one or more HDUs $h_{\rm
		subpix}$ with the keyword
	        %
	        \begin{eqnarray}
	          \content & = & {\rm AXAF\_SUBPIX},
	        \end{eqnarray}
	        %
	        then \pixadj\ is changed to ``none'' and \acisprocessevents\
		produces a warning message.

	      \item
	        {Keyword}: \\
	        %
	        If the HDUs $h_{\rm subpix}$ of the \subpixfile\ do not
		include the keyword \ccdid, then \pixadj\ is changed to
		``none'' and \acisprocessevents\ produces a warning message.

	      \item
	        {Columns}: \\
	        %
	        If the HDUs $h_{\rm subpix}$ of the \subpixfile\ do not
		include binary tables with the columns \fltgrade, \npoints,
		\energy, \chipxoffset, and \chipyoffset, then \pixadj\ is
		changed to ``none'' and \acisprocessevents\ produces a
		warning message. Hereafter these columns are referred to as
		$\fltgrade_{\rm subpix}$, $\npoints_{\rm subpix}$,
		$\energy_{\rm subpix}$, $\chipxoffset_{\rm subpix}$, and
		$\chipyoffset_{\rm subpix}$, respectively.

	    \end{enumerate}

	\end{enumerate}

    \end{enumerate}

\end{enumerate}

\subsubsection{ Initializations }

\begin{enumerate}

  \item
    {Focal-point CCD}: \\
    %
    If
    %
    \begin{eqnarray}
      \obsmode_{\rm in} & = & {\rm pointing}
    \end{eqnarray}
    %
    and
    %
    \begin{eqnarray}
      \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
      \datamode_{\rm in} & = & {\rm CC33\_GRADED},
    \end{eqnarray}
    %
    then the values of $\rapnt_{\rm in}$ and $\decpnt_{\rm in}$ are used to
    determine the \ccdid\ associated with the focal point.  Hereafter this
    value is referred to as $\ccdid_{\rm focus}$.%
    %
    \footnote{The focal point is the location associated with the optical
      axis in the absence of dither.  This location should not be confused
      with the aim point, which is the location illuminated by an undithered
      point source provided that the source is not offset from the target
      location.}

  { \red

  \item
    {$\tim_{\rm min}$ and $\tim_{\rm max}$}: \\
    %
    If
    %
    \begin{eqnarray}
      \obsmode_{\rm in} & = & {\rm pointing}\ {\rm and} \\
      \acaofffile & \ne & {\rm none\ and} \\
      \alignmentfile & \ne & {\rm none},
    \end{eqnarray}
    %
    then the \acaofffile\ data are processed to determine the earliest and
    latest times for which there is aspect information:
    %
    \begin{eqnarray}
      \tim_{\rm min} & = &
        {\rm min} \left( \tim_{\rm acaoff} \right)\ {\rm and} \\
      \tim_{\rm max} & = &
        {\rm max} \left( \tim_{\rm acaoff} \right).
    \end{eqnarray}

  \item
    {$\chipxtarg_{\rm acaoff,med}$, $\chipytarg_{\rm acaoff,med}$}: \\
    %
    If
    %
    \begin{eqnarray}
      \obsmode_{\rm in} & = & {\rm pointing}
    \end{eqnarray}
    %
    and
    \begin{eqnarray}
      \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
      \datamode_{\rm in} & = & {\rm CC33\_GRADED}
    \end{eqnarray}
    %
    and
    %
    \begin{eqnarray}
      \acaofffile & \ne & {\rm none\ and} \\
      \alignmentfile & \ne & {\rm none},
    \end{eqnarray}
    %
    then the values of $\chipxtarg_{\rm acaoff}$ and $\chipytarg_{\rm
    acaoff}$ are computed from the values of \ratarg\ and \dectarg\ using
    the orientation of the telescope (i.e.\ \ra, \dec, and \roll) and the
    orientation of the SIM (i.e.\ \dy, \dz, and \dtheta) and the {\tim}s in
    the \acaofffile.  The values of $\chipxtarg_{\rm acaoff}$ and
    $\chipytarg_{\rm acaoff}$ are processed to obtain the median values:
    %
    \begin{eqnarray}
      \chipxtarg_{\rm acaoff,med} & = & {\rm median} ( \chipxtarg_{\rm acaoff}
        )\ {\rm and} \\
      \chipytarg_{\rm acaoff,med} & = & {\rm median} ( \chipytarg_{\rm acaoff}
        ).
    \end{eqnarray}

  }

\end{enumerate}

\subsubsection{ Loop over events }
\label{loop}

The following steps are performed, in sequence, for each event.

\begin{enumerate}

  \item
    {\status}:
    %
    \begin{enumerate}

      \item
        {Exists}: \\
        %
	If HDU $h_{\rm in}$ of the \infile\ includes a 32-bit column named
	\status, then
	%
	\begin{enumerate}

	  \item
	    The values of the bits for an event are read from the \infile.

	  \item
	    %
	    % Unset all of these bits.
	    % Bits 1, 2, 3, and 14 will be reset if appropriate.
	    % Bits 4, 5, and 16-19 will be reset if the badpixfile is
	    %   specified.  If badpixfile=none, then they should stay unset.
	    % Bit 23 will be reset if appropriate provided check_vf_pha=yes.
	    %   If check_vf_pha=no, then they should stay unset.
	    %
	    The value of $\status[k]$ is set to zero for bits $k = 1$--5,
	    14, 16--19, and 23 (of 0--31), bits that can be set by
	    \acisprocessevents.

	  \item
	    %
	    % Bits 20 can be reset only if doevtgrade=yes.  If apply_cti=no,
	    %   then they should stay unset.
	    %
	    If
	    %
	    \begin{eqnarray}
	      \doevtgrade & = & {\rm yes},
	    \end{eqnarray}
	    %
	    then the value of $\status[20]$, the other bit that can be set
	    by \acisprocessevents, is set to zero.

	\end{enumerate}

      \item
        {Does not exist}: \\
        %
	If HDU $h_{\rm in}$ does not include a 32-bit column named \status,
	then
	%
	\begin{enumerate}

	  \item
	    A set of 32 bits are allocated for the event.

	  \item
  	    The values of the 32 bits are initialized to zero.

	\end{enumerate}

    \end{enumerate}

  \item
    {\expno}:
    %
    \begin{enumerate}

      \item
        {Read}: \\
        %
        The value of \expno\ for an event is given by $\expno_{\rm in}$.

      \item
        {Validation}: \\
        %
        If
	%
	\begin{eqnarray}
	  \expno & < & 0\ {\rm or} \\
	  \expno & \ge & 10^{8},
	\end{eqnarray}
	%
	then \acisprocessevents\ produces a warning upon completion with a
	count of the total number of events for which one or the other of
	these conditions is true.  These values should not occur.

    \end{enumerate}

  \item
    {\ccdid}:
    %
    \begin{enumerate}

      \item
        {Read}: \\
        %
        The value of \ccdid\ for an event is given by $\ccdid_{\rm in}$.

      \item
        {Validation}: \\
        %
        If
	%
	\begin{eqnarray}
	  \ccdid & < & 0\ {\rm or} \\
	  \ccdid & > & 9,
	\end{eqnarray}
	%
	then \acisprocessevents\ exits with an error message because
	\ccdid-dependent computations could fail if the value of \ccdid\ is
	unphysical.

    \end{enumerate}

  \item
    {\chipx}:
    %
    \begin{enumerate}

      \item
        {Read}:
	%
	\begin{enumerate}

	  \item
            If the \infile\ includes the column \chipx, then the value of
	    \chipx\ for an event is given by
	    %
	    \begin{eqnarray}
	      \chipx & = & \chipx_{\rm in}.
	    \end{eqnarray}

	  \item
            If the \infile\ does not include the column \chipx, then the
	    value of \chipx\ for an event is given by
	    %
	    \begin{eqnarray}
	      \chipx & = & \ccdx_{\rm in} + 1.
	    \end{eqnarray}
	    
	\end{enumerate}

      \item
        {Validation}:
        %
	\begin{enumerate}

	  \item
	    {Unphysical}: \\
	    %
            If
	    %
	    \begin{eqnarray}
	      \chipx & < & 1\ {\rm or} \\
	      \chipx & > & 1024,
	    \end{eqnarray}
	    %
	    then \acisprocessevents\ exits with an error message because
	    \chipx-dependent computations could fail if the value of \chipx\
	    is unphysical.

          \item
	    {Unexpected}: \\
	    %
            If
	    %
	    \begin{eqnarray}
	      \chipx & = & 1\ {\rm or} \\
	      \chipx & = & 1024,
	    \end{eqnarray}
	    %
	    then \acisprocessevents\ produces a warning upon completion with
	    a count of the total number of events for which one or the other
	    of these conditions is true.  Although these values are not
	    unphysical, they should not occur.

	\end{enumerate}

    \end{enumerate}

  \item
    {\chipxadj}:
    %
    \begin{enumerate}

      \item
        {Initialize}:
	%
	\begin{eqnarray}
	  \chipxadj & = & \chipx.
	\end{eqnarray}

    \end{enumerate}

  \item
    {\nodeid}:
    %
    \begin{enumerate}
      \item
        {Calculate}: \\
	%
        The \nodeid\ of an event is given by
        %
        \begin{eqnarray}
	  \nodeid & = & {\rm int} \left( \frac{ \chipx - 1 }{ 256 } \right),
        \end{eqnarray}
	%
        where ``int'' means the integer portion of (i.e. truncate or round
	down) the quantity in parentheses.
    \end{enumerate}

  \item
    {\chipy}:
    %
    \begin{enumerate}

      \item
        {Read}:
	%
	\begin{enumerate}

	  \item
            If the \infile\ includes the column \chipy, then the value of
	    \chipy\ for an event is given by
	    %
	    \begin{eqnarray}
	      \chipy & = & \chipy_{\rm in}.
	    \end{eqnarray}

	  \item
            If the \infile\ does not include the column \chipy\ and
	    %
	    \begin{eqnarray}
              \datamode_{\rm in} & = & {\rm FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm FAINT\_BIAS}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm GRADED}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm VFAINT},
	    \end{eqnarray}
	    %
	    then the value of \chipy\ for an event is given by
	    %
	    \begin{eqnarray}
	      \chipy & = & \ccdy_{\rm in} + 1.
	    \end{eqnarray}

	  \item
            If the \infile\ does not include the column \chipy\ and
	    %
	    \begin{eqnarray}
              \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm CC33\_GRADED},
	    \end{eqnarray}
	    %
	    then the value of \chipy\ for an event is given by
	    %
	    \begin{eqnarray}
	      \chipy & = & \trow_{\rm in} + 1.
	    \end{eqnarray}

	\end{enumerate}

      \item
        {Validation}:
	%
	\begin{enumerate}

	  \item
	    {Unphysical}:
	    %
	    \begin{enumerate}

	      \item
	        {Timed-exposure mode}: \\
		%
                If
	        %
	        \begin{eqnarray}
	          \datamode_{\rm in} & = & {\rm FAINT}\ {\rm or} \\
	          \datamode_{\rm in} & = & {\rm FAINT\_BIAS}\ {\rm or} \\
	          \datamode_{\rm in} & = & {\rm GRADED}\ {\rm or} \\
	          \datamode_{\rm in} & = & {\rm VFAINT}
	        \end{eqnarray}
	        %
	        and
	        %
	        \begin{eqnarray}
	          \chipy & < & 1\ {\rm or} \\
	          \chipy & > & 1024,
	        \end{eqnarray}
	        %
	        then \acisprocessevents\ exits with an error message because
		\chipy-dependent computations could fail if the value of
		\chipy\ is unphysical.

	      \item
	        {Continuous-clocking mode}: \\
		%
                If
	        %
	        \begin{eqnarray}
	          \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
	          \datamode_{\rm in} & = & {\rm CC33\_GRADED}
	        \end{eqnarray}
	        %
	        and
	        %
	        \begin{eqnarray}
	          \chipy & < & 1\ {\rm or} \\
	          \chipy & > & 512,
	        \end{eqnarray}
	        %
	        then \acisprocessevents\ exits with an error message because
		the \chipy\ value is out of range and \chipy-dependent
		computations could fail if the value of \chipy\ is
		unphysical (especially if it is less than 1).

	    \end{enumerate}

	  \item
	    {Unexpected}:
	    %
	    \begin{enumerate}

	      \item
	        {FAINT, FAINT\_BIAS, or GRADED}: \\
		%
                If
	        %
	        \begin{eqnarray}
	          \datamode_{\rm in} & = & {\rm FAINT}\ {\rm or} \\
	          \datamode_{\rm in} & = & {\rm FAINT\_BIAS}\ {\rm or} \\
	          \datamode_{\rm in} & = & {\rm GRADED}
	        \end{eqnarray}
	        %
	        and
	        %
	        \begin{eqnarray}
	          \chipy & = & 1\ {\rm or} \\
	          \chipy & = & 1024,
	        \end{eqnarray}
	        %
	        then \acisprocessevents\ produces a warning upon completion
		with a count of the total number of events for which one or
		the other of these conditions is true.  Although these
		values are not unphysical, they should not occur.

	      \item
	        {VFAINT}: \\
		%
                If
	        %
	        \begin{eqnarray}
	          \datamode_{\rm in} & = & {\rm VFAINT}
	        \end{eqnarray}
	        %
	        and
	        %
	        \begin{eqnarray}
	          \chipy & = & 1\ {\rm or} \\
	          \chipy & = & 2\ {\rm or} \\
	          \chipy & = & 1023\ {\rm or} \\
	          \chipy & = & 1024,
	        \end{eqnarray}
	        %
	        then \acisprocessevents\ produces a warning upon completion
		with a count of the total number of events for which one or
		another of these conditions is true.  Although these values
		are not unphysical, they should not occur.

	      \item
	        {CC33\_FAINT or CC33\_GRADED}: \\
		%
                If
	        %
	        \begin{eqnarray}
	          \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
	          \datamode_{\rm in} & = & {\rm CC33\_GRADED}
	        \end{eqnarray}
	        %
	        and
	        %
	        \begin{eqnarray}
	          \chipy & = & 1\ {\rm or} \\
	          \chipy & = & 512,
	        \end{eqnarray}
	        %
	        then \acisprocessevents\ produces a warning upon completion
		with a count of the total number of events for which one or
		the other of these conditions is true.  Although these
		values are not unphysical, they should not occur.

	    \end{enumerate}

	\end{enumerate}

    \end{enumerate}

  \item
    {\timero}:
    %
    % This column is only used for continuous-clocking mode.
    %
    \begin{enumerate}

      \item
        {Continuous-clocking mode}: \\
	%
        If
	%
        \begin{eqnarray}
          \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
          \datamode_{\rm in} & = & {\rm CC33\_GRADED},
        \end{eqnarray}
	%
	then
	%
	\begin{enumerate}

	  \item
	    {Read}:
	    %
	    \begin{enumerate}

	      \item
	        {Level 0}: \\
		%
	        If
	        %
	        \begin{eqnarray}
                  \content_{\rm in} & = & {\rm EVT0},
	        \end{eqnarray}
	        %
	        then the value of \timero\ for an event is given by
		$\tim_{\rm in}$.

	      \item
	        {Level 1, 1.5, or 2}: \\
		%
	        If
	        %
	        \begin{eqnarray}
                  \content_{\rm in} & = & {\rm EVT1}\ {\rm or} \\
                  \content_{\rm in} & = & {\rm TGEVT1}\ {\rm or} \\
                  \content_{\rm in} & = & {\rm EVT2}
                \end{eqnarray}
		%
		and
		%
		\begin{eqnarray}
		  \timero_{\rm in} & > & 0,
		\end{eqnarray}
		%
		then
		%
		\begin{eqnarray}
		  \timero & = & \timero_{\rm in}.
		\end{eqnarray}
		%
	        If
	        %
	        \begin{eqnarray}
                  \content_{\rm in} & = & {\rm EVT1}\ {\rm or} \\
                  \content_{\rm in} & = & {\rm TGEVT1}\ {\rm or} \\
                  \content_{\rm in} & = & {\rm EVT2}
                \end{eqnarray}
		%
		and
		%
		\begin{eqnarray}
		  \timero_{\rm in} & = & 0,
		\end{eqnarray}
		%
		then
		%
		\begin{eqnarray}
		  \timero & = & \tim_{\rm in}.
		\end{eqnarray}

	    \end{enumerate}

	  \item
	    {Validation}: \\
	    %
            If
	    %
	    \begin{eqnarray}
	      \timero & < & 0\ {\rm or} \\
	      \timero & \ge & 3 \times 10^{9},
	    \end{eqnarray}
	    %
	    then \acisprocessevents\ produces a warning upon completion with
	    a count of the total number of events for which one or the other
	    of these conditions is true.  These values should not occur.

	\end{enumerate}

    \end{enumerate}
    
  \item
    $\chipxtarg_{\rm evt}$, $\chipytarg_{\rm evt}$, and
    $\chipytarg_{\rm eff}$: \\
    %
    The coordinate $\chipytarg_{\rm eff}$ is used to compute the coordinates
    \x, \y, and \skyoned.
    %
    \begin{enumerate}

      \item
        Approximate: \\
	%
        If
        %
        \begin{eqnarray}
          \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
          \datamode_{\rm in} & = & {\rm CC33\_GRADED}
        \end{eqnarray}
        %
        and
        %
        \begin{eqnarray}
          \acaofffile & \ne & {\rm none},
        \end{eqnarray}
        %
        then:
	%
	\begin{enumerate}

	  \item
	    Initial values: \\
	    %
	    The values of $\chipxtarg_{\rm evt}$ and $\chipytarg_{\rm evt}$
	    are computed from the values of \ratarg\ and \dectarg\ using the
	    value of $\ccdid_{\rm focus}$ and using the orientation of the
	    telescope (i.e.\ \ra, \dec, and \roll) and the orientation of
	    the SIM (i.e.\ \dy, \dz, and \dtheta) at the time given by
	    $\timero - (\chipytarg_{\rm acaoff,med} + 1028) \times
	    \timedel$.  The value of $\chipytarg_{\rm evt}$ can be negative.

	  \item
	    {ACIS-I0 or -I2}: \\
	    %
	    If
	    %
	    \begin{eqnarray}
	      \ccdid_{\rm focus} & = & 0\ {\rm or} \\
	      \ccdid_{\rm focus} & = & 2,
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{enumerate}

	      \item
                If
		%
		\begin{eqnarray}
		  \ccdid & = & 0\ {\rm or} \\
		  \ccdid & = & 2,
		\end{eqnarray}
		%
		then
		%
		\begin{eqnarray}
		  \chipytarg_{\rm eff} & = & \chipytarg_{\rm evt}.
		\end{eqnarray}

	      \item
                If
		%
		\begin{eqnarray}
		  \ccdid & = & 1\ {\rm or} \\
		  \ccdid & = & 3,
		\end{eqnarray}
		%
		then
		%
		\begin{eqnarray}
		  \chipytarg_{\rm eff} & = & 512 - ( \chipytarg_{\rm evt} -
		    \chipytarg_{\rm acaoff,med} ).
		\end{eqnarray}

	      \item
                If
		%
		\begin{eqnarray}
		  \ccdid & \ge & 4,
		\end{eqnarray}
		%
		then
		%
		\begin{eqnarray}
		  \chipytarg_{\rm eff} & = & 512 -
		    ( \chipxtarg_{\rm evt} - \chipxtarg_{\rm acaoff,med} ).
		\end{eqnarray}

	    \end{enumerate}

	  \item
	    {ACIS-I1 or -I3}: \\
	    %
	    If
	    %
	    \begin{eqnarray}
	      \ccdid_{\rm focus} & = & 1\ {\rm or} \\
	      \ccdid_{\rm focus} & = & 3,
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{enumerate}

	      \item
                If
		%
		\begin{eqnarray}
		  \ccdid & = & 0\ {\rm or} \\
		  \ccdid & = & 2,
		\end{eqnarray}
		%
		then
		%
		\begin{eqnarray}
		  \chipytarg_{\rm eff} & = & 512 - ( \chipytarg_{\rm evt} -
		    \chipytarg_{\rm acaoff,med} ).
		\end{eqnarray}

	      \item
                If
		%
		\begin{eqnarray}
		  \ccdid & = & 1\ {\rm or} \\
		  \ccdid & = & 3,
		\end{eqnarray}
		%
		then
		%
		\begin{eqnarray}
		  \chipytarg_{\rm eff} & = & \chipytarg_{\rm evt}.
		\end{eqnarray}

	      \item
                If
		%
		\begin{eqnarray}
		  \ccdid & \ge & 4,
		\end{eqnarray}
		%
		then
		%
		\begin{eqnarray}
		  \chipytarg_{\rm eff} & = & 512 +
		    ( \chipxtarg_{\rm evt} - \chipxtarg_{\rm acaoff,med} ).
		\end{eqnarray}

	    \end{enumerate}

	  \item
	    {ACIS-S}: \\
	    %
	    If
	    %
	    \begin{eqnarray}
	      \ccdid_{\rm focus} & \ge & 4,
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{enumerate}

	      \item
                If
		%
		\begin{eqnarray}
		  \ccdid & = & 0\ {\rm or} \\
		  \ccdid & = & 2,
		\end{eqnarray}
		%
		then
		%
		\begin{eqnarray}
		  \chipytarg_{\rm eff} & = & 512 +
		    ( \chipxtarg_{\rm evt} - \chipxtarg_{\rm acaoff,med} ).
		\end{eqnarray}

	      \item
                If
		%
		\begin{eqnarray}
		  \ccdid & = & 1\ {\rm or} \\
		  \ccdid & = & 3,
		\end{eqnarray}
		%
		then
		%
		\begin{eqnarray}
		  \chipytarg_{\rm eff} & = & 512 -
		    ( \chipxtarg_{\rm evt} - \chipxtarg_{\rm acaoff,med} ).
		\end{eqnarray}

	      \item
                If
		%
		\begin{eqnarray}
		  \ccdid & \ge & 4,
		\end{eqnarray}
		%
		then
		%
		\begin{eqnarray}
		  \chipytarg_{\rm eff} & = & \chipytarg_{\rm evt}.
		\end{eqnarray}

	    \end{enumerate}

	\end{enumerate}

      \item
        {Validation}: \\
	%
	If
        \begin{eqnarray}
          \chipytarg_{\rm eff} & < & -256\ {\rm or} \\
          \chipytarg_{\rm eff} & \ge & 1280,
        \end{eqnarray}
	%
	then \acisprocessevents\ produces a warning message.

    \end{enumerate}

  \item
    {\tgm}:
    %
    \begin{enumerate}

      \item
        {Continuous-clocking mode with gratings}: \\
	%
        If
        %
        \begin{eqnarray}
          \obsmode_{\rm in} & = & {\rm pointing}
        \end{eqnarray}
        %
        and
	%
        \begin{eqnarray}
          \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
          \datamode_{\rm in} & = & {\rm CC33\_GRADED}
        \end{eqnarray}
	%
	and
	%
	\begin{eqnarray}
          \content_{\rm in} & = & {\rm TGEVT1},
	\end{eqnarray}
	%
	then
	%
	\begin{enumerate}

	  \item
            {Read}: \\
	    %
	    The value of \tgm\ for an event is given by $\tgm_{\rm in}.$

          \item
            {Validation}:
	    %
	    \begin{enumerate}
	 
	      \item
	        If
	        %
	        \begin{eqnarray}
	          \tgm & < & -99,
	        \end{eqnarray}
	        %
	        then
	        %
	        \begin{eqnarray}
	          \tgm & = & -99
	        \end{eqnarray}
	        %
	        and \acisprocessevents\ produces a warning upon completion
		with a count of the total number of events for which this
		condition is true.  These values should not occur.

	      \item
	        If
	        %
	        \begin{eqnarray}
	          \tgm & > & 99,
	        \end{eqnarray}
	        %
	        then
	        %
	        \begin{eqnarray}
	          \tgm & = & 99
	        \end{eqnarray}
	        %
	        and \acisprocessevents\ produces a warning upon completion
		with a count of the total number of events for which this
		condition is true.  These values should not occur.

	    \end{enumerate}

	\end{enumerate}

    \end{enumerate}

  \item
    {\chipytg}:
    %
    \begin{enumerate}

      \item
        {Continuous-clocking mode with gratings}: \\
	%
        If
        %
        \begin{eqnarray}
          \obsmode_{\rm in} & = & {\rm pointing}
        \end{eqnarray}
        %
        and
	%
        \begin{eqnarray}
          \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
          \datamode_{\rm in} & = & {\rm CC33\_GRADED}
        \end{eqnarray}
	%
	and
	%
	\begin{eqnarray}
          \content_{\rm in} & = & {\rm TGEVT1},
	\end{eqnarray}
	%
	then
	%
	\begin{enumerate}

          \item
            {Read}: \\
	    %
	    The value of \chipytg\ for an event is given by $\chipytg_{\rm
	    in}.$

          \item
            {Validation}: \\
	    %
	    \begin{enumerate}

	      \item
                If
	        %
	        \begin{eqnarray}
                  \tgm & > & -99\ {\rm and} \\
                  \tgm & < & 99\ {\rm and} \\
		  \chipytg & \ne & {\rm NaN}
                \end{eqnarray}
	        %
	        and
	        %
	        \begin{eqnarray}
	          \chipytg & \le & 0\ {\rm or} \\
	          \chipytg & \ge & 1025,
	        \end{eqnarray}
	        %
	        then \acisprocessevents\ exits with an error message because
		\chipytg-dependent computations could fail if the value of
		\chipytg\ is unphysical.

              \item
                If
	        %
	        \begin{eqnarray}
                  \tgm & > & -99\ {\rm and} \\
                  \tgm & < & 99\ {\rm and} \\
		  \chipytg & \ne & {\rm NaN}\ {\rm and} \\
	          \chipytg & < & 1,
	        \end{eqnarray}
	        %
	        then
	        %
	        \begin{eqnarray}
	          \chipytg & = & 1.
	        \end{eqnarray}

              \item
                If
	        %
	        \begin{eqnarray}
                  \tgm & > & -99\ {\rm and} \\
                  \tgm & < & 99\ {\rm and} \\
		  \chipytg & \ne & {\rm NaN}\ {\rm and} \\
	          \chipytg & > & 1024,
	        \end{eqnarray}
	        %
	        then
	        %
	        \begin{eqnarray}
	          \chipytg & = & 1024.
	        \end{eqnarray}

	    \end{enumerate}

	\end{enumerate}

    \end{enumerate}

  \item
    {\tim\ and \chipyadj}:
    \label{chipyadj} \\
    %
    For continuous-clocking mode observations, the value of \chipyadj\ is
    used to compute the \tim, pulse heights, and the coordinates \tdetx,
    \tdety, \detx, and \dety.
    %
    \begin{enumerate}

      \item
        Calculate:
	%
	\begin{enumerate}

	  \item
	    {Timed exposure mode}: \\
	    %
            If
	    %
            \begin{eqnarray}
              \datamode_{\rm in} & = & {\rm FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm FAINT\_BIAS}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm GRADED}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm VFAINT},
            \end{eqnarray}
	    %
	    then
            %
	    \begin{eqnarray}
	      \tim & = & \tim_{\rm in} {\rm and} \\
	      \chipyadj & = & \chipy.
	    \end{eqnarray}

          \item
	    {Continuous-clocking mode}: \\
	    %
            If
	    %
            \begin{eqnarray}
              \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm CC33\_GRADED}
            \end{eqnarray}
	    %
	    then
	    %
	    \begin{enumerate}

	      \item
	        Set
		%
		\begin{eqnarray}
		  \chipyadj & = & 512\ {\rm and} \\
		  \tim' & = & \timero - ( \chipyadj + 1028 ) \times \timedel.
		\end{eqnarray}

	      \item
	        If
	        %
		\begin{eqnarray}
		  \acaofffile & \ne & {\rm none},
		\end{eqnarray}
	        %
		then
		%
		\begin{eqnarray}
		  \chipyadj' & = & \chipytarg_{\rm eff}\ {\rm and} \\
		  \tim' & = & \timero - ( \chipyadj' + 1028 ) \times \timedel,
		\end{eqnarray}
		%
		and \chipyadj\ is computed from the values of \ratarg\ and
		\dectarg\ using the orientation of the telescope (i.e.\ \ra,
		\dec, and \roll) and the orientation of the SIM (i.e.\ \dy,
		\dz, and \dtheta) at the time $\tim'$.  At this step, the
		value of \chipyadj\ can be negative.

	      \item
	        If
		%
		\begin{eqnarray}
		  \content_{\rm in} & = & {\rm TGEVT1\ and} \\
		  \tgm & > & -99\ {\rm and} \\
		  \tgm & < & 99\ {\rm and} \\
		  \chipytg & \ne & {\rm NaN},
		\end{eqnarray}
		%
		then
		%
		\begin{eqnarray}
		  \chipyadj & = & \chipytg.
		\end{eqnarray}

	      \item
	        If
		%
		\begin{eqnarray}
		  \content_{\rm in} & = & {\rm TGEVT1}
		\end{eqnarray}
		%
		and
		%
		\begin{eqnarray}
		  \tgm & = & -99\ {\rm or} \\
		  \tgm & = & 99,
		\end{eqnarray}
		%
		then
		%
		\begin{eqnarray}
		  \chipyadj & = & 512.
		\end{eqnarray}

	      \item
	        If
	        %
		\begin{eqnarray}
		  \acaofffile & \ne & {\rm none}
		\end{eqnarray}
	        %
		and
		\begin{eqnarray}
		  \tim' & < & \tim_{\rm min}\ {\rm or} \\
		  \tim' & \ge & \tim_{\rm max},
		\end{eqnarray}
		%
		then
		%
		\begin{eqnarray}
		  \chipyadj & = & 512.
		\end{eqnarray}

	      \item
	        If
	        %
		\begin{eqnarray}
		  \acaofffile & \ne & {\rm none} 
		\end{eqnarray}
	        %
		and
		\begin{eqnarray}
		  \tim' & < & \tim_{\rm min}\ {\rm or} \\
		  \tim' & \ge & \tim_{\rm max},
		\end{eqnarray}
		%
		and
		%
		\begin{eqnarray}
		  \ccdid_{\rm focus} & = & 0\ {\rm or} \\
		  \ccdid_{\rm focus} & = & 2
		\end{eqnarray}
		%
		and
		%
		\begin{eqnarray}
		  \ccdid & = & 0\ {\rm or} \\
		  \ccdid & = & 2,
		\end{eqnarray}
		%
		then
		%
		\begin{eqnarray}
		  \chipyadj & = & \chipytarg_{\rm acaoff,med}.
		\end{eqnarray}

	      \item
	        If
	        %
		\begin{eqnarray}
		  \acaofffile & \ne & {\rm none}
		\end{eqnarray}
	        %
		and
		\begin{eqnarray}
		  \tim' & < & \tim_{\rm min}\ {\rm or} \\
		  \tim' & \ge & \tim_{\rm max},
		\end{eqnarray}
		%
		and
		%
		\begin{eqnarray}
		  \ccdid_{\rm focus} & = & 1\ {\rm or} \\
		  \ccdid_{\rm focus} & = & 3
		\end{eqnarray}
		%
		and
		%
		\begin{eqnarray}
		  \ccdid & = & 1\ {\rm or} \\
		  \ccdid & = & 3,
		\end{eqnarray}
		%
		then
		%
		\begin{eqnarray}
		  \chipyadj & = & \chipytarg_{\rm acaoff,med}.
		\end{eqnarray}

	      \item
	        If
	        %
		\begin{eqnarray}
		  \acaofffile & \ne & {\rm none} 
		\end{eqnarray}
	        %
		and
		\begin{eqnarray}
		  \tim' & < & \tim_{\rm min}\ {\rm or} \\
		  \tim' & \ge & \tim_{\rm max},
		\end{eqnarray}
		%
		and
		%
		\begin{eqnarray}
		  \ccdid_{\rm focus} & \ge & 4\ {\rm and} \\
		  \ccdid & \ge & 4,
		\end{eqnarray}
		%
		then
		%
		\begin{eqnarray}
		  \chipyadj & = & \chipytarg_{\rm acaoff,med}.
		\end{eqnarray}

	      \item
	        If
	        %
		\begin{eqnarray}
		  \acaofffile & = & {\rm none} 
		\end{eqnarray}
		%
		and
		%
		\begin{eqnarray}
		  \content_{\rm in} & \ne & {\rm TGEVT1},
		\end{eqnarray}
	        %
		then
		%
		\begin{eqnarray}
		  \chipyadj & = & 512.
		\end{eqnarray}

	      \item
	        If
	        %
		\begin{eqnarray}
		  \ccdid_{\rm focus} & \le & 3\ {\rm and} \\
		  \ccdid & \ge & 4,
		\end{eqnarray}
		%
		then
		%
		\begin{eqnarray}
		  \chipyadj & = & 512.
		\end{eqnarray}

	      \item
	        If
	        %
		\begin{eqnarray}
		  \ccdid_{\rm focus} & \ge & 4\ {\rm and} \\
		  \ccdid & \le & 3,
		\end{eqnarray}
		%
		then
		%
		\begin{eqnarray}
		  \chipyadj & = & 512.
		\end{eqnarray}

	      \item
	        If
	        %
                \begin{eqnarray}
                  \obsmode_{\rm in} & = & {\rm secondary},
                \end{eqnarray}
		%
		then
		%
		\begin{eqnarray}
		  \chipyadj & = & 512.
		\end{eqnarray}

	      \item
	        If
	        %
                \begin{eqnarray}
		  \chipyadj & < & 0.5\ {\rm or} \\
		  \chipyadj & \ge & 1024.5
                \end{eqnarray}
		%
		then
		%
		\begin{eqnarray}
		  \chipyadj & = & 512.
		\end{eqnarray}

              \item
	        Set
		%
		\begin{eqnarray}
		  \tim & = & \timero - ( \chipyadj + 1028 ) \times \timedel.
		\end{eqnarray}

	    \end{enumerate}
	    %
	    In continuous-clocking mode, the coordinate \chipyadj\ is used
	    to compute the time, the pulse heights, and the coordinates
	    (except for \x, \y, and \skyoned).

	\end{enumerate}

      \item
        {Validation}:
	%
	\begin{enumerate}

	  \item
            If
	    %
	    \begin{eqnarray}
	      \tim & < & 0\ {\rm or} \\
	      \tim & \ge & 3 \times 10^{9},
	    \end{eqnarray}
	    %
	    then \acisprocessevents\ produces a warning upon completion with
	    a count of the total number of events for which one or the other
	    of these conditions is true.  These values should not occur.

	  \item
	    If
	    %
	    \begin{eqnarray}
	      \chipyadj & < & 0.5\ {\rm or} \\
	      \chipyadj & \ge & 1024.5,
	    \end{eqnarray}
	    %
	    then \acisprocessevents\ exits with an error message because
	    \chipyadj-dependent computations could fail if the value of
	    \chipyadj\ is unphysical.

	\end{enumerate}

    \end{enumerate}

  \item
    {Bad pixel}:
    %
    \begin{enumerate}

      \item
        If
	%
	\begin{eqnarray}
	  \badpixfile & \ne & {\rm none} 
	\end{eqnarray}
	%
	and the \badpixfile\ includes a valid HDU $h_{\rm badpix}$ where
	$\ccdid_{\rm badpix} = \ccdid$, then the HDU $h_{\rm badpix}$ is
	searched as follows to determine if the event should have one or
	more \status\ bits set to one.

	\begin{enumerate}

	  \item
	    If $\datamode_{\rm in} = {\rm CC33\_FAINT}$ or $\datamode_{\rm
	    in} = {\rm CC33\_GRADED}$ and there are one or more rows $r$ in
	    HDU $h_{\rm badpix}$ where
	    %
	    \begin{eqnarray}
	      \chipx & \ge & \chipx_{{\rm badpix},r}[0]\ {\rm and} \\
	      \chipx & \le & \chipx_{{\rm badpix},r}[1]\ {\rm and} \\
	      \tim & \ge & \tim_{{\rm badpix},r}\ {\rm and} \\
	      \tim & < & \timestop_{{\rm badpix},r}
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \status_{{\rm badpix},r}[5] & = & 1\ {\rm or} \\
	      \status_{{\rm badpix},r}[6] & = & 1\ {\rm or} \\
	      \status_{{\rm badpix},r}[9] & = & 1,
	    \end{eqnarray}
            then
	    %
	    \begin{equation}
	      \status[0] = 1
	    \end{equation}
	    %
	    for the event. Here $\ccdid_{\rm badpix}$ is the value of the
	    keyword \ccdid\ in HDU $h_{\rm badpix}$ of the \badpixfile,
	    %
	    $\chipx_{{\rm badpix},r}[0]$ and $\chipx_{{\rm badpix},r}[1]$
	    are the first and second values in the vector column named
	    \chipx\ of row $r$ of HDU $h_{\rm badpix}$ of the \badpixfile,
	    and
	    %
	    $\tim_{{\rm badpix},r}$ and $\timestop_{{\rm badpix},r}$ are the
	    values in the columns named \tim\ and \timestop, respectively,
	    of row $r$ of HDU $h_{\rm badpix}$ of the \badpixfile.

	  \item
	    If $\datamode_{\rm in} = {\rm CC33\_FAINT}$ or $\datamode_{\rm
	    in} = {\rm CC33\_GRADED}$ and there are one or more rows $r$
	    in HDU $h_{\rm badpix}$ where
	    %
	    \begin{eqnarray}
	      \chipx & \ge & \chipx_{{\rm badpix},r}[0]\ {\rm and} \\
	      \chipx & \le & \chipx_{{\rm badpix},r}[1]\ {\rm and} \\
	      \tim & \ge & \tim_{{\rm badpix},r}\ {\rm and} \\
	      \tim & < & \timestop_{{\rm badpix},r}
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \status_{{\rm badpix},r}[0] & = & 1\ {\rm or} \\
	      \status_{{\rm badpix},r}[1] & = & 1\ {\rm or} \\
	      \status_{{\rm badpix},r}[7] & = & 1\ {\rm or} \\
	      \status_{{\rm badpix},r}[11] & = & 1\ {\rm or} \\
	      \status_{{\rm badpix},r}[12] & = & 1\ {\rm or} \\
	      \status_{{\rm badpix},r}[13] & = & 1\ {\rm or} \\
	      \status_{{\rm badpix},r}[14] & = & 1\ {\rm or} \\
	      \status_{{\rm badpix},r}[16] & = & 1,
	    \end{eqnarray}
            then
	    %
	    \begin{equation}
	      \status[4] = 1
	    \end{equation}
	    %
	    for the event.

	  \item
	    If $\datamode_{\rm in} = {\rm CC33\_FAINT}$ or $\datamode_{\rm
	    in} = {\rm CC33\_GRADED}$ and there are one or more rows $r$ in
	    HDU $h_{\rm badpix}$ where
	    %
	    \begin{eqnarray}
	      \chipx & \ge & \chipx_{{\rm badpix},r}[0]\ {\rm and} \\
	      \chipx & \le & \chipx_{{\rm badpix},r}[1]\ {\rm and} \\
	      \tim & \ge & \tim_{{\rm badpix},r}\ {\rm and} \\
	      \tim & < & \timestop_{{\rm badpix},r}
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \status_{{\rm badpix},r}[8] & = & 1\ {\rm or} \\
	      \status_{{\rm badpix},r}[10] & = & 1,
	    \end{eqnarray}
            then
	    %
	    \begin{equation}
	      \status[5] = 1
	    \end{equation}
	    %
	    for the event.

	  \item
	    If $\datamode_{\rm in} = {\rm CC33\_FAINT}$ or $\datamode_{\rm
	    in} = {\rm CC33\_GRADED}$ and there are one or more rows $r$ in
	    HDU $h_{\rm badpix}$ where
	    %
	    \begin{eqnarray}
	      \chipx & \ge & \chipx_{{\rm badpix},r}[0]\ {\rm and} \\
	      \chipx & \le & \chipx_{{\rm badpix},r}[1]\ {\rm and} \\
	      \tim & \ge & \tim_{{\rm badpix},r}\ {\rm and} \\
	      \tim & < & \timestop_{{\rm badpix},r}
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \status_{{\rm badpix},r}[3] & = & 1,
	    \end{eqnarray}
            then
	    %
	    \begin{equation}
	      \status[6] = 1
	    \end{equation}
	    %
	    for the event.

	  \item
	    If $\datamode_{\rm in} = {\rm CC33\_FAINT}$ or $\datamode_{\rm
	    in} = {\rm CC33\_GRADED}$ and there are one or more rows $r$ in
	    HDU $h_{\rm badpix}$ where
	    %
	    \begin{eqnarray}
	      \chipx & \ge & \chipx_{{\rm badpix},r}[0]\ {\rm and} \\
	      \chipx & \le & \chipx_{{\rm badpix},r}[1]\ {\rm and} \\
	      \tim & \ge & \tim_{{\rm badpix},r}\ {\rm and} \\
	      \tim & < & \timestop_{{\rm badpix},r}
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \status_{{\rm badpix},r}[2] & = & 1\ {\rm or} \\
	      \status_{{\rm badpix},r}[4] & = & 1,
	    \end{eqnarray}
            then
	    %
	    \begin{equation}
	      \status[8] = 1
	    \end{equation}
	    %
	    for the event.

	  \item
	    If $\datamode_{\rm in} = {\rm CC33\_FAINT}$ or $\datamode_{\rm
	    in} = {\rm CC33\_GRADED}$ and there are one or more rows $r$ in
	    HDU $h_{\rm badpix}$ where
	    %
	    \begin{eqnarray}
	      \chipx & \ge & \chipx_{{\rm badpix},r}[0]\ {\rm and} \\
	      \chipx & \le & \chipx_{{\rm badpix},r}[1]\ {\rm and} \\
	      \tim & \ge & \tim_{{\rm badpix},r}\ {\rm and} \\
	      \tim & < & \timestop_{{\rm badpix},r}
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \status_{{\rm badpix},r}[15] & = & 1,
	    \end{eqnarray}
            then
	    %
	    \begin{equation}
	      \status[16] = 1
	    \end{equation}
	    %
	    for the event.

	  \item
	    In summary, the mapping between a bad-pixel \status\ bit and the
	    corresponding event \status\ bit is listed in Table~\ref{tab01}.
	    %
            \begin{table}[h]
	      \caption{Bad-pixel to event \status\ bit mapping}
              \begin{center}
                \begin{tabular}{cc}
	          \hline
	          \hline
    	          Bad-pixel \status\ bit & Event \status\ bit \\
    	          \hline
		   0 &  4 \\
		   1 &  4 \\
		   2 &  8 \\
		   3 &  6 \\
		   4 &  8 \\
		   5 &  0 \\
		   6 &  0 \\
		   7 &  4 \\
		   8 &  5 \\
		   9 &  0 \\
		  10 &  5 \\
		  11 &  4 \\
		  12 &  4 \\
		  13 &  4 \\
		  14 &  4 \\
		  15 & 16 \\
		  16 &  4\\
	          \hline
                \end{tabular}
              \end{center}
	      \label{tab01}
            \end{table}

	\end{enumerate}

    \end{enumerate}

  \item
    {\phas}:
    %
    \begin{enumerate}
      \item
        If HDU~1 of the \infile\ includes the column \phas, then
	%
	\begin{enumerate}
	  \item
	    the values of \phas\ for an event are read from the \infile.
	  \item
	    If $\phas[4] < {\rm the}$ split threshold, then $\status[k] = 1$
	    for bit $k = 1$.
	  \item
	    If $\phas[4] \le \phas[j]$ for one or more $j = 0$--3 or 5--8,
	    then $\status[k] = 1$ for bit $k = 1$.
	  \item
	    If $\phas[j] > 4095$ for one or more $j = 0$--8, then
	    $\status[k] = 1$ for bit $k = 2$.
	\end{enumerate}
    \end{enumerate}

  \item
    {\phasadj}:
    %
    \begin{enumerate}
      \item
        If HDU~1 of the \infile\ includes $\datamode_{\rm in} = {\rm
	CC33\_FAINT}$ and the parameter $\applycti = {\rm yes}$ and the
	\ctifile\ and \mtlfile\ are specified, then the CTI-adjusted pulse
	heights are computed as follows.
	%
	\begin{enumerate}
	  \item
	    The real-valued arrays for the serial CTI adjustment
	    $\Delta_{x}$, the parallel CTI adjustment $\Delta_{y}$, and the
	    adjusted pulse heights \phasadj\ are initialized such that
	    %
	    \begin{eqnarray}
	      \Delta_{x}[j] & = & 0, \\
	      \Delta_{y}[j] & = & 0,\ {\rm and} \\
	      \phasadj[j] & = & \phas[j]
	    \end{eqnarray}
	    %
	    for every element $j = 0$--8, where the starting point for the
	    adjusted pulse heights are the unadjusted pulse heights \phas.
	    Note that the values of the unadjusted pulse heights \phas\
	    remain unchanged to ensure that it is possible to remove the CTI
	    adjustment or to reapply the adjustment if the algorithm or
	    calibration data are modified.
	  \item
	    The CTI iteration counter $n$ is initialized such that
	    %
	    \begin{equation}
	      n = 1.
	    \end{equation}
	    %
	  \item
	    \label{tempvars}
	    %
	    The temporary variables $\Delta_{x}'$, $\Delta_{y}'$, and
	    $\phasadj'$ are set such that
	    %
            \begin{eqnarray}
              \Delta_{x}'[j] & = & \Delta_{x}[j], \\
              \Delta_{y}'[j] & = & \Delta_{y}[j],\ {\rm and} \\
              \phasadj'[j] & = & \phasadj[j]
            \end{eqnarray}
	    %
	    for each element $j$.
	  \item
	    %
	    \begin{enumerate}
	      \item
	        If there is a serial CTI trap-density map in the \ctifile\
		for \ccdid\ and $\nodeid = 0$ or 2, then the values of
		$\Delta_{x}$ are given by
	        %
                \begin{eqnarray}
	          \Delta_{x}[0] & = & c_{x}[0] s_{x} \rho_{x}[0] V_{x}[0], \\
	          \Delta_{x}[1] & = & c_{x}[1] s_{x} \rho_{x}[1] V_{x}[1] -
		    c'_{x}[0] s_{x} \rho_{x}[0] V_{x}[0], \\
		  \Delta_{x}[2] & = & c_{x}[2] s_{x} \rho_{x}[2] V_{x}[2] -
		    c'_{x}[1] s_{x} \rho_{x}[1] V_{x}[1], \\
	          \Delta_{x}[3] & = & c_{x}[3] s_{x} \rho_{x}[3] V_{x}[3], \\
	          \Delta_{x}[4] & = & c_{x}[4] s_{x} \rho_{x}[4] V_{x}[4] -
		    c'_{x}[3] s_{x} \rho_{x}[3] V_{x}[3], \\
	          \Delta_{x}[5] & = & c_{x}[5] s_{x} \rho_{x}[5] V_{x}[5] -
		    c'_{x}[4] s_{x} \rho_{x}[4] V_{x}[4], \\
	          \Delta_{x}[6] & = & c_{x}[6] s_{x} \rho_{x}[6] V_{x}[6], \\
	          \Delta_{x}[7] & = & c_{x}[7] s_{x} \rho_{x}[7] V_{x}[7] -
		    c'_{x}[6] s_{x} \rho_{x}[6] V_{x}[6],\ {\rm and} \\
	          \Delta_{x}[8] & = & c_{x}[8] s_{x} \rho_{x}[8] V_{x}[8] -
		    c'_{x}[7] s_{x} \rho_{x}[7] V_{x}[7],
                \end{eqnarray}
	        %
	        where
		%
		\begin{eqnarray}
		  c_{x}[j] & = &
		    \left\{
                      \begin{array}{cl}
		        0 &
			  \left\{
			    \begin{array}{l}
			      \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] <\
			        {\rm split\ threshold} \\
			      \hspace*{0.25in} {\rm (for\ all}\ j),
			    \end{array}
			  \right.
			  \\
			\frctrlx &
			  \left\{
			    \begin{array}{l}
			      \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] \ge\
			        {\rm split\ threshold\ and} \\
			      \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] < \\
			      \hspace*{0.25in} \phas[j-1] + \Delta_{x}'[j-1] +
			        \Delta_{y}'[j-1] \\
			      \hspace*{0.25in} {\rm (for}\ j = 1, 2, 4, 5, 7,
			        8), \\
			    \end{array}
			  \right.
			  \\
			1 &
			  \left\{
			    \begin{array}{l}
			      \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] \ge\
			        {\rm split\ threshold} \\
			      \hspace*{0.25in} {\rm (for}\ j = 0, 3, 6) \\
			      \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] \ge\
			        {\rm split\ threshold\ and} \\
			      \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] \ge \\
			      \hspace*{0.25in} \phas[j-1] + \Delta_{x}'[j-1] +
			        \Delta_{y}'[j-1] \\
			      \hspace*{0.25in} {\rm (for}\ j = 1, 2, 4, 5, 7,
			        8), \\
			    \end{array}
			  \right.
			  \\
                      \end{array}
	            \right.
		    \nonumber
		    \\
		  c_{x}'[j] & = &
		    \left\{
                      \begin{array}{cl}
		        0 &
			  \left\{
			    \begin{array}{l}
			      \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j]
			        <\ {\rm split\ threshold\ or} \\
		              \phas[j+1] + \Delta_{x}'[j+1] + \Delta_{y}'[j+1]
			        <\ {\rm split\ threshold\ or} \\
			      j \rightarrow \chipx = 1, 256, 513,\ {\rm or}\
			        768 \\
			      \hspace*{0.25in} ({\rm for}\ j = 0, 1, 3, 4,
			        6, 7), \\
			    \end{array}
			  \right.
			  \\
			\frctrlx &
			  \left\{
			    \begin{array}{l}
			      \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] > \\
			      \hspace*{0.25in} \phas[j+1] + \Delta_{x}'[j+1] +
			        \Delta_{y}'[j+1]\ {\rm and} \\
			      \phas[j+1] + \Delta_{x}'[j+1] + \Delta_{y}'[j+1]
			        \ge\ {\rm split\ threshold} \\
			      \hspace*{0.25in} {\rm (for}\ j = 0, 1, 3, 4, 6,
			        7), \\
			    \end{array}
			  \right.
			  \\
			1 &
			  \left\{
			    \begin{array}{l}
			      \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] \le \\
			      \hspace*{0.25in} \phas[j+1] + \Delta_{x}'[j+1] +
			        \Delta_{y}'[j+1]\ {\rm and} \\
			      \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] \ge\
			        {\rm split\ threshold} \\
			      \hspace*{0.25in} {\rm (for}\ j = 0, 1, 3, 4,
			        6, 7), \\
			    \end{array}
			  \right.
			  \\
                      \end{array}
	            \right.
		    \nonumber
		    \\
	          s_{x} & = & 1 + \tctix \left( T - {\fptemp}{\tt{0}}
		    \right), \label{eqnsx} \\
		  & &
		    \left\{
                      \begin{array}{l}
		        s_{x}\ {\rm is\ a\ temperature\ dependent\
			  scaling\ factor}, \\
		        {\rm \tctix\ is\ the\ \ccdid\ dependent\
			  value\ in\ the\ column\ \tctix\ of\ the} \\
			{\hspace*{0.25in} \ctifile,} \\
			{\rm \fptemp{\tt{0}}\ is\ the\ name\ of\ a\ keyword\
			  in\ the\ \ctifile,}
                      \end{array}
	            \right.
		    \nonumber
		    \\
                  T & = & \left( \frac{t' - t'_{k}}{t'_{k+1} - t'_{k}} \right)
                    \left( \fptemp_{k+1} - \fptemp_{k} \right) +
		    \fptemp_{k}, \label{eqnt} \\
		  & &
		    \left\{
                      \begin{array}{l}
		        T\ {\rm is\ the\ time\ dependent\ focal\ plane\
			  temperature}, \\
                      \end{array}
	            \right.
		    \nonumber
		    \\
		  t' & = &
		    t + \timedel_{\rm in}
		    \left( \timepixr_{\rm evt} - 0.5 \right), \label{eqntp} \\
		  & &
		    \left\{
                      \begin{array}{l}
		        t\ {\rm is\ the}\ \tim\ {\rm of\ the\ event}, \\
		        \timepixr_{\rm evt}\ {\rm is\ a\ keyword\ in\ the}\
  		          \infile,
                      \end{array}
	            \right.
		    \nonumber
		    \\
		  t'_{k} & = &
		    \tim_{k} + \timedel_{\rm mtl}
		    \left( \timepixr_{\rm mtl} - 0.5 \right), \label{eqntk} \\
		  & &
		    \left\{
                      \begin{array}{l}
		        \tim_{k}\ {\rm is\ the}\ k^{\rm th}\ {\rm element\
			  of\ the\ column\ \tim\ in\ the\ \mtlfile}, \\
			t'_{k} \le t', \\
			{\rm If}\ t' < t'_{k}\ {\rm for}\ k=0,\ {\rm then}\
			  k=0, \\
		        \fptemp_{k}\ {\rm is\ the}\ k^{\rm th}\ {\rm
			  element\ of\ the\ column\ \fptemp\ in\ the\
			  \mtlfile}, \\
		        \timedel_{\rm mtl}\ {\rm is\ a\ keyword\ in\ the}\
			  \mtlfile, \\
		        \timepixr_{\rm mtl}\ {\rm is\ a\ keyword\ in\ the}\
			  \mtlfile,
                      \end{array}
	            \right.
		    \nonumber
		    \\
                  t'_{k+1} & = &
                    \tim_{k+1} + \timedel_{\rm mtl}
		    \left( \timepixr_{\rm mtl} - 0.5 \right), \label{eqntk1} \\
		  & &
		    \left\{
                      \begin{array}{l}
		        \tim_{k+1}\ {\rm is\ the}\ (k+1)^{\rm th}\ {\rm
			  element\ of\ the\ column\ \tim\ in\ the\
			  \mtlfile}, \\
			t'_{k+1} > t', \\
			{\rm If}\ t' > t'_{k}\ {\rm for}\ k=n,\ {\rm where}\
			  n\ {\rm is\ the\ last\ element,\ then}\ k=n, \\
		        \fptemp_{k+1}\ {\rm is\ the}\ (k+1)^{\rm th}\ {\rm
			  element\ of\ the\ column\ \fptemp\ in\ the} \\
			{\hspace*{0.25in} \mtlfile,}
                      \end{array}
	            \right.
		    \nonumber
		    \\
                  \rho_{x}[j] & = & {\rm serial\ trap\ density,}
		    \label{eqnrhox} \\
		  & &
		    \left\{
                      \begin{array}{l}
		        \rho_{x}[j]\ {\rm depends\ upon\ the\ \ccdid\ and\
			  upon\ the\ \chipx\ and\ {\rm nint}(\chipyadj)} \\
			  % only use \chipyadj for CC mode
			{\hspace*{0.25in} \rm coordinates\ associated\ with\
			  element}\ j\ {\rm of}\ \phasadj[j]\ {\rm (see\
			  Fig.~\ref{fig01})},
                      \end{array}
	            \right.
		    \nonumber
		    \\
		  V_{x}[j] & = &
		    \left(
		      \frac{\phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] -
		        \pha_{l}}{\pha_{l+1} - \pha_{l}}
		    \right) \left(
		      \volumex_{l+1} - \volumex_{l}
		    \right) +
		    \nonumber
		    \\
		  & & \hspace*{0.25in} \volumex_{l}, \label{eqnvx}
		  \\
		  & &
		    \left\{
                      \begin{array}{l}
		        \pha_{l}\ {\rm is\ the}\ l^{\rm th}\ {\rm element\
			  of\ the\ column\ \pha\ in\ the\ \ctifile}, \\
			\pha_{l}\ {\rm (and}\ \pha_{l+1})\ {\rm are\ \ccdid\
			  depdendent}, \\
			\pha_{l} \le \phas[j] + \Delta_{x}'[j] +
			  \Delta_{y}'[j], \\
			{\rm If}\ \pha_l > \phas[j] + \Delta_{x}'[j] +
			  \Delta_{y}'[j]\ {\rm for}\ l=0,\ {\rm then}\
			  l=0, \\
		        \pha_{l+1}\ {\rm is\ the}\ (l+1)^{\rm th}\ {\rm
			  element\ of\ the\ column\ \pha\ in\ the\
			  \ctifile}, \\
			\pha_{l+1} > \phas[j] + \Delta_{x}'[j] +
			  \Delta_{y}'[j], \\
			{\rm If}\ \pha_{l+1} \le \phas[j] + \Delta_{x}'[j] +
			  \Delta_{y}'[j]\ {\rm for}\ l=n,\ {\rm where}\ n\
			  {\rm is\ the\ last} \\
			{\hspace*{0.25in} \rm element,\ then}\ l=n, \\
			\volumex_{l}\ {\rm is\ the}\ l^{\rm th}\ {\rm
			  element\ of\ the\ column\ \volumex\ in\ the\
			  \ctifile,} \\
			\volumex_{l},\ {\rm which\ is\ \ccdid\ depdendent,\
			  is\ associated\ with}\ \pha_{l}, \\
			\volumex_{l+1}\ {\rm is\ the}\ (l+1)^{\rm th}\ {\rm
			  element\ of\ the\ column\ \volumex\ in\ the} \\
			\hspace*{0.25in} \ctifile,\ {\rm and} \\
			\volumex_{l+1},\ {\rm which\ is\ \ccdid\ depdendent,\
			  is\ associated\ with}\ \pha_{l+1}
                      \end{array}
	            \right.
		    \nonumber
		\end{eqnarray}
		%
	      \item
	        If there is a serial CTI trap-density map in the \ctifile\
		for \ccdid\ and $\nodeid = 1$ or 3, then the values of
		$\Delta_{x}$ are given by
	        %
                \begin{eqnarray}
		  \Delta_{x}[0] & = & c_{x}[0] s_{x} \rho_{x}[0] V_{x}[0] -
		    c'_{x}[1] s_{x} \rho_{x}[1] V_{x}[1], \\
	          \Delta_{x}[1] & = & c_{x}[1] s_{x} \rho_{x}[1] V_{x}[1] -
		    c'_{x}[2] s_{x} \rho_{x}[2] V_{x}[2], \\
	          \Delta_{x}[2] & = & c_{x}[2] s_{x} \rho_{x}[2] V_{x}[2], \\
	          \Delta_{x}[3] & = & c_{x}[3] s_{x} \rho_{x}[3] V_{x}[3] -
		    c'_{x}[4] s_{x} \rho_{x}[4] V_{x}[4], \\
	          \Delta_{x}[4] & = & c_{x}[4] s_{x} \rho_{x}[4] V_{x}[4] -
		    c'_{x}[5] s_{x} \rho_{x}[5] V_{x}[5], \\
	          \Delta_{x}[5] & = & c_{x}[5] s_{x} \rho_{x}[5] V_{x}[5], \\
	          \Delta_{x}[6] & = & c_{x}[6] s_{x} \rho_{x}[6] V_{x}[6] -
		    c'_{x}[7] s_{x} \rho_{x}[7] V_{x}[7], \\
	          \Delta_{x}[7] & = & c_{x}[7] s_{x} \rho_{x}[7] V_{x}[7] -
		    c'_{x}[8] s_{x} \rho_{x}[8] V_{x}[8],\ {\rm and} \\
	          \Delta_{x}[8] & = & c_{x}[8] s_{x} \rho_{x}[8] V_{x}[8],
                \end{eqnarray}
	        %
	        where
		%
		\begin{eqnarray}
		  c_{x}[j] & = &
		    \left\{
                      \begin{array}{cl}
		        0 &
			  \left\{
			    \begin{array}{l}
			      \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] <\
			        {\rm split\ threshold} \\
			      \hspace*{0.25in} {\rm (for\ all}\ j),
			    \end{array}
			  \right.
			  \\
			\frctrlx &
			  \left\{
			    \begin{array}{l}
			      \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] \ge\
			        {\rm split\ threshold\ and} \\
			      \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] < \\
			      \hspace*{0.25in} \phas[j+1] + \Delta_{x}'[j+1] +
			        \Delta_{y}'[j+1] \\
			      \hspace*{0.25in} {\rm (for}\ j = 0, 1, 3, 4,
			        6, 7), \\
			    \end{array}
			  \right.
			  \\
			1 &
			  \left\{
			    \begin{array}{l}
			      \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] \ge\
			        {\rm split\ threshold} \\
			      \hspace*{0.25in} {\rm (for}\ j = 2, 5, 8) \\
			      \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] \ge\
			        {\rm split\ threshold\ and} \\
			      \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] \ge \\
			      \hspace*{0.25in} \phas[j+1] + \Delta_{x}'[j+1] +
			        \Delta_{y}'[j+1] \\
			      \hspace*{0.25in} {\rm (for}\ j = 0, 1, 3, 4, 6,
			        7), \\
			    \end{array}
			  \right.
			  \\
                      \end{array}
	            \right.
		    \nonumber
		    \\
		  c_{x}'[j] & = &
		    \left\{
                      \begin{array}{cl}
		        0 &
			  \left\{
			    \begin{array}{l}
			      \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j]
			        <\ {\rm split\ threshold\ or} \\
		              \phas[j-1] + \Delta_{x}'[j-1] + \Delta_{y}'[j-1]
			        <\ {\rm split\ threshold\ or} \\
			      j \rightarrow \chipx = 257, 512, 769,\ {\rm or}\
			        1024 \\
			      \hspace*{0.25in} ({\rm for}\ j = 1, 2, 4, 5,
			        7, 8), \\
			    \end{array}
			  \right.
			  \\
			\frctrlx &
			  \left\{
			    \begin{array}{l}
			      \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] > \\
			      \hspace*{0.25in} \phas[j-1] + \Delta_{x}'[j-1] +
			        \Delta_{y}'[j-1]\ {\rm and} \\
			      \phas[j-1] + \Delta_{x}'[j-1] + \Delta_{y}'[j-1]
			        \ge\ {\rm split\ threshold} \\
			      \hspace*{0.25in} {\rm (for}\ j = 1, 2, 4, 5, 7,
			        8), \\
			    \end{array}
			  \right.
			  \\
			1 &
			  \left\{
			    \begin{array}{l}
			      \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] \le \\
			      \hspace*{0.25in} \phas[j-1] + \Delta_{x}'[j-1] +
			        \Delta_{y}'[j-1]\ {\rm and} \\
			      \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] \ge\
			        {\rm split\ threshold} \\
			      \hspace*{0.25in} {\rm (for}\ j = 1, 2, 4, 5,
			        7, 8), \\
			    \end{array}
			  \right.
			  \\
                      \end{array}
	            \right.
		    \nonumber
		\end{eqnarray}
	    \end{enumerate}
	    %
	    and $s_{x}$, $T$, $t'$, $t'_{k}$, $t'_{k+1}$, $\rho_{x}[j]$, and
	    $V_{x}[j]$ are given by equations.~\ref{eqnsx}, \ref{eqnt},
	    \ref{eqntp}, \ref{eqntk}, \ref{eqntk1}, \ref{eqnrhox}, and
	    \ref{eqnvx}, respectively.
	  \item
	    If there is a parallel CTI trap-density map in the \ctifile\ for
	    \ccdid, then the values of $\Delta_{y}$ are given by
	    %
            \begin{eqnarray}
	      \Delta_{y}[0] & = & c_{y}[0] s_{y} \rho_{y}[0] V_{y}[0], \\
	      \Delta_{y}[1] & = & c_{y}[1] s_{y} \rho_{y}[1] V_{y}[1], \\
	      \Delta_{y}[2] & = & c_{y}[2] s_{y} \rho_{y}[2] V_{y}[2], \\
	      \Delta_{y}[3] & = & c_{y}[3] s_{y} \rho_{y}[3] V_{y}[3] -
	        c'_{y}[0] s_{y} \rho_{y}[0] V_{y}[0], \\
	      \Delta_{y}[4] & = & c_{y}[4] s_{y} \rho_{y}[4] V_{y}[4] -
	        c'_{y}[1] s_{y} \rho_{y}[1] V_{y}[1], \\
	      \Delta_{y}[5] & = & c_{y}[5] s_{y} \rho_{y}[5] V_{y}[5] -
	        c'_{y}[2] s_{y} \rho_{y}[2] V_{y}[2], \\
	      \Delta_{y}[6] & = & c_{y}[6] s_{y} \rho_{y}[6] V_{y}[6] -
	        c'_{y}[3] s_{y} \rho_{y}[3] V_{y}[3], \\
	      \Delta_{y}[7] & = & c_{y}[7] s_{y} \rho_{y}[7] V_{y}[7] -
	        c'_{y}[4] s_{y} \rho_{y}[4] V_{y}[4],\ {\rm and} \\
	      \Delta_{y}[8] & = & c_{y}[8] s_{y} \rho_{y}[8] V_{y}[8] -
	        c'_{y}[5] s_{y} \rho_{y}[5] V_{y}[5],
            \end{eqnarray}
	    %
	    where
	    %
	    \begin{eqnarray}
	      c_{y}[j] & = &
		\left\{
                  \begin{array}{cl}
		    0 &
		      \left\{
			\begin{array}{l}
			  \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] <\
			    {\rm split\ threshold} \\
			  \hspace*{0.25in} {\rm (for\ all}\ j),
			\end{array}
		      \right.
		      \\
		    \frctrly &
		      \left\{
			\begin{array}{l}
			  \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] \ge\
			    {\rm split\ threshold\ and} \\
			  \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] < \\
			  \hspace*{0.25in} \phas[j-3] + \Delta_{x}'[j-3] +
			    \Delta_{y}'[j-3] \\
			  \hspace*{0.25in} {\rm (for}\ j = 3, 4, 5, 6, 7, 8),
			    \\
			\end{array}
		      \right.
		      \\
		    1 &
		      \left\{
			\begin{array}{l}
			  \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] \ge\
			    {\rm split\ threshold} \\
			  \hspace*{0.25in} {\rm (for}\ j = 0, 1, 2) \\
			  \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] \ge\
			    {\rm split\ threshold\ and} \\
			  \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] \ge \\
			  \hspace*{0.25in} \phas[j-3] + \Delta_{x}'[j-3] +
			    \Delta_{y}'[j-3] \\
			  \hspace*{0.25in} {\rm (for}\ j = 3, 4, 5, 6, 7, 8),
			    \\
			\end{array}
		      \right.
		      \\
                  \end{array}
	        \right.
		\nonumber
		\\
	      c_{y}'[j] & = &
		\left\{
                  \begin{array}{cl}
		    0 &
		      \left\{
		        \begin{array}{l}
			  \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j]
			    <\ {\rm split\ threshold\ or} \\
		          \phas[j+3] + \Delta_{x}'[j+3] + \Delta_{y}'[j+3]
			    <\ {\rm split\ threshold\ or} \\
			  j \rightarrow \chipy = 1 {\rm or}\ 1024 \\
			  \hspace*{0.25in} ({\rm for}\ j = 1, 2, 3, 4, 5), \\
			\end{array}
		      \right.
		      \\
		    \frctrly &
		      \left\{
			\begin{array}{l}
			  \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] > \\
			  \hspace*{0.25in} \phas[j+3] + \Delta_{x}'[j+3] +
			    \Delta_{y}'[j+3]\ {\rm and} \\
			  \phas[j+3] + \Delta_{x}'[j+3] + \Delta_{y}'[j+3]
			    \ge\ {\rm split\ threshold} \\
			  \hspace*{0.25in} {\rm (for}\ j = 0, 1, 2, 3, 4, 5),
			    \\
			\end{array}
		      \right.
		      \\
		    1 &
		      \left\{
			\begin{array}{l}
			  \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] \le \\
			  \hspace*{0.25in} \phas[j+3] + \Delta_{x}'[j+3] +
			    \Delta_{y}'[j+3]\ {\rm and} \\
			  \phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] \ge\
			    {\rm split\ threshold} \\
			  \hspace*{0.25in} {\rm (for}\ j = 0, 1, 2, 3, 4, 5),
			    \\
			\end{array}
		      \right.
		      \\
                  \end{array}
	        \right.
		\nonumber
		\\
	      s_{y} & = & 1 + \tctiy \left( T - {\fptemp}{\tt{0}}
		\right), \\
	      & &
		\left\{
                  \begin{array}{l}
		    s_{y}\ {\rm is\ a\ temperature\ dependent\
		      scaling\ factor}, \\
		    {\rm \tctiy\ is\ the\ \ccdid\ dependent\
		      value\ in\ the\ column\ \tctiy\ of\ the} \\
		    {\hspace*{0.25in} \ctifile,} \\
		    {\rm \fptemp{\tt{0}}\ is\ the\ name\ of\ a\ keyword\
		      in\ the\ \ctifile,}
                  \end{array}
	        \right.
		\nonumber
		\\
              \rho_{y}[j] & = & {\rm parallel\ trap\ density,} \\
	      & &
		\left\{
                  \begin{array}{l}
		    \rho_{y}[j]\ {\rm depends\ upon\ the\ \ccdid\ and\
		      upon\ the\ \chipx\ and\ {\rm nint}(\chipyadj)} \\
		      % only use \chipyadj for CC mode
		    {\hspace*{0.25in} \rm coordinates\ associated\ with\
		      element}\ j\ {\rm of}\ \phasadj[j]\ {\rm (see\
		      Fig.~\ref{fig01})},
                  \end{array}
	        \right.
		\nonumber
		\\
	      V_{y}[j] & = &
		\left(
		  \frac{\phas[j] + \Delta_{x}'[j] + \Delta_{y}'[j] -
		    \pha_{l}}{\pha_{l+1} - \pha_{l}}
		\right) \left(
		  \volumey_{l+1} - \volumey_{l}
		\right) +
		\nonumber
		\\
	      & & \hspace*{0.25in} \volumey_{l},
	      \\
	      & &
		\left\{
                  \begin{array}{l}
		    \pha_{l}\ {\rm is\ the}\ l^{\rm th}\ {\rm element\
		      of\ the\ column\ \pha\ in\ the\ \ctifile}, \\
		    \pha_{l}\ {\rm (and}\ \pha_{l+1})\ {\rm are\ \ccdid\
		      depdendent}, \\
		    \pha_{l} \le \phas[j] + \Delta_{x}'[j] +
		      \Delta_{y}'[j], \\
		    {\rm If}\ \pha_l > \phas[j] + \Delta_{x}'[j] +
		      \Delta_{y}'[j]\ {\rm for}\ l=0,\ {\rm then}\
		      l=0, \\
		    \pha_{l+1}\ {\rm is\ the}\ (l+1)^{\rm th}\ {\rm
		      element\ of\ the\ column\ \pha\ in\ the\
		      \ctifile}, \\
		    \pha_{l+1} > \phas[j] + \Delta_{x}'[j] +
		      \Delta_{y}'[j], \\
		    {\rm If}\ \pha_{l+1} \le \phas[j] + \Delta_{x}'[j] +
		      \Delta_{y}'[j]\ {\rm for}\ l=n,\ {\rm where}\ n\
		      {\rm is\ the\ last} \\
		    {\hspace*{0.25in} \rm element,\ then}\ l=n, \\
		    \volumey_{l}\ {\rm is\ the}\ l^{\rm th}\ {\rm
		      element\ of\ the\ column\ \volumey\ in\ the\
		      \ctifile,} \\
		    \volumey_{l},\ {\rm which\ is\ \ccdid\ depdendent,\
		      is\ associated\ with}\ \pha_{l}, \\
		    \volumey_{l+1}\ {\rm is\ the}\ (l+1)^{\rm th}\ {\rm
		      element\ of\ the\ column\ \volumey\ in\ the} \\
		    {\hspace*{0.25in} \ctifile,} \\
		    \volumey_{l+1},\ {\rm which\ is\ \ccdid\ depdendent,\
		      is\ associated\ with}\ \pha_{l+1},
                  \end{array}
	        \right.
		\nonumber
	    \end{eqnarray}
	    %
	    and $T$, $t'$, $t'_{k}$, and $t'_{k+1}$, are given by
	    equations.~\ref{eqnt}, \ref{eqntp}, \ref{eqntk}, and \ref{eqntk1},
	    respectively.
	    %
	  \item
	    The CTI-adjusted pulse heights
	    %
	    \begin{equation}
	      \phasadj[j]
	        =
		\phas[j] +
		\Delta_{x}[j] +
		\Delta_{y}[j]
	    \end{equation}
	    %
	    for all $j$.
	    %
	  \item
	    \label{phasadjcheck}
	    %
	    \begin{enumerate}
	      \item
	      %
	      If
	      \begin{eqnarray}
	        | \phasadj'[j] - \phasadj[j] | & < & \cticonverge\ {\rm (for\
		  all}\ j)\ {\rm and} \\
	        n & \le & \maxctiiter,
	      \end{eqnarray}
	      %
	      then the computation of \phasadj\ is complete for the event.
	      %
	      \item
	      %
	      If
	      %
	      \begin{eqnarray}
	        | \phasadj'[j] - \phasadj[j] | & \ge & \cticonverge\ {\rm (for\
		  one\ or\ more}\ j)\ {\rm and} \\
	        n & < & \maxctiiter,
	      \end{eqnarray}
	      %
	      then $n = n + 1$ and steps
	      1.5.\ref{tempvars}--1.5.\ref{phasadjcheck} are repeated.
	      %
	      \item
	      %
	      If
	      %
	      \begin{eqnarray}
	        | \phasadj'[j] - \phasadj[j] | & \ge & \cticonverge\ {\rm (for\
		  one\ or\ more}\ j)\ {\rm and} \\
	        n & \ge & \maxctiiter,
	      \end{eqnarray}
	      %
	      then no additional iterations are performed, the values of
	      $\phasadj[j]$ from the most recent iteration are used as are,
	      and $\status[k] = 1$ for bit $k = 20$ to indicate that the CTI
	      adjustment did not converge.
	    \end{enumerate}
	\end{enumerate}
    \end{enumerate}

  \item
    {\fltgrade}:
    %
    \begin{enumerate}

      \item
        If
	%
	\begin{eqnarray}
	  \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm and} \\
	  \applycti & = & {\rm yes},
	\end{eqnarray}
	%
	then
	%
        \begin{eqnarray}
	  \fltgrade & = &
	    c_{\rm f}[0] +
	    2 c_{\rm f}[1] +
	    4 c_{\rm f}[2] +
	    8 c_{\rm f}[3] +
	    16 c_{\rm f}[5] +
	    32 c_{\rm f}[6] +
	    64 c_{\rm f}[7] +
	    128 c_{\rm f}[8],
        \end{eqnarray}
	%
	where
	%
	\begin{equation}
	  c_{\rm f}[j] =
            \left\{
              \begin{array}{ll}
	        0 & {\rm if}\ \phasadj[j] < {\rm split\ threshold} \\
		1 & {\rm otherwise},
              \end{array}
	    \right.
	\end{equation}
	%
	and the elements $j = 0$--3 and 5--8 of \phasadj\ are depicted in
	Figure~\ref{fig01}.
	%
        \begin{figure}[t]
          \hfil
          \hbox{\epsfig{file=fig01}}
          \hfil
          %
          \caption{The relative \chipx\ and \chipy\ coordinates of the nine
	    elements $j = 0$--8 of a 3~pixel $\times$ 3~pixel event island
	    $\phas[j]$ or $\phasadj[j]$.
          %
          \label{fig01}}
        \end{figure}

      \item
        If
	%
	\begin{eqnarray}
	  \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm and} \\
	  \applycti & = & {\rm no},
	\end{eqnarray}
	%
	then
	%
        \begin{eqnarray}
	  \fltgrade & = &
	    c_{\rm f}[0] +
	    2 c_{\rm f}[1] +
	    4 c_{\rm f}[2] +
	    8 c_{\rm f}[3] +
	    16 c_{\rm f}[5] +
	    32 c_{\rm f}[6] +
	    64 c_{\rm f}[7] +
	    128 c_{\rm f}[8],
        \end{eqnarray}
	%
	where
	%
	\begin{equation}
	  c_{\rm f}[j] =
            \left\{
              \begin{array}{ll}
	        0 & {\rm if}\ \phas[j] < {\rm split\ threshold} \\
	        0 & {\rm if}\ \phas[j] > 4095 \\
	        0 & {\rm if}\ \phas[j] > \phas[4]\ {\rm for}\ j = 0-3) \\
	        0 & {\rm if}\ \phas[j] \ge \phas[4]\ {\rm for}\ j = 5-8) \\
		1 & {\rm otherwise}.
              \end{array}
	    \right.
	\end{equation}

      \item
        If
	%
	\begin{eqnarray}
	  \datamode_{\rm in} & = & {\rm CC33\_GRADED},
	\end{eqnarray}
	%
	then the \fltgrade\ of an event is equal to the value of \fltgrade\
	for the event in the \infile.

    \end{enumerate}

  \item
    {\grade}:
    %
    \begin{enumerate}
      \item
        If the \gradefile\ is specified, then the \grade\ of an event is
	determined from the \fltgrade\ of the event as follows.
	%
	\begin{enumerate}
	  \item
            The appropriate HDU of the \gradefile\ is identified.  This HDU
	    is the one where the header keyword \cbd\ includes the
	    $\datamode_{\rm in}$ of HDU~1 of the \infile.
          \item
            The row $i$ of the appropriate HDU of the \gradefile\ is
	    identified. This row is the one where
	    %
	    \begin{equation}
	      {\fltgrade}_{{\rm grade},i} = \fltgrade,
	    \end{equation}
	    %
	    where ${\fltgrade}_{\rm grade}$ is a column in the \gradefile.
          \item
            The \grade\ of the event is given by
	    %
	    \begin{equation}
	      \grade = {\grade}_{{\rm grade},i},
	    \end{equation}
	    %
	    where ${\grade}_{\rm grade}$ is a column in the \gradefile.
	\end{enumerate}
    \end{enumerate}

  \item
    {\pharo}:
    %
    \begin{enumerate}

      \item
        {Not GRADED}: \\
	%
        If
        %
        \begin{eqnarray}
          \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
          \datamode_{\rm in} & = & {\rm FAINT}\ {\rm or} \\
          \datamode_{\rm in} & = & {\rm FAINT\_BIAS}\ {\rm or} \\
          \datamode_{\rm in} & = & {\rm VFAINT},
        \end{eqnarray}
        %
	then
	%
	\begin{enumerate}

	  \item
	    {Compute, if possible}: \\
	    %
	    If
	    %
            \begin{eqnarray}
	      \doevtgrade & = & {\rm yes},
            \end{eqnarray}
            %
	    then
	    %
            \begin{equation}
	      \pharo =
	        \sum_{j=0}^{8}
	          \beta[j] p[j],
            \end{equation}
            %
	    where
	    \begin{enumerate}

	      \item
	        %
	        \begin{equation}
	          p[j] = \phas[j],
	        \end{equation}
		%
		the pulse height that does not have cti- and time-dependent
		gain adjustments.

              \item
	        The elements $j = 0$--8 of \phas\ are depicted in
	        Figure~\ref{fig01}.

	      \item
	        %
                \begin{eqnarray}
	          \beta[j] = 0 &
	            {\rm if} &
		    p[j] < {\rm split\ threshold}.
                \end{eqnarray}

	      \item
	        %
                \begin{equation}
	          \beta[j] = 0\
	            {\rm if}\
                    \left\{
                      \begin{array}{l}
	                p[j] > p[4]\ ({\rm for}\ j=0{\rm{-}}3) \\
		        p[j] \ge p[4]\ ({\rm for}\ j=5{\rm{-}}8)
                      \end{array}
	            \right.
                \end{equation}

              \item
                If $\corners\ = -1$, then
	        %
	        \begin{equation}
	          \beta[0] =
	          \beta[2] =
	          \beta[6] =
	          \beta[8] =
	          0.
	        \end{equation}

	      \item
	        If $\corners\ = 0$, then there are no additional constraints
		on $\beta[0]$, $\beta[2]$, $\beta[6]$, and $\beta[8]$.

              \item
                If $\corners\ = 1$, then
                %
	        \begin{eqnarray}
	          \beta[0] = 0 & {\rm if} &
	            \beta[1] = 0\ {\rm and}\ \beta[3] = 0. \\
	          \beta[2] = 0 & {\rm if} &
	            \beta[1] = 0\ {\rm and}\ \beta[5] = 0. \\
	          \beta[6] = 0 & {\rm if} &
	            \beta[3] = 0\ {\rm and}\ \beta[7] = 0. \\
	          \beta[8] = 0 & {\rm if} &
	            \beta[5] = 0\ {\rm and}\ \beta[7] = 0.
	        \end{eqnarray}

              \item
                If $\corners\ = 2$, then
                %
	        \begin{eqnarray}
	          \beta[0] = 0 & {\rm if} &
	            \beta[1] = 0\ {\rm or}\ \beta[3] = 0\ {\rm or}\
		      \grade \ne 6. \\
	          \beta[2] = 0 & {\rm if} &
	            \beta[1] = 0\ {\rm or}\ \beta[5] = 0\ {\rm or}\
		      \grade \ne 6. \\
	          \beta[6] = 0 & {\rm if} &
	            \beta[3] = 0\ {\rm or}\ \beta[7] = 0\ {\rm or}\
		      \grade \ne 6. \\
	          \beta[8] = 0 & {\rm if} &
	            \beta[5] = 0\ {\rm or}\ \beta[7] = 0\ {\rm or}\
		      \grade \ne 6.
	        \end{eqnarray}
	    \end{enumerate}

	  \item
	    {Otherwise copy}: \\
	    %
	    If
	    %
            \begin{eqnarray}
	      \doevtgrade & = & {\rm no}
            \end{eqnarray}
            %
	    and the \infile\ includes the column \pharo, then
	    %
	    \begin{eqnarray}
	      \pharo & = & \pharo_{\rm in}.
	    \end{eqnarray}

	  \item
	    {Error}: \\
	    %
	    If
	    %
            \begin{eqnarray}
	      \doevtgrade & = & {\rm no}
            \end{eqnarray}
            %
	    and the \infile\ does not include the column \pharo, then
	    %
	    \begin{eqnarray}
	      \pharo & = & {\rm NULL}.
	    \end{eqnarray}

	\end{enumerate}

      \item
        GRADED: \\
	%
        If
        %
        \begin{eqnarray}
          \datamode_{\rm in} & = & {\rm CC33\_GRADED}\ {\rm or} \\
          \datamode_{\rm in} & = & {\rm GRADED},
        \end{eqnarray}
        %
	then
	%
	\begin{enumerate}

	  \item
	    {Copy \pharo, if possible}: \\
	    %
	    If the \infile\ includes the column \pharo, then
	    %
	    \begin{eqnarray}
	      \pharo & = & \pharo_{\rm in}.
	    \end{eqnarray}

	  \item
	    {Otherwise copy \pha}: \\
	    %
	    If the \infile\ does not include the column \pharo\ and
	    %
	    \begin{eqnarray}
	      \tgaincor_{\rm in} & = & 0,
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{eqnarray}
	      \pharo & = & \pha_{\rm in}.
	    \end{eqnarray}

	  \item
	    {Error}: \\
	    %
	    If the \infile\ does not include the column \pharo\ and
	    %
	    \begin{eqnarray}
	      \tgaincor_{\rm in} & = & 1,
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{eqnarray}
	      \pharo & = & {\rm NULL}.
	    \end{eqnarray}

	\end{enumerate}

      \item
        {Validation}: \\
	%
        If \pharo\ is less than the split threshold, then
	%
	\begin{eqnarray}
	  \pharo & = & {\rm NULL}.
	\end{eqnarray}

    \end{enumerate}

    \item
    {\pha, including time-dependent gain}:
    %
    \begin{enumerate}
      \item
        If
        %
        \begin{equation}
	  \datamode_{\rm in} = {\rm CC33\_FAINT},
        \end{equation}
        %
	then
	%
        \begin{equation}
	  \pha =
	    \sum_{j=0}^{8}
	      \beta[j] p[j],
        \end{equation}
        %
	where
	\begin{enumerate}
	  \item
	    %
	    \begin{equation}
	      p[j] =
                \left\{
                  \begin{array}{ll}
	            \phasadj[j] &
		      {\rm if}\ \applycti = {\rm yes} \\
		    \phas[j] &
		      {\rm if}\ \applycti = {\rm no}
                  \end{array}
	        \right.
	    \end{equation}
	    %
          \item
	    The elements $j = 0$--8 of \phasadj\ (or \phas) are depicted in
	    Figure~\ref{fig01}.
	  \item
	    %
            \begin{eqnarray}
	      \beta[j] = 0 &
	        {\rm if} &
		p[j] < {\rm split\ threshold}.
            \end{eqnarray}
	    %
	  \item
	    If the CTI adjustment is not performed, then
	    %
            \begin{equation}
	      \beta[j] = 0\
	        {\rm if}\
                \left\{
                  \begin{array}{l}
	            p[j] > p[4]\ ({\rm for}\ j=0{\rm{-}}3) \\
		    p[j] \ge p[4]\ ({\rm for}\ j=5{\rm{-}}8)
                  \end{array}
	        \right.
            \end{equation}
	    %
          \item
            If $\corners\ = -1$, then
	    %
	    \begin{equation}
	      \beta[0] =
	      \beta[2] =
	      \beta[6] =
	      \beta[8] =
	      0.
	    \end{equation}
	    %
	  \item
	    If $\corners\ = 0$, then there are no additional constraints on
	    $\beta[0]$, $\beta[2]$, $\beta[6]$, and $\beta[8]$.
	    %
          \item
            If $\corners\ = 1$, then
            %
	    \begin{eqnarray}
	      \beta[0] = 0 & {\rm if} &
	        \beta[1] = 0\ {\rm and}\ \beta[3] = 0. \\
	      \beta[2] = 0 & {\rm if} &
	        \beta[1] = 0\ {\rm and}\ \beta[5] = 0. \\
	      \beta[6] = 0 & {\rm if} &
	        \beta[3] = 0\ {\rm and}\ \beta[7] = 0. \\
	      \beta[8] = 0 & {\rm if} &
	        \beta[5] = 0\ {\rm and}\ \beta[7] = 0.
	    \end{eqnarray}
	    %
          \item
            If $\corners\ = 2$, then
            %
	    \begin{eqnarray}
	      \beta[0] = 0 & {\rm if} &
	        \beta[1] = 0\ {\rm or}\ \beta[3] = 0\ {\rm or}\
		  \grade \ne 6. \\
	      \beta[2] = 0 & {\rm if} &
	        \beta[1] = 0\ {\rm or}\ \beta[5] = 0\ {\rm or}\
		  \grade \ne 6. \\
	      \beta[6] = 0 & {\rm if} &
	        \beta[3] = 0\ {\rm or}\ \beta[7] = 0\ {\rm or}\
		  \grade \ne 6. \\
	      \beta[8] = 0 & {\rm if} &
	        \beta[5] = 0\ {\rm or}\ \beta[7] = 0\ {\rm or}\
		  \grade \ne 6.
	    \end{eqnarray}
	\end{enumerate}

      \item
        If
        %
        \begin{equation}
	  \datamode_{\rm in} = {\rm CC33\_GRADED},
        \end{equation}
        %
	then the value of \pha\ for the event is read from the \infile.

      \item
        If
	%
        \begin{equation}
	  \applytgain = {\rm yes},
        \end{equation}
        %
	then
	%
	\begin{equation}
	  \pha =
	    \pha -
	    {\rm int}
	    \left[
	      \left(
	        \frac{ \tim - \epoch{\tt{1}} }{
	          \epoch{\tt{2}} - \epoch{\tt{1}} }
	      \right)
	      \left(
	        \delta_{2} - \delta_{1}
	      \right) +
	      \delta_{1} -
	      \epsilon
	    \right],
	\end{equation}
	%
	where
	%
	\begin{eqnarray}
          {\rm int} & = & {\rm the\ integer\ portion\ of\ (i.e.\ truncate\ or\
	    round\ down)}, \\
	  %
	  \tim & = & {\rm the\ time\ of\ the\ event}, \\
	  %
	  \epoch{\tt{1}} & = & {\rm a\ keyword\ in\ the\ \tgainfile}, \\
	  %
	  \epoch{\tt{2}} & = & {\rm a\ keyword\ in\ the\ \tgainfile}, \\
	  %
	  \delta_{1} & = &
	    \left(
	      \frac{ \pha - \pha_{m}[r] }{ \pha_{m+1}[r] - \pha_{m}[r] }
	    \right)
	    \left(
	      \deltpha{\tt{1}}_{m+1}[r] - \deltpha{\tt{1}}_{m}[r]
	    \right) + \\
	  & & \deltpha{\tt{1}}_{m}[r], \\
	  %
	  & & \left\{
                \begin{array}{l}
		  r\ {\rm is\ the\ row\ of\ the\ \tgainfile\ where} \\
		    \left\{
		      \begin{array}{l}
		        \ccdid[r] = \ccdid, \\
		        \chipxlo[r] \le \chipx, \\
		        \chipxhi[r] \ge \chipx, \\
		        \chipylo[r] \le {\rm nint} (\chipyadj),\ {\rm and} \\
			% \chipyadj only for CC mode
		        \chipyhi[r] \ge {\rm nint} (\chipyadj). \\
			% \chipyadj only for CC mode
		      \end{array}
		    \right. \\
		  m\ {\rm is\ the\ element\ of\ row}\ r\ {\rm where} \\
		    \left\{
		      \begin{array}{l}
		        \pha_{m}[r] \le \pha\ {\rm and} \\
		        \pha_{m+1}[r] > \pha. \\
			{\rm If\ \pha} < \pha_{m}[r]\ {\rm for}\ m = 0,\
			  {\rm then}\ m = 0. \\
			{\rm If\ \pha} \ge \pha_{m}[r]\ {\rm for}\ m = M\
			  {\rm and}\ M\ {\rm is\ the\ last\ element\ of}\
			  \pha[r], \\
			\hspace*{0.25in} {\rm then}\ m = M-1.
		      \end{array}
		    \right. \\
		  {\rm The\ \tgainfile\ includes\ a\ binary\ table\ with\
		    columns\ named} \\
		  \hspace*{0.25in} {\rm \ccdid, \chipxlo, \chipxhi,
		    \chipylo, \chipyhi, \pha,
		    \deltpha{\tt{1}},\ and} \\
		  \hspace*{0.25in} {\deltpha{\tt{2}}.}
                \end{array}
	      \right. \\
	  %
	  \delta_{2} & = &
	    \left(
	      \frac{ \pha - \pha_{m}[r] }{ \pha_{m+1}[r] - \pha_{m}[r] }
	    \right)
	    \left(
	      \deltpha{\tt{2}}_{m+1}[r] - \deltpha{\tt{2}}_{m}[r]
	    \right) + \\
	  & & \deltpha{\tt{2}}_{m}[r], \\
	  \epsilon & = & {\rm is\ a\ uniform\ random\ deviate\ in\ the\
	    range} \ [0,1), \\
          & & \left\{
                \begin{array}{l}
		  {\rm If}\ \randpha = {\rm no},\ {\rm then}\ \epsilon = 0.
                \end{array}
	      \right.
	\end{eqnarray}

      \item
        If
	%
	\begin{equation}
	  \pha \ge 32767,
	\end{equation}
	%
	then $\status[k] = 1$ for bit $k = 3$.

    \end{enumerate}

  \item
    {\cornpha}:
    %
    \begin{enumerate}
      \item
        If
	%
	\begin{equation}
	  \datamode_{\rm in} = {\rm CC33\_GRADED},
	\end{equation}
	%
	then the value of \cornpha\ is read from the \infile.
    \end{enumerate}

  \item
    {\energy}:
    %
    \begin{enumerate}
      \item
        If the parameter $\calculatepi = {\rm yes}$ and the parameter
	\gainfile\ is specified and $\pha > 0$, then
        %
        \begin{enumerate}
          \item
            The row $i$ in the \gainfile\ is identified such that
            %
	    \begin{eqnarray}
	      & \ccdid = {\ccdid}_{{\rm gain},i}, & \\
	      & {\chipxmin}_{{\rm gain},i} \le \chipx \le
	        {\chipxmax}_{{\rm gain},i}, & {\rm and} \\
	      & {\chipymin}_{{\rm gain},i} \le {\rm nint} (\chipyadj) \le
	        {\chipymax}_{{\rm gain},i}, &
	    \end{eqnarray}
	    %
	    where ${\ccdid}_{\rm gain}$, ${\chipxmin}_{\rm gain}$,
	    ${\chipxmax}_{\rm gain}$, ${\chipymin}_{\rm gain}$, and
	    ${\chipymax}_{\rm gain}$ are columns in the \gainfile.
          \item
            A uniform random deviate $\Delta p$ is computed over the
	    interval from $[-0.5,+0.5)$.
          \item
            The element $j$ of row $i$ of ${\pha}_{\rm gain}$ is identified
	    such that
	    %
	    \begin{equation}
	      {\pha}_{{\rm gain},i}[j] \le ( \pha + \Delta p ) <
	        {\pha}_{{\rm gain},i}[j+1],
	    \end{equation}
	    %
	    where ${\pha}_{\rm gain}$ is a vector column in the \gainfile.
	    If $\pha + \Delta p < {\pha}_{{\rm gain},i}[0]$, then $j = 0$.
	    If ${\pha}_{{\rm gain},i}[\npoints-2] \le \pha + \Delta p$, then
	    $j = \npoints-2$, where \npoints\ is a column in the \gainfile.
          \item
	    The \energy\ of an event is computed from the \pha\ of the event:
	    %
	    \begin{eqnarray}
	      \energy & = &
	        \left(
	          \frac{\pha + \Delta p - {\pha}_{{\rm gain},i}[j]}{
		    {\pha}_{{\rm gain},i}[j+1] - {\pha}_{{\rm gain},i}[j]}
		\right)
		\left( {\energy}_{{\rm gain},i}[j+1] -
		  {\energy}_{{\rm gain},i}[j] \right) + \nonumber \\
	      & & {\energy}_{{\rm gain},i}[j],
	    \end{eqnarray}
	    %
	    where ${\energy}_{\rm gain}$ is a vector column in the \gainfile.
          \item
	    If $\energy < 0$, then $\energy = 0$.
        \end{enumerate}
      \item
        If the parameter $\calculatepi = {\rm yes}$ and the parameter
	\gainfile\ is specified and $\pha \le 0$, then $\energy = 0$.
      \item
        If the parameter $\calculatepi = {\rm no}$ or if the parameter
	\gainfile\ is not specified, then
	%
	\begin{enumerate}
	  \item
	    If the \infile\ includes the \energy\ of an event, then the
	    \energy\ of the event is equal to the \energy\ in the \infile.
	  \item
	    If the \infile\ does not include the \energy\ of an event, then
	    $\energy = 0$.
	\end{enumerate}
    \end{enumerate}

  \item
    {\pinv}:
    %
    \begin{enumerate}

      \item
        If
	%
	\begin{equation}
	  \calculatepi = {\rm yes},
	\end{equation}
	%
	then
	%
	\begin{enumerate}

	  \item
	    %
            \begin{equation}
              \pinv = {\rm int} \left( \frac{\energy}{\pibinwidth} \right) +
	        1,
	      \label{eqnpi}
            \end{equation}
	    %
	    where ``int'' indicates the integer portion of what is in
	    parentheses (i.e.\ the value is truncated or rounded down).

	  \item
	    If
	    %
            \begin{equation}
	      \pinv < 1,
            \end{equation}
	    %
	    then $\pinv = 1.$

	  \item
            If
	    %
            \begin{equation}
	      \pinv > \pinumbins,
            \end{equation}
	    %
	    then $\pinv = \pinumbins.$

	\end{enumerate}

      \item
        If
	%
	\begin{equation}
	  \calculatepi = {\rm no}
	\end{equation}
	%
	and the \infile\ includes the value of \pinv\ for an event, then the
	value of \pinv\ is read from the \infile.

    \end{enumerate}

  \item
    {\pixadj}:
    %
    \begin{enumerate}

      \item
        {centroid}:
	%
	\begin{enumerate}

	  \item
            If
	    %
	    \begin{equation}
	      \pixadj = {\rm centroid}
	    \end{equation}
	    %
	    and
	    %
	    \begin{eqnarray}
              \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm FAINT\_BIAS}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm VFAINT},
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{eqnarray}
	      \chipxadj & = & \chipxadj - w'[0] + w'[2] - w'[3] + w'[5] -
	        w'[6] + w'[8]\ {\rm and} \\
	      \chipyadj & = & \chipyadj - w'[0] - w'[1] - w'[2] + w'[6] +
	        w'[7] + w'[8],
	    \end{eqnarray}
	    %
	    where
	    %
	    \begin{equation}
	      w'[j] = \frac{ w[j] }{ \sum_{j=0}^{8} w[j] },
	    \end{equation}
	    %
	    \begin{equation}
	      w[j] =
                \left\{
                  \begin{array}{ll}
	            p[j] & {\rm if\ the\ pixel\ is\ valid} \\
		    0 & {\rm if\ the\ pixel\ is\ invalid,} \\
                  \end{array}
	        \right.
	    \end{equation}
	    %
	    \begin{equation}
	      p[j] =
                \left\{
                  \begin{array}{ll}
	            \phasadj[j] & {\rm if}\ \applycti = {\rm yes} \\
		    \phas[j] & {\rm if}\ \applycti = {\rm no}, \\
                  \end{array}
	        \right.
	    \end{equation}
	    %
	    and the pixel is invalid if
	    %
	    \begin{eqnarray}
	      \beta[j] & = & 0\ {\rm or} \\
	      \status[0] & = & 1\ {\rm or} \\
	      \status[1] & = & 1\ {\rm or} \\
	      \status[2] & = & 1\ {\rm or} \\
	      \status[3] & = & 1\ {\rm or} \\
	      \status[4] & = & 1\ {\rm or} \\
	      \status[11] & = & 1\ {\rm or} \\
	      \status[13] & = & 1\ {\rm or} \\
	      \status[14] & = & 1\ {\rm or} \\
	      \status[15] & = & 1\ {\rm or} \\
	      \status[16] & = & 1.
	    \end{eqnarray}

	  \item
            %
	    If
	    %
	    \begin{eqnarray}
              \pixadj & = & {\rm centroid\ and} \\
              \datamode_{\rm in} & = & {\rm CC33\_FAINT},
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{eqnarray}
	      \tim & = & \tim + ( w'[0] + w'[1] + w'[2] - w'[6] - w'[7] -
	        w'[8] ) \times \timedel_{\rm in}.
	    \end{eqnarray}
	    %
	    Note that it is possible for the centroid algorithm to yield
	    adjustments to \chipxadj\ and/or \chipyadj\ that are greater
	    than half a pixel.  However, the adjustment cannot equal or
	    exceed one pixel.

	\end{enumerate}

      \item
        {edser}:

	\begin{enumerate}

	  \item
            If
	    %
	    \begin{equation}
	      \pixadj = {\rm edser}
	    \end{equation}
	    %
	    and
	    %
	    \begin{eqnarray}
              \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm CC33\_GRADED}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm FAINT\_BIAS}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm GRADED}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm VFAINT},
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{enumerate}

	      \item
	        If
		%
		\begin{eqnarray}
		  \energy & \ne & {\rm NaN}\ {\rm and} \\
		  \energy & > & 0,
		\end{eqnarray}
		%
		then
		%
                \begin{eqnarray}
	          \chipxadj & = & \chipxadj +
	            \left( \frac{\energy - E[k]}{E[k+1] - E[k]} \right)
	            \left( \Delta X[k+1] - \Delta X[k] \right) +
	            \Delta X[k]
                \end{eqnarray}
		%
		and
		%
                \begin{eqnarray}
	          \chipyadj & = & \chipyadj +
	            \left( \frac{\energy - E[k]}{E[k+1] - E[k]} \right)
	            \left( \Delta Y[k+1] - \Delta Y[k] \right) +
	            \Delta Y[k],
                \end{eqnarray}
 	        %
	        where
	        %
	        $E[k]$ and $E[k+1]$, $\Delta X[k]$ and $\Delta X[k+1]$, and
		$\Delta Y[k]$ and $\Delta Y[k+1]$ are the $k^{\rm}$ and
		$(k+1)^{th}$ elements of the vector columns $\energy_{\rm
		subpix}$, $\chipxoffset_{\rm subpix}$, and
		$\chipyoffset_{\rm subpix}$, respectively.
	        %
	        These columns are in the HDU of the \subpixfile\ where the
		value of the keyword \ccdid\ is equal to the value of the
		\ccdid\ of the event.
	        %
	        The appropriate row of these columns is the one where
		$\fltgrade_{\rm subpix} = \fltgrade$.
	        %
	        The values of $k$ are the ones where
	        %
	        \begin{eqnarray}
	          \energy & \ge & E[k]\ {\rm and} \\
	          \energy & < & E[k+1].
	        \end{eqnarray}
	        %
	        Note that if
	        %
	        \begin{eqnarray}
	          \energy & \le & E[0],
	        \end{eqnarray}
	        %
	        then $k = 0$.  Similarly, if
	        %
	        \begin{eqnarray}
	          \energy & \ge & E[\npoints_{\rm subpix}-2],
	        \end{eqnarray}
	        %
	        then $k = \npoints_{\rm subpix} - 2$.

	      \item
	        If
		%
		\begin{eqnarray}
		  \energy & = & {\rm NaN}\ {\rm or} \\
		  \energy & \le & 0,
		\end{eqnarray}
		%
		then the \chipxadj\ and \chipyadj\ coordinates are not
		modified.

	    \end{enumerate}

	  \item
            If
	    %
	    \begin{equation}
	      \pixadj = {\rm edser}
	    \end{equation}
	    %
	    and
	    %
	    \begin{eqnarray}
              \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm CC33\_GRADED},
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{enumerate}

	      \item
	        If
		%
		\begin{eqnarray}
		  \energy & \ne & {\rm NaN}\ {\rm and} \\
		  \energy & > & 0,
		\end{eqnarray}
		%
		then
		%
                \begin{eqnarray}
	          \tim & = & \tim -
	            \left(
	              \left( \frac{\energy - E[k]}{E[k+1] - E[k]} \right)
	              \left( \Delta Y[k+1] - \Delta Y[k] \right) +
	              \Delta Y[k]
	            \right) \times \timedel_{\rm in}
                \end{eqnarray}

	      \item
	        If
		%
		\begin{eqnarray}
		  \energy & = & {\rm NaN}\ {\rm or} \\
		  \energy & \le & 0,
		\end{eqnarray}
		%
		then the \tim\ is not modified.

	    \end{enumerate}

	\end{enumerate}

      \item
        {none}: \\
	%
        If
	%
	\begin{equation}
	  \pixadj = {\rm none},
	\end{equation}
	%
	then
	%
	\begin{eqnarray}
	  \chipxadj & = & \chipxadj\ {\rm and} \\
	  \chipyadj & = & \chipyadj\ {\rm and} \\
	  \tim & = & \tim.
	\end{eqnarray}
	%
	No sub-pixel adjustments are applied to the values of \chipxadj\ and
	\chipyadj\ (for timed exposure mode) or \chipxadj\ and \tim\ (for
	continuous-clocking mode).

      \item
        {randomize}:

	\begin{enumerate}

	  \item
            If
	    %
	    \begin{equation}
	      \pixadj = {\rm randomize},
	    \end{equation}
	    %
	    then
	    %
	    \begin{eqnarray}
	      \chipxadj & = & \chipxadj + \epsilon_{x}\ {\rm and} \\
	      \chipyadj & = & \chipyadj + \epsilon_{y},
	    \end{eqnarray}
	    %
	    where $\epsilon_{x}$ and $\epsilon_{y}$ are a uniform random
	    deviates in the range $[-0.5,+0.5)$~pixel.

	  \item
	    If
	    %
	    \begin{eqnarray}
              \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm CC33\_GRADED},
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{eqnarray}
	      \tim & = & \tim - \epsilon_{y} \times \timedel_{\rm in}.
	    \end{eqnarray}

	\end{enumerate}

      \item
        If
	%
	\begin{eqnarray}
	  \chipxadj & < & 0.5,
	\end{eqnarray}
	%
	then
	%
	\begin{eqnarray}
	  \chipxadj & = & 1.
	\end{eqnarray}

      \item
        If
	%
	\begin{eqnarray}
	  \chipxadj & \ge & 1024.5,
	\end{eqnarray}
	%
	then
	%
	\begin{eqnarray}
	  \chipxadj & = & 1024.
	\end{eqnarray}

      \item
        If
	%
	\begin{eqnarray}
	  \chipyadj & < & 0.5,
	\end{eqnarray}
	%
	then
	%
	\begin{eqnarray}
	  \chipyadj & = & 1.
	\end{eqnarray}

      \item
        If
	%
	\begin{eqnarray}
	  \chipyadj & \ge & 1024.5,
	\end{eqnarray}
	%
	then
	%
	\begin{eqnarray}
	  \chipyadj & = & 1024.
	\end{eqnarray}

    \end{enumerate}

  \item
    {\x\ and \y}:
    %
    \begin{enumerate}

      \item
        If
	%
	\begin{eqnarray}
	  \stp & = & {\rm sky},
	\end{eqnarray}
	%
	then
	%
	\begin{enumerate}

          \item
	    If
	    %
	    \begin{eqnarray}
              \datamode_{\rm in} & = & {\rm FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm FAINT\_BIAS}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm GRADED}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm VFAINT},
	    \end{eqnarray}
	    %
	    then the values of \x\ and \y\ are computed using the
	    real-valued coordinates \chipxadj\ and \chipyadj\ and the
	    orientation of the telescope (i.e.\ \ra, \dec, and \roll) at the
	    time \tim.

          \item
	    If
	    %
	    \begin{eqnarray}
              \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm CC33\_GRADED},
	    \end{eqnarray}
	    %
	    then the values of \x\ and \y\ are computed using the
	    real-valued coordinates \chipxadj\ and $\chipytarg_{\rm eff}$
	    and the orientation of the telescope (i.e.\ \ra, \dec, and
	    \roll) at the time \tim.

          \item
	    If
	    %
	    \begin{eqnarray}
	      \acaofffile & \ne & {\rm none} 
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \content_{\rm in} & \ne & {\rm TGEVT1}
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \tim & < & \tim_{\rm min}\ {\rm or} \\
	      \tim & \ge & \tim_{\rm max},
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{eqnarray}
	      \x & = & {\rm NaN\ and} \\
	      \y & = & {\rm NaN}.
	    \end{eqnarray}

          \item
	    If
	    %
	    \begin{eqnarray}
	      \acaofffile & \ne & {\rm none} 
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \content_{\rm in} & = & {\rm TGEVT1\ and} \\
	      \chipytg & = & {\rm NaN},
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{eqnarray}
	      \x & = & {\rm NaN\ and} \\
	      \y & = & {\rm NaN}.
	    \end{eqnarray}
	    
	\end{enumerate}

    \end{enumerate}

  \item
    {\skyoned}:
    %
    \begin{enumerate}

      \item
        If
	%
	\begin{eqnarray}
	  \stp & = & {\rm sky}
	\end{eqnarray}
	%
	and
	%
	\begin{eqnarray}
	  \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
	  \datamode_{\rm in} & = & {\rm CC33\_GRADED},
	\end{eqnarray}
	%
	then
	%
	\begin{enumerate}

          \item
            The value of \skyoned\ is computed using the real-valued
	    coordinates \chipxadj\ and $\chipytarg_{\rm eff}$ and the
	    orientation of the telescope (i.e.\ \ra, \dec, and \roll) at the
	    time \tim.

          \item
	    If
	    %
	    \begin{eqnarray}
	      \acaofffile & \ne & {\rm none} 
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \content_{\rm in} & \ne & {\rm TGEVT1}
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \tim & < & \tim_{\rm min}\ {\rm or} \\
	      \tim & \ge & \tim_{\rm max},
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{eqnarray}
	      \skyoned & = & {\rm NaN}.
	    \end{eqnarray}

          \item
	    If
	    %
	    \begin{eqnarray}
	      \acaofffile & \ne & {\rm none} 
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \content_{\rm in} & = & {\rm TGEVT1\ and} \\
	      \chipytg & = & {\rm NaN},
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{eqnarray}
	      \skyoned & = & {\rm NaN}.
	    \end{eqnarray}
	    
	\end{enumerate}

    \end{enumerate}

  \item
    {\detx\ and \dety}:
    %
    \begin{enumerate}

      \item
        If
	%
	\begin{eqnarray}
	  \stp & = & {\rm det}\ {\rm or} \\
	  \stp & = & {\rm tan}\ {\rm or} \\
	  \stp & = & {\rm sky},
	\end{eqnarray}
	%
	then
	%
	\begin{enumerate}

          \item
            The values of \detx\ and \dety\ are computed using the
	    real-valued coordinates \chipxadj\ and \chipyadj\ and the
	    orientation of the SIM (i.e.\ \dy, \dz, and \dtheta) at the time
	    \tim.

          \item
	    If
	    %
	    \begin{eqnarray}
	      \acaofffile & \ne & {\rm none} 
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \content_{\rm in} & \ne & {\rm TGEVT1}
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \tim & < & \tim_{\rm min}\ {\rm or} \\
	      \tim & \ge & \tim_{\rm max},
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{eqnarray}
	      \detx & = & {\rm NaN\ and} \\
	      \dety & = & {\rm NaN}.
	    \end{eqnarray}

          \item
	    If
	    %
	    \begin{eqnarray}
	      \acaofffile & \ne & {\rm none} 
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \content_{\rm in} & = & {\rm TGEVT1\ and} \\
	      \chipytg & = & {\rm NaN},
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{eqnarray}
	      \detx & = & {\rm NaN\ and} \\
	      \dety & = & {\rm NaN}.
	    \end{eqnarray}
	    
        \end{enumerate}

    \end{enumerate}

  \item
    {\tdetx\ and \tdety}:
    %
    \begin{enumerate}

      \item
        If
	%
	\begin{eqnarray}
	  \stp & = & {\rm tdet}\ {\rm or} \\
	  \stp & = & {\rm det}\ {\rm or} \\
	  \stp & = & {\rm tan}\ {\rm or} \\
	  \stp & = & {\rm sky}
	\end{eqnarray}
	%
	then
	%
	\begin{enumerate}

          \item
            The values of \tdetx\ and \tdety\ are computed using the values
	    of nint(\chipxadj) and nint(\chipyadj).  Here, ``nint''
	    indicates that the real-valued coordinate is rounded to the
	    nearest integer.

          \item
	    If
	    %
	    \begin{eqnarray}
	      \acaofffile & \ne & {\rm none} 
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
	      \datamode_{\rm in} & = & {\rm CC33\_GRADED}
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \content_{\rm in} & \ne & {\rm TGEVT1}
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \tim & < & \tim_{\rm min}\ {\rm or} \\
	      \tim & \ge & \tim_{\rm max},
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{eqnarray}
	      \tdetx & = & {\rm NULL\ and} \\
	      \tdety & = & {\rm NULL}.
	    \end{eqnarray}

          \item
	    If
	    %
	    \begin{eqnarray}
	      \acaofffile & \ne & {\rm none} 
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
	      \datamode_{\rm in} & = & {\rm CC33\_GRADED}
	    \end{eqnarray}
	    %
	    and
	    %
	    \begin{eqnarray}
	      \content_{\rm in} & = & {\rm TGEVT1\ and} \\
	      \chipytg & = & {\rm NaN},
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{eqnarray}
	      \tdetx & = & {\rm NULL\ and} \\
	      \tdety & = & {\rm NULL}.
	    \end{eqnarray}
	    
	\end{enumerate}

    \end{enumerate}

\end{enumerate}

\subsubsection{ Write \outfile }

\begin{enumerate}

  \item
    {\pixadjkey}:
    %
    \begin{enumerate}

      \item
        If
	%
	\begin{eqnarray}
	  \pixadj & = & {\rm centroid},
	\end{eqnarray}
	%
	then
	%
	\begin{eqnarray}
	  \pixadjkey & = & {\rm CENTROID}.
	\end{eqnarray}

      \item
        If
	%
	\begin{eqnarray}
	  \pixadj & = & {\rm edser},
	\end{eqnarray}
	%
	then
	%
	\begin{eqnarray}
	  \pixadjkey & = & {\rm EDSER}.
	\end{eqnarray}

      \item
        If
	%
	\begin{eqnarray}
	  \pixadj & = & {\rm none},
	\end{eqnarray}
	%
	then
	%
	\begin{eqnarray}
	  \pixadjkey & = & {\rm NONE}.
	\end{eqnarray}

      \item
        If
	%
	\begin{eqnarray}
	  \pixadj & = & {\rm randomize},
	\end{eqnarray}
	%
	then
	%
	\begin{eqnarray}
	  \pixadjkey & = & {\rm RANDOMIZE}.
	\end{eqnarray}

    \end{enumerate}

  \item
    {\randsky}:
    %
    \begin{enumerate}

      \item
        If
	%
	\begin{eqnarray}
	  \pixadj & = & {\rm centroid},
	\end{eqnarray}
	%
	then
	%
	\begin{eqnarray}
	  \randsky & = & 0.0.
	\end{eqnarray}

      \item
        If
	%
	\begin{eqnarray}
	  \pixadj & = & {\rm edser},
	\end{eqnarray}
	%
	then
	%
	\begin{eqnarray}
	  \randsky & = & 0.0.
	\end{eqnarray}

      \item
        If
	%
	\begin{eqnarray}
	  \pixadj & = & {\rm none},
	\end{eqnarray}
	%
	then
	%
	\begin{eqnarray}
	  \randsky & = & 0.0.
	\end{eqnarray}

      \item
        If
	%
	\begin{eqnarray}
	  \pixadj & = & {\rm randomize},
	\end{eqnarray}
	%
	then
	%
	\begin{eqnarray}
	  \randsky & = & 0.5.
	\end{eqnarray}

    \end{enumerate}

  \item
    {\timeadj}:
    %
    \begin{enumerate}

      \item
        {Timed-exposure mode}: \\
        If
        %
        \begin{eqnarray}
          \datamode_{\rm in} & = & {\rm FAINT}\ {\rm or} \\
          \datamode_{\rm in} & = & {\rm FAINT\_BIAS}\ {\rm or} \\
          \datamode_{\rm in} & = & {\rm GRADED}\ {\rm or} \\
          \datamode_{\rm in} & = & {\rm VFAINT},
        \end{eqnarray}
        %
        then
        %
        \begin{eqnarray}
          \timeadj & = & {\rm NONE}.
        \end{eqnarray}

      \item
        {Continuous-clocking mode}:
        %
        \begin{enumerate}

          \item
	    Set
            %
            \begin{eqnarray}
              \timeadj & = & {\rm MIDCHIP}.
            \end{eqnarray}

          \item
	    If
	    %
            \begin{eqnarray}
              \obsmode_{\rm in} & = & {\rm pointing}\ {\rm and} \\
	      \acaofffile & \ne & {\rm none} 
            \end{eqnarray}
	    %
	    then
            %
            \begin{eqnarray}
              \timeadj & = & {\rm TARGET}.
            \end{eqnarray}

          \item
	    If
	    %
            \begin{eqnarray}
              \obsmode_{\rm in} & = & {\rm pointing}\ {\rm and} \\
              \content_{\rm in} & = & {\rm TGEVT1},
            \end{eqnarray}
	    %
	    then
            %
            \begin{eqnarray}
              \timeadj & = & {\rm GRATING}.
            \end{eqnarray}

        \end{enumerate}

    \end{enumerate}

\end{enumerate}

% 8. TBD

\section{TBD}

\begin{itemize}

  \item
    Include all timed exposure mode processing.
    
  \item
    Add the graded mode cti adjustment.

  \item
    Should {\content}s other than EVT0, EVT1, TGEVT1, and EVT2 be included?

  \item
    Should $\content = {\rm EVT2}$ be dropped?

  \item
    Should {\datamode}s other than CC33\_FAINT, CC33\_GRADED, FAINT,
    FAINT\_BIAS, GRADED, and VFAINT be included?

  \item
    Are the $\beta$ in \pharo\ the same as the $\beta$ in \pha?

  \item
    Should something be done about \skyoned?

\end{itemize}

% 10. Finish

\end{document}

