Index: /trunk/MagicSoft/TDAS-Extractor/Algorithms.tex
===================================================================
--- /trunk/MagicSoft/TDAS-Extractor/Algorithms.tex	(revision 6377)
+++ /trunk/MagicSoft/TDAS-Extractor/Algorithms.tex	(revision 6378)
@@ -599,4 +599,5 @@
 \begin{equation}
 \tau=\frac{(e\tau)_{i_0^*}}{e_{i_0^*}}
+\label{eq:offsettau}
 \end{equation}
 
@@ -883,3 +884,4 @@
 %%% TeX-master: "MAGIC_signal_reco.te"
 %%% TeX-master: "MAGIC_signal_reco.te"
+%%% TeX-master: "MAGIC_signal_reco"
 %%% End: 
Index: /trunk/MagicSoft/TDAS-Extractor/Pedestal.tex
===================================================================
--- /trunk/MagicSoft/TDAS-Extractor/Pedestal.tex	(revision 6377)
+++ /trunk/MagicSoft/TDAS-Extractor/Pedestal.tex	(revision 6378)
@@ -9,56 +9,70 @@
 \par
 
-By definition, the noise autocorrelation matrix $B$ and thus the ``pedestal RMS'' 
+By definition, the $\boldsymbol{B}$ and thus the ``pedestal RMS'' 
 is independent from the signal extractor.
 
