%+
% Name:
%   memo_fltgrade_grade_pha_1.7.tex
%
% History:
%   2001 Nov 30, created, Glenn E. Allen
%   2001 Dec 18, added section about default values of CORNERS, GEA
%   2001 Dec 21, added some of Bev's comments and rewrote, GEA
%   2002 Sep 09, modified header, GEA
%   2003 May 16, modified description of the default value of CORNERS (v1.4), GEA
%   2007 Jan 08, fixed a typo (v1.5), GEA
%   2013 Jul 07, switched from changebar (v1.6), GEA
%   2014 Mar 18, modified to address the change in FLTGRADE to GRADE mapping
%     scheme for CC33_GRADED mode observations (v1.7), GEA
%-

\documentclass{article}

\usepackage{/nfs/inconceivable/d0/SRC/LATEX/STY/cxo_memo_logo}
\usepackage{epsfig}
\usepackage{/nfs/inconceivable/d0/SRC/LATEX/STY/gea}
\usepackage{pstricks}

\newrgbcolor{red}{1 0 0}

\newcommand{\phasadj}{{\rm PHAS\_ADJ}}

\begin{document}

% 1. Header

\memobasic{
   Jonathan McDowell, SDS Group Leader }{
   Glenn Allen, SDS }{
   The computation of FLTGRADE, GRADE, and PHA }{
   1.7 }{
   http://space.mit.edu/CXC/docs/docs.html\#grades }{
   /nfs/inconceivable/d0/SDS/specs/fltgrade\_grade\_pha/memo\_fltgrade\_grade\_pha\_1.7.tex }

% 2. Introduction

