Index: trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc	(revision 2233)
+++ trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc	(revision 2237)
@@ -263,9 +263,14 @@
 
 #include "MParList.h"
+#include "MSigmabar.h"
+
 #include "MGeomPix.h"
 #include "MGeomCam.h"
+
 #include "MCerPhotPix.h"
 #include "MCerPhotEvt.h"
-#include "MSigmabar.h"
+
+#include "MPedestalPix.h"
+#include "MPedestalCam.h"
 
 #include "MGGroupFrame.h" // MGGroupFrame
@@ -328,14 +333,14 @@
         MCerPhotPix &pix = (*fEvt)[i];
 
-        const Int_t id = pix.GetPixId();
-
-        const Float_t  entry = pix.GetNumPhotons();
-        const Float_t  noise = pix.GetErrorPhot();
-
-	//
+        const Int_t idx = pix.GetPixId();
+
+        const Float_t entry = pix.GetNumPhotons();
+        const Float_t noise = (*fPed)[idx].GetSigma();
+
+        //
 	// We calculate a correction factor which accounts for the 
 	// fact that pixels have different size (see TDAS 02-14).
 	//
-        const Double_t factor = TMath::Sqrt(fCam->GetPixRatio(id));
+        const Double_t factor = TMath::Sqrt(fCam->GetPixRatio(idx));
 
         // COBB: '<=' to skip entry=noise=0
@@ -485,11 +490,11 @@
     // get pixel id of this entry
     //
-    const Int_t id = pix.GetPixId();
+    const Int_t idx = pix.GetPixId();
 
     //
     // check the num of photons against the noise level
     //
-    const Float_t  entry = pix.GetNumPhotons();
-    const Float_t  noise = pix.GetErrorPhot();
+    const Float_t entry = pix.GetNumPhotons();
+    const Float_t noise = (*fPed)[idx].GetSigma();
 
     //
@@ -497,5 +502,5 @@
     // fact that pixels have different size (see TDAS 02-14).
     //
-    const Double_t factor = TMath::Sqrt(fCam->GetPixRatio(id));
+    const Double_t factor = TMath::Sqrt(fCam->GetPixRatio(idx));
 
     return (entry * factor <= fCleanLvl2 * noise);
@@ -653,12 +658,21 @@
     }
 
-    if (fCleaningMethod != kDemocratic)
-        return kTRUE;
-
-    fSgb = (MSigmabar*)pList->FindObject("MSigmabar");
-    if (!fSgb)
-    {
-        *fLog << dbginf << "MSigmabar not found... aborting." << endl;
-        return kFALSE;
+    if (fCleaningMethod == kDemocratic)
+    {
+        fSgb = (MSigmabar*)pList->FindObject("MSigmabar");
+        if (!fSgb)
+        {
+            *fLog << dbginf << "MSigmabar not found... aborting." << endl;
+            return kFALSE;
+        }
+    }
+    else
+    {
+        fPed = (MPedestalCam*)pList->FindObject("MPedestalCam");
+        if (!fPed)
+        {
+            *fLog << dbginf << "MPedestalCam not found... aborting." << endl;
+            return kFALSE;
+        }
     }
 
@@ -674,8 +688,19 @@
     if (fSgb)
         fInnerNoise = fSgb->GetSigmabarInner();
-
+#ifdef DEBUG
+    *fLog << all << "CleanStep 1" << endl;
+#endif
     CleanStep1();
+#ifdef DEBUG
+    *fLog << all << "CleanStep 2" << endl;
+#endif
     CleanStep2();
+#ifdef DEBUG
+    *fLog << all << "CleanStep 3" << endl;
+#endif
     CleanStep3();
+#ifdef DEBUG
+    *fLog << all << "Done." << endl;
+#endif
 
     return kTRUE;
Index: trunk/MagicSoft/Mars/mimage/MImgCleanStd.h
===================================================================
--- trunk/MagicSoft/Mars/mimage/MImgCleanStd.h	(revision 2233)
+++ trunk/MagicSoft/Mars/mimage/MImgCleanStd.h	(revision 2237)
@@ -10,4 +10,5 @@
 class MCerPhotPix;
 class MCerPhotEvt;
+class MPedestalCam;
 
 class MGGroupFrame;
@@ -22,7 +23,8 @@
 
 private:
-    const MGeomCam    *fCam;  //!
-          MCerPhotEvt *fEvt;  //!
-	  MSigmabar   *fSgb;  //!
+    const MGeomCam     *fCam;  //!
+          MCerPhotEvt  *fEvt;  //!
+          MSigmabar    *fSgb;  //!
+          MPedestalCam *fPed;  //!
 
     CleaningMethod_t fCleaningMethod;
