\magnification=\magstep1
\baselineskip=12pt
\parskip=5pt plus1pt
\parindent=0pt
\settabs 4 \columns
\tolerance=2000

\centerline{\bf IDL Routines to correct BCS spectra for deadtime effects.}
\bigskip
\bigskip
\centerline{Dave Pike, ISAS.}
\bigskip
\bigskip

{\bf 1.0 Introduction}

The following routines calculate the factor required to
correct for the deadtime effects within the BCS
detector electronics.  Currently, there is still some debate over the best
method of determining this correction.  The routines described here allow two
of the proposed methods to be implemented.  The Fortran routine MKBSD also
applies deadtime corrections but the IDL procedures allow the quick look
data to be corrected.  This is important for the interpretation of the light
curves produced, for instance, by GS\_LC.

\bigskip
\bigskip
{\bf 2.0 Calculation of the correction factor.}
\bigskip
\bigskip

Use the procedure {\bf DT\_FACTOR} to calculate the correction factor.  This
procedure takes three mandatory and three optional parameters.  

A typical call is thus:

IDL$>$ dt\_factor, dp\_sync, roadmap, dt\_fac [, flag, stime, etime, infil]


The mandatory parameters are:

1) dp\_sync  - the dp synchronous data.  This array can be loaded by the normal
use of test\_rd or by explicit use of the procedure 

IDL$>$ rd\_bda\_dp, infil, dp\_sync     

where infil is the file name.

2) roadmap  -  the normal roadmap structure, again loaded via test\_rd or by
using

IDL$>$ rd\_roadmap, infil, roadmap

3) dt\_fac - the returned array. It has dimensions (4,nnn) where nnn is the
number of datasets in the file.  Note that even if you do not calculate the
deadtime correction for all the file, the size of the correction array  is
kept the same size so that applying the correction is simplified (ie no
troublsome offsets are involved).


The optional parameters are:

4)  a flag to indicate which kind of correction factor is to be calculated. 
There are only two options at the moment.  When type = 1, then the correction
is calculated as the LIMited/ACCepted counts for each channel.  When type = 2
then the ratio of the sum(LIMited)/sum(ACCepted) is used where the summation is
over channels 1 and 2 OR 3 and 4 for each pair of channels.

5) the time (UT) of the dataset at which the correction is to start.

6) the time (UT) of the dataset at which the correction is to end.

These last two parameters are provided to allow small time windows within the
data file to be corrected since calculating the correction for all the datasets
in the
large files we have at the moment is time consuming.


\bigskip
\bigskip
{\bf 3.0 Displaying the correction factor.}
\bigskip
\bigskip


Purely for inspection, the correction-factor array can be plotted in a compact
form using the procedure:

IDL$>$ {\bf plot\_dtfac}, roadmap, dt\_fac, stime, etime, infil


\bigskip
\bigskip
{\bf 4.0 Applying the correction factor.}
\bigskip
\bigskip

The correction factor held in the {\bf dt\_fac} array can be applied directly
by the IDL user to the spectral data.  All the values in the bins of the j-th
dataset of the i-th channel should be multiplied by dt\_fac(i,j).

The GS routine {\bf GS\_LC} now asks whether the correction factor is
available and applies it if it is.  Note that for GS\_LC to apply the
correction it must be held in an array called dt\_fac.


\vfill\eject
\end
