Index: /trunk/Mars/mcore/DrsCalib.h
===================================================================
--- /trunk/Mars/mcore/DrsCalib.h	(revision 12945)
+++ /trunk/Mars/mcore/DrsCalib.h	(revision 12946)
@@ -155,4 +155,5 @@
     }
 
+
     static void ApplyCh(float *vec, const int16_t *val, int16_t start, uint32_t roi,
                         const int32_t *offset, const uint32_t scaleabs,
@@ -229,4 +230,53 @@
                     p[i] = (p[i-1]+p[i+2])/2;
                     p[i+1] = p[i];
+                }
+            }
+        }
+    }
+
+    static void RemoveSpikes2(float *vec, uint32_t roi)//from Werner
+    {
+        if (roi<4)
+            return;
+
+        for (size_t ch=0; ch<1440; ch++)
+        {
+            float *p = vec + ch*roi;
+
+            std::vector<float> Ameas(p, p+roi);
+
+            std::vector<float> N1mean(roi);
+            for (size_t i=2; i<roi-2; i++)
+            {
+                N1mean[i] = (p[i-1] + p[i+1])/2.;
+            }
+
+            const float fract = 0.8;
+            float x, xp, xpp;
+
+            for (size_t i=0; i<roi-3; i++)
+            {
+                x = Ameas[i] - N1mean[i];
+                if ( x > -5.)
+                    continue;
+
+                xp  = Ameas[i+1] - N1mean[i+1];
+                xpp = Ameas[i+2] - N1mean[i+2];
+
+                if(Ameas[i+2] - (Ameas[i] + Ameas[i+3])/2. > 10.)
+                {
+                    p[i+1]=(Ameas[i] + Ameas[i+3])/2.;
+                    p[i+2]=(Ameas[i] + Ameas[i+3])/2.;
+
+                    i += 3;
+
+                    continue;
+                }
+                if ( (xp > -2.*x*fract) && (xpp < -10.) )
+                {
+                    p[i+1] = N1mean[i+1];
+                    N1mean[i+2] = (Ameas[i+1] - Ameas[i+3] / 2.);
+
+                    i += 2;
                 }
             }
@@ -622,5 +672,5 @@
         {
             std::ostringstream msg;
-            msg << "Could not open file " << str << ": " << strerror(errno);
+            msg << "Could not open file '" << str << "': " << strerror(errno);
             return msg.str();
         }
@@ -629,5 +679,5 @@
         {
             std::ostringstream msg;
-            msg << "Reading " << str << " failed: Not a valid FACT file (TELESCOP not FACT in header)";
+            msg << "Reading '" << str << "' failed: Not a valid FACT file (TELESCOP not FACT in header)";
             return msg.str();
         }
@@ -636,5 +686,5 @@
         {
             std::ostringstream msg;
-            msg << "Reading " << str << " failed: Is not a DRS calib file (STEP not found in header)";
+            msg << "Reading '" << str << "' failed: Is not a DRS calib file (STEP not found in header)";
             return msg.str();
         }
@@ -643,5 +693,5 @@
         {
             std::ostringstream msg;
-            msg << "Reading " << str << " failed: Number of rows in table is not 1.";
+            msg << "Reading '" << str << "' failed: Number of rows in table is not 1.";
             return msg.str();
         }
