\section{Criteria for an optimal pedestal extraction}

\ldots {\it In this section, the distinction is made between: 
\begin{itemize}
\item Defining the pedestal RMS as contribution
    to the extracted signal fluctuations (later used in the calibration) 
\item Defining the Pedestal Mean and RMS as the result of distributions obtained by 
    applying the extractor to pedestal runs (yielding biases and modified widths).
\item Deriving the correct probability for background fluctuations based on the extracted signal height. 
  ( including biases and modified widths).
\end{itemize}
}

\subsection{Pedestal RMS}


\vspace{1cm}
\ldots {\it  Modified email by W. Wittek from 25 Oct 2004 and 10 Nov 2004}
\vspace{1cm}

The Pedestal RMS can be completely described by the matrix

\begin{equation}
   < (P_i - <P_i>) * (P_j - <P_j>) >
\end{equation}

where $i$ and $j$ denote the $i^{th}$ and $j^{th}$ FADC slice and 
$P_i$ is the pedestal
value in slice $i$ for an event and the average $<>$ is over many events (usually 1000).
\par

By definition, the pedestal RMS is independent from the signal extractor.
Therefore, no signal extractor is needed to calculate the pedestals.

\subsection{Bias and Error}

Consider a large number of signals (FADC spectra), all with the same
integrated charge $ST$ (true signal). By applying some signal extractor
we obtain a distribution of extracted signals $SE$ (for fixed $ST$ and
fixed background fluctuations $BG$). The distribution of the quantity

\begin{equation}
X = SE-ST 
\end{equation}

has the mean $B$ and the RMS $R$

\begin{eqnarray}
   B    &=& <X> \\
   R^2  &=& <(X-B)^2>
\end{eqnarray}

One may also define

\begin{equation}
   D^2 = <(SE-ST)^2> = <(SE-ST-B + B)^2> = B^2 + R^2
\end{equation}

$B$ is the bias, $R$ is the RMS of the distribution of $X$ and $D$ is something
like the (asymmetric) error of $SE$. 
The distribution of $X$, and thus the parameters $B$ and $R$, 
depend on the size of $ST$ and the size of the background fluctuations $BG$.

\par

For the normal image cleaning, knowledge of $B$ is sufficient and the 
error $R$ should be know in order to calculate a correct background probability.
\par
Also for the model analysis $B$ and $R$ are needed, because you want to keep small
signals. 
\par
In the case of the calibration with the F-Factor methoid, 
the basic relation is:

\begin{equation}
\frac{(\Delta ST)^2}{<ST>^2} = \frac{1}{<m_{pe}>} * F^2
\end{equation}

Here $\Delta ST$ is the fluctuation of the true signal $ST$ due to the
fluctuation of the number of photo electrons. $ST$ is obtained from the
measured fluctuations of $SE$  ($RMS_{SE}$) by subtracting the fluctuation of the
extracted signal ($R$) due to the fluctuation of the pedestal.

\begin{equation}
 (\Delta ST)^2 = RMS_{SE}^2 - R^2
\end{equation}

A way to check whether the right RMS has been subtracted is to make the
Razmick plot

\begin{equation}
    \frac{(\Delta ST)^2}{<ST>^2} \quad \textit{vs.} \quad \frac{1}{<ST>}
\end{equation}

This should give a straight line passing through the origin. The slope of
the line is equal to

\begin{equation}
    c * F^2
\end{equation}

where $c$ is the photon/ADC conversion factor  $<ST>/<m_{pe}>$.

\subsection{How to retrieve Bias $B$ and Error $R$}

$R$ is in general different from the pedestal RMS. It cannot be
obtained by applying the signal extractor to pedestal events, especially 
for large signals (e.g. calibration signals).
\par
In the case of the optimum filter, $R$ can be obtained from the
fitted error of the extracted signal ($\Delta(SE)_{fitted}$), 
which one can calculate for every event. 

\vspace{1cm}
\ldots {\it Whether this statemebt is true should be checked by MC.}
\vspace{1cm}

For large signals, one would expect the bias of the extracted signal 
to be small and negligible (i.e. $<ST> \approx <SE>$).
\par

In order to get the missing information, we did the following investigations:
\begin{enumerate}
\item Determine bias $B$ and resolution $R$ from MC events with and without added noise. 
    Assuming that $R$ and $B$ are negligible for the events without noise, one can 
    get a dependency of both values from the size of the signal. 
\item Determine $R$ from the fitted error of $SE$, which is possible for the 
    fit and the digital filter. In prinicple, all dependencies can be retrieved with this 
    method.
