Index: /fact/tools/pyscripts/pyfact/calfactfits.h
===================================================================
--- /fact/tools/pyscripts/pyfact/calfactfits.h	(revision 14486)
+++ /fact/tools/pyscripts/pyfact/calfactfits.h	(revision 14487)
@@ -225,5 +225,6 @@
 			return false;
 		}
-		else {
+		else 
+        {
 			UInt_t drs_calib_offset;
             double raw, raw_bsl, shifted;
@@ -241,5 +242,6 @@
 
                 // stolen from TBs MARS ... DrsCalib.h or something like that
-                double *p = npcaldata;
+                 double *p = npcaldata+(pixel*data_nroi);
+
                 // second loop for despiking
                 for (size_t i=1; i<data_nroi-2; i++)
@@ -247,8 +249,10 @@
                     if (p[i]-p[i-1]>25 && p[i]-p[i+1]>25)
                     {
+                        //std::cout << "single cand:\t" << pixel << "\t" << i << std::endl;
                         p[i] = (p[i-1]+p[i+1])/2;
                     }
                     if (p[i]-p[i-1]>22 && fabs(p[i]-p[i+1])<4 && p[i+1]-p[i+2]>22)
                     {
+                        //std::cout << "double cand:\t" << pixel << "\t" << i << std::endl;
                         p[i] = (p[i-1]+p[i+2])/2;
                         p[i+1] = p[i];
