Index: /trunk/Mars/mcore/DrsCalib.h
===================================================================
--- /trunk/Mars/mcore/DrsCalib.h	(revision 12068)
+++ /trunk/Mars/mcore/DrsCalib.h	(revision 12069)
@@ -378,20 +378,23 @@
     }
 
-    static void GetPixelMax(float *ptr, const float *data, uint16_t roi, int32_t first, int32_t last)
-    {
-        if (roi==0 || first>=roi || last>=roi || last<first)
+    static void GetPixelMax(float *max, const float *data, uint16_t roi, int32_t first, int32_t last)
+    {
+        if (roi==0 || first<0 || last<0 || first>=roi || last>=roi || last<first)
             return;
 
         for (int i=0; i<1440; i++)
         {
-            const float *vec = data+i*roi;
-
-            float &max = ptr[i];
-
-            max = vec[first];
-            for (int j=first+1; j<=last; j++)
-                if (vec[j]>max)
-                    max = vec[j];
-        }
+            const float *beg = data+i*roi+first;
+            const float *end = data+i*roi+last;
+
+            const float *pmax = beg;
+
+            for (const float *ptr=beg+1; ptr<=end; ptr++)
+                if (*ptr>*pmax)
+                    pmax = ptr;
+
+            max[i] = *pmax;
+        }
+
     }
 
