%+
% Name:
%    memo_fltgrade_grade_pha_1.3b.tex
%
% Usage:
%    latex memo_fltgrade_grade_pha_1.3b.tex
%
% Description:
%    This document describes how the values of FLTGRADE, GRADE, and PHA are
%    computed from the central nine elements of PHAS (or PHAS_ADJ).
%
% Input:
%
% Output:
%
% Notes:
%
% History:
%    30 Nov 01, created, Glenn E. Allen
%    18 Dec 01, added section about default values of CORNERS, GEA
%    21 Dec 01, added some of Bev's comments and rewrote, GEA
%    09 Sep 02, modified header, GEA
%-

\documentclass{article}

\usepackage{cxo-memo-logo}
\usepackage[dvips]{graphics}
\usepackage{gea}
\usepackage{psfig}

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

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% 1. Header

\memobasic{
   Martin Elvis, SDS Group Leader }{
   Glenn Allen, SDS }{
   The computation of FLTGRADE, GRADE, and PHA }{
   1.3b }{
   http://space.mit.edu/CXC/docs/docs.html\#grades }{
   /nfs/cxc/h2/gea/sds/docs/memos/memo\_fltgrade\_grade\_pha\_1.3b.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 supercedes 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{\psfig{file=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{\psfig{file=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{\psfig{file=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 
an event.  The range of possible values for GRADE is 0--7 inclusive.  The 
scheme used to determine the value of the GRADE of an ACIS event is 
identical to the scheme used to assign the values of GRADE to {\sl ASCA} SIS 
events.  To date, only one scheme has been used for TIMED FAINT, TIMED VFAINT, 
and CONTINUOUS CC33\_FAINT mode observations (Table~\ref{tab1}).
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\begin{table}[h]
\begin{center}
\begin{tabular}{| c | c |}
\hline
\
   &
   \\
GRADE
   & FLTGRADE
   \\
\
   &
   \\
\hline \hline
\
   &
   \\
0
   & 0
   \\
\
   &
   \\
1
   & 1, 4, 5, 32, 33, 36, 37, 128, 129, 132, 133, 160, 161, 164, 165
   \\
\
   &
   \\
2
   & 2, 34, 64, 65, 68, 69, 130, 162
   \\
\
   &
   \\
3
   & 8, 12, 136, 140
   \\
\
   &
   \\
4
   & 16, 17, 48, 49
   \\
\
   &
   \\
5
   & 3, 6, 9, 13, 20, 21, 35, 38, 40, 44, 52, 53, 96, 97, 100, 101, 
   \\
\
   & 131, 134, 137, 141, 144, 145, 163, 166, 168, 172, 176, 177, 192, 193, 196, 197
   \\
\
   &
   \\
6
   & 10, 11, 18, 22, 50, 54, 72, 76, 80, 81, 104, 108, 138, 139, 208, 209
   \\
\
   &
   \\
7
   & 7, 14, 15, 19, 23, 24, 25, 26, 27, 28, 29, 30, 31, 39, 41, 42,
   \\
\
   & 43, 45, 46, 47, 51, 55, 56, 57, 58, 59, 60, 61, 62, 63, 66, 67,
   \\
\
   & 70, 71, 73, 74, 75, 77, 78, 79, 82, 83, 84, 85, 86, 87, 88, 89,
   \\
\
   & 90, 91, 92, 93, 94, 95, 98, 99, 102, 103, 105, 106, 107, 109, 110, 111,
   \\
\
   & 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
   \\
\
   & 135, 142, 143, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158,
   \\
\
   & 159, 167, 169, 170, 171, 173, 174, 175, 178, 179, 180, 181, 182, 183, 184, 185,
   \\
\
   & 186, 187, 188, 189, 190, 191, 194, 195, 198, 199, 200, 201, 202, 203, 204, 205,
   \\
\
   & 206, 207, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
   \\
\
   & 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
   \\
\
   & 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
   \\
\
   &
   \\
\hline
\end{tabular}
\end{center}
\caption{The mapping of FLTGRADE to GRADE.
\label{tab1}
}
\end{table}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% 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 FLTGRADE 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 or 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{\psfig{file=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{\psfig{file=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 default value of CORNERS used for standard ACIS pipeline processing has 
been two.  The corresponding set of rules to compute PHA is allegedly the 
same as the set of rules used to compute PHA for {\sl ASCA} SIS data.  
However, if a user reruns acis\_process\_events and recomputes the values of 
the GRADE of the events, the default value of CORNERS is one.  In this 
case, the corresponding set of rules used to compute PHA is the same as the 
set of rules used to compute PHA onboard for graded mode observations.  
Using ${\rm CORNERS} = 1$ will ensure that the calibration of the nongraded 
modes applies to the graded modes as well.  However, this issue may be mute 
in the sense that the events whose PHA values differ if ${\rm CORNERS} = 2$ 
instead of 1 are events whose GRADEs are either 5 or 7.

\vfill

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% 6. Finish

\end{document}
