Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 7894)
+++ trunk/MagicSoft/Mars/Changelog	(revision 7895)
@@ -18,4 +18,20 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2006/08/21 Thomas Bretz
+
+   * msignal/MExtractTimeAndChargeDigitalFilter.[h,cc]:
+     - there are three cases in which the digital filter algorithm
+       cannot run to the end (eg. division by zero). For this cases
+       more correct return values are set.
+     - made sure that the fHiGainFirst is not added a second time
+       through fTimeShiftHiGain
+     - made sure that the case is handled correctly in which the sliding
+       DF either couldn't slide at all or the maximum is below zero
+
+   * msignal/MExtractTimeAndChargeSpline.[h,cc]:
+     - made sure that dsum is always set correctly
+
+
+
  2006/08/20 Thomas Bretz
 
Index: trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.cc	(revision 7894)
+++ trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.cc	(revision 7895)
@@ -239,5 +239,5 @@
     // here for speed reason. The low-gain has a changing extraction offset,
     // so it will be added at every event (in FindTimeAndChargeLoGain)
-    fTimeShiftHiGain = 0.5 + 1./fBinningResolutionHiGain + fHiGainFirst;
+    fTimeShiftHiGain = 0.5 + 1./fBinningResolutionHiGain;
     fTimeShiftLoGain = 0.5 + 1./fBinningResolutionLoGain;
 
@@ -404,7 +404,7 @@
   
   Float_t time_sum  = 0.;
-  Float_t fmax      = 0.;
+  Float_t fmax      = -FLT_MAX;
   Float_t ftime_max = 0.;
-  Int_t   max_p     = 0;
+  Int_t   max_p     = -1;
   
   //
@@ -436,6 +436,21 @@
     } /*   for (Int_t i=0;i<range-fWindowSizeHiGain+1;i++) */
 
+  if (max_p<0)
+  {
+      sum = 0;
+      time = -1;
+      dsum = -1;
+      dtime = -1;
+      return;
+  }
+
   if (fmax==0)
+  {
+      sum = 0;
+      time = -1;
+      dsum = 0;
+      dtime = 0;
       return;
+  }
 
   ftime_max        /= fmax;
@@ -479,5 +494,10 @@
 
   if (sum == 0)
+  {
+      time = -1;
+      dsum = 0;
+      dtime = 0;
       return;
+  }
 
   // here, the first high-gain slice is already included in the fTimeShiftHiGain
@@ -544,7 +564,7 @@
 
   Float_t time_sum  = 0.;
-  Float_t fmax      = 0.;
+  Float_t fmax      = -FLT_MAX;
   Float_t ftime_max = 0.;
-  Int_t   max_p     = 0;
+  Int_t   max_p     = -1;
   
   //
@@ -576,7 +596,21 @@
     } /*   for (Int_t i=0;i<range-fWindowSizeLoGain+1;i++) */
 
-  time = 0;
+  if (max_p<0)
+  {
+      sum = 0;
+      time = -1;
+      dsum = -1;
+      dtime = -1;
+      return;
+  }
+
   if (fmax==0)
+  {
+      sum = 0;
+      time = -1;
+      dsum = 0;
+      dtime = 0;
       return;
+  }
 
   ftime_max        /= fmax;
@@ -617,5 +651,10 @@
 
   if (sum == 0)
+  {
+      time = -1;
+      dsum = 0;
+      dtime = 0;
       return;
+  }
 
   time = max_p + fTimeShiftLoGain + (Float_t)fLoGainFirst /* this shifts the time to the start of the rising edge */
Index: trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSpline.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSpline.cc	(revision 7894)
+++ trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSpline.cc	(revision 7895)
@@ -374,4 +374,5 @@
 
   sat = 0;
+  dsum = 0; // In all cases the extracted signal is valid
 
   const Float_t pedes  = ped.GetPedestal();
@@ -741,4 +742,6 @@
   Int_t  max    = -9999;
 
+  dsum = 0; // In all cases the extracted signal is valid
+
   //
   // Check for saturation in all other slices