-\subsection{Bias and Error}
-
-Consider a large number of signals (FADC spectra), all with the same
-integrated charge $ST$ (true signal). By applying a signal extractor
-we obtain a distribution of extracted signals $SE$ (for fixed $ST$ and
+\subsection{Bias and Mean-squared Error}
+
+Consider a large number of same signals $S$. By applying a signal extractor
+we obtain a distribution of estimated signals $\widehat{S}$ (for fixed $S$ 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$ defined by:
+X = \widehat{S}-S 
+\end{equation}
+
+has the mean $B$ and the Variance $MSE$ defined as:
 
 \begin{eqnarray}
-   B    &=& <X> \\
-   R    &=& \sqrt{<(X-B)^2>}
+   B   \ \ \ \  = \ \ \ \ \ \ <X> \ \ \ \ \  &=& \ \ <\widehat{S}> \ -\ S\\
+   R   \ \ \ \  = \ <(X-B)^2> &=& \ Var[\widehat{S}]\\
+   MSE \      = \ \ \ \ \ <X^2> \ \ \ \  &=& \ Var[\widehat{S}] +\ B^2
 \end{eqnarray}
 
-The parameter $B$ can be called the {\textit{\bf bias}} of the pedestal extractor and $R$ 
-the RMS of the distribution of $X$ which 
-depend generally 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 known in order to calculate a correct background probability.
-\par
-Also for the model analysis, $B$ and $R$ are needed if one wants to keep small
-signals. 
+The parameter $B$ is also called the {\textit{\bf BIAS}} of the estimator and $MSE$ 
+the {\textit{\bf MEAN-SQUARED ERROR}} which combines the variance of $\widehat{S}$ and 
+the bias. Both depend generally on the size of $S$ and the background fluctuations $BG$, 
+thus: $B = B(S,BG)$ and $MSE = MSE(S,BG)$.
+
+\par
+Usually, one measures easily the parameter $R$, but needs the $MSE$ for statistical analysis (e.g. 
+in the image cleaning). 
+However, only in case of a vanishing bias $B$, the two numbers are equal. Otherwise, 
+the bias $B$ has to be known beforehand. Note that every sliding window extractor has a 
+bias, especially at low or vanishing signals $S$.
 
 \subsection{Pedestal Fluctuations as Contribution to the Signal Fluctuations}
 
-In case of the calibration with the F-Factor methoid, 
-the basic relation is:
-
-\begin{equation}
-\frac{(\Delta ST)^2}{<ST>^2} = \frac{1}{<n_{phe}>} * 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}$) subtracting those contributions to the 
-fluctuations of the
-extracted signal which are due to the fluctuation of the pedestal\footnote{%
+A photo-multiplier signal yields, to a very good approximation, the 
+following relation:
+
+\begin{equation}
+\frac{Var[Q]}{<Q>^2} = \frac{1}{<n_{phe}>} * F^2
+\end{equation}
+
+Here, $Q$ is the signal fluctuation due to the number of signal photo-electrons
+(equiv. to the signal $S$), and $Var[Q]$ the fluctuations of the true signal $Q$ 
+due to the Poisson fluctuations of the number of photo-electrons. Because of: 
+
+\begin{eqnarray}
+\widehat{Q} &=& Q + X \\
+Var(\widehat{Q}) &=& Var(Q) + Var(X) \\
+Var(Q) &=& Var(\widehat{Q}) - Var(X)
+\end{eqnarray}
+
+$Var[Q]$ can be obtained from: 
+
+\begin{eqnarray}
+Var(Q) &\approx& Var(\widehat{Q}) - Var(\widehat{Q}=0)
+\label{eq:rmssubtraction}
+\end{eqnarray}
+
+In the last line of eq.~\ref{eq:rmssubtraction}, it is assumed that $R$ does not dependent 
+on the signal height\footnote{%
 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>}
+    \frac{Var[\widehat{Q}]}{<\widehat{Q}>^2} \quad \textit{vs.} \quad \frac{1}{<\widehat{Q}>}
 \end{equation}
 
@@ -70,40 +84,88 @@
 \end{equation}
 
-where $c$ is the photon/ADC conversion factor  $<ST>/<m_{pe}>$.}.
-
-\begin{equation}
- (\Delta ST)^2 = RMS_{SE}^2 - R^2 
-\label{eq:rmssubtraction}
-\end{equation}
-
-If $R$ does not dependent on the signal height, (as it is the case 
-for the digital filter, eq.~\ref{eq:of_noise}), then one can retrieve $R$ by 
-applying the signal extractor on a {\textit{\bf fixed window}} of pedestal events.
-
-\subsection{Methods to Retrieve Bias $B$ and Errors $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 digital filter, $R$ is in theory independent from the 
-signal amplitude $ST$ and depends only on the background $BG$ (eq.~\ref{eq:of_noise}).
-It can be obtained from the
-fitted error of the extracted signal ($\Delta(SE)_{fitted}$), 
-which one can calculate for every event or by applying the extractor to a fixed window 
-of pure background events (``pedestal events'').
-
-\par
-
-In order to get the missing information, we did the following investigations:
+where $c$ is the photon/ADC conversion factor  $<Q>/<m_{pe}>$.}
+(as is the case 
+for the digital filter, eq.~\ref{eq:of_noise}). One can then retrieve $R$ 
+by applying the signal extractor to a {\textit{\bf fixed window}} of pedestal events, where the 
+bias vanishes and measure $Var[\widehat{Q}=0]$.
+
+\subsection{Methods to Retrieve Bias and Mean-Squared Error}
+
+In general, the extracted signal variance $R$ is different from the pedestal RMS. 
+It cannot be obtained by applying the signal extractor to pedestal events, because of the 
+(unknown) bias. 
+\par
+In the case of the digital filter, $R$ is expected to be independent from the 
+signal amplitude $S$ and depends only on the background $BG$ (eq.~\ref{eq:of_noise}).
+It can then be obtained from the calculation of the variance $Var[\widehat{Q}]$ 
+by applying the extractor to a fixed window of pure background events (``pedestal events'') 
+and get rid of the bias in that way. Figures~\ref{fig:amp:relmean} through~\ref{fig:df:relmean} 
+show that the bias vanishes indeed for the used extractors in this TDAS. 
+
+\begin{figure}[htp]
+\centering
+\includegraphics[height=0.3\textheight]{MExtractTimeAndChargeSpline_Amplitude_Amplitude_Range_01_09_01_10_Run_38993_RelMean.eps}
+\vspace{\floatsep}
+\includegraphics[height=0.3\textheight]{MExtractTimeAndChargeSpline_Amplitude_Amplitude_Range_01_09_01_10_Run_38995_RelMean.eps}
+\vspace{\floatsep}
+\includegraphics[height=0.3\textheight]{MExtractTimeAndChargeSpline_Amplitude_Amplitude_Range_01_09_01_10_Run_38996_RelMean.eps}
+\caption{MExtractTimeAndChargeSpline with amplitude extraction: 
+Difference in mean pedestal (per FADC slice) between extraction algorithm
+applied on a fixed window of 1 FADC slice (``extractor random'') and a simple addition of 
+2 FADC slices (``fundamental''). On the top, a run with closed camera has been taken, in the center
+ an opened camera observing an extra-galactic star field and on the bottom, an open camera being 
+illuminated by the continuous light of the calibration (level: 100). Every entry corresponds to one 
+pixel.}
+\label{fig:amp:relmean}
+\end{figure}
+
+
+\begin{figure}[htp]
+\centering
+\includegraphics[height=0.3\textheight]{MExtractTimeAndChargeSpline_Rise-and-Fall-Time_0.5_1.5_Range_01_10_02_12_Run_38993_RelMean.eps}
+\vspace{\floatsep}
+\includegraphics[height=0.3\textheight]{MExtractTimeAndChargeSpline_Rise-and-Fall-Time_0.5_1.5_Range_01_10_02_12_Run_38995_RelMean.eps}
+\vspace{\floatsep}
+\includegraphics[height=0.3\textheight]{MExtractTimeAndChargeSpline_Rise-and-Fall-Time_0.5_1.5_Range_01_10_02_12_Run_38996_RelMean.eps}
+\caption{MExtractTimeAndChargeSpline with integral over 2 slices: 
+Difference in mean pedestal (per FADC slice) between extraction algorithm
+applied on a fixed window of 2 FADC slices (``extractor random'') and a simple addition of 
+2 FADC slices (``fundamental''). On the top, a run with closed camera has been taken, in the center
+ an opened camera observing an extra-galactic star field and on the bottom, an open camera being 
+illuminated by the continuous light of the calibration (level: 100). Every entry corresponds to one 
+pixel.}
+\label{fig:int:relmean}
+\end{figure}
+
+\begin{figure}[htp]
+\centering
+\includegraphics[height=0.3\textheight]{MExtractTimeAndChargeDigitalFilter_Weights_cosmics_weights.dat_Range_01_14_02_14_Run_38993_RelMean.eps}
+\vspace{\floatsep}
+\includegraphics[height=0.3\textheight]{MExtractTimeAndChargeDigitalFilter_Weights_cosmics_weights.dat_Range_01_14_02_14_Run_38995_RelMean.eps}
+\vspace{\floatsep}
+\includegraphics[height=0.3\textheight]{MExtractTimeAndChargeDigitalFilter_Weights_cosmics_weights.dat_Range_01_14_02_14_Run_38996_RelMean.eps}
+\caption{MExtractTimeAndChargeDigitalFilter: 
+Difference in mean pedestal (per FADC slice) between extraction algorithm
+applied on a fixed window of 6 FADC slices and time-randomized weights (``extractor random'') 
+and a simple addition of 
+6 FADC slices (``fundamental''). On the top, a run with closed camera has been taken, in the center
+ an opened camera observing an extra-galactic star field and on the bottom, an open camera being 
+illuminated by the continuous light of the calibration (level: 100). Every entry corresponds to one 
+pixel.}
+\label{fig:df:relmean}
+\end{figure}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+In order to calculate bias and Mean-squared error, we proceeded in the following ways:
 \begin{enumerate}
 \item Determine $R$ 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 source, but no signal size 
