# l3gain -- fits avalanche gain of L3CCD

**l3gain** works out the avalanche gain given a frame with at most one real count per pixel
(just a bias will often do because of CICs). It takes a histogram and then fits with an exponential
(straight line to the log), with the gradient returning the gain. This is based upon the principle
that given a single photon input, the avalanche gain system has an output probability distribution
closely approximated by (1/g)*exp(-c/g) (above the bias level). Thus the distribution for a low counts
CCD will consist of a weighted sum of the single electron pixels plus the zero electron pixels, the latter
leading to a peak around the bias level spread by normal read noise. We can therefore deduce the gain by making
a straight line fit to the log(histogram) as long as we exclude the zero electron events. This routine does
so somewhat crudely by asking the user to specify the range of count levels over which to fit.

Pixels with more than one electron are likely to cause problems. These lead to a distribution which is the convolution of
two single electron distributions. This will lead to a slower fall-off at high count levels than expected which
could be mis-interpreted as a larger gain than is really the case. The best test data therefore will be dominated
by zero electron pixels. Deviations from lineraity of the plot produced by this routine in the sense of a decrease in the
slope at high count levels is an indication of this problem. A more sophisticated treatment could take this into account.

**NB** This script requires that you have installed the program **ponto** and have defined
environment variables PONTO pointing to the program and ULTRACAM pointing to the directory of
ULTRACAM executables.

## Arguments:

*x1* | --- | The left-hand X limit of the fit. Should exclude the zero electron pixels. If you have not a clue
of a good value, then run stats with window=ALL |

*x1* | --- | The right-hand X-limit of the fit. Large enough to get a decent change without including values
with enormous errors. |

*nbin* | --- | Number of histogram bins to use from x1 to x2 |

*image1, image2 etc* | --- | the test images. Use lots to build up statistics. These are sent to the 'hist' program
which can handle them fairly quickly. |

## Classes

This command is a member of the classes: Observing, Scripts, Spectra.

Author: T.R.Marsh

Created: 22 November 2006

Revised: 23 November 2006

Page generated Fri Jul 5 12:23:42 2013