Index: trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc	(revision 4188)
+++ trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc	(revision 4452)
@@ -128,4 +128,5 @@
 // the terms commonly used in the class.
 //
+//
 // STANDARD CLEANING:
 // =================
@@ -165,10 +166,10 @@
 // // add the image cleaning to the main task list
 //
+//
 // DEMOCRATIC CLEANING:
 // ===================
 // You use this cleaning method when you want to compare the number of
-// photo-electons of each pixel with the average pedestal RMS
-// (fInnerNoise = fSgb->GetSigmabarInner()) of the inner pixels (for the
-// MAGIC camera they are the smaller ones):
+// photo-electons of each pixel with the average pedestal RMS of the
+// inner pixels (for the MAGIC camera they are the smaller ones):
 //Begin_Html
 //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="images/MImgCleanStd-f2.png">
@@ -178,17 +179,8 @@
 // have a different area) are compared to the same pedestal RMS, coming
 // from the inner pixels.
-// To calculate the average pedestal RMS of the inner pixels, you have to
-// add to the main task list an object of type MSigmabarCalc before the
-// MImgCleanStd object. To know how the calculation of fInnerNoise is done
-// look at the MSigmabarCalc Class.
-//
-// Example:
-//
-// MSigmabarCalc   sbcalc;
-// //creates an object that calcutates the average pedestal RMS
-// MImgCleanStd clean;
-// ...
-// tlist.AddToList(&sbcalc);
-// tlist.AddToList(&clean);
+//
+// Make sure that you used a class calculating the MPedPhotCam which also
+// updated the contents of the mean values (Recalc) correctly.
+//
 //
 // Member Function:  SetMethod()
@@ -206,4 +198,5 @@
 // clean.SetMethod(MImgCleanStd::kDemocratic);
 // //now the method of cleaning is changed to Democratic
+//
 //
 // FIRST AND SECOND CLEANING LEVEL
@@ -245,6 +238,6 @@
 //  Input Containers:
 //   MGeomCam
+//   MPedPhotCam
 //   MCerPhotEvt
-//   [MSigmabar]
 //
 //  Output Containers:
@@ -265,5 +258,4 @@
 
 #include "MParList.h"
-#include "MSigmabar.h"
 #include "MCameraData.h"
 
@@ -298,5 +290,5 @@
 MImgCleanStd::MImgCleanStd(const Float_t lvl1, const Float_t lvl2,
                            const char *name, const char *title)
-    : fSgb(NULL), fCleaningMethod(kStandard), fCleanLvl1(lvl1),
+    : fCleaningMethod(kStandard), fCleanLvl1(lvl1),
     fCleanLvl2(lvl2), fCleanRings(1)
 
@@ -358,5 +350,5 @@
 
     while ((pix=static_cast<MCerPhotPix*>(Next())))
-          {
+    {
         // get pixel id of this entry
         const Int_t idx = pix->GetPixId();
@@ -391,7 +383,8 @@
     Next.Reset();
     while ((pix=static_cast<MCerPhotPix*>(Next())))
-      {
-	if ( pix->IsPixelUsed())
-        pix->SetPixelCore();}
+    {
+	if (pix->IsPixelUsed())
+            pix->SetPixelCore();
+    }
 } 
 
@@ -434,7 +427,5 @@
     //
     if (pix.GetRing() != 0)
-      {  
-	return;
-      }
+        return;
 
     //
@@ -480,26 +471,18 @@
         MCerPhotEvtIter NextAll(fEvt, kFALSE);
         while ((pix=static_cast<MCerPhotPix*>(NextAll())))
-	  {
+        {
             //
 	    // if pixel is a core pixel or unmapped, go to the next pixel
             //
-	  if (pix->IsPixelCore())
-	    {
-	    continue;}
-	  if (pix->IsPixelUnmapped())
-	    {
-	    continue;}
-	  
-	  if (data[pix->GetPixId()] <= fCleanLvl2)
-	    {
-	      continue;}
-
-	  if (r==1)
-	    {
-	    CleanStep3b(*pix);}
-	  else
-	    {
-	    CleanStep4(r, *pix);}
-	  
+            if (pix->IsPixelCore() || pix->IsPixelUnmapped())
+                continue;
+
+            if (data[pix->GetPixId()] <= fCleanLvl2)
+                continue;
+
+            if (r==1)
+                CleanStep3b(*pix);
+            else
+                CleanStep4(r, *pix);
         }
     }
@@ -527,21 +510,9 @@
     }
 