-    dependency can be retrieved with the method. 
-\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 
+    dependency can be retrieved with this method. 
+\item Determine $B$ and $MSE$ from MC events with and without added noise. 
+    Assuming that $MSE$ 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 
+\item Determine $MSE$ from the fitted error of $\widehat{S}$, which is possible for the 
     fit and the digital filter (eq.~\ref{eq:of_noise}). 
     In prinicple, all dependencies can be retrieved with this method.
@@ -114,20 +176,24 @@
 
 By applying the signal extractor to a fixed window of pedestal events, we 
-determine the parameter $R$ for the case of no signal ($ST = 0$). In the case of 
-all extractors using a fixed window from the beginning (extractors nr. \#1 to \#22 
-in section~\ref{sec:algorithms}), the results are by construction the same as calculating 
-the pedestal RMS.
-\par
-In MARS, this possibility is implemented with a function-call to: \\ 
-
-{\textit{\bf MJPedestal::SetExtractionWithExtractorRndm()}}. \\
-
-In the case of the {\textit{\bf amplitude extracting spline}} (extractor nr. \#23), we placed the 
-spline maximum value (which determines the exact extraction window) at a random place 
-within the digitizing binning resolution of one central FADC slice. 
-In the case of the {\textit{\bf digital filter}} (extractor nr. \#28), the time shift was  
-randomized for each event within a fixed global extraction window.
-
-\par
+determine the parameter $R$ for the case of no signal ($Q = 0$). In the case of 
+extractors using a fixed window (extractors nr. \#1 to \#22 
+in section~\ref{sec:algorithms}), the results are the same by construction 
+as calculating the pedestal RMS.
+\par
+In MARS, this functionality is implemented with a function-call to: \\ 
+
+{\textit{\bf MJPedestal::SetExtractionWithExtractorRndm()}} and/or \\
+{\textit{\bf MExtractPedestal::SetRandomCalculation()}}\\
+
+Besides fixing the global extraction window, additionally the following steps are undertaken 
+in order to assure that the bias vanishes: 
+
+\begin{description}
+\item[\textit{MExtractTimeAndChargeSpline}:\xspace] The spline 
+maximum position -- which determines the exact extraction window -- is placed arbitrarily 
+at a random place within the digitizing binning resolution of one central FADC slice. 
+\item[{\textit{MExtractTimeAndChargeDigitalFilter}:\xspace] The second step timing 
+offset $\tau$ (eq.~\ref{eq:offsettau} gets randomized for each event. 
+\end{description}
 
 The following plots~\ref{fig:sw:distped} through~\ref{fig:amp:relrms:run38996} show results 
@@ -212,58 +278,5 @@
 
 
-\begin{figure}[htp]
-\centering
-\includegraphics[height=0.3\textheight]{MExtractTimeAndChargeSpline_Amplitude_Amplitude_Range_01_09_01_10_Run_38993_RelMean.eps}
-\vspace{\floatsep}
-\includegraphics[height=0.3\textheight]{MExtractTimeAndChargeSpline_Amplitude_Amplitude_Range_01_09_01_10_Run_38995_RelMean.eps}
-\vspace{\floatsep}
-\includegraphics[height=0.3\textheight]{MExtractTimeAndChargeSpline_Amplitude_Amplitude_Range_01_09_01_10_Run_38996_RelMean.eps}
-\caption{MExtractTimeAndChargeSpline with amplitude extraction: 
-Difference in mean pedestal (per FADC slice) between extraction algorithm
-applied on a fixed window of 1 FADC slice (``extractor random'') and a simple addition of 
-2 FADC slices (``fundamental''). On the top, a run with closed camera has been taken, in the center
- an opened camera observing an extra-galactic star field and on the bottom, an open camera being 
-illuminated by the continuous light of the calibration (level: 100). Every entry corresponds to one 
-pixel.}
-\label{fig:amp:relmean}
-\end{figure}
-
-
-\begin{figure}[htp]
-\centering
-\includegraphics[height=0.3\textheight]{MExtractTimeAndChargeSpline_Rise-and-Fall-Time_0.5_1.5_Range_01_10_02_12_Run_38993_RelMean.eps}
-\vspace{\floatsep}
-\includegraphics[height=0.3\textheight]{MExtractTimeAndChargeSpline_Rise-and-Fall-Time_0.5_1.5_Range_01_10_02_12_Run_38995_RelMean.eps}
-\vspace{\floatsep}
-\includegraphics[height=0.3\textheight]{MExtractTimeAndChargeSpline_Rise-and-Fall-Time_0.5_1.5_Range_01_10_02_12_Run_38996_RelMean.eps}
-\caption{MExtractTimeAndChargeSpline with integral over 2 slices: 
-Difference in mean pedestal (per FADC slice) between extraction algorithm
-applied on a fixed window of 2 FADC slices (``extractor random'') and a simple addition of 
-2 FADC slices (``fundamental''). On the top, a run with closed camera has been taken, in the center
- an opened camera observing an extra-galactic star field and on the bottom, an open camera being 
-illuminated by the continuous light of the calibration (level: 100). Every entry corresponds to one 
-pixel.}
-\label{fig:int:relmean}
-\end{figure}
-
-\begin{figure}[htp]
-\centering
-\includegraphics[height=0.3\textheight]{MExtractTimeAndChargeDigitalFilter_Weights_cosmics_weights.dat_Range_01_14_02_14_Run_38993_RelMean.eps}
-\vspace{\floatsep}
-\includegraphics[height=0.3\textheight]{MExtractTimeAndChargeDigitalFilter_Weights_cosmics_weights.dat_Range_01_14_02_14_Run_38995_RelMean.eps}
-\vspace{\floatsep}
-\includegraphics[height=0.3\textheight]{MExtractTimeAndChargeDigitalFilter_Weights_cosmics_weights.dat_Range_01_14_02_14_Run_38996_RelMean.eps}
-\caption{MExtractTimeAndChargeDigitalFilter: 
-Difference in mean pedestal (per FADC slice) between extraction algorithm
-applied on a fixed window of 6 FADC slices and time-randomized weights (``extractor random'') 
-and a simple addition of 
-6 FADC slices (``fundamental''). On the top, a run with closed camera has been taken, in the center
- an opened camera observing an extra-galactic star field and on the bottom, an open camera being 
-illuminated by the continuous light of the calibration (level: 100). Every entry corresponds to one 
-pixel.}
-\label{fig:df:relmean}
-\end{figure}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%1
 
 \begin{figure}[htp]
@@ -324,5 +337,5 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-Figures~\ref{fig:df:distped}
+Figures~\ref{fig:df:distped},~\ref{fig:amp:distped}
 and~\ref{fig:amp:distped} show the 
 extracted pedestal distributions for the digital filter with cosmics weights (extractor~\#28) and the 
