Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 3828)
+++ trunk/MagicSoft/Mars/Changelog	(revision 3829)
@@ -19,4 +19,19 @@
                                                  -*-*- END OF LINE -*-*-
 
+ 2004/04/25: Abelardo Moralejo
+
+   * mbadpixels/MBadPixelsTreat.cc
+     - Change in line 204:    if ((*fBadPixels)[i].IsBad()) by
+       if ((*fBadPixels)[j].IsBad())   The way it was done, it never
+       worked, because the check on whether the neighbour pixels
+       were OK was performed on the same pixel to be treated (i), which 
+       is obviously not OK. The same problem fixed in the interpolation 
+       of pedestals. Amazingly, this error would have shown up in any
+       test of the class.... I assume it must have been commited 
+       completely untested.
+
+     - In InterpolateSignal: moved division of summed charge over 
+       number of pixels : put it after the check of the number of 
+       valid neighbours to avoid division by 0.
 
 
@@ -26,5 +41,4 @@
      - fixed a bug in the ReInit() for the number of average events in 
        each area index and sector
-
 
 
Index: trunk/MagicSoft/Mars/mbadpixels/MBadPixelsTreat.cc
===================================================================
--- trunk/MagicSoft/Mars/mbadpixels/MBadPixelsTreat.cc	(revision 3828)
+++ trunk/MagicSoft/Mars/mbadpixels/MBadPixelsTreat.cc	(revision 3829)
@@ -201,5 +201,5 @@
             // Do not use blind neighbors
             //
-            if ((*fBadPixels)[i].IsBad())
+            if ((*fBadPixels)[nidx].IsBad())
                 continue;
 
@@ -225,11 +225,4 @@
         }
 
-        //
-        // Now the mean is calculated and the values rescaled back
-        // to the pixel area
-        //
-	nphot[i] /= (num*ratio);
-        perr[i]   = TMath::Sqrt(perr[i]/(num*ratio));
- 
 	// Check if there are enough neighbors to calculate the mean
         // If not, unmap the pixel. The maximum number of blind neighbors
@@ -241,4 +234,11 @@
         }
 
+        //
+        // Now the mean is calculated and the values rescaled back
+        // to the pixel area
+        //
+	nphot[i] /= (num*ratio);
+        perr[i]   = TMath::Sqrt(perr[i]/(num*ratio));
+ 
         pix->Set(nphot[i], perr[i]);
     }
@@ -299,5 +299,5 @@
             // Do not use blind neighbors
             //
-            if ((*fBadPixels)[i].IsBad())
+            if ((*fBadPixels)[nidx].IsBad())
                 continue;
 