\item Determine $R$ for low signals by applying the signal extractor to a fixed window
    of pedestal events. The background fluctuations can be simulated with different 
    levels of night sky background and the continuous light, but no signal size 
    dependency can be retrieved with the method. Its results are only valid for small 
    signals.
\end{enumerate}

\par

\subsubsection{Determine error $R$ by applying the signal extractor to a fixed window
of pedestal events}

By applying the signal extractor to pedestal events we want to
determine these parameters. There are the following possibilities:

\begin{enumerate}
\item Applying the signal extractor allowing for a possible sliding window 
    to get information about the bias $B$ (valid for low signals). 
\item Applying the signal extractor to a fixed window, to get something like 
    $R$. In the case of the digital filter, this has to be done by randomizing 
    the time slice indices.
\end{enumerate}

\vspace{1cm}
\ldots {\it This assumptions still have to proven, best mathematically!!! Wolfgang, Thomas???} 
\vspace{1cm}
\par

\begin{figure}[htp]
\centering
\includegraphics[height=0.29\textheight]{MExtractTimeAndChargeDigitalFilter_Weights_cosmics_weights.dat_Range_00_18_02_14_Run_38993_Signal_Pixel200.eps}
\caption{MExtractTimeAndChargeDigitalFilter: Distribution of extracted "pedestals"  from pedestal run with 
closed camera lids for one channel.}
\vspace{\floatsep}
\includegraphics[height=0.29\textheight]{MExtractTimeAndChargeDigitalFilter_Weights_cosmics_weights.dat_Range_00_18_02_14_Run_38995_Signal_Pixel200.eps}
\caption{MExtractTimeAndChargeDigitalFilter: Distribution of extracted "pedestals"  from pedestal run with galactic star background for one channel.}
\vspace{\floatsep}
\includegraphics[height=0.29\textheight]{MExtractTimeAndChargeDigitalFilter_Weights_cosmics_weights.dat_Range_00_18_02_14_Run_38996_Signal_Pixel200.eps}
\caption{MExtractTimeAndChargeDigitalFilter: Distribution of extracted "pedestals"  from run with 
continuous light level 100 for one channel.}
\end{figure}

\begin{figure}[htp]
\centering
\includegraphics[height=0.27\textheight]{MExtractTimeAndChargeDigitalFilter_Weights_cosmics_weights.dat_Range_00_18_02_14_Run_38993_RelMean.eps}
\caption{MExtractTimeAndChargeDigitalFilter: Relative Difference Mean Pedestal per FADC slice from pedestal run with closed camera lids}
\vspace{\floatsep}
\includegraphics[height=0.27\textheight]{MExtractTimeAndChargeDigitalFilter_Weights_cosmics_weights.dat_Range_00_18_02_14_Run_38995_RelMean.eps}
\caption{MExtractTimeAndChargeDigitalFilter: Relative Difference Mean Pedestal per FADC slice from pedestal run with galactic star background}
\vspace{\floatsep}
\includegraphics[height=0.27\textheight]{MExtractTimeAndChargeDigitalFilter_Weights_cosmics_weights.dat_Range_00_18_02_14_Run_38996_RelMean.eps}
\caption{MExtractTimeAndChargeDigitalFilter: Relative Difference Mean Pedestal per FADC slice from run with continuous light level: 100}
\end{figure}


\begin{figure}[htp]
\centering
\includegraphics[height=0.23\textheight]{MExtractTimeAndChargeDigitalFilter_Weights_cosmics_weights.dat_Range_00_18_02_14_Run_38993_RMSRelDiff.eps}
\caption{MExtractTimeAndChargeDigitalFilter: Relative Difference Pedestal RMS per FADC slice (calculated out of 2 FADC slices each) from pedestal run 
with closed camera lids for inner (left) and outer (right) pixels. An equivalent number of 2.5 FADC slices has been 
used for the normalization of the pedestal RMS. The difference amounts to about 10\%.}
\vspace{\floatsep}
\includegraphics[height=0.23\textheight]{MExtractTimeAndChargeDigitalFilter_Weights_cosmics_weights.dat_Range_00_18_02_14_Run_38995_RMSRelDiff.eps}
\caption{MExtractTimeAndChargeDigitalFilter: Relative Difference Pedestal RMS per FADC slice (calculated out of 2 FADC slices each) from pedestal run 
 with galactic star background for inner (left) and outer (right) pixels. An equivalent number of 2.5 FADC slices 
has been used for the normalization of the pedestal RMS. The difference amounts to about 4\%.}
\vspace{\floatsep}
\includegraphics[height=0.23\textheight]{MExtractTimeAndChargeDigitalFilter_Weights_cosmics_weights.dat_Range_00_18_02_14_Run_38996_RMSRelDiff.eps}
\caption{MExtractTimeAndChargeDigitalFilter: Relative Difference Pedestal RMS per FADC slice (calculated out of 2 FADC slices each) from run 
 with continuous light level: 100 for inner (left) and outer (right) pixels. An equivalent number of 2.5 FADC slices 
has been used for the normalization of the pedestal RMS. The difference amounts to about 3--5\%.} 
\end{figure}


