%+
% Name:
%   deltoclk_spec_1.0.tex
%
% History:
%   2011 Jun 03, created (v1.0), Glenn E. Allen
%-

\documentclass{article}

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

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

\begin{document}

% 1. Header

\memobasic{
   Jonathan McDowell, SDS Group Leader }{
   Glenn E.\ Allen, SDS }{
   Deltoclk spec }{
   1.0 }{
   http://space.mit.edu/CXC/docs/docs.html\#deltoclk }{
   /nfs/cxc/h2/gea/sds/docs/memos/deltoclk\_spec\_1.0.tex }

% 2. Description

\section{ Description }

Occasionally the values of {\tt DELTOCLK} in exposure-records files are
anomalously high or anomalously low.  Since the values of {\tt DELTOCLK} are
used to compute the pulse heights of event data, events that are processed
using anomalous values have a {\tt STATUS} bit set to one and are discarded
from Level 2 event-data files.

% 3. Input

\section{ Input }

\begin{enumerate}

  \item
    One or more Level 0 event-data file (acis*evt0.fits)

  \item
    One or more Level 0 exposure-records file (acis*exr0.fits)

\end{enumerate}

% 4. Output

\section{ Output }

\begin{enumerate}

  \item
    An event-data file

  \item
    A Level 1 exposure statistics file (acis*stat1.fits)

\end{enumerate}

% 5. Parameters

\section{ Parameters }

\begin{enumerate}

  \item
    { \tt infile,f,a,"",,,"Name of input event-data file(s)" }

  \item
    { \tt outfile,f,a"",,,"Name of output event-data file" }

  \item
    { \tt exrfile,f,a,"",,,"Name of input exposure-records file" }

  \item
    { \tt expstatsfile,f,a,"",,,"Name of output exposure-statistics file" }

  \item
    { \tt expnowidth,i,h,5,3,1001,"Number of frames in the sliding time
    window" }

  \item
    { \tt deltoclkthresh,i,h,6,1,4096,"Minimum offset for anomalous
    DELTOCLKs" } 

\end{enumerate}

% 6. Processing

\section{ Processing }

The tool {\tt acis\_format\_events} includes the following processing
steps. 
%
\begin{enumerate}

  \item
    Verify that the {\tt infile} and {\tt exrfile} exist.
    %
    If {\tt clobber=no}, then verify that the {\tt outfile} and {\tt
    expstatsfile} do not exist. 
    %
    Verify that the values of the parameters {\tt expnowidth} and {\tt
    deltoclkthresh} are in the valid ranges for these parameters. 
    %
    Note that {\tt expnowidth} must be an odd number.

  \item
    For each node of each CCD of each frame $i$ of data, compute the median
    value $M_{i}$ of the {\tt DELTOCLK}s from frames $i-w$ to $i+w$ of the
    same node.  Here, $w = ( {\tt expnowidth} - 1 ) / 2$ (\ie\ there are
    {\tt expnowidth} frames in the full range).  Note that the width of the
    time window is smaller at the beginning and the end of the data.  For
    example, the appropriate range for the first and second frames of data
    are $i$ to $i+w$ and $i-1$ to $i+w$, respectively.
  
  \item
    If ${\tt DELTOCLK}_{i} \ge M_{i} + {\tt deltoclkthresh}$ or ${\tt
    DELTOCLK}_{i} \le M_{i} - {\tt deltoclkthresh}$ for a particular node,
    then set {\tt STATUS} bit 10 (of 0-31) to one for all of the events in
    frame $i$ on that node and include the {\tt EXPNO}, {\tt CCD\_ID}, and
    {\tt NODE\_ID} information in the ``BADOCLK'' HDU of the {\tt
    expstatsfile}.

\end{enumerate}

% 7. Finish

\end{document}

