Index: trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc	(revision 2049)
+++ trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc	(revision 2052)
@@ -285,5 +285,5 @@
 //
 MImgCleanStd::MImgCleanStd(const Float_t lvl1, const Float_t lvl2,
-                     const char *name, const char *title)
+                           const char *name, const char *title)
     : fSgb(NULL), fCleaningMethod(kStandard), fCleanLvl1(lvl1),
     fCleanLvl2(lvl2), fCleanRings(1)
@@ -324,12 +324,12 @@
         MCerPhotPix &pix = (*fEvt)[i];
 
-        const Float_t entry = pix.GetNumPhotons();
-        const Float_t noise = pix.GetErrorPhot();
-
         const Int_t id = pix.GetPixId();
+
+        const Float_t  entry = pix.GetNumPhotons();
+        const Float_t  noise = pix.GetErrorPhot();
         const Double_t ratio = TMath::Sqrt(fCam->GetPixRatio(id));
 
         // COBB: '<=' to skip entry=noise=0
-        if (entry <= fCleanLvl1 * noise / ratio)
+        if (entry * ratio <= fCleanLvl1 * noise)
             pix.SetPixelUnused();
 
@@ -366,12 +366,11 @@
         MCerPhotPix &pix = (*fEvt)[i];
 
-        const Float_t entry = pix.GetNumPhotons();
-
         const Int_t id = pix.GetPixId();
 
+        const Float_t  entry = pix.GetNumPhotons();
         const Double_t ratio = fCam->GetPixRatio(id);
 
         // COBB: '<=' to skip entry=noise=0
-        if (entry <= fCleanLvl1 * fInnerNoise / ratio)
+        if (entry * ratio <= fCleanLvl1 * fInnerNoise)
             pix.SetPixelUnused();
 
@@ -451,8 +450,8 @@
             const Int_t id2 = gpix.GetNeighbor(j);
 
-	    // when you find an used  neighbor, break the loop
+	    // when you find an used neighbor, break the loop
             if (ispixused[id2] == 1)
             {
-		hasNeighbor = kTRUE ;
+		hasNeighbor = kTRUE;
 		break;
             }
@@ -460,5 +459,5 @@
 	
 	if (hasNeighbor == kFALSE)
-	  pix.SetPixelUnused();
+            pix.SetPixelUnused();
     }
 
@@ -493,10 +492,9 @@
     // 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 = pix.GetErrorPhot();
     const Double_t ratio = TMath::Sqrt(fCam->GetPixRatio(id));
 
-    return (entry <= fCleanLvl2 * noise / ratio);
+    return (entry * ratio <= fCleanLvl2 * noise);
 }
 
@@ -517,9 +515,8 @@
     // check the num of photons against the noise level
     //
-    const Float_t entry = pix.GetNumPhotons();
-
+    const Float_t  entry = pix.GetNumPhotons();
     const Double_t ratio = fCam->GetPixRatio(id);
 
-    return (entry <= fCleanLvl2 * fInnerNoise / ratio);
+    return (entry * ratio <= fCleanLvl2 * fInnerNoise);
 }
 
@@ -583,5 +580,5 @@
 
         pix.SetRing(r);
-	    break;
+        break;
     }
 }
@@ -819,3 +816,13 @@
     }
     out << ");" << endl;
-}
+
+    if (fCleaningMethod!=kDemocratic)
+        return;
+
+    out << "   " << GetUniqueName() << ".SetMethod(MImgCleanStd::kDemocratic);" << endl;
+
+    if (fCleanRings==1)
+        return;
+
+    out << "   " << GetUniqueName() << ".SetCleanRings(" << fCleanRings << ");" << endl;
+}
Index: trunk/MagicSoft/Mars/mimage/MImgCleanStd.h
===================================================================
--- trunk/MagicSoft/Mars/mimage/MImgCleanStd.h	(revision 2049)
+++ trunk/MagicSoft/Mars/mimage/MImgCleanStd.h	(revision 2052)
@@ -62,5 +62,5 @@
     UShort_t GetCleanRings() const { return fCleanRings;}
 
-    void SetCleanRings(UShort_t r) { fCleanRings=r; }
+    void SetCleanRings(UShort_t r) { if(r==0) r=1; fCleanRings=r; }
     void SetMethod(CleaningMethod_t m) { fCleaningMethod = m; }
 