\vspace*{0.3in}
This memo describes the computation of the values of the columns FLTGRADE,
GRADE, and PHA for Level 1 TIMED FAINT, TIMED VFAINT, and CONTINUOUS
CC33\_FAINT mode ACIS event data.  These computations are based on the
distribution of charge in the central 3 pixel by 3 pixel ``event island'' of
an event.  If the CTI adjustment has not been performed, the distribution of
charge is quantified in the column PHAS.  If the adjustment has been
performed, use the column \phasadj\ instead of PHAS.  Since the algorithms
used for CTI-adjusted data differ somewhat from the algorithms used for
unadjusted data, the differences are described.  This memo supersedes the
document entitled ``CXC implementation of ACIS event grading schemes (V1.1)''
(see http://space.mit.edu/CXC/docs/grades.ps.gz).

% 3. Indexing the PHAS Array

\section{Indexing the PHAS Array}
\label{index}

For TIMED VFAINT and CONTINUOUS CC33\_FAINT mode observations, the relative
CHIPX and CHIPY coordinates of each pixel of an event island are shown in
Figure~\ref{fig1}.  The coordinates of the central pixel of the event island
are reported as the location of the event on the detector.  Figure~\ref{fig1}
also shows the appropriate one ($i$) and two ($j,k$) index values for each
pixel of the event island.

%
\begin{figure}[h]
  \hfil
  \hbox{\epsfig{file=figs/memo_fltgrade_grade_pha_fig1.eps,width=5.86in}}
  \hfil
  %
  \caption{The relative CHIPX and CHIPY coordinates of the nine elements of
    a 3 pixel by 3 pixel ACIS event island (\ie\ the nine elements of PHAS
    or \phasadj\ for TIMED FAINT and CONTINUOUS CC33\_FAINT mode data).  The
    figure on the left-hand (right-hand) side is appropriate if one (two)
    index is used. \label{fig1}}
  %
\end{figure}

% 4. FLTGRADE

\section{FLTGRADE}
\label{fltgrade}

The value of the FLTGRADE of an event is a numerical representation of the
distribution of charge in the event island.  The value is given by
%
\begin{equation}
{\rm FLTGRADE}
   =
   \sum_{i=0}^{8} \alpha_{i} f_{i},
\label{eqn1}
\end{equation}
%
where $\alpha_{i} = 1$ if the pixel is valid, $\alpha_{i} = 0$ if the pixel
is not valid, and the value of $f_{i}$ is different for each pixel in the
event island (Fig.~\ref{fig2}).  The range of possible values for FLTGRADE
is 0--255 inclusive.

\begin{figure}[h]
  \hfil
  \hbox{\epsfig{file=figs/memo_fltgrade_grade_pha_fig2.eps,width=2.82in}}
  \hfil
  %
  \caption{The values of $f_{i}$ (Eqn.~\ref{eqn1}) for each of the nine
    pixels of an event island. \label{fig2}}
  %
\end{figure}
%

A pixel is considered valid for the computation of FLTGRADE (\ie\ $\alpha_{i}
= 1$) if all of the following set of criteria are satisfied.

\begin{enumerate}

\item
The amount of charge in the pixel must be greater than or equal to the split
threshold $s$.  (The default value of the split threshold $s = 13$ adu.)  If
the CTI adjustment is not performed, then this condition is satisfied if
%
\begin{equation}
{\rm PHAS}[i] \ge s.
\label{eqn2}
\end{equation}
%
If the CTI adjustment is performed, then this condition is satisfied if
%
\begin{equation}
\phasadj[i] \ge s.
\label{eqn4}
\end{equation}
%

\item
If the CTI adjustment is not performed, then the amount of charge in the pixel
should not exceed the maximum value that can be obtained using a twelve-bit
analog-to-digital converter:
%
\begin{equation}
{\rm PHAS}[i] \le 4095.
\label{eqn6}
\end{equation}
%
If the CTI adjustment is performed, the amount of charge in a pixel is set
to 4095 adu if $\phasadj[i] > 4095$ for the pixel.  In this case,
Equation~\ref{eqn6} is satisfied by design.

\item
If the CTI adjustment is not performed, the amount of charge in the outer
eight pixels of the 3 pixel by 3 pixel event island must not exceed the
amount of charge in the central pixel of the event island.  For some of the
pixels, the appropriate inequality is ``$\le$.''  For others, it is ``$<$''
(Fig~\ref{fig3}).
%
\begin{figure}[h]
  \hfil
  \hbox{\epsfig{file=figs/memo_fltgrade_grade_pha_fig3.eps,width=2.82in}}
  \hfil
  %
  \caption{The inequality to be used when comparing the amount of charge in
    the outer eight pixels of an event island to the amount of charge in the
    central pixel ($p_{\rm c}$) of the island (Eqns.~\ref{eqn8} and
    \ref{eqn10}). \label{fig3}}
  %
\end{figure}
%
If the index number $i$ for the pixel is in the range 0--3 (see the left-hand
side of Fig.~\ref{fig1}), then this condition is satisfied if
%
\begin{equation}
{\rm PHAS}[i] \le p_{\rm c},
\label{eqn8}
\end{equation}
%
where $p_{\rm c}$ ($= {\rm PHAS}[4]$) is the amount of charge in the central
pixel.  If the index number for the pixel is in the range 5--8, then this
condition is satisfied if
%
\begin{equation}
{\rm PHAS}[i] < p_{\rm c}.
\label{eqn10}
\end{equation}
%
If the CTI adjustment is performed, the outer eight pixels of the event
island may have more charge than the central pixel.

\end{enumerate}

In summary, if the CTI adjustment is not performed and Equations~\ref{eqn2},
\ref{eqn6}, and \ref{eqn8} (or \ref{eqn10}) are satisfied for a given pixel,
the value of $\alpha_{i} = 1$ for the pixel and it is included in the
computation of the value of FLTGRADE (see Equation~\ref{eqn1}).  If one
of more of these equations is not satisfied, the pixel is not valid and
$\alpha_{i} = 0$.  If the CTI adjustment is performed, $\alpha_{i} = 1$
if and only if Equation~\ref{eqn4} is satisfied.  If Equation~\ref{eqn4}
is not satisfied, then $\alpha_{i} = 0$ for the pixel.

% 5. GRADE

\section{GRADE}
\label{grade}

The value of the GRADE of an event is based on the value of the FLTGRADE of
the event.  The range of possible values for GRADE is 0--7 inclusive.  The
scheme used to determine the value of the GRADE is similar to the scheme
used to assign the values of GRADE to {\sl ASCA} SIS events.  {\red To date,
only one scheme has been used for CC33\_FAINT, FAINT, FAINT\_BIAS, GRADED,
RAW, and VFAINT, mode observations.  However, two schemes have been used for
CC33\_GRADED mode observations.  See
http://space.mit.edu/CXC/docs/docs.html\#grade\_ard for the details about
these schemes.}

% 6. PHA

\section{PHA}
\label{pha}

The value of the PHA of an event is an estimate of the total amount of
charge in a 3 pixel by 3 pixel event island.  If the CTI adjustment is not
performed, the value is given by
%
\begin{equation}
{\rm PHA}
   =
   \sum_{i=0}^{8} c'_{i} {\rm PHAS}[i],
\label{eqn12}
\end{equation}
%
where $c'_{i} = 1$ if the pixel is valid and $c'_{i} = 0$ if the pixel is not
valid.  If the CTI adjustment is performed, the value is given by
%
\begin{equation}
{\rm PHA}
   =
   \sum_{i=0}^{8} c'_{i} \phasadj[i].
\label{eqn13}
\end{equation}
%

A pixel is considered valid for the computation of PHA if all of the
following set of criteria are satisfied.

\begin{enumerate}

\item
The amount of charge in a pixel must be greater than or equal to the split
threshold $s$.  If the CTI adjustment is not performed, then
%
\begin{eqnarray}
c'_{i} = 1 & {\rm if} & {\rm PHAS}[i] \ge s\ {\rm and}
\label{eqn14}
\\
c'_{i} = 0 & {\rm if} & {\rm PHAS}[i] < s.
\label{eqn15}
\end{eqnarray}
%
If the CTI adjustment is performed, then
%
\begin{eqnarray}
c'_{i} = 1 & {\rm if} & \phasadj[i] \ge s\ {\rm and}
\label{eqn16}
\\
c'_{i} = 0 & {\rm if} & \phasadj[i] < s.
\label{eqn17}
\end{eqnarray}
%

\item
If the CTI adjustment is not performed, the amount of charge in the outer
eight pixels of the 3 pixel by 3 pixel event island must not exceed the
amount of charge in the central pixel of the event island.  For some of the
pixels, the appropriate inequality is ``$\le$.''  For others, it is ``$<$''
(Fig~\ref{fig3}).  If the index number for a pixel ($i$ in the left-hand
side of Fig.~\ref{fig1}) is in the range 0--3, then
%
\begin{eqnarray}
c'_{i} = 1 & {\rm if} & {\rm PHAS}[i] \le p_{\rm c}\ {\rm and}
\label{eqn18}
\\
c'_{i} = 0 & {\rm if} & {\rm PHAS}[i] > p_{\rm c},
\label{eqn19}
\end{eqnarray}
%
where $p_{\rm c} = {\rm PHAS}[4]$ is the amount of charge in the central
pixel.  If the index number for a pixel is in the range 5--8, then
%
\begin{eqnarray}
c'_{i} = 1 & {\rm if} & {\rm PHAS}[i] < p_{\rm c}\ {\rm and}
\label{eqn20}
\\
c'_{i} = 0 & {\rm if} & {\rm PHAS}[i] \ge p_{\rm c}.
\label{eqn21}
\end{eqnarray}
%
If the CTI adjustment is performed, the outer eight pixels of the 3 pixel by
3 pixel event island may have more charge than the central pixel of the
event island.

\item
One or more of the corner pixels of a 3 pixel by 3 pixel event island is
included in the computation of PHA if the pixel satisfies the appropriate
set of criteria.  There are four possible sets of criteria.  The set of
criteria used during processing can be determined from the value of the
keyword CORNERS in the header of the event data file.  The range of possible
values for corners is from $-$1 to $+$2 inclusive.  The default value is 2.
\begin{itemize}

\item
If ${\rm CORNERS} = -1$, none of the corner pixels is included in the
computation of PHA.

\item
If ${\rm CORNERS} = 0$, all of the corner pixels may be included.

\item
If ${\rm CORNERS} = 1$, a corner pixel may be included in the computation of
PHA if one or both of the adjacent outer eight pixels satisfies
Equations~\ref{eqn14} and \ref{eqn18} (if the CTI adjustment is not applied)
or Equation~\ref{eqn16} (if the CTI adjustment is applied).  This set of
criteria is displayed for each of the corner pixels in Figure~\ref{fig4}.
\item
If ${\rm CORNERS} = 2$, a corner pixel may be included in the computation of
PHA if both of the adjacent outer eight pixels satisfy Equations~\ref{eqn14}
and \ref{eqn18} (if the CTI adjustment is not applied) or Equation~\ref{eqn16}
(if the CTI adjustment is applied).  This set of criteria is displayed for
each of the corner pixels in Figure~\ref{fig5}.  Furthermore, the value of
GRADE for the event must be 6 (instead of 7).

\end{itemize}

\end{enumerate}

\begin{figure}[h]
  \hfil
  \hbox{\epsfig{file=figs/memo_fltgrade_grade_pha_fig4.eps,width=5.89in}}
  \hfil
  %
  \caption{If ${\rm CORNERS} = 1$, a corner pixel may be included in the
    computation of PHA if it satisfies the criteria displayed in this
    figure. The left-hand figure is appropriate if the CTI adjustment is not
    applied. Here, $p_{i} = {\rm PHAS}[i]$.  The right-hand figure is
    appropriate if the CTI adjustment is applied.  In this case, $p_{i} =
    \phasadj[i]$.  Note that the inequalities vary from one corner pixel to
    the next. \label{fig4}}
  %
\end{figure}

\begin{figure}[h]
  \hfil
  \hbox{\epsfig{file=figs/memo_fltgrade_grade_pha_fig5.eps,width=5.89in}}
  \hfil
  %
  \caption{If ${\rm CORNERS} = 2$, a corner pixel may be included in the
    computation of PHA if it satisfies the criteria displayed in this
    figure. The left-hand figure is appropriate if the CTI adjustment is not
    applied. Here, $p_{i} = {\rm PHAS}[i]$.  The right-hand figure is
    appropriate if the CTI adjustment is applied.  In this case, $p_{i} =
    \phasadj[i]$.  Note that the inequalities vary from one pixel to the
    next. \label{fig5}}
  %
\end{figure}
%
In summary, if the CTI adjustment is not performed and Equations~\ref{eqn14}
and \ref{eqn18} or \ref{eqn20} are satisfied and the appropriate set of
criteria for the corner pixels is satisfied for a given pixel, the value of
$c'_{i} = 1$ for the pixel in Equation~\ref{eqn12}.  If Equation~\ref{eqn15}
or \ref{eqn19} or \ref{eqn21} hold or the appropriate set of criteria for
the corner pixels are not satisfied, then $c'_{i} = 0$ for the pixel.  If
the CTI adjustment is performed, $c'_{i} = 1$ for a pixel in
Equation~\ref{eqn13} if and only if Equation~\ref{eqn16} is true and the
appropriate set of criteria for the corner pixels is satisfied.  If
Equation~\ref{eqn17} applies or the appropriate set of criteria for the
corner pixels are not satisfied, then $c'_{i} = 0$ for the pixel.

% 5.2. Default Value of CORNERS

\subsection{Default Value of CORNERS}

The set of rules used to compute the values of PHA in standard pipeline
processing is the set of rules appropriate for ${\rm CORNERS} = 2$.  (This
set of rules is alleged to be the same as the set of rules used to compute
PHA for {\sl ASCA} SIS data.) It is possible to (re)process ACIS event data
using a different value of CORNERS. Note that the set of rules used by the
onboard flight software to compute the values PHA for graded mode
observations is the set of rules appropriate for ${\rm CORNERS} = 1$ (not
2). If the gain and response of the detectors are calibrated using data
processed with ${\rm CORNERS} = 2$, then the calibration data is
inconsistent with the values of PHA for graded mode observations.  However,
this issue may not be important since the rules used to compute PHA with
${\rm CORNERS} = 1$ and ${\rm CORNERS} = 2$ differ only for events that have
${\rm GRADE} = 5$ and 7.

\vfill

% 6. Finish

\end{document}