-    if (fCleaningMethod == kDemocratic)
-    {
-        fSgb = (MSigmabar*)pList->FindObject(AddSerialNumber("MSigmabar"));
-        if (!fSgb)
-        {
-            *fLog << dbginf << "MSigmabar not found... aborting." << endl;
-            return kFALSE;
-        }
-    }
-    else
-    {
-        fPed = (MPedPhotCam*)pList->FindObject(AddSerialNumber("MPedPhotCam"));
-        if (!fPed)
-        {
-            *fLog << dbginf << "MPedPhotCam not found... aborting." << endl;
-            return kFALSE;
-        }
+    fPed = (MPedPhotCam*)pList->FindObject(AddSerialNumber("MPedPhotCam"));
+    if (!fPed)
+    {
+        *fLog << dbginf << "MPedPhotCam not found... aborting." << endl;
+        return kFALSE;
     }
 
@@ -559,8 +530,16 @@
 Int_t MImgCleanStd::Process()
 {
-    if (fSgb)
-        fData->CalcCleaningLevel(*fEvt, *fSgb, *fCam);
-    else
+    switch (fCleaningMethod)
+    {
+    case kStandard:
         fData->CalcCleaningLevel(*fEvt, *fPed, *fCam);
+        break;
+    case kScaled:
+        fData->CalcCleaningLevel2(*fEvt, *fPed, *fCam);
+        break;
+    case kDemocratic:
+        fData->CalcCleaningLevelDemocratic(*fEvt, *fPed, *fCam);
+        break;
+    }
 
 #ifdef DEBUG
@@ -568,4 +547,9 @@
 #endif
     CleanStep1();
+
+    // For speed reasons skip the rest of the cleaning if no
+    // action will be taken!
+    if (fCleanLvl1>=fCleanLvl2)
+        return kTRUE;
 
 #ifdef DEBUG
@@ -599,4 +583,7 @@
         *fLog << "standard";
         break;
+    case kScaled:
+        *fLog << "scaled";
+        break;
     }
     *fLog << " cleaning initialized with noise level " << fCleanLvl1 << " and " << fCleanLvl2;
@@ -611,62 +598,62 @@
 void MImgCleanStd::CreateGuiElements(MGGroupFrame *f)
 {
-  //
-  // Create a frame for line 3 and 4 to be able
-  // to align entry field and label in one line
-  //
-  TGHorizontalFrame *f1 = new TGHorizontalFrame(f, 0, 0);
-  TGHorizontalFrame *f2 = new TGHorizontalFrame(f, 0, 0);
+    //
+    // Create a frame for line 3 and 4 to be able
+    // to align entry field and label in one line
+    //
+    TGHorizontalFrame *f1 = new TGHorizontalFrame(f, 0, 0);
+    TGHorizontalFrame *f2 = new TGHorizontalFrame(f, 0, 0);
+    
+    /*
+     * --> use with root >=3.02 <--
+     *
+     
+     TGNumberEntry *fNumEntry1 = new TGNumberEntry(frame, 3.0, 2, M_NENT_LVL1, kNESRealOne, kNEANonNegative);
+     TGNumberEntry *fNumEntry2 = new TGNumberEntry(frame, 2.5, 2, M_NENT_LVL1, kNESRealOne, kNEANonNegative);
   
-  /*
-   * --> use with root >=3.02 <--
-   *
-   
-   TGNumberEntry *fNumEntry1 = new TGNumberEntry(frame, 3.0, 2, M_NENT_LVL1, kNESRealOne, kNEANonNegative);
-   TGNumberEntry *fNumEntry2 = new TGNumberEntry(frame, 2.5, 2, M_NENT_LVL1, kNESRealOne, kNEANonNegative);
-
-  */
-  TGTextEntry *entry1 = new TGTextEntry(f1, "****", kImgCleanLvl1);
-  TGTextEntry *entry2 = new TGTextEntry(f2, "****", kImgCleanLvl2);
-  
-  // --- doesn't work like expected (until root 3.02?) --- fNumEntry1->SetAlignment(kTextRight);
-  // --- doesn't work like expected (until root 3.02?) --- fNumEntry2->SetAlignment(kTextRight);
-  
-  entry1->SetText("3.0");
-  entry2->SetText("2.5");
-  
-  entry1->Associate(f);
-  entry2->Associate(f);
-  
-  TGLabel *l1 = new TGLabel(f1, "Cleaning Level 1");
-  TGLabel *l2 = new TGLabel(f2, "Cleaning Level 2");
-  
-  l1->SetTextJustify(kTextLeft);
-  l2->SetTextJustify(kTextLeft);
-  
-  //
-  // Align the text of the label centered, left in the row
-  // with a left padding of 10
-  //
-  TGLayoutHints *laylabel = new TGLayoutHints(kLHintsCenterY|kLHintsLeft, 10);
-  TGLayoutHints *layframe = new TGLayoutHints(kLHintsCenterY|kLHintsLeft,  5, 0, 10);
-  
-  //
-  // Add one entry field and the corresponding label to each line
-  //
-  f1->AddFrame(entry1);
-  f2->AddFrame(entry2);
-  
-  f1->AddFrame(l1, laylabel);
-  f2->AddFrame(l2, laylabel);
-  
-  f->AddFrame(f1, layframe);
-  f->AddFrame(f2, layframe);
-  
-  f->AddToList(entry1);
-  f->AddToList(entry2);
-  f->AddToList(l1);
-  f->AddToList(l2);
-  f->AddToList(laylabel);
-  f->AddToList(layframe);
+    */
+    TGTextEntry *entry1 = new TGTextEntry(f1, "****", kImgCleanLvl1);
+    TGTextEntry *entry2 = new TGTextEntry(f2, "****", kImgCleanLvl2);
+    
+    // --- doesn't work like expected (until root 3.02?) --- fNumEntry1->SetAlignment(kTextRight);
+    // --- doesn't work like expected (until root 3.02?) --- fNumEntry2->SetAlignment(kTextRight);
+    
+    entry1->SetText("3.0");
+    entry2->SetText("2.5");
+    
+    entry1->Associate(f);
+    entry2->Associate(f);
+    
+    TGLabel *l1 = new TGLabel(f1, "Cleaning Level 1");
+    TGLabel *l2 = new TGLabel(f2, "Cleaning Level 2");
+    
+    l1->SetTextJustify(kTextLeft);
+    l2->SetTextJustify(kTextLeft);
+    
+    //
+    // Align the text of the label centered, left in the row
+    // with a left padding of 10
+    //
+    TGLayoutHints *laylabel = new TGLayoutHints(kLHintsCenterY|kLHintsLeft, 10);
+    TGLayoutHints *layframe = new TGLayoutHints(kLHintsCenterY|kLHintsLeft,  5, 0, 10);
+    
+    //
+    // Add one entry field and the corresponding label to each line
+    //
+    f1->AddFrame(entry1);
+    f2->AddFrame(entry2);
+    
+    f1->AddFrame(l1, laylabel);
+    f2->AddFrame(l2, laylabel);
+    
+    f->AddFrame(f1, layframe);
+    f->AddFrame(f2, layframe);
+    
+    f->AddToList(entry1);
+    f->AddToList(entry2);
+    f->AddToList(l1);
+    f->AddToList(l2);
+    f->AddToList(laylabel);
+    f->AddToList(layframe);
 }
 
Index: trunk/MagicSoft/Mars/mimage/MImgCleanStd.h
===================================================================
--- trunk/MagicSoft/Mars/mimage/MImgCleanStd.h	(revision 4188)
+++ trunk/MagicSoft/Mars/mimage/MImgCleanStd.h	(revision 4452)
@@ -20,4 +20,5 @@
     typedef enum {
         kStandard,
+        kScaled,
         kDemocratic
     } CleaningMethod_t;
@@ -26,5 +27,4 @@
     const MGeomCam    *fCam;  //!
           MCerPhotEvt *fEvt;  //!
-          MSigmabar   *fSgb;  //!
           MPedPhotCam *fPed;  //!
           MCameraData *fData; //!
