%+
% Name:
%   ape_spec_3.11.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
%-

\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{\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{\chipyzo}{{\tt CHIPY\_ZO}}
\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{\decadj}{{\tt DEC\_ADJ}}
\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{\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{\raadj}{{\tt RA\_ADJ}}
\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{\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{\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 }{
   3.11 }{
   http://space.mit.edu/CXC/docs/docs.html\#ape }{
   /nfs/inconceivable/d0/SDS/SPECS/acis\_process\_events/ape\_spec\_3.11.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
    {\infile}:
    %
    \begin{enumerate}

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

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

      \item
        {Validation}:
	%
	\begin{enumerate}
	
	  \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
            {\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
            {\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}
	    %
	    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 if 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 if 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 if 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 if HDU $h_{\rm in}$ of the \infile\ does not include the
		column \ccdx, then \acisprocessevents\ exits with an error
		message.  Hereafter, this column is referred to as
		$\ccdx_{\rm in}$.
		
	    \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 if 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}
	        %
		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 if HDU $h_{\rm in}$ of the \infile\ does not include the
		column \ccdy, then \acisprocessevents\ exits with an error
		message.  Hereafter, this column is referred to as
		$\ccdy_{\rm in}$.
		
            \end{enumerate}

          \item
            {\trow}:
	    %
            \begin{enumerate}
	    
	      \item
	        If
	        %
	        \begin{eqnarray}
                  \content_{\rm in} & = & {\rm EVT0},
	        \end{eqnarray}
	        %
		if
		%
	        \begin{eqnarray}
                  \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
                  \datamode_{\rm in} & = & {\rm CC33\_GRADED}
	        \end{eqnarray}
	        %
	        and if HDU $h_{\rm in}$ of the \infile\ does not include the
		column \trow, then \acisprocessevents\ exits with an error
		message.  Hereafter, this column is referred to as
		$\trow_{\rm in}$.
		
            \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 if 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
	    {\ratarg, \dectarg, \ranom, \decnom, \rapnt, \decpnt, \timedel,
	    \chipytg, \chipyzo, and \tgm}: \\ 
	    %
            If
            %
            \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, and
		\timedel}: \\ 
	        %
                If HDU $h_{\rm in}$ of the \infile\ does not include the
		keywords \ratarg, \dectarg, \ranom, \decnom, \rapnt,
		\decpnt, and \timedel, then \acisprocessevents\ exits with
		an error message. Hereafter these keywords are referred to
		$\ratarg_{\rm in}$, $\dectarg_{\rm in}$, $\ranom_{\rm in}$,
		$\decnom_{\rm in}$, $\rapnt_{\rm in}$, $\decpnt_{\rm in}$,
		and $\timedel_{\rm in}$, respectively.

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

	    \end{enumerate}

	\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}: \\
	%
	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 \acisprocessevents\ exits with an error message.

    \end{enumerate}

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

      \item
        {Validation for CC mode}: \\
	%
	% There's no point in performing CC mode computations without using
	% CHIPY_ADJ.
	%
        If
        %
        \begin{eqnarray}
          \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
          \datamode_{\rm in} & = & {\rm CC33\_GRADED},
        \end{eqnarray}
        %
        then
        %
        \begin{enumerate}

          \item
	    {Setting}: \\
	    %
            If
	    %
	    \begin{eqnarray}
	      \acaofffile & = & {\rm none\ or} \\
	      \acaofffile & = & {\rm NONE},
	    \end{eqnarray}
	    %
	    then \acisprocessevents\ exits with an error message.

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

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

          \item
	    {\content}: \\
	    %
            If the \acaofffile\ does not have an HDU $h_{\rm acaoff}$ with
	    the keyword
	    %
	    \begin{eqnarray}
	      \content & = & {\rm ASPSOL},
	    \end{eqnarray}
	    %
	    then \acisprocessevents\ exits with an error message.

          \item
	    {Keyword}: \\
	    %
            If HDU $h_{\rm acaoff}$ of the \acaofffile\ does not include the
	    keyword \tstart, then \acisprocessevents\ exits with an error
	    message.

          \item
	    {Columns}: \\
	    %
            If HDU $h_{\rm acaoff}$ of the \acaofffile\ does not include the
	    columns \tim, \ra, \dec, and \roll\ then \acisprocessevents\
	    exits with an error message.  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, but the the
	    values \tstart\ are not in increasing order, then
	    \acisprocessevents\ exits with an error message.

        \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 if 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
    {\alignmentfile}:
    %
    \begin{enumerate}

      \item
        {Validation for CC mode}: \\
	%
        If
        %
        \begin{eqnarray}
          \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
          \datamode_{\rm in} & = & {\rm CC33\_GRADED},
        \end{eqnarray}
        %
        then
        %
        \begin{enumerate}

          \item
	    {Setting}: \\
	    %
            If
	    %
	    \begin{eqnarray}
	      \alignmentfile & = & {\rm none\ or} \\
	      \alignmentfile & = & {\rm NONE},
	    \end{eqnarray}
	    %
	    then \acisprocessevents\ exits with an error message.

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

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

          \item
	    {\content}: \\
	    %
            If the \alignmentfile\ does not have an HDU $h_{\rm alignment}$
	    with the keyword
	    %
	    \begin{eqnarray}
	      \content & = & {\rm ASPSOL},
	    \end{eqnarray}
	    then \acisprocessevents\ exits with an error message.

          \item
	    {Keyword}: \\
	    %
            If HDU $h_{\rm alignment}$ of the \alignmentfile\ does not
	    include the keyword \tstart, then \acisprocessevents\ exits with
	    an error message.

          \item
	    {Columns}: \\
	    %
            If HDU $h_{\rm alignment}$ of the \alignmentfile\ does not
	    include the columns \dy, \dz, and \dtheta\ then
	    \acisprocessevents\ exits with an error message.

          \item
	    {Sequential}: \\
	    %
            If more than one valid \alignmentfile\ is specified, but the the
	    values \tstart\ are not in increasing order, then
	    \acisprocessevents\ exits with an error message.

        \end{enumerate}

    \end{enumerate}

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

      \item
        {Validation}: \\
	%
        If
        %
        \begin{eqnarray}
          \badpixfile & \ne & {\rm none\ and} \\
          \badpixfile & \ne & {\rm NONE},
        \end{eqnarray}
        %
        then
        %
        \begin{enumerate}

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

          \item
	    {Permission}: \\
	    %
            If the \badpixfile\ exists, but 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 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 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.

          \item
	    {Columns}: \\
	    %
	    If 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, but 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, but 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
            {\stp}: \\
	    %
	    If
	    %
	    \begin{eqnarray}
	      \pixadj & = & {\rm centroid}\ {\rm or} \\
	      \pixadj & = & {\rm edser}\ {\rm or} \\
	      \pixadj & = & {\rm randomize}
	    \end{eqnarray}
	    %
	    and if
	    %
	    \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 if 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 if 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, but 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}: \\
    %
    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.} 

  \item
    {Zeroth-order coordinates}: \\
    %
    If
    %
    \begin{eqnarray}
      \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
      \datamode_{\rm in} & = & {\rm CC33\_GRADED},
    \end{eqnarray}
    %
    and if
    %
    \begin{eqnarray}
      \content_{\rm in} & = & {\rm TGEVT1},
    \end{eqnarray}
    %
    then the $\chipyzo_{\rm in}$ coordinates are processed to obtain the
    minimum, median, and maximum values:
    %
    \begin{eqnarray}
      \chipyzo_{\rm min} & = & {\rm minimum} \left( \chipyzo_{\rm in} \right),
        \\
      \chipyzo_{\rm med} & = & {\rm median} \left( \chipyzo_{\rm in} \right),\
        {\rm and} \\
      \chipyzo_{\rm max} & = & {\rm maximum} \left( \chipyzo_{\rm in} \right).
    \end{eqnarray}
    %
    Only events in the good-time intervals are included in the computation
    of the values of $\chipyzo_{\rm min}$, $\chipyzo_{\rm med}$, and
    $\chipyzo_{\rm max}$.

  \item
    {\acaofffile}: \\
    %
    If
    %
    \begin{eqnarray}
      \datamode & = & {\rm CC33\_FAINT}\ {\rm or} \\
      \datamode & = & {\rm CC33\_GRADED},
    \end{eqnarray}
    %
    then
    %
    \begin{enumerate}

      \item
        $\tim_{\rm min}$, $\tim_{\rm max}$, $\ra_{\rm c}$, and
	  $\dec_{\rm c}$: \\
        %
        The \acaofffile\ data are processed to determine the earliest and
	latest times for which there is aspect information and to determine
	the right ascension and declination coordinates near the center of
	the dither pattern:
        %
        \begin{eqnarray}
	  \tim_{\rm min} & = &
	    {\rm min} \left( \tim_{\rm acaoff} \right), \\
	  \tim_{\rm max} & = &
	    {\rm max} \left( \tim_{\rm acaoff} \right), \\
          \ra_{\rm c} & = &
            {\rm median} \left( \ra_{\rm acaoff} \right),\ {\rm and} \\
          \dec_{\rm c} & = &
            {\rm median} \left( \dec_{\rm acaoff} \right).
        \end{eqnarray}

      \item
        {$\tim_{\rm c}$}: \\
        %
        The \acaofffile\ data are processed to determine the time $\tim_{\rm
	c}$ at which the quantity
	%
	\begin{eqnarray}
	  \cos \left( \dec_{\rm acaoff} \right)
	  \cos \left( \dec_{\rm c} \right)
	  \cos \left( \ra_{\rm acaoff} - \ra_{\rm c} \right) +
	  \sin \left( \dec_{\rm acaoff} \right)
	  \sin \left( \dec_{\rm c} \right)
	\end{eqnarray}
        %
	is maximized (i.e.\ the time at which the telescope is pointed the
	closest to $( \ra_{\rm c}, \dec_{\rm c} )$.

      \item
        {$\raadj_{\rm I}$, $\decadj_{\rm I}$, $\raadj_{\rm S}$,
	$\decadj_{\rm S}$}: \\
        %
        The effective values of \ra\ and \dec\ are computed for the ACIS-I
	and ACIS-S arrays.  These coordinates are used to determine the
	values of \tim\ and \chipyadj.

	\begin{enumerate}

          \item
	    {ACIS-I aim point}: \\
	    %
	    For the ACIS-I array, the values of $\raadj_{\rm I}$ and
	    $\decadj_{\rm I}$ are initialized assuming that the source is at
	    the ACIS-I aim point [i.e.\ that $( \tim, \ccdid, \chipx, \chipy
	    ) = ( \tim_{\rm c}, 3, 965, 963 )$%
	    %
	    \footnote{As described in the Proposers' Observatory Guide, the
	    location of the aim point on the ACIS-I array has drifted with
	    time. The location used here is within a few dozen pixels of the
	    actual aim point, provided the default \simy\ and \simz\ offsets
	    are used.}.

          \item
	    {ACIS-S aim point}: \\
	    %
	    For the ACIS-S array, the values of $\raadj_{\rm S}$ and
	    $\decadj_{\rm S}$ are initialized assuming that the source is at
	    the ACIS-S aim point [i.e.\ that $( \tim, \ccdid, \chipx, \chipy
	    ) = ( \tim_{\rm c}, 7, 227, 509 )$%
	    %
	    \footnote{Again, the location used here is within a few dozen
	    pixels of the actual aim point, provided the default \simy\ and
	    \simz\ offsets are used.}.

	  \item
	    {Target location}: \\
	    %
	    For the CCD at the focal point (i.e.\ $\ccdid_{\rm focus}$), the
	    values of \chipy\ are computed for each row of the \acaofffile,
	    assuming that the source is at the location specified by
	    $\ratarg_{\rm in}$ and $\dectarg_{\rm in}$.  These values of
	    \chipy\ are referred to as \chipytarg. If
	    %
	    \begin{eqnarray}
	      {\rm median} \left( \chipytarg \right) & \ge & 16.5\ {\rm and} \\
	      {\rm median} \left( \chipytarg \right) & < & 1008.5,
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{enumerate}

	      \item
	        {ACIS-I}: \\
	        %
	        If
		%
	        \begin{eqnarray}
	          \ccdid_{\rm focus} & \ge & 0\ {\rm and} \\
	          \ccdid_{\rm focus} & \le & 3,
	        \end{eqnarray}
	        %
	        then
	        %
	        \begin{eqnarray}
		  \raadj_{\rm I} & = & \ratarg_{\rm in}\ {\rm and} \\
		  \decadj_{\rm I} & = & \dectarg_{\rm in}.
	        \end{eqnarray}

	      \item
	        {ACIS-S}: \\
	        %
	        If
		%
	        \begin{eqnarray}
	          \ccdid_{\rm focus} & \ge & 4\ {\rm and} \\
	          \ccdid_{\rm focus} & \le & 9,
	        \end{eqnarray}
	        %
	        then
	        %
	        \begin{eqnarray}
		  \raadj_{\rm S} & = & \ratarg_{\rm in}\ {\rm and} \\
		  \decadj_{\rm S} & = & \dectarg_{\rm in}.
	        \end{eqnarray}

	    \end{enumerate}

	\end{enumerate}

    \end{enumerate}

\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
            {Level 0}: \\
            %
            If
	    %
	    \begin{eqnarray}
	      \content_{\rm in} & = & {\rm EVT0},
	    \end{eqnarray}
	    %
	    then the value of \chipx\ for an event is given by
	    %
	    \begin{eqnarray}
	      \chipx & = & \ccdx_{\rm in} + 1.
	    \end{eqnarray}

          \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}
	    %
	    then the value of \chipx\ for an event is given by $\chipx_{\rm
	    in}$.

	\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
    {\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
	    {Level 0}: \\
	    %
            If
	    %
	    \begin{eqnarray}
              \content_{\rm in} & = & {\rm EVT0},
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{enumerate}
	    
	      \item
	        {TE 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 the value of \chipy\ for an event is given by
	        %
	        \begin{eqnarray}
	          \chipy & = & \ccdy_{\rm in} + 1.
	        \end{eqnarray}
	
	      \item
	        {CC mode}: \\
		%
                If
	        %
	        \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
	    {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}
	    %
	    then the value of \chipy\ for an event is given by $\chipy_{\rm
	    in}$.
	    
	\end{enumerate}

      \item
        {Validation}: 
	%
	\begin{enumerate}
	
	  \item
	    {Unphysical}: 
	    %
	    \begin{enumerate}
	    
	      \item
	        {TE 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 if
	        %
	        \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
	        {CC mode}: \\
		%
                If
	        %
	        \begin{eqnarray}
	          \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
	          \datamode_{\rm in} & = & {\rm CC33\_GRADED}
	        \end{eqnarray}
	        %
	        and if
	        %
	        \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 if
	        %
	        \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 if
	        %
	        \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 if
	        %
	        \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
    {\tgm}:
    %
    \begin{enumerate}

      \item
        {CC mode with gratings}: \\
	%
        If
	%
        \begin{eqnarray}
          \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
          \datamode_{\rm in} & = & {\rm CC33\_GRADED}
        \end{eqnarray}
	%
	and if
	\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
        {CC mode with gratings}: \\
	%
        If
	%
        \begin{eqnarray}
          \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
          \datamode_{\rm in} & = & {\rm CC33\_GRADED}
        \end{eqnarray}
	%
	and if
	\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,
                \end{eqnarray}
	        %
	        and if
	        %
	        \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, \\
                  \tgm & < & 99, {\rm and} \\
	          \chipytg & < & 1,
	        \end{eqnarray}
	        %
	        then
	        %
	        \begin{eqnarray}
	          \chipytg & = & 1.
	        \end{eqnarray}
	      
              \item
                If
	        %
	        \begin{eqnarray}
                  \tgm & > & -99, \\
                  \tgm & < & 99, {\rm and} \\
	          \chipytg & > & 1024,
	        \end{eqnarray}
	        %
	        then
	        %
	        \begin{eqnarray}
	          \chipytg & = & 1024.
	        \end{eqnarray}
	      
	    \end{enumerate}
	    
	\end{enumerate}

    \end{enumerate}

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

      \item
        {CC mode with gratings}: \\
	%
        If
	%
        \begin{eqnarray}
          \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
          \datamode_{\rm in} & = & {\rm CC33\_GRADED}
        \end{eqnarray}
	%
	and if
	\begin{eqnarray}
          \content_{\rm in} & = & {\rm TGEVT1},
	\end{eqnarray}
	%
	then
	%
	\begin{enumerate}
	
          \item
            {Read}: \\
	    %
	    The value of \chipyzo\ for an event is given by $\chipyzo_{\rm
	    in}.$

	\end{enumerate}

    \end{enumerate}

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

      \item
        {CC 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}
                %
	        then the value of \timero\ for an event is given by
		$\timero_{\rm in}$.
		
	    \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
    {\tim\ and \chipyadj}:
    \label{chipyadj}
    %
    \begin{enumerate}

      \item
        {Read or calculate}: \\
	%
	\begin{enumerate}
	
	  \item
	    {TE 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
	    {CC mode without grating data}: \\
	    %
            If
	    %
            \begin{eqnarray}
              \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm CC33\_GRADED}
            \end{eqnarray}
	    %
	    and if
	    %
	    \begin{eqnarray}
              \content_{\rm in} & = & {\rm EVT0}\ {\rm or} \\
              \content_{\rm in} & = & {\rm EVT1}\ {\rm or} \\
              \content_{\rm in} & = & {\rm EVT2},
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{enumerate}
	    
	      \item
	        {$\tim'$}: \\
		%
                The approximate time of arrival
	        %
	        \begin{eqnarray}
	          {\tim}' & = & \timero -
	            \left( 512 + 1028 \right) \times \timedel_{\rm in}.
	        \end{eqnarray}

	      \item
	        {$\chipyadj'$}: \\
		%
	        If
	        %
		\begin{eqnarray}
		  \ccdid_{\rm focus} & \ge & 0\ {\rm and} \\
		  \ccdid_{\rm focus} & \le & 3,
		\end{eqnarray}
		%
		then $\chipyadj'$ (the approximate value of \chipyadj) is
		given by the \chipy\ location (on the focal-point CCD) of
		the coordinates $\raadj_{\rm I}$ and $\decadj_{\rm I}$ at
		the time ${\tim}'$.  If ${\tim}' < \tim_{\rm min}$ or
		${\tim}' > \tim_{\rm max}$, then $\tim_{\rm c}$ is used
		instead of ${\tim}'$.
		%
	        If
	        %
		\begin{eqnarray}
		  \ccdid_{\rm focus} & \ge & 4\ {\rm and} \\
		  \ccdid_{\rm focus} & \le & 9,
		\end{eqnarray}
		%
		then $\chipyadj'$ is given by the \chipy\ location (on the
		focal-point CCD) of the coordinates $\raadj_{\rm S}$ and
		$\decadj_{\rm S}$ at the time ${\tim}'$. If ${\tim}' <
		\tim_{\rm min}$ or ${\tim}' > \tim_{\rm max}$, then
		$\tim_{\rm c}$ is used instead of ${\tim}'$.

	      \item
	        {\tim}: \\
		%
	        The value of ${\chipyadj}'$ is used to obtain a better
		estimate of the time of arrival
	        %
	        \begin{eqnarray}
	          \tim & = & \timero -
	    	    \left( \chipyadj' + 1028 \right) \times \timedel_{\rm in}.
	        \end{eqnarray}
    
	      \item
	        {\chipyadj}: \\
		%
	        If
	        %
		\begin{eqnarray}
		  \ccdid_{\rm focus} & \ge & 0\ {\rm and} \\
		  \ccdid_{\rm focus} & \le & 3,
		\end{eqnarray}
		%
		then the value of \chipyadj\ is given by the \chipy\
		location (on the focal-point CCD) of the coordinates
		$\raadj_{\rm I}$ and $\decadj_{\rm I}$ at the time \tim. If
		${\tim} < \tim_{\rm min}$ or ${\tim} > \tim_{\rm max}$, then
		$\tim_{\rm c}$ is used instead of ${\tim}$.
		%
	        If
	        %
		\begin{eqnarray}
		  \ccdid_{\rm focus} & \ge & 4\ {\rm and} \\
		  \ccdid_{\rm focus} & \le & 9,
		\end{eqnarray}
		%
		then the value of \chipyadj\ is given by the \chipy\
		location (on the focal-point CCD) of the coordinates
		$\raadj_{\rm S}$ and $\decadj_{\rm S}$ at the time \tim. If
		${\tim} < \tim_{\rm min}$ or ${\tim} > \tim_{\rm max}$, then
		$\tim_{\rm c}$ is used instead of ${\tim}$.
		
	    \end{enumerate}

	  \item
	    {CC mode with ACIS-S grating data}: \\
	    %
            If
	    %
            \begin{eqnarray}
              \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm CC33\_GRADED},
            \end{eqnarray}
	    %
	    if
	    %
	    \begin{eqnarray}
              \content_{\rm in} & = & {\rm TGEVT1},
	    \end{eqnarray}
	    %
	    and if
	    %
	    \begin{eqnarray}
	      \ccdid_{\rm focus} & \ge & 4\ {\rm and} \\
	      \ccdid_{\rm focus} & \le & 9,
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{enumerate}
	    
	      \item
	        {Source events}: \\
		%
		If
		%
	        \begin{eqnarray}
	          \tgm & > & -99\ {\rm and} \\
	          \tgm & < & 99,
	        \end{eqnarray}
		%
		then
		%
	        \begin{eqnarray}
	          \chipyadj & = & \chipytg\ {\rm and} \label{eqn217} \\
	          \tim & = & \timero -
	            \left( \chipyadj + 1028 \right) \times \timedel_{\rm in}.
	        \end{eqnarray}
		%
		If the event does not occur during a good-time interval,
		then $\chipyadj = \chipyzo_{\rm med}$ instead of $\chipytg$
		in equation~\ref{eqn217}.
		
	      \item
	        {Background events with zeroth order on the array}: \\
		%
		If
		%
	        \begin{eqnarray}
	          \tgm & = & -99\ {\rm or} \\
	          \tgm & = & 99
	        \end{eqnarray}
		%
		and if
		%
	        \begin{eqnarray}
	          \chipyzo_{\rm min} & \ge & 0.5\ {\rm and} \\
	          \chipyzo_{\rm max} & < & 1024.5,
	        \end{eqnarray}
		%
		then
		%
	        \begin{eqnarray}
	          \chipyadj & = & \chipyzo\ {\rm and} 
		    \label{eqn223} \\
	          \tim & = & \timero -
	            \left( \chipyadj + 1028 \right) \times \timedel_{\rm in}.
	        \end{eqnarray}
		%
		If the event does not occur during a good-time interval,
		then $\chipyadj = \chipyzo_{\rm med}$ instead of $\chipyzo$
		in equation.~\ref{eqn223}.
		
	      \item
	        {Background events with zeroth order off the array}: \\
		%
		If
		%
	        \begin{eqnarray}
	          \tgm & = & -99\ {\rm or} \\
	          \tgm & = & 99
	        \end{eqnarray}
		%
		and if
		%
	        \begin{eqnarray}
	          \chipyzo_{\rm max} & < & 0.5\ {\rm or} \\
	          \chipyzo_{\rm min} & \ge & 1024.5,
	        \end{eqnarray}
		%
		then
		%
	        \begin{eqnarray}
	          \chipyadj & = & 512 +
		    \left( \chipyzo - \chipyzo_{\rm med} \right)\ {\rm and} 
		      \label{eqn229} \\
	          \tim & = & \timero -
	            \left( \chipyadj + 1028 \right) \times \timedel_{\rm in}.
	        \end{eqnarray}
		%
		If the event does not occur during a good-time interval,
		then $\chipyadj = 512$ instead of $512 + \chipyzo -
		\chipyzo_{\rm med}$ in equation.~\ref{eqn229}.

	    \end{enumerate}
	    
	  \item
	    {CC mode with ACIS-I grating data}: \\
	    %
	    % The following should be fine for LETG obtain, but HETG
	    % observations on ACIS-I are not supported.
	    %
            If
	    %
            \begin{eqnarray}
              \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm CC33\_GRADED},
            \end{eqnarray}
	    %
	    if
	    %
	    \begin{eqnarray}
              \content_{\rm in} & = & {\rm TGEVT1},
	    \end{eqnarray}
	    %
	    and if
	    %
	    \begin{eqnarray}
	      \ccdid_{\rm focus} & \ge & 0\ {\rm and} \\
	      \ccdid_{\rm focus} & \le & 3,
	    \end{eqnarray}
	    %
	    then
	    %
	    \begin{enumerate}
	    
	      \item
	        {$\tim'$}: \\
		%
                The approximate time of arrival
	        %
	        \begin{eqnarray}
	          {\tim}' & = & \timero -
	            \left( 512 + 1028 \right) \times \timedel_{\rm in}.
	        \end{eqnarray}

	      \item
	        {$\chipyadj'$}: \\
		%
                $\chipyadj'$ (the approximate value of \chipyadj) is given
		by the \chipy\ location (on the focal-point CCD) of the
		coordinates $\raadj_{\rm I}$ and $\decadj_{\rm I}$ at the
		time ${\tim}'$. If the event does not occur during a
		good-time interval, then $\tim_{\rm c}$ is used instead of
		${\tim}'$.

	      \item
	        {\tim}: \\
		%
	        The value of ${\chipyadj}'$ is used to obtain a better
		estimate of the time of arrival
	        %
	        \begin{eqnarray}
	          \tim & = & \timero -
	    	    \left( \chipyadj' + 1028 \right) \times \timedel_{\rm in}.
	        \end{eqnarray}
    
	      \item
	        {\chipyadj}: \\
		%
		The value of \chipyadj\ is given by the \chipy\ location (on
		the focal-point CCD) of the coordinates $\raadj_{\rm I}$ and
		$\decadj_{\rm I}$ at the time \tim. If the event does not
		occur during a good-time interval, then $\tim_{\rm c}$ is
		used instead of ${\tim}$.
		
	    \end{enumerate}
	    
	\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\ and} \\
	  \badpixfile & \ne & {\rm NONE}
	\end{eqnarray}
	%
	and if 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 if there are one or more rows $r$
	    in HDU $h_{\rm badpix}$ where
	    %
	    \begin{eqnarray}
	      \chipx & \ge & \chipx_{{\rm badpix},r}[0], \\
	      \chipx & \le & \chipx_{{\rm badpix},r}[1], \\
	      \tim & \ge & \tim_{{\rm badpix},r}, \\
	      \tim & < & \timestop_{{\rm badpix},r}
	    \end{eqnarray}
	    %
	    and where
	    %
	    \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 if there are one or more rows $r$
	    in HDU $h_{\rm badpix}$ where
	    %
	    \begin{eqnarray}
	      \chipx & \ge & \chipx_{{\rm badpix},r}[0], \\
	      \chipx & \le & \chipx_{{\rm badpix},r}[1], \\
	      \tim & \ge & \tim_{{\rm badpix},r}, \\
	      \tim & < & \timestop_{{\rm badpix},r}
	    \end{eqnarray}
	    %
	    and where
	    %
	    \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 if there are one or more rows $r$
	    in HDU $h_{\rm badpix}$ where
	    %
	    \begin{eqnarray}
	      \chipx & \ge & \chipx_{{\rm badpix},r}[0], \\
	      \chipx & \le & \chipx_{{\rm badpix},r}[1], \\
	      \tim & \ge & \tim_{{\rm badpix},r}, \\
	      \tim & < & \timestop_{{\rm badpix},r}
	    \end{eqnarray}
	    %
	    and where
	    %
	    \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 if there are one or more rows $r$
	    in HDU $h_{\rm badpix}$ where
	    %
	    \begin{eqnarray}
	      \chipx & \ge & \chipx_{{\rm badpix},r}[0], \\
	      \chipx & \le & \chipx_{{\rm badpix},r}[1], \\
	      \tim & \ge & \tim_{{\rm badpix},r}, \\
	      \tim & < & \timestop_{{\rm badpix},r}
	    \end{eqnarray}
	    %
	    and where
	    %
	    \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 if there are one or more rows $r$
	    in HDU $h_{\rm badpix}$ where
	    %
	    \begin{eqnarray}
	      \chipx & \ge & \chipx_{{\rm badpix},r}[0], \\
	      \chipx & \le & \chipx_{{\rm badpix},r}[1], \\
	      \tim & \ge & \tim_{{\rm badpix},r}, \\
	      \tim & < & \timestop_{{\rm badpix},r}
	    \end{eqnarray}
	    %
	    and where
	    %
	    \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 if there are one or more rows $r$
	    in HDU $h_{\rm badpix}$ where
	    %
	    \begin{eqnarray}
	      \chipx & \ge & \chipx_{{\rm badpix},r}[0], \\
	      \chipx & \le & \chipx_{{\rm badpix},r}[1], \\
	      \tim & \ge & \tim_{{\rm badpix},r}, \\
	      \tim & < & \timestop_{{\rm badpix},r}
	    \end{eqnarray}
	    %
	    and where
	    %
	    \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}$, if the parameter $\applycti = {\rm yes}$, and if 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 if $\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 if $\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], \\
	      \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
        If
        %
        \begin{equation}
	  \datamode_{\rm in} = {\rm CC33\_FAINT},
        \end{equation}
        %
	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}
	    %
          \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
        If
        %
        \begin{equation}
	  \datamode_{\rm in} = {\rm CC33\_GRADED},
        \end{equation}
        %
	then
	%
	\begin{enumerate}
          \item
	    If
	    %
            \begin{equation}
	      \content_{\rm in} = {\rm EVT0},
            \end{equation}
	    %
	    then the value of \pharo\ for the event is the value of \pha\ in
	    the \infile.

	  \item
	    If
	    %
            \begin{equation}
	      \content_{\rm in} = {\rm EVT1},\ {\rm TGEVT1},\ {\rm or}\ {\rm
	        EVT2},
            \end{equation}
	    %
	    then the value of \pharo\ for the event is the value of \pharo\
	    in the \infile.
	\end{enumerate}

    \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\ = 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}$, if the parameter
	\gainfile\ is specified, and if $\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}$, if the parameter
	\gainfile\ is specified, and if $\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 if 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
        If
	%
	\begin{equation}
	  \pixadj = {\rm centroid},
	\end{equation}
	%
	then
	%
	\begin{eqnarray}
	  \chipxadj & = & \chipxadj - w'[0] + w'[2] - w'[3] + w'[5] -
	    w'[6] + w'[8] 
	\end{eqnarray}
	%
	and if
	%
	\begin{eqnarray}
          \datamode & = & {\rm FAINT}\ {\rm or} \\
          \datamode & = & {\rm FAINT\_BIAS}\ {\rm or} \\
          \datamode & = & {\rm GRADED}\ {\rm or} \\
          \datamode & = & {\rm VFAINT},
	\end{eqnarray}
	%
	then
	%
	\begin{eqnarray}
	  \chipyadj & = & \chipyadj - w'[0] - w'[1] - w'[2] + w'[6] +
	    w'[7] + w'[8] 
	\end{eqnarray}
	%
	and if
	%
	\begin{eqnarray}
          \datamode & = & {\rm CC33\_FAINT}\ {\rm or} \\
          \datamode & = & {\rm CC33\_GRADED},
	\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}
	%
	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}
        %
	Note that it is possible for the centroid algorithm to yield an
	adjustment to \chipxadj\ and/or \chipyadj\ that is greater than half
	a pixel.  However, the adjustment cannot equal or exceed one pixel.

      \item
        If
	%
	\begin{equation}
	  \pixadj = {\rm edser},
	\end{equation}
	%
	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 if
	%
	\begin{eqnarray}
          \datamode & = & {\rm FAINT}\ {\rm or} \\
          \datamode & = & {\rm FAINT\_BIAS}\ {\rm or} \\
          \datamode & = & {\rm GRADED}\ {\rm or} \\
          \datamode & = & {\rm VFAINT},
	\end{eqnarray}
	%
	then
	%
        \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}
	%
	and if
	%
	\begin{eqnarray}
          \datamode & = & {\rm CC33\_FAINT}\ {\rm or} \\
          \datamode & = & {\rm CC33\_GRADED},
	\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}
	%
	where
	%
	$E[k]$ and $E[k+1]$, $X[k]$ and $X[k+1]$, and $Y[k]$ and
	$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{equation}
	  \pixadj = {\rm none},
	\end{equation}
	%
	then the values of \chipxadj\ and \chipyadj\ remain unchanged.

      \item
        If
	%
	\begin{equation}
	  \pixadj = {\rm randomize},
	\end{equation}
	%
	then
	%
	\begin{eqnarray}
	  \chipxadj & = & \chipxadj + \epsilon_{x}
	\end{eqnarray}
	%
	and if
	%
	\begin{eqnarray}
          \datamode & = & {\rm FAINT}\ {\rm or} \\
          \datamode & = & {\rm FAINT\_BIAS}\ {\rm or} \\
          \datamode & = & {\rm GRADED}\ {\rm or} \\
          \datamode & = & {\rm VFAINT},
	\end{eqnarray}
	%
	then
	%
	\begin{eqnarray}
	  \chipyadj & = & \chipyadj +
	    \epsilon_{y}
	\end{eqnarray}
	%
	and if
	%
	\begin{eqnarray}
          \datamode & = & {\rm CC33\_FAINT}\ {\rm or} \\
          \datamode & = & {\rm CC33\_GRADED},
	\end{eqnarray}
	%
	then
	%
	\begin{eqnarray}
	  \tim & = & \tim - \epsilon_{y} \times \timedel_{\rm in},
	\end{eqnarray}
	%
	where $\epsilon_{x}$ and $\epsilon_{y}$ are uniform random deviates
	in the range $[-0.5,+0.5)$~pixel.

      \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
    {\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 the values of \tdetx\ and \tdety\ are computed using the values
	of ${\rm nint}(\chipxadj)$ and ${\rm nint}(\chipyadj)$. Here,
	``nint'' indicates that the real-valued coordinate is rounded to the
	nearest integer before the computation of the {\rm TDET} coordinate.
    \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 the values of \detx\ and \dety\ are computed using the
	real-valued coordinates \chipxadj\ and \chipyadj.

    \end{enumerate}

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

      \item
        If
	%
	\begin{eqnarray}
	  \stp & = & {\rm sky},
	\end{eqnarray}
	%
	then the values of \x\ and \y\ are computed using the real-valued
	coordinates \chipxadj\ and \chipyadj.

    \end{enumerate}

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

      \item
        If
	%
	\begin{eqnarray}
	  \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
	  \datamode_{\rm in} & = & {\rm CC33\_GRADED}
	\end{eqnarray}
	%
	and if
	%
	\begin{eqnarray}
	  \stp & = & {\rm sky},
	\end{eqnarray}
	%
	then the value of \skyoned\ is computed.

    \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
        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
	%
	\begin{enumerate}

	  \item
	    If
	    %
            \begin{eqnarray}
              \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm CC33\_GRADED},
            \end{eqnarray}
	    %
	    if
	    %
	    \begin{eqnarray}
              \content_{\rm in} & = & {\rm EVT0}\ {\rm or} \\
              \content_{\rm in} & = & {\rm EVT1}\ {\rm or} \\
              \content_{\rm in} & = & {\rm EVT2},
	    \end{eqnarray}
	    %
	    if
	    %
	    \begin{eqnarray}
              \ccdid_{\rm focus} & \ge & 0\ {\rm and} \\
              \ccdid_{\rm focus} & \le & 3,
	    \end{eqnarray}
	    %
	    and if
	    %
	    \begin{eqnarray}
	      &
	      \cos \left( \decadj_{\rm I} \right)
	      \cos \left( \dectarg_{\rm in} \right)
	      \cos \left( \raadj_{\rm I} - \ratarg_{\rm in} \right) +
	      & \\
	      &
	      \sin \left( \decadj_{\rm I} \right)
	      \sin \left( \dectarg_{\rm in} \right) <
	      & \\
	      &
	      4.855 \times 10^{-11},
	      &
	    \end{eqnarray}
	    %
	    then
 	    %
	    \begin{eqnarray}
	      \timeadj & = & {\rm TARGET}.
	    \end{eqnarray}

	  \item
	    If
	    %
            \begin{eqnarray}
              \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm CC33\_GRADED},
            \end{eqnarray}
	    %
	    if
	    %
	    \begin{eqnarray}
              \content_{\rm in} & = & {\rm EVT0}\ {\rm or} \\
              \content_{\rm in} & = & {\rm EVT1}\ {\rm or} \\
              \content_{\rm in} & = & {\rm EVT2},
	    \end{eqnarray}
	    %
	    if
	    %
	    \begin{eqnarray}
              \ccdid_{\rm focus} & \ge & 4\ {\rm and} \\
              \ccdid_{\rm focus} & \le & 9,
	    \end{eqnarray}
	    %
	    and if
	    %
	    \begin{eqnarray}
	      &
	      \cos \left( \decadj_{\rm S} \right)
	      \cos \left( \dectarg_{\rm in} \right)
	      \cos \left( \raadj_{\rm S} - \ratarg_{\rm in} \right) +
	      & \\
	      &
	      \sin \left( \decadj_{\rm S} \right)
	      \sin \left( \dectarg_{\rm in} \right) <
	      & \\
	      &
	      4.855 \times 10^{-11},
	      &
	    \end{eqnarray}
	    %
	    then
 	    %
	    \begin{eqnarray}
	      \timeadj & = & {\rm TARGET}.
	    \end{eqnarray}

	\end{enumerate}

      \item
	%
	\begin{enumerate}

	  \item
	    If
	    %
            \begin{eqnarray}
              \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm CC33\_GRADED},
            \end{eqnarray}
	    %
	    if
	    %
	    \begin{eqnarray}
              \content_{\rm in} & = & {\rm EVT0}\ {\rm or} \\
              \content_{\rm in} & = & {\rm EVT1}\ {\rm or} \\
              \content_{\rm in} & = & {\rm EVT2},
	    \end{eqnarray}
	    %
	    if
	    %
	    \begin{eqnarray}
              \ccdid_{\rm focus} & \ge & 0\ {\rm and} \\
              \ccdid_{\rm focus} & \le & 3,
	    \end{eqnarray}
	    %
	    and if
	    %
	    \begin{eqnarray}
	      &
	      \cos \left( \decadj_{\rm I} \right)
	      \cos \left( \dectarg_{\rm in} \right)
	      \cos \left( \raadj_{\rm I} - \ratarg_{\rm in} \right) +
	      & \\
	      &
	      \sin \left( \decadj_{\rm I} \right)
	      \sin \left( \dectarg_{\rm in} \right) \ge
	      & \\
	      &
	      4.855 \times 10^{-11},
	      &
	    \end{eqnarray}
	    %
	    then
 	    %
	    \begin{eqnarray}
	      \timeadj & = & {\rm AIMPOINT}.
	    \end{eqnarray}

	  \item
	    If
	    %
            \begin{eqnarray}
              \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
              \datamode_{\rm in} & = & {\rm CC33\_GRADED},
            \end{eqnarray}
	    %
	    if
	    %
	    \begin{eqnarray}
              \content_{\rm in} & = & {\rm EVT0}\ {\rm or} \\
              \content_{\rm in} & = & {\rm EVT1}\ {\rm or} \\
              \content_{\rm in} & = & {\rm EVT2},
	    \end{eqnarray}
	    %
	    if
	    %
	    \begin{eqnarray}
              \ccdid_{\rm focus} & \ge & 4\ {\rm and} \\
              \ccdid_{\rm focus} & \le & 9,
	    \end{eqnarray}
	    %
	    and if
	    %
	    \begin{eqnarray}
	      &
	      \cos \left( \decadj_{\rm S} \right)
	      \cos \left( \dectarg_{\rm in} \right)
	      \cos \left( \raadj_{\rm S} - \ratarg_{\rm in} \right) +
	      & \\
	      &
	      \sin \left( \decadj_{\rm S} \right)
	      \sin \left( \dectarg_{\rm in} \right) \ge
	      & \\
	      &
	      4.855 \times 10^{-11},
	      &
	    \end{eqnarray}
	    %
	    then
 	    %
	    \begin{eqnarray}
	      \timeadj & = & {\rm AIMPOINT}.
	    \end{eqnarray}

	\end{enumerate}

      \item
        If
	%
        \begin{eqnarray}
          \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
          \datamode_{\rm in} & = & {\rm CC33\_GRADED}
        \end{eqnarray}
	%
	if
	%
	\begin{eqnarray}
          \content_{\rm in} & = & {\rm TGEVT1}
	\end{eqnarray}
	%
	and if
	%
        \begin{eqnarray}
          \ccdid_{\rm focus} & \ge & 4\ {\rm and} \\
          \ccdid_{\rm focus} & \le & 9
        \end{eqnarray}
	%
	then
	%
	\begin{eqnarray}
	  \timeadj & = & {\rm GRATING}.
	\end{eqnarray}

      \item
        If
	%
        \begin{eqnarray}
          \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
          \datamode_{\rm in} & = & {\rm CC33\_GRADED}
        \end{eqnarray}
	%
        if
	%
	\begin{eqnarray}
          \content_{\rm in} & = & {\rm TGEVT1}
	\end{eqnarray}
	%
	if
	%
        \begin{eqnarray}
          \ccdid_{\rm focus} & \ge & 0\ {\rm and} \\
          \ccdid_{\rm focus} & \le & 3
        \end{eqnarray}
	%
	and if
	%
	\begin{eqnarray}
	  &
	  \cos \left( \decadj_{\rm I} \right)
	  \cos \left( \dectarg_{\rm in} \right)
	  \cos \left( \raadj_{\rm I} - \ratarg_{\rm in} \right) +
	  & \\
	  &
	  \sin \left( \decadj_{\rm I} \right)
	  \sin \left( \dectarg_{\rm in} \right) <
	  & \\
	  &
	  4.855 \times 10^{-11},
	  &
	\end{eqnarray}
	%
	then
	%
	\begin{eqnarray}
	  \timeadj & = & {\rm TARGET}.
	\end{eqnarray}

      \item
        If
	%
        \begin{eqnarray}
          \datamode_{\rm in} & = & {\rm CC33\_FAINT}\ {\rm or} \\
          \datamode_{\rm in} & = & {\rm CC33\_GRADED}
        \end{eqnarray}
	%
        if
	%
	\begin{eqnarray}
          \content_{\rm in} & = & {\rm TGEVT1}
	\end{eqnarray}
	%
	if
	%
        \begin{eqnarray}
          \ccdid_{\rm focus} & \ge & 0\ {\rm and} \\
          \ccdid_{\rm focus} & \le & 3
        \end{eqnarray}
	%
	and if
	%
	\begin{eqnarray}
	  &
	  \cos \left( \decadj_{\rm I} \right)
	  \cos \left( \dectarg_{\rm in} \right)
	  \cos \left( \raadj_{\rm I} - \ratarg_{\rm in} \right) +
	  & \\
	  &
	  \sin \left( \decadj_{\rm I} \right)
	  \sin \left( \dectarg_{\rm in} \right) \ge
	  & \\
	  &
	  4.855 \times 10^{-11},
	  &
	\end{eqnarray}
	%
	then
	%
	\begin{eqnarray}
	  \timeadj & = & {\rm AIMPOINT}.
	\end{eqnarray}

    \end{enumerate}

\end{enumerate}

% 8. TBD

\section{TBD}

\begin{itemize}

  \item
    Complete the spec to include all of the timed exposure mode processing.

  \item
    Complete sections 1.1, 1.2, 1.3, and 1.4.

  \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 \ratarg, \dectarg, \ranom, \decnom, and \timedel\ keywords in
    the output of afe (need \obsfile\ sometimes)?

  \item
    What if \timero\ is not in the \infile\ (output of afe? EVT2 files?)?

  \item
    What if a small fraction of the values of \chipytarg\ are off the chip
    due to bad aspect?

  \item
    Make sure that the \status\ bits are unset and reset properly.

  \item
    What about aoff and soff files instead of asol files?

  \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}

