Index: trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc	(revision 1875)
+++ trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc	(revision 1880)
@@ -414,4 +414,16 @@
 }
 
+void MImgCleanStd::SetLvl1(Float_t lvl)
+{
+    fCleanLvl1 = lvl;
+    *fLog << inf << "Cleaning level 1 set to " << lvl << " sigma." << endl;
+}
+
+void MImgCleanStd::SetLvl2(Float_t lvl)
+{
+    fCleanLvl2 = lvl;
+    *fLog << inf << "Cleaning level 2 set to " << lvl << " sigma." << endl;
+}
+
 // --------------------------------------------------------------------------
 //
@@ -433,11 +445,9 @@
     {
     case kImgCleanLvl1:
-        fCleanLvl1 = lvl;
-        *fLog << "Cleaning level 1 set to " << lvl << " sigma." << endl;
+        SetLvl1(lvl);
         return kTRUE;
 
     case kImgCleanLvl2:
-        fCleanLvl2 = lvl;
-        *fLog << "Cleaning level 2 set to " << lvl << " sigma." << endl;
+        SetLvl2(lvl);
         return kTRUE;
     }
@@ -465,2 +475,38 @@
     out << ");" << endl;
 }
+
+// --------------------------------------------------------------------------
+//
+// Read the setup from a TEnv:
+//   Float_t fCleanLvl1: CleaningLevel1
+//   Float_t fCleanLvl2: CleaningLevel2
+//
+Bool_t MImgCleanStd::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    Bool_t rc = kTRUE;
+    if (!IsEnvDefined(env, prefix, "CleaningLevel1", print))
+        rc = kFALSE;
+    else
+    {
+        SetLvl1(GetEnvValue(env, prefix, "CleaningLevel1", fCleanLvl1));
+        if (fCleanLvl1<0)
+        {
+            *fLog << err << "ERROR - Negative values for Cleaning Level 1 forbidden." << endl;
+            return kERROR;
+        }
+    }
+
+    if (!IsEnvDefined(env, prefix, "CleaningLevel2", print))
+        rc = kFALSE;
+    else
+    {
+        SetLvl2(GetEnvValue(env, prefix, "CleaningLevel2", fCleanLvl2));
+        if (fCleanLvl2<0)
+        {
+            *fLog << err << "ERROR - Negative values for Cleaning Level 2 forbidden." << endl;
+            return kERROR;
+        }
+    }
+
+    return rc;
+}
Index: trunk/MagicSoft/Mars/manalysis/MImgCleanStd.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MImgCleanStd.h	(revision 1875)
+++ trunk/MagicSoft/Mars/manalysis/MImgCleanStd.h	(revision 1880)
@@ -20,4 +20,7 @@
     Float_t fCleanLvl2;
 
+    void SetLvl1(Float_t lvl);
+    void SetLvl2(Float_t lvl);
+
     void CreateGuiElements(MGGroupFrame *f);
     void StreamPrimitive(ofstream &out) const;
@@ -40,4 +43,5 @@
 
     Bool_t ProcessMessage(Int_t msg, Int_t submsg, Long_t param1, Long_t param2);
+    Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
 
     ClassDef(MImgCleanStd, 0)    // task doing a standard image cleaning
Index: trunk/MagicSoft/Mars/manalysis/MNewImagePar.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MNewImagePar.cc	(revision 1875)
+++ trunk/MagicSoft/Mars/manalysis/MNewImagePar.cc	(revision 1880)
@@ -72,5 +72,5 @@
                           const MHillas *hillas)
 {
-    fHillas = hillas;
+    //fHillas = (MHillas*)hillas;
 
     const UInt_t npixevt = evt.GetNumPixels();
@@ -96,7 +96,6 @@
     }
 
-
-    fLeakage1 = edgepix1 / fHillas->GetSize();
-    fLeakage2 = edgepix2 / fHillas->GetSize();
+    fLeakage1 = edgepix1 / hillas->GetSize();
+    fLeakage2 = edgepix2 / hillas->GetSize();
 
     SetReadyToSave();