\begin{figure}[htp]
\centering
\includegraphics[height=0.29\textheight]{MExtractTimeAndChargeSpline_Amplitude_Range_00_10_04_11_Run_38993_Signal_Pixel200.eps}
\caption{MExtractTimeAndChargeSpline with amplitude: Distribution of extracted "pedestals"  from pedestal run 
with closed camera lids for one channel.}
\vspace{\floatsep}
\includegraphics[height=0.29\textheight]{MExtractTimeAndChargeSpline_Amplitude_Range_00_10_04_11_Run_38995_Signal_Pixel200.eps}
\caption{MExtractTimeAndChargeSpline with amplitude: Distribution of extracted "pedestals"  from pedestal run 
with galactic star background for one channel.}
\vspace{\floatsep}
\includegraphics[height=0.29\textheight]{MExtractTimeAndChargeSpline_Amplitude_Range_00_10_04_11_Run_38996_Signal_Pixel200.eps}
\caption{MExtractTimeAndChargeSpline with amplitude: Distribution of extracted "pedestals"  from run with 
continuous light level: 100 for one channel.}
\end{figure}

\begin{figure}[htp]
\centering
\includegraphics[height=0.27\textheight]{MExtractTimeAndChargeSpline_Amplitude_Range_00_10_04_11_Run_38993_RelMean.eps}
\caption{MExtractTimeAndChargeSpline with amplitude: Relative Difference Mean Pedestal per FADC slice from pedestal run with closed camera lids}
\vspace{\floatsep}
\includegraphics[height=0.27\textheight]{MExtractTimeAndChargeSpline_Amplitude_Range_00_10_04_11_Run_38995_RelMean.eps}
\caption{MExtractTimeAndChargeSpline with amplitude: Relative Difference Mean Pedestal per FADC slice from pedestal run with galactic star background}
\vspace{\floatsep}
\includegraphics[height=0.27\textheight]{MExtractTimeAndChargeSpline_Amplitude_Range_00_10_04_11_Run_38996_RelMean.eps}
\caption{MExtractTimeAndChargeSpline with amplitude: Relative Difference Mean Pedestal per FADC slice from run with continuous light level: 100}
\end{figure}


\begin{figure}[htp]
\centering
\includegraphics[height=0.23\textheight]{MExtractTimeAndChargeSpline_Amplitude_Range_00_10_04_11_Run_38993_RMSRelDiff.eps}
\caption{MExtractTimeAndChargeSpline with amplitude: Relative Difference Pedestal RMS per FADC slice (calculated out of 2 FADC slices each)  from pedestal run 
with closed camera lids for inner (left) and outer (right) pixels. An equivalent number of 1 FADC slice has been 
used for the normalization of the pedestal RMS. The difference amounts to about 20\%.}
\vspace{\floatsep}
\includegraphics[height=0.23\textheight]{MExtractTimeAndChargeSpline_Amplitude_Range_00_10_04_11_Run_38995_RMSRelDiff.eps}
\caption{MExtractTimeAndChargeSpline with amplitude: Relative Difference Pedestal RMS per FADC slice (calculated out of 2 FADC slices each)  from pedestal run 
 with galactic star background for inner (left) and outer (right) pixels. An equivalent number of 1 FADC slice 
has been used for the normalization of the pedestal RMS. The difference amounts to about 25\%.}
\vspace{\floatsep}
\includegraphics[height=0.23\textheight]{MExtractTimeAndChargeSpline_Amplitude_Range_00_10_04_11_Run_38996_RMSRelDiff.eps}
\caption{MExtractTimeAndChargeSpline with amplitude: Relative Difference Pedestal RMS per FADC slice (calculated out of 2 FADC slices each)  from run 
 with continuous light level: 100 for inner (left) and outer (right) pixels. An equivalent number of 1 FADC slice 
has been used for the normalization of the pedestal RMS. The difference amounts to about 25\%.} 
\end{figure}


\vspace{1cm}
\ldots{\it More test plots can be found under: 
http://magic.ifae.es/$\sim$markus/ExtractorPedestals/ }
\vspace{1cm}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "MAGIC_signal_reco"
%%% TeX-master: "MAGIC_signal_reco"
%%% TeX-master: "MAGIC_signal_reco"
%%% TeX-master: "MAGIC_signal_reco."
%%% TeX-master: "MAGIC_signal_reco"
%%% End: 
