Index: trunk/MagicSoft/TDAS-Extractor/Algorithms.tex
===================================================================
--- trunk/MagicSoft/TDAS-Extractor/Algorithms.tex	(revision 5272)
+++ trunk/MagicSoft/TDAS-Extractor/Algorithms.tex	(revision 5276)
@@ -145,4 +145,106 @@
 This extractor is implemented in the MARS-class {\textit{MExtractTimeAndChargeDigitalFilter}}.
 
+
+The goal of the digital filtering method \cite{OF94,OF99,OF_original} is to optimally reconstruct the amplitude and time origin of a signal with a known signal shape from discrete measurements of the signal. Thereby the noise contribution to the amplitude reconstruction is minimized.
+
+For the digital filtering method two assumptions have to be made:
+
+\begin{itemize}
+\item{The normalized signal shape has to be independent of the signal amplitude.}
+\item{The noise properties have to be independent of the signal amplitude.}
+\end{itemize}
+
+Let $g(t)$ be the normalized signal shape, $E$ the signal amplitude and $\tau$ the time shift of the physical signal from the predicted signal shape. Then the time dependence of the signal, $y(t)$, is given by:
+
+\begin{equation}
+y(t)=E \cdot  g(t-\tau) + b(t) \ ,
+\end{equation}
+
+where $b(t)$ is the time dependent noise distribution. For small time shifts $\tau$ the time dependence can be linearized by the use of a Taylor expansion:
+
+\begin{equation} \label{shape_taylor_approx}
+y(t)=E \cdot  g(t) - E\tau \cdot  \dot{g}(t) + b(t) \ ,
+\end{equation}
+
+where $\dot{g}(t)$ is the time derivative of the signal shape. Discrete
+measurements $y_i$ of the signal at times $t_i \ (i=1,...,n)$ have the form:
+
+\begin{equation}
+y_i=E \cdot g_i- E\tau \cdot \dot{g}_i +b_i \ .
+\end{equation}
+
+The correlation of the noise contributions at times $t_i$ and $t_j$ is expressed in the noise autocorrelation matrix $\boldsymbol{B}$:
+
+\begin{equation}
+\boldsymbol{B_{ij}} = \langle b_i b_j \rangle - \langle b_i \rangle \langle b_j
+\rangle  \ .
+\end{equation}
+%\equiv \langle b_i b_j \rangle with $\langle b_i \rangle = 0$.
+
+The signal amplitude, $E$, and the product of amplitude and time shift, $E \tau$, can be estimated from the given set of
+measurements $\boldsymbol{y} = (y_1, ... ,y_n)$ by minimizing:
+
+\begin{eqnarray}
+\chi^2(E, E\tau) &=& \sum_{i,j}(y_i-E g_i-E\tau \dot{g}_i) \boldsymbol{B}^{-1}_{ij} (y_j - E g_j-E\tau \dot{g}_i) \\
+&=& (\boldsymbol{y} - E
+\boldsymbol{g} - E\tau \dot{\boldsymbol{g}})^T \boldsymbol{B}^{-1} (\boldsymbol{y} - E \boldsymbol{g}- E\tau \dot{\boldsymbol{g}}) \ ,
+\end{eqnarray}
+
+where the last expression is matricial. The minimum is obtained for:
+
+\begin{equation}
+\frac{\partial \chi^2(E, E\tau)}{\partial E} = 0 \qquad \text{and} \qquad \frac{\partial \chi^2(E, E\tau)}{\partial(E\tau)} = 0 \ .
+\end{equation}
+
+This leads to the following two equations for the estimated amplitude $\overline{E}$ and the estimation for the product of amplitude and time offset $\overline{E\tau}$:
+
+\begin{eqnarray}
+0&=&-\boldsymbol{g}^T\boldsymbol{B}^{-1}\boldsymbol{y}+\boldsymbol{g}^T\boldsymbol{B}^{-1}\boldsymbol{g}\overline{E}+\boldsymbol{g}^T\boldsymbol{B}^{-1}\dot{\boldsymbol{g}}\overline{E\tau} 
+\\
+0&=&-\dot{\boldsymbol{g}}^T\boldsymbol{B}^{-1}\boldsymbol{y}+\dot{\boldsymbol{g}}^T\boldsymbol{B}^{-1}\boldsymbol{g}\overline{E}+\dot{\boldsymbol{g}}^T\boldsymbol{B}^{-1}\dot{\boldsymbol{g}}\overline{E\tau} \ .
+\end{eqnarray}
+
+Solving these equations one gets the solutions:
+
+\begin{equation}
+\overline{E}= \boldsymbol{w}_{\text{amp}}^T \boldsymbol{y} \quad \mathrm{with} \quad \boldsymbol{w}_{\text{amp}} = \frac{ (\dot{\boldsymbol{g}}^T\boldsymbol{B}^{-1}\dot{\boldsymbol{g}}) \boldsymbol{B}^{-1} \boldsymbol{g} -(\boldsymbol{g}^T\boldsymbol{B}^{-1}\dot{\boldsymbol{g}})  \boldsymbol{B}^{-1} \dot{\boldsymbol{g}}}  {(\boldsymbol{g}^T \boldsymbol{B}^{-1} \boldsymbol{g})(\dot{\boldsymbol{g}}^T\boldsymbol{B}^{-1}\dot{\boldsymbol{g}}) -(\dot{\boldsymbol{g}}^T\boldsymbol{B}^{-1}\boldsymbol{g})^2 } \ ,
+\end{equation}
+
+\begin{equation}
+\overline{E\tau}= \boldsymbol{w}_{\text{time}}^T \boldsymbol{y} \quad \mathrm{with} \quad \boldsymbol{w}_{\text{time}} = \frac{ ({\boldsymbol{g}}^T\boldsymbol{B}^{-1}{\boldsymbol{g}}) \boldsymbol{B}^{-1} \dot{\boldsymbol{g}} -(\boldsymbol{g}^T\boldsymbol{B}^{-1}\dot{\boldsymbol{g}})  \boldsymbol{B}^{-1} {\boldsymbol{g}}}  {(\boldsymbol{g}^T \boldsymbol{B}^{-1} \boldsymbol{g})(\dot{\boldsymbol{g}}^T\boldsymbol{B}^{-1}\dot{\boldsymbol{g}}) -(\dot{\boldsymbol{g}}^T\boldsymbol{B}^{-1}\boldsymbol{g})^2 } \ .
+\end{equation}
+
+
+Thus $\overline{E}$ and $\overline{E\tau}$ are given by a weighted sum of the discrete measurements $y_i$ with the digital filtering weights for the amplitude, $w_{\text{amp},i}$, and time shift, $w_{\text{time},i}$.
+
+Because of the truncation of the Taylor series in equation (\ref{shape_taylor_approx}) the above results are only valid for vanishing time offsets $\tau$. For non-zero time offsets one has to iterate the problem using the time shifted signal shape $g(t-\tau)$.
+
+The covariance matrix $\boldsymbol{V}$ of $\overline{E}$ and $\overline{E\tau}$ is given by:
+
+\begin{equation}
+\boldsymbol{V}^{-1}=\frac{1}{2}\left(\frac{\partial^2 \chi^2(E, E\tau)}{\partial \alpha_i \partial \alpha_j} \right) \quad \text{with} \quad \alpha_i,\alpha_j \in [E, E\tau] \ .
+\end{equation}
+
+The expected contribution of the noise to the estimated amplitude, $\sigma_E$, is:
+
+\begin{equation}\label{of_noise}
+\sigma_E^2=\frac{\dot{\boldsymbol{g}}^T\boldsymbol{B}^{-1}\dot{\boldsymbol{g}}}{(\boldsymbol{g}^T \boldsymbol{B}^{-1} \boldsymbol{g})(\dot{\boldsymbol{g}}^T\boldsymbol{B}^{-1}\dot{\boldsymbol{g}}) -(\dot{\boldsymbol{g}}^T\boldsymbol{B}^{-1}\boldsymbol{g})^2} \ .
+\end{equation}
+
+In the case of an uncorrelated noise with zero mean the noise autocorrelation matrix is:
+
+\begin{equation}
+\boldsymbol{B}_{ij}= \langle b_i b_j \rangle \delta_{ij} = \sigma^2(b_i) \ ,
+\end{equation}
+
+where $\sigma(b_i)$ is the standard deviation of the noise of the discrete measurements. Equation (\ref{of_noise}) than becomes:
+
+
+\begin{equation}
+\frac{\sigma^2(b_i)}{\sigma_E^2} = \sum_{i=1}^{n}{g_i^2} - \frac{\sum_{i=1}^{n}{g_i \dot{g}_i}}{\sum_{i=1}^{n}{\dot{g}_i^2}} \ .
+\end{equation}
+
+
+
 \ldots {\it Hendrik ... }
 
Index: trunk/MagicSoft/TDAS-Extractor/Changelog
===================================================================
--- trunk/MagicSoft/TDAS-Extractor/Changelog	(revision 5272)
+++ trunk/MagicSoft/TDAS-Extractor/Changelog	(revision 5276)
@@ -20,4 +20,8 @@
                                                  -*-*- END OF LINE -*-*-
 
+2004/10/14: Hendrik Bartko
+  * inserted some theory about the digital filter, could in principle
+    be moved to an appendix
+
 2004/10/13: Hendrik Bartko
   * MAGIC_signal_reco.tex: uncommented the \citesort command