Index: trunk/MagicSoft/Mars/manalysis/MNewImagePar.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MNewImagePar.h	(revision 1875)
+++ trunk/MagicSoft/Mars/manalysis/MNewImagePar.h	(revision 1880)
@@ -11,7 +11,4 @@
 {
 private:
-    const MHillas    *fHillas; //! Input parameters
-    const MSrcPosCam *fSrcPos; //! Source position in the camera
-
     Float_t fLeakage1;   // (photons in most outer ring of pixels) over fSize
     Float_t fLeakage2;   // (photons in the 2 outer rings of pixels) over fSize
@@ -20,6 +17,6 @@
     MNewImagePar(const char *name=NULL, const char *title=NULL);
 
-    void SetSrcPos(const MSrcPosCam *pos) { fSrcPos = pos; }
-    const MSrcPosCam *GetSrcPos() const   { return fSrcPos; }
+    //    void SetSrcPos(MSrcPosCam *pos) { fSrcPos = pos; }
+    //    const MSrcPosCam *GetSrcPos() const   { return fSrcPos; }
 
     void Reset();
Index: trunk/MagicSoft/Mars/manalysis/MNewImageParCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MNewImageParCalc.cc	(revision 1875)
+++ trunk/MagicSoft/Mars/manalysis/MNewImageParCalc.cc	(revision 1880)
@@ -107,6 +107,4 @@
         return kFALSE;
 
-    fNewImagePar->SetSrcPos(fSrcPos);
-
     fErrors = 0;
 
Index: trunk/MagicSoft/Mars/manalysis/MNewImageParCalc.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MNewImageParCalc.h	(revision 1875)
+++ trunk/MagicSoft/Mars/manalysis/MNewImageParCalc.h	(revision 1880)
@@ -15,6 +15,6 @@
 {
 private:
-    const MGeomCam    *fGeomCam;
-    const MCerPhotEvt *fCerPhotEvt;
+    MGeomCam    *fGeomCam;
+    MCerPhotEvt *fCerPhotEvt;
 
     MHillas      *fHillas;       //! Pointer to the source independent hillas parameters
Index: trunk/MagicSoft/Mars/manalysis/MRanForest.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MRanForest.cc	(revision 1875)
+++ trunk/MagicSoft/Mars/manalysis/MRanForest.cc	(revision 1880)
@@ -288,7 +288,5 @@
 
     // give running output
-    TString str=Form("%.2f",100.*fErr);
-    cout.width(5);  cout<<fTreeNo;
-    cout.width(15); cout<<str<<endl;
+    cout << setw(5) << fTreeNo << setw(15) << Form("%.2f",100.*fErr) << endl;
 
     // adding tree to forest
Index: trunk/MagicSoft/Mars/manalysis/MSigmabar.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MSigmabar.cc	(revision 1875)
+++ trunk/MagicSoft/Mars/manalysis/MSigmabar.cc	(revision 1880)
@@ -91,7 +91,4 @@
   Int_t outerPixels[6]       = {0,0,0,0,0,0};
 
-  Int_t currentSector;
-  Float_t angle;
-  
   // sum up sigma**2 for each sector, separately for inner and outer region;
   // all pixels are renormalized to the area of pixel 0
@@ -117,5 +114,5 @@
 
       Int_t j = cerpix.GetPixId();
-      Double_t Area = geom.GetPixRatio(j);
+      Double_t area = geom.GetPixRatio(j);
 
       const MGeomPix    &gpix = geom[j];
@@ -125,7 +122,8 @@
       //if (angle<0.0) angle+=6.0;
 
-      angle = 6.0*atan2(gpix.GetY(),gpix.GetX()) / (2.0*TMath::Pi());
-      if (angle<0.0) angle+=6.0;
-      currentSector=(Int_t)angle;
+      Float_t angle = atan2(gpix.GetY(),gpix.GetX())*6 / (TMath::Pi()*2);
+      if (angle<0) angle+=6;
+
+      Int_t currentSector=(Int_t)angle;
        
       // count only those pixels which have a sigma != 0.0 
@@ -134,13 +132,13 @@
       if ( sigma != 0.0 )
       {  
-        if (Area < 1.5)
+        if (area < 1.5)
         {
           innerPixels[currentSector]++;
-          innerSquaredSum[currentSector]+= sigma*sigma / Area;
+          innerSquaredSum[currentSector]+= sigma*sigma / area;
         }
         else
         {
           outerPixels[currentSector]++;
-          outerSquaredSum[currentSector]+= sigma*sigma / Area;
+          outerSquaredSum[currentSector]+= sigma*sigma / area;
         }
       }
@@ -191,5 +189,5 @@
   }
     
-  return (fSigmabar);
+  return fSigmabar;
 }
 
