Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 5832)
+++ trunk/MagicSoft/Mars/Changelog	(revision 5833)
@@ -21,4 +21,9 @@
                                                  -*-*- END OF LINE -*-*-
 
+ 2005/01/14 Markus Gaug
+
+   * msignal/MExtractTimeAndChargeDigitalFilter.cc
+     - added a small acceleration of the program, tested by Hendrik and
+       me.
 
  2005/01/14 Thomas Bretz
Index: trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.cc	(revision 5832)
+++ trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.cc	(revision 5833)
@@ -246,8 +246,8 @@
 
   Int_t range = fHiGainLast - fHiGainFirst + 1;
+  Int_t  maxpos = 0;
   
   const Byte_t *end = ptr + range;
   Byte_t *p     = ptr;
-  Byte_t maxpos = 0;
   Byte_t max    = 0;
 
@@ -309,5 +309,5 @@
   if (sat > 0)
     return;
-
+  
   //
   // Slide with a window of size fWindowSizeHiGain over the sample 
@@ -327,4 +327,21 @@
     }
   
+  dtime = 1.0;
+  const Int_t uplim = range-fWindowSizeHiGain+1;
+
+  if (maxpos > uplim)
+    {
+      time = uplim+1;
+      return;
+    }
+  
+  maxpos -= 3;
+  
+  if (maxpos < 0)
+    {
+      time = 0.;
+      return;
+    }
+      
   Float_t time_sum  = 0.;
   Float_t fmax      = 0.;
@@ -333,7 +350,7 @@
   
   //
-  // Calculate the sum of the first fWindowSize slices
-  //
-  for (Int_t i=0;i<range-fWindowSizeHiGain+1;i++)
+  // Perform first only 3 temptative calculations around the maximum!
+  //
+  for (Int_t i=maxpos; i<maxpos+fWindowSizeHiGain+3;i++)
     {
       sum      = 0.;
@@ -358,5 +375,5 @@
 	max_p     = i;
       }
-    } /*   for (Int_t i=0;i<range-fWindowSizeHiGain+1;i++) */
+    } /*   for (Int_t i=maxpos;i<maxpos+fWindowSizeHiGain+3;i++) */
 
   time = 0;
@@ -419,7 +436,4 @@
   const Byte_t *end = ptr + range;
   Byte_t *p     = ptr;
-  Byte_t maxpos = 0;
-  Byte_t max    = 0;
-
   //
   // Prepare the low-gain pedestal
@@ -438,10 +452,4 @@
     {
       *sample++ = (Float_t)*p - pedmean[(ids++ + abflag) & 0x1];
-
-      if (*p > max)
-        {
-          max    = *p;
-          maxpos =  p-ptr;
-        }
 
       if (*p++ >= fSaturationLimit)
