Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 1539)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 1540)
@@ -85,4 +85,6 @@
      - added some comments
 
+   * manalysis/MImgCleanStd.cc:
+     - pixels with to many 'used' neighbors are left used
 
 
Index: /trunk/MagicSoft/Mars/NEWS
===================================================================
--- /trunk/MagicSoft/Mars/NEWS	(revision 1539)
+++ /trunk/MagicSoft/Mars/NEWS	(revision 1540)
@@ -76,4 +76,8 @@
    - PrintStatistics can now be instructud to print also the title, too:
      use PrintStatistics(0, kTRUE)
+
+   - Changed the image cleaning so that pixels with to many 'used'
+     neighbors are left used (to get rid of 'holes' in events)
+
 
 
Index: /trunk/MagicSoft/Mars/macros/readMagic.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/readMagic.C	(revision 1539)
+++ /trunk/MagicSoft/Mars/macros/readMagic.C	(revision 1540)
@@ -46,10 +46,10 @@
 }
 
-void readMagic(const char *fname="~/data/camera.root")
+void readMagic(const char *fname="~/data/Gamma_0_7*.root")
 {
     MParList plist;
 
     MGeomCamMagic geomcam;
-    MHillas       hillas;
+    MHillasExt    hillas;
     MTaskList     tlist;
 
@@ -59,21 +59,25 @@
 
     MReadMarsFile     read("Events", fname);
+    read.DisableAutoScheme();
 
+    MPrint            print("MMcEvt");
     MMcPedestalCopy   pcopy;
     MMcPedestalNSBAdd pnsb;
     MCerPhotCalc      ncalc;
+    MBlindPixelCalc   blind;
+    blind.SetUseInterpolation();
     MClone            clone("MCerPhotEvt");
     MImgCleanStd      clean;
-    MBlindPixelCalc   blind;
     MHillasCalc       hcalc;
 
 
     tlist.AddToList(&read);
+    tlist.AddToList(&print);
     tlist.AddToList(&pcopy);
     tlist.AddToList(&pnsb);
     tlist.AddToList(&ncalc);
+    tlist.AddToList(&blind);
     tlist.AddToList(&clone);
     tlist.AddToList(&clean);
-    tlist.AddToList(&blind);
     tlist.AddToList(&hcalc);
 
Index: /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 1540)
@@ -34,5 +34,4 @@
 
 #include "MGeomCam.h"
-#include "MGeomPix.h"
 
 ClassImp(MCerPhotEvt);
@@ -159,6 +158,4 @@
         return -5.;
 
-    const Float_t A0 = geom ? (*geom)[0].GetA() : 0;
-
     Float_t minval = (*this)[0].GetNumPhotons();
 
@@ -170,5 +167,5 @@
 
         if (geom)
-            testval *= A0/(*geom)[pix.GetPixId()].GetA();
+            testval *= geom->GetPixRatio(pix.GetPixId());
 
         if (testval < minval)
@@ -190,5 +187,4 @@
         return 50.;
 
-    const Float_t A0 = geom ? (*geom)[0].GetA() : 0;
     Float_t maxval = (*this)[0].GetNumPhotons();
 
@@ -200,5 +196,5 @@
 
         if (geom)
-            testval *= A0/(*geom)[pix.GetPixId()].GetA();
+            testval *= geom->GetPixRatio(pix.GetPixId());
 
         if (testval > maxval)
@@ -208,2 +204,104 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// get the minimum ratio of photons/error
+//
+Float_t MCerPhotEvt::GetRatioMin() const
+{
+    if (fNumPixels <= 0)
+        return -5.;
+
+    Float_t minval = (*this)[0].GetNumPhotons()/(*this)[0].GetErrorPhot();
+
+    for (UInt_t i=1; i<fNumPixels; i++)
+    {
+        const MCerPhotPix &pix = (*this)[i];
+
+        Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot();
+        if (testval < minval)
+            minval = testval;
+    }
+
+    return minval;
+}
+
+// --------------------------------------------------------------------------
+//
+// get the maximum ratio of photons/error
+//
+Float_t MCerPhotEvt::GetRatioMax() const
+{
+    if (fNumPixels <= 0)
+        return -5.;
+
+    Float_t maxval = (*this)[0].GetNumPhotons()/(*this)[0].GetErrorPhot();
+
+    for (UInt_t i=1; i<fNumPixels; i++)
+    {
+        const MCerPhotPix &pix = (*this)[i];
+
+        Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot();
+        if (testval > maxval)
+            maxval = testval;
+    }
+
+    return maxval;
+}
+
+// --------------------------------------------------------------------------
+//
+// get the minimum of error
+// If you specify a geometry the number of photons is weighted with the
+// area of the pixel
+//
+Float_t MCerPhotEvt::GetErrorPhotMin(const MGeomCam *geom) const
+{
+    if (fNumPixels <= 0)
+        return 50.;
+
+    Float_t minval = (*this)[0].GetErrorPhot();
+
+    for (UInt_t i=1; i<fNumPixels; i++)
+    {
+        const MCerPhotPix &pix = (*this)[i];
+
+        Float_t testval = pix.GetErrorPhot();
+
+        if (geom)
+            testval *= geom->GetPixRatio(pix.GetPixId());
+
+        if (testval < minval)
+            minval = testval;
+    }
+    return minval;
+}
+
+// --------------------------------------------------------------------------
+//
+// get the maximum ratio of photons/error
+// If you specify a geometry the number of photons is weighted with the
+// area of the pixel
+//
+Float_t MCerPhotEvt::GetErrorPhotMax(const MGeomCam *geom) const
+{
+    if (fNumPixels <= 0)
+        return 50.;
+
+    Float_t maxval = (*this)[0].GetErrorPhot();
+
+    for (UInt_t i=1; i<fNumPixels; i++)
+    {
+        const MCerPhotPix &pix = (*this)[i];
+
+        Float_t testval = pix.GetErrorPhot();
+
+        if (geom)
+            testval *= geom->GetPixRatio(pix.GetPixId());
+
+        if (testval > maxval)
+            maxval = testval;
+    }
+    return maxval;
+}
+
Index: /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 1539)
+++ /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 1540)
@@ -38,4 +38,10 @@
     Float_t GetNumPhotonsMax(const MGeomCam *geom=NULL) const;
 
+    Float_t GetRatioMin() const;
+    Float_t GetRatioMax() const;
+
+    Float_t GetErrorPhotMin(const MGeomCam *geom=NULL) const;
+    Float_t GetErrorPhotMax(const MGeomCam *geom=NULL) const;
+
     MCerPhotPix &operator[](int i)       { return *(MCerPhotPix*)(fPixels->UncheckedAt(i)); }
     MCerPhotPix &operator[](int i) const { return *(MCerPhotPix*)(fPixels->UncheckedAt(i)); }
Index: /trunk/MagicSoft/Mars/manalysis/MHillas.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MHillas.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/manalysis/MHillas.cc	(revision 1540)
@@ -220,6 +220,12 @@
 // In case you don't call Calc from within an eventloop make sure, that
 // you call the Reset member function before.
-//
-Bool_t MHillas::Calc(const MGeomCam &geom, const MCerPhotEvt &evt)
+// Returns:
+//   0  no error
+//   1  number of pixels < 3
+//   2  size==0
+//   3  number of used pixel < 3
+//   4  CorrXY == 0
+//
+Int_t MHillas::Calc(const MGeomCam &geom, const MCerPhotEvt &evt)
 {
     const UInt_t npixevt = evt.GetNumPixels();
@@ -228,8 +234,8 @@
     // sanity check
     //
-    if (npixevt <= 2)
-    {
-        *fLog << warn << "MHillas::Calc: Event has less than two pixels... skipped." << endl;
-        return kFALSE;
+    if (npixevt < 3)
+    {
+        //*fLog << warn << "MHillas::Calc: Event has less than three pixels... skipped." << endl;
+        return 1;
     }
 
@@ -280,5 +286,5 @@
     {
         //*fLog << inf << GetDescriptor() << ": Event has zero cerenkov photons... skipped." << endl;
-        return kFALSE;
+        return 2;
     }
 
@@ -286,5 +292,5 @@
     {
         //*fLog << inf << GetDescriptor() << ": Event has less than 3 used pixels... skipped." << endl;
-        return kFALSE;
+        return 3;
     }
 
@@ -334,6 +340,6 @@
     if (corrxy==0)
     {
-        *fLog << inf << GetDescriptor() << ": Event has CorrXY==0... skipped." << endl;
-        return kFALSE;
+        //*fLog << inf << GetDescriptor() << ": Event has CorrXY==0... skipped." << endl;
+        return 4;
     }
 
@@ -375,5 +381,5 @@
     SetReadyToSave();
 
-    return kTRUE;
+    return 0;
 }
 
Index: /trunk/MagicSoft/Mars/manalysis/MHillas.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MHillas.h	(revision 1539)
+++ /trunk/MagicSoft/Mars/manalysis/MHillas.h	(revision 1540)
@@ -45,5 +45,5 @@
     void Reset();
 
-    virtual Bool_t Calc(const MGeomCam &geom, const MCerPhotEvt &pix);
+    virtual Int_t Calc(const MGeomCam &geom, const MCerPhotEvt &pix);
 
     virtual void Print(Option_t *opt=NULL) const;
Index: /trunk/MagicSoft/Mars/manalysis/MHillasCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MHillasCalc.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/manalysis/MHillasCalc.cc	(revision 1540)
@@ -88,4 +88,6 @@
         return kFALSE;
 
+    memset(fErrors, 0, sizeof(fErrors));
+
     return kTRUE;
 }
@@ -100,5 +102,34 @@
 Bool_t MHillasCalc::Process()
 {
-    return fHillas->Calc(*fGeomCam, *fCerPhotEvt) ? kTRUE : kCONTINUE;
+    const Int_t rc = fHillas->Calc(*fGeomCam, *fCerPhotEvt);
+    if (rc<0 || rc>4)
+    {
+        *fLog << err << dbginf << "MHillas::Calc returned unknown error code!" << endl;
+        return kFALSE;
+    }
+    fErrors[rc]++;
+
+    return rc==0 ? kTRUE : kCONTINUE;
 }
 
+// --------------------------------------------------------------------------
+//
+//  Prints some statistics about the hillas calculation. The percentage
+//  is calculated with respect to the number of executions of this task.
+//
+Bool_t MHillasCalc::PostProcess()
+{
+    if (GetNumExecutions()==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << " " << setw(7) << fErrors[1] << " (" << setw(3) << (int)(fErrors[1]*100/GetNumExecutions()) << "%) Evts skipped due to: Event has less than 3 pixels" << endl;
+    *fLog << " " << setw(7) << fErrors[2] << " (" << setw(3) << (int)(fErrors[2]*100/GetNumExecutions()) << "%) Evts skipped due to: Calculated Size == 0" << endl;
+    *fLog << " " << setw(7) << fErrors[3] << " (" << setw(3) << (int)(fErrors[3]*100/GetNumExecutions()) << "%) Evts skipped due to: Number of used pixels < 3" << endl;
+    *fLog << " " << setw(7) << fErrors[4] << " (" << setw(3) << (int)(fErrors[4]*100/GetNumExecutions()) << "%) Evts skipped due to: CorrXY==0" << endl;
+    *fLog << " " << fErrors[0] << " (" << (int)(fErrors[0]*100/GetNumExecutions()) << "%) Evts survived Hillas calculation!" << endl;
+    *fLog << endl;
+
+    return kTRUE;
+}
Index: /trunk/MagicSoft/Mars/manalysis/MHillasCalc.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MHillasCalc.h	(revision 1539)
+++ /trunk/MagicSoft/Mars/manalysis/MHillasCalc.h	(revision 1540)
@@ -24,10 +24,13 @@
           MHillas     *fHillas;     // ouput container to store result
 
-    TString fHilName;
-public:
-    MHillasCalc(const char *hil="MHillas", const char *name=NULL, const char *title=NULL);
+          TString      fHilName;
+          Int_t        fErrors[5];
 
     Bool_t PreProcess(MParList *pList);
     Bool_t Process();
+    Bool_t PostProcess();
+
+public:
+    MHillasCalc(const char *hil="MHillas", const char *name=NULL, const char *title=NULL);
 
     ClassDef(MHillasCalc, 0)   // Task to calculate Hillas parameters
Index: /trunk/MagicSoft/Mars/manalysis/MHillasExt.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MHillasExt.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/manalysis/MHillasExt.cc	(revision 1540)
@@ -111,8 +111,9 @@
 // and the cerenkov photon event
 //
-Bool_t MHillasExt::Calc(const MGeomCam &geom, const MCerPhotEvt &evt)
-{
-    if (!MHillas::Calc(geom, evt))
-        return kFALSE;
+Int_t MHillasExt::Calc(const MGeomCam &geom, const MCerPhotEvt &evt)
+{
+    const Int_t rc = MHillas::Calc(geom, evt);
+    if (rc>0)
+        return rc;
 
     //
@@ -237,5 +238,5 @@
     SetReadyToSave();
 
-    return kTRUE;
+    return 0;
 }
 
Index: /trunk/MagicSoft/Mars/manalysis/MHillasExt.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MHillasExt.h	(revision 1539)
+++ /trunk/MagicSoft/Mars/manalysis/MHillasExt.h	(revision 1540)
@@ -30,5 +30,5 @@
     Float_t GetM3Trans() const { return fM3Trans; }
 
-    Bool_t Calc(const MGeomCam &geom, const MCerPhotEvt &pix);
+    Int_t Calc(const MGeomCam &geom, const MCerPhotEvt &pix);
 
     void Print(Option_t *opt=NULL) const;
Index: /trunk/MagicSoft/Mars/manalysis/MHillasSrc.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MHillasSrc.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/manalysis/MHillasSrc.cc	(revision 1540)
@@ -113,5 +113,5 @@
     if (dist==0)
     {
-        *fLog << warn << GetDescriptor() << ": Event has Dist==0... skipped." << endl;
+        //*fLog << warn << GetDescriptor() << ": Event has Dist==0... skipped." << endl;
         return kFALSE;
     }
Index: /trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.cc	(revision 1540)
@@ -91,4 +91,6 @@
     fHillasSrc->SetSrcPos(fSrcPos);
 
+    fErrors = 0;
+
     return kTRUE;
 }
@@ -98,7 +100,31 @@
 Bool_t MHillasSrcCalc::Process()
 {
-    return fHillasSrc->Calc(fHillas) ? kTRUE : kCONTINUE;
+
+    if (!fHillasSrc->Calc(fHillas))
+    {
+        fErrors++;
+        return kCONTINUE;
+
+    }
+    return kTRUE;
 }
 
+// --------------------------------------------------------------------------
+//
+//  Prints some statistics about the hillas calculation. The percentage
+//  is calculated with respect to the number of executions of this task.
+//
+Bool_t MHillasSrcCalc::PostProcess()
+{
+    if (GetNumExecutions()==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << " " << fErrors << " (" << (int)(fErrors*100/GetNumExecutions()) << "%) Evts skipped due to: Dist==0" << endl;
+    *fLog << endl;
+
+    return kTRUE;
+}
 
 // --------------------------------------------------------------------------
Index: /trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.h	(revision 1539)
+++ /trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.h	(revision 1540)
@@ -20,5 +20,11 @@
     TString     fHillasName;
 
+    Int_t       fErrors;
+
     void StreamPrimitive(ofstream &out) const;
+
+    Bool_t PreProcess(MParList *plist);
+    Bool_t Process();
+    Bool_t PostProcess();
 
 public:
@@ -26,7 +32,4 @@
                    const char *name=NULL, const char *title=NULL);
 
-    Bool_t PreProcess(MParList *plist);
-    Bool_t Process();
-
     ClassDef(MHillasSrcCalc, 1) // task to calculate the source position depandant hillas parameters
 };
Index: /trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc	(revision 1540)
@@ -159,6 +159,8 @@
         // check if pixel is in use, if not goto next pixel in list
         //
+#if 0
         if (!pix.IsPixelUsed())
             continue;
+#endif
 
         //
@@ -168,10 +170,10 @@
 
         //
-        // count number of next neighbors of this pixel which
-        // state is 'used'
+        // check for 'used' neighbors this pixel which
         //
         const MGeomPix &gpix  = (*fCam)[id];
         const Int_t     nnmax = gpix.GetNumNeighbors();
 
+#if 0
         Bool_t cnt = kFALSE;
         for (Int_t j=0; j<nnmax; j++)
@@ -179,5 +181,5 @@
             const Int_t id2 = gpix.GetNeighbor(j);
 
-            if (!ispixused[id2])
+            if (id2>max || !ispixused[id2])
                 continue;
 
@@ -187,4 +189,24 @@
         if (cnt)
             continue;
+#else
+        Int_t cnt = 0;
+        for (Int_t j=0; j<nnmax; j++)
+        {
+            const Int_t id2 = gpix.GetNeighbor(j);
+
+            if (id2>max || !ispixused[id2])
+                continue;
+
+            if (cnt++>nnmax-4)
+                break;
+        }
+        if (cnt==nnmax-2 && nnmax>=4)
+        {
+            pix.SetPixelUsed();
+            continue;
+        }
+        if (cnt>0)
+            continue;
+#endif
 
         //
@@ -238,5 +260,5 @@
         const Float_t noise = pix.GetErrorPhot();
 
-        if (entry <= fCleanLvl2 * noise )
+        if (entry <= fCleanLvl2 * noise)
             continue;
 
Index: /trunk/MagicSoft/Mars/manalysis/MImgCleanStd.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MImgCleanStd.h	(revision 1539)
+++ /trunk/MagicSoft/Mars/manalysis/MImgCleanStd.h	(revision 1540)
@@ -36,4 +36,7 @@
     void Print(Option_t *o="") const;
 
+    Float_t GetCleanLvl1() const { return fCleanLvl1; }
+    Float_t GetCleanLvl2() const { return fCleanLvl2; }
+
     Bool_t ProcessMessage(Int_t msg, Int_t submsg, Long_t param1, Long_t param2);
 
Index: /trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc	(revision 1540)
@@ -46,5 +46,7 @@
 #include "MLogManip.h"
 
+#include "MPedestalPix.h"
 #include "MPedestalCam.h"
+
 #include "MRawRunHeader.h"
 #include "MMcFadcHeader.hxx"
@@ -113,6 +115,5 @@
 // --------------------------------------------------------------------------
 //
-// Check for the runtype. (not yet: If the check fails the eventloop is
-// stopped.)
+// Check for the runtype.
 // Initialize the size of MPedestalCam to the number of pixels from
 // MMcFadcHeader.
Index: /trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc	(revision 1540)
@@ -26,10 +26,11 @@
 //                                                                         //
 //  MMcPedestalNSBAdd                                                      //
+//  -----------------                                                      //
 //                                                                         //
 //  This Task adds the contribution of the diffuse NSB to the FADC         //
 //  pedestals. We assume that NSB introduces larger fluctuation but does   //
 //  not change the mean value.                                             //
-//  To be precise we add quadratically to the rms that is already in       //
-//  MPedestalCam the NSB contribution.                                     //
+//  To be precise we add quadratically to the rms, which is already in     //
+//  MPedestalCam, the NSB contribution.                                    //
 //  The number of photons from the diffuse NSB follows a poisson           // 
 //  distribution with expected mean value X, then its standard deviation   //
@@ -50,5 +51,4 @@
 //                                                                         //
 /////////////////////////////////////////////////////////////////////////////
-
 #include "MMcPedestalNSBAdd.h"
 
@@ -58,10 +58,13 @@
 #include "MLogManip.h"
 
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MPedestalPix.h"
 #include "MPedestalCam.h"
+
 #include "MRawRunHeader.h"
 #include "MMcRunHeader.hxx"
 #include "MMcFadcHeader.hxx"
-#include "MGeomCam.h"
-#include "MGeomPix.h"
 
 ClassImp(MMcPedestalNSBAdd);
Index: /trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc	(revision 1540)
@@ -31,6 +31,13 @@
 /////////////////////////////////////////////////////////////////////////////
 #include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include <TClonesArray.h>
 
 #include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+
 
 ClassImp(MPedestalCam);
@@ -62,4 +69,40 @@
 // --------------------------------------------------------------------------
 //
+// Set the size of the camera
+//
+inline void MPedestalCam::InitSize(const UInt_t i)
+{
+    fArray->ExpandCreate(i);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the size of the MPedestalCam
+//
+inline Int_t MPedestalCam::GetSize() const
+{
+    return fArray->GetEntries();
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel (pixel number)
+//
+inline MPedestalPix &MPedestalCam::operator[](Int_t i)
+{
+    return *(MPedestalPix*)fArray->UncheckedAt(i);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel (pixel number)
+//
+inline MPedestalPix &MPedestalCam::operator[](Int_t i) const
+{
+    return *(MPedestalPix*)fArray->UncheckedAt(i);
+}
+
+// --------------------------------------------------------------------------
+//
 // Check if position i is inside bounds
 //
@@ -69,3 +112,70 @@
 } 
 
+void MPedestalCam::Clear(Option_t *o)
+{
+    fArray->ForEach(TObject, Clear)();
+}
 
+void MPedestalCam::Print(Option_t *o="") const
+{
+    *fLog << all << GetDescriptor() << ":" << endl;
+    int id = 0;
+
+    TIter Next(fArray);
+    MPedestalPix *pix;
+    while ((pix=(MPedestalPix*)Next()))
+    {
+        id++;
+
+        if (!pix->IsValid())
+            continue;
+
+        *fLog << id-1 << ": ";
+        *fLog << pix->GetMean() << " " << pix->GetSigma() << " ";
+        *fLog << pix->GetMeanRms() << " " << pix->GetSigmaRms() << endl;
+    }
+}
+
+Float_t MPedestalCam::GetMeanMin(const MGeomCam *geom) const
+{
+    if (fArray->GetEntries() <= 0)
+        return 50.;
+
+    Float_t minval = (*this)[0].GetMean();
+
+    for (Int_t i=1; i<fArray->GetEntries(); i++)
+    {
+        const MPedestalPix &pix = (*this)[i];
+
+        Float_t testval = pix.GetMean();
+
+        if (geom)
+            testval *= geom->GetPixRatio(i);
+
+        if (testval < minval)
+            minval = testval;
+    }
+    return minval;
+}
+
+Float_t MPedestalCam::GetMeanMax(const MGeomCam *geom) const
+{
+    if (fArray->GetEntries() <= 0)
+        return 50.;
+
+    Float_t maxval = (*this)[0].GetMean();
+
+    for (Int_t i=1; i<fArray->GetEntries(); i++)
+    {
+        const MPedestalPix &pix = (*this)[i];
+
+        Float_t testval = pix.GetMean();
+
+        if (geom)
+            testval *= geom->GetPixRatio(i);
+
+        if (testval > maxval)
+            maxval = testval;
+    }
+    return maxval;
+}
Index: /trunk/MagicSoft/Mars/manalysis/MPedestalCam.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MPedestalCam.h	(revision 1539)
+++ /trunk/MagicSoft/Mars/manalysis/MPedestalCam.h	(revision 1540)
@@ -6,11 +6,8 @@
 #endif
 
-#ifndef MARS_MPedestalPix
-#include "MPedestalPix.h"
-#endif
+class TClonesArray;
 
-#ifndef ROOT_TClonesArray
-#include <TClonesArray.h>
-#endif
+class MGeomCam;
+class MPedestalPix;
 
 class MPedestalCam : public MParContainer
@@ -23,10 +20,18 @@
     ~MPedestalCam();
 
-    void InitSize(const UInt_t i) { fArray->ExpandCreate(i); }
+    void Clear(Option_t *o="");
 
-    MPedestalPix &operator[](Int_t i)       { return *(MPedestalPix*)fArray->UncheckedAt(i); }
-    MPedestalPix &operator[](Int_t i) const { return *(MPedestalPix*)fArray->UncheckedAt(i); }
+    void InitSize(const UInt_t i);
+    Int_t GetSize() const;
+
+    MPedestalPix &operator[](Int_t i);
+    MPedestalPix &operator[](Int_t i) const;
+
+    Float_t GetMeanMin(const MGeomCam *cam) const;
+    Float_t GetMeanMax(const MGeomCam *cam) const;
 
     Bool_t CheckBounds(Int_t i);
+
+    void Print(Option_t *o="") const;
 
     ClassDef(MPedestalCam, 1)	// Storage Container for all pedestal information of the camera
Index: /trunk/MagicSoft/Mars/manalysis/MPedestalPix.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MPedestalPix.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/manalysis/MPedestalPix.cc	(revision 1540)
@@ -38,6 +38,18 @@
 
 MPedestalPix::MPedestalPix()
-    : fMean(0.0), fSigma(0.0), fMeanRms(0.0), fSigmaRms(0.0)
 {
+    Clear();
 }
 
+// ------------------------------------------------------------------------
+//
+// Invalidate values
+//
+void MPedestalPix::Clear(Option_t *o)
+{
+    fMean = -1;
+    fSigma = -1;
+    fMeanRms = -1;
+    fSigmaRms = -1;
+}
+
Index: /trunk/MagicSoft/Mars/manalysis/MPedestalPix.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MPedestalPix.h	(revision 1539)
+++ /trunk/MagicSoft/Mars/manalysis/MPedestalPix.h	(revision 1540)
@@ -17,4 +17,6 @@
     MPedestalPix();
 
+    void Clear(Option_t *o="");
+
     Float_t GetMean() const     { return fMean;     }
     Float_t GetSigma() const    { return fSigma;    }
@@ -30,4 +32,6 @@
     void SetPedestalRms(Float_t m, Float_t s) { fMeanRms = m; fSigmaRms = s; }
 
+    Bool_t IsValid() const { return fMean>=0||fSigma>=0||fMeanRms>=0||fSigmaRms>=0; }
+
     ClassDef(MPedestalPix, 1)	// Storage Container for Pedestal information of one pixel
 };
Index: /trunk/MagicSoft/Mars/mbase/BaseLinkDef.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/BaseLinkDef.h	(revision 1539)
+++ /trunk/MagicSoft/Mars/mbase/BaseLinkDef.h	(revision 1540)
@@ -35,4 +35,5 @@
 #pragma link C++ class MClone+;
 #pragma link C++ class MPrint+;
+#pragma link C++ class MContinue+;
 
 #pragma link C++ class MArray;
Index: /trunk/MagicSoft/Mars/mbase/MClone.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MClone.h	(revision 1539)
+++ /trunk/MagicSoft/Mars/mbase/MClone.h	(revision 1540)
@@ -30,5 +30,6 @@
     Bool_t Process();
 
-    TObject *GetClone() const { return fClone; }
+    TObject *GetClone() const  { return fClone; }
+    const TObject *GetObject() const { return fObject; }
 
     void Clear(Option_t *opt=NULL);
Index: /trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 1540)
@@ -86,4 +86,5 @@
 #ifdef __MARS__
 #include "MReadTree.h"       // for setting progress bar
+#include "MProgressBar.h"    // MProgressBar::GetBar
 #endif
 
@@ -126,4 +127,16 @@
     enable ? SetBit(kIsOwner) : ResetBit(kIsOwner);
 }
+
+#ifdef __MARS__
+// --------------------------------------------------------------------------
+//
+//  Specify an existing MProgressBar object. It will display the progress
+//  graphically. This will make thing about 1-2% slower.
+//
+void MEvtLoop::SetProgressBar(MProgressBar *bar)
+{
+    fProgress = bar->GetBar();
+}
+#endif
 
 // --------------------------------------------------------------------------
Index: /trunk/MagicSoft/Mars/mbase/MEvtLoop.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 1539)
+++ /trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 1540)
@@ -17,4 +17,7 @@
 class MTaskList;
 class TGProgressBar;
+#ifdef __MARS__
+class MProgressBar;
+#endif
 
 class MEvtLoop : public MParContainer
@@ -44,4 +47,7 @@
 
     void SetProgressBar(TGProgressBar *bar) { fProgress = bar; }
+#ifdef __MARS__
+    void SetProgressBar(MProgressBar *bar);
+#endif
 
     Bool_t PreProcess(const char *tlist="MTaskList");
Index: /trunk/MagicSoft/Mars/mbase/MTask.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 1540)
@@ -252,8 +252,10 @@
 // --------------------------------------------------------------------------
 //
-// Prints the number of times this task has been processed.
-// For convinience the lvl argument results in a number of spaces at the
-// beginning of the line. So that the structur of a tasklist can be
-// identified.
+//  Prints the number of times all the tasks in the list has been.
+//  For convinience the lvl argument results in a number of spaces at the
+//  beginning of the line. So that the structur of a tasklist can be
+//  identified. If a Tasklist or task has filter applied the name of the
+//  filter is printer in <>-brackets behind the number of executions.
+//  Use MTaskList::PrintStatistics without an argument.
 //
 void MTask::PrintStatistics(const Int_t lvl, Bool_t title) const
@@ -261,4 +263,6 @@
     *fLog << all << setw(lvl) << " " << GetDescriptor() << "\t";
     *fLog << dec << fNumExecutions;
+    if (fFilter)
+        *fLog << " <" << fFilter->GetName() << ">";
     if (title)
         *fLog << "\t" << fTitle;
@@ -280,6 +284,6 @@
     /*
      If we don't stream filter which are not in the task list itself
-     (which means: alrteady streamed) we may be able to use the
-     primitive streamer as some kind of validity check for the macros
+     (which means: already streamed) we may be able to use
+     SavePrimitive as some kind of validity check for the macros
 
      fFilter->SavePrimitive(out);
Index: /trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 1540)
@@ -66,4 +66,5 @@
 #include "MLogManip.h"
 
+#include "MFilter.h"
 #include "MParList.h"
 #include "MInputStreamID.h"
@@ -71,6 +72,7 @@
 ClassImp(MTaskList);
 
-static const TString gsDefName  = "MTaskList";
-static const TString gsDefTitle = "A list for tasks to be executed";
+const TString MTaskList::gsDefName  = "MTaskList";
+const TString MTaskList::gsDefTitle = "A list for tasks to be executed";
+
 // --------------------------------------------------------------------------
 //
@@ -492,5 +494,7 @@
 //  For convinience the lvl argument results in a number of spaces at the
 //  beginning of the line. So that the structur of a tasklist can be
-//  identified. Use MTaskList::PrintStatistics without an argument.
+//  identified. If a Tasklist or task has filter applied the name of the
+//  filter is printer in <>-brackets behind the number of executions.
+//  Use MTaskList::PrintStatistics without an argument.
 //
 void MTaskList::PrintStatistics(const Int_t lvl, Bool_t title) const
@@ -502,4 +506,6 @@
         *fLog << "---------------------" << endl;
         *fLog << GetDescriptor();
+        if (GetFilter())
+            *fLog << " <" << GetFilter()->GetName() << ">";
         if (title)
             *fLog << "\t" << fTitle;
Index: /trunk/MagicSoft/Mars/mbase/MTaskList.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 1539)
+++ /trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 1540)
@@ -21,10 +21,10 @@
 {
 private:
-    TList    *fTasks;	    // Container for the ordered list of different tasks
-    TList    fTasksProcess; //!
-    MParList *fParList;     //!
+    static const TString gsDefName;  // default name
+    static const TString gsDefTitle; // default title
 
-    UInt_t *fCntContinue;   //!
-    UInt_t *fCntTrue;       //!
+    TList    *fTasks;        // Container for the ordered list of different tasks
+    TList     fTasksProcess; //! Task which overload the Process function
+    MParList *fParList;      //! The parameter list given in PreProcess
 
     enum { kIsOwner = BIT(14) };
Index: /trunk/MagicSoft/Mars/mbase/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/mbase/Makefile	(revision 1539)
+++ /trunk/MagicSoft/Mars/mbase/Makefile	(revision 1540)
@@ -20,5 +20,5 @@
 # @endcode 
 
-INCLUDES = -I. -I../mraw -I../MRawFormat -I../mmc -I../mfileio
+INCLUDES = -I. -I../mraw -I../MRawFormat -I../mmc -I../mfileio -I../mmain
 
 # @code 
@@ -48,4 +48,5 @@
            MTime.cc \
            MClone.cc \
+           MContinue.cc \
            MPrint.cc \
            MLogManip.cc
Index: /trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.cc
===================================================================
--- /trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.cc	(revision 1540)
@@ -32,5 +32,5 @@
 #include "MGTask.h"              // MGTask::CreateGui
 #include "MClone.h"              // MClone
-#include "MHillas.h"             // MHillas
+#include "MHillasExt.h"          // MHillasExt
 #include "MParList.h"            // MParList::AddToList
 #include "MEvtLoop.h"            // MEvtLoop::GetParList
@@ -81,5 +81,5 @@
      WARNING:
      Bacause of some strage and hidden dependencies the
-     GetMaiFrame call in the destructor of TGButton may fail if some
+     GetMainFrame call in the destructor of TGButton may fail if some
      of the other gui elements are deleted first.
      AddFirst adds the buttons at the beginning of the deletion list,
@@ -134,7 +134,9 @@
     MGeomCamMagic *geom   = new MGeomCamMagic;
     MPedestalCam  *pedest = new MPedestalCam;
+    MHillasExt    *hext   = new MHillasExt;
 
     plist->AddToList(geom);
     plist->AddToList(pedest);
+    plist->AddToList(hext);
 
     return geom;
@@ -160,11 +162,35 @@
     AddSetupElements();
 
+    TCanvas *canv2 = AddTab("Errors");
+    TCanvas *canv3 = AddTab("Phot/Err");
+    TCanvas *canv4 = AddTab("Levels");
+    TCanvas *canv5 = AddTab("Pedestals");
+
     //
     // Show camera display for the actual geometry
     //
+    fDisplay  = new MCamDisplay(geom);
+    fDisplay2 = new MCamDisplay(geom);
+    fDisplay3 = new MCamDisplay(geom);
+    fDisplay4 = new MCamDisplay(geom);
+    fDisplay5 = new MCamDisplay(geom);
+
+    fList->Add(fDisplay);
+    fList->Add(fDisplay2);
+    fList->Add(fDisplay3);
+    fList->Add(fDisplay4);
+    fList->Add(fDisplay5);
+
     fCanvas->cd();
-    fDisplay = new MCamDisplay(geom);
     fDisplay->Draw();
-    fList->Add(fDisplay);
+    canv2->cd();
+    fDisplay2->Draw();
+    canv3->cd();
+    fDisplay3->Draw();
+    canv4->cd();
+    fDisplay4->Draw();
+    canv5->cd();
+    fDisplay5->Draw();
+
 
     ReadFirstEvent();
@@ -213,5 +239,5 @@
     // Display the requested event. This does a Canvas update, too.
     //
-    MCerPhotEvt *evt = NULL;
+    MCerPhotEvt  *evt = NULL;
     if (fDisplayRaw)
     {
@@ -230,5 +256,12 @@
     }
 
+    const MImgCleanStd *clean = (MImgCleanStd*)GetTaskList()->FindObject("MImgCleanStd");
+    const MPedestalCam *ped   = (MPedestalCam*)plist->FindObject("MPedestalCam");
+
     fDisplay->DrawPhotNum(evt);
+    fDisplay2->DrawErrorPhot(evt);
+    fDisplay3->DrawRatio(evt);
+    fDisplay4->DrawLevels(evt, *clean);
+    fDisplay5->DrawPedestals(ped);
 }
 
Index: /trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.h
===================================================================
--- /trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.h	(revision 1539)
+++ /trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.h	(revision 1540)
@@ -18,5 +18,10 @@
 
     TGListBox   *fPixelList;
+
     MCamDisplay *fDisplay;
+    MCamDisplay *fDisplay2;
+    MCamDisplay *fDisplay3;
+    MCamDisplay *fDisplay4;
+    MCamDisplay *fDisplay5;
 
     void AddSetupElements();
Index: /trunk/MagicSoft/Mars/meventdisp/MGEvtDisplay.cc
===================================================================
--- /trunk/MagicSoft/Mars/meventdisp/MGEvtDisplay.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/meventdisp/MGEvtDisplay.cc	(revision 1540)
@@ -208,4 +208,21 @@
 // --------------------------------------------------------------------------
 //
+//  Add a tab with an embedded canvas for an camera display and return the
+//  pointer to the canvas
+//
+TCanvas *MGEvtDisplay::AddTab(TString name)
+{
+    TGLayoutHints *laycanvas = new TGLayoutHints(kLHintsCenterX|kLHintsCenterY|kLHintsExpandX|kLHintsExpandY);
+    fList->Add(laycanvas);
+
+    TGCompositeFrame *frame = fEvtDisplay->AddTab(name);
+    TRootEmbeddedCanvas *canvas = new TRootEmbeddedCanvas(name+"Display", frame, 400, 400);
+    frame->AddFrame(canvas, laycanvas);
+    fList->Add(canvas);
+    return canvas->GetCanvas();
+}
+
+// --------------------------------------------------------------------------
+//
 //  Add the mid frame: This are the two tabs with the canvas in the right one
 //
@@ -230,21 +247,10 @@
     //
     // Create second part of frame
-    // 
-    TGTab *tabdisp = new TGTab(frame, 300, 300);
-
-    TGLayoutHints *laycanvas = new TGLayoutHints(kLHintsCenterX|kLHintsCenterY|kLHintsExpandX|kLHintsExpandY);
-
-    TGCompositeFrame *tab2 = tabdisp->AddTab("Event Display");
-    TRootEmbeddedCanvas *canvas = new TRootEmbeddedCanvas("EventDisplay", tab2, 400, 400);
-    tab2->AddFrame(canvas, laycanvas);
-    fList->Add(canvas);
-
-    fCanvas = canvas->GetCanvas();
-
-    TGCompositeFrame *tab3 = tabdisp->AddTab("Geometry");
-    canvas = new TRootEmbeddedCanvas("CamDisplay", tab3, 400, 400);
-    tab3->AddFrame(canvas, laycanvas);
-    fList->Add(canvas);
-
+    //
+    fEvtDisplay = new TGTab(frame, 300, 300);
+
+    fCanvas=AddTab("Photons");
+
+    AddTab("Geometry");
     MGeomCamMagic geom;
     MCamDisplay *display = new MCamDisplay(&geom);
@@ -257,11 +263,10 @@
     //
     TGLayoutHints *laydisp = new TGLayoutHints(kLHintsNormal|kLHintsExpandY|kLHintsExpandX, 10, 10, 10, 10);
-    frame->AddFrame(tabdisp, laydisp);
+    frame->AddFrame(fEvtDisplay, laydisp);
 
     //
     // Now add all gui elements to 'autodel'-list
     //
-    fList->Add(tabdisp);
-    fList->Add(laycanvas);
+    fList->Add(fEvtDisplay);
     fList->Add(laydisp);
     fList->Add(laytabs);
@@ -475,5 +480,7 @@
     txt += "m  ZA=";
     txt += (int)(evt->GetTheta()*180/TMath::Pi()+.5);
-    txt += "°     ";
+    txt += "°  ";
+    txt += evt->GetPhotElfromShower();
+    txt += "PhEl";
 
     fEvtInfo->SetText(txt);
@@ -640,2 +647,3 @@
     return kTRUE;
 }
+
Index: /trunk/MagicSoft/Mars/meventdisp/MGEvtDisplay.h
===================================================================
--- /trunk/MagicSoft/Mars/meventdisp/MGEvtDisplay.h	(revision 1539)
+++ /trunk/MagicSoft/Mars/meventdisp/MGEvtDisplay.h	(revision 1540)
@@ -10,4 +10,5 @@
 #endif
 
+class TGTab;
 class TList;
 class TCanvas;
@@ -29,4 +30,6 @@
     TGLabel     *fEvtInfo;
     TGTextEntry *fTxtEvtNr;
+
+    TGTab       *fEvtDisplay;
 
     void AddMenuBar();
@@ -60,4 +63,6 @@
     MReadTree *GetReader() const;
 
+    TCanvas *AddTab(TString name);
+
     void   ReadFirstEvent();
     Bool_t IsInitOk() { return fInitOk; }
Index: /trunk/MagicSoft/Mars/mfileio/MCT1ReadAscii.cc
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MCT1ReadAscii.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/mfileio/MCT1ReadAscii.cc	(revision 1540)
@@ -51,4 +51,6 @@
 #include "MParList.h"
 #include "MCerPhotEvt.h"
+
+#include "MPedestalPix.h"
 #include "MPedestalCam.h"
 
Index: /trunk/MagicSoft/Mars/mgeom/MGeomCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeomCam.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/mgeom/MGeomCam.cc	(revision 1540)
@@ -112,4 +112,14 @@
 // --------------------------------------------------------------------------
 //
+//  returns the ratio of the area of the given pixel to the pixel with
+//  the id 0 to scale variables with the pixel size.
+//
+inline Float_t MGeomCam::GetPixRatio(Int_t i) const
+{
+    return (*this)[0].GetA()/(*this)[i].GetA();
+}
+
+// --------------------------------------------------------------------------
+//
 //  Prints the Geometry information of all pixels in the camera
 //
Index: /trunk/MagicSoft/Mars/mgeom/MGeomCam.h
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeomCam.h	(revision 1539)
+++ /trunk/MagicSoft/Mars/mgeom/MGeomCam.h	(revision 1540)
@@ -31,12 +31,15 @@
     virtual ~MGeomCam();
 
-    Float_t GetCameraDist() const { return fCamDist; }
-    Float_t GetConvMm2Deg() const { return fConvMm2Deg; }
+    Float_t GetCameraDist() const      { return fCamDist; }
+    Float_t GetConvMm2Deg() const      { return fConvMm2Deg; }
 
-    UInt_t  GetNumPixels() const { return fNumPixels; }
-    Float_t GetMaxRadius() const { return fMaxRadius; }
+    UInt_t  GetNumPixels() const       { return fNumPixels; }
+    Float_t GetMaxRadius() const       { return fMaxRadius; }
+    Float_t GetPixRatio(Int_t i) const;
 
     MGeomPix &operator[](Int_t i)       { return *(MGeomPix*)fPixels->UncheckedAt(i); }
     MGeomPix &operator[](Int_t i) const { return *(MGeomPix*)fPixels->UncheckedAt(i); }
+
+
 
     virtual void Print(Option_t *opt=NULL) const;
Index: /trunk/MagicSoft/Mars/mgui/MCamDisplay.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 1540)
@@ -28,5 +28,6 @@
 // MCamDisplay
 //
-// Camera Display
+// Camera Display. The Pixels are displayed in
+// contents/area [somthing/mm^2]
 //
 ////////////////////////////////////////////////////////////////////////////
@@ -38,4 +39,5 @@
 #include <TBox.h>
 #include <TText.h>
+#include <TArrow.h>
 #include <TStyle.h>
 #include <TCanvas.h>
@@ -45,5 +47,4 @@
 #include "MHexagon.h"
 
-#include "MGeomPix.h"
 #include "MGeomCam.h"
 
@@ -51,4 +52,9 @@
 #include "MCerPhotEvt.h"
 
+#include "MPedestalPix.h"
+#include "MPedestalCam.h"
+
+#include "MImgCleanStd.h"
+
 #define kItemsLegend 50 // see SetPalette(1,0)
 
@@ -60,5 +66,5 @@
 //
 MCamDisplay::MCamDisplay(MGeomCam *geom)
-    : fAutoScale(kTRUE), fMinPhe(-2), fMaxPhe(50), fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)
+    : fAutoScale(kTRUE), fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)
 {
     fGeomCam = (MGeomCam*)geom; // FIXME: Clone doesn't work! (MGeomCam*)geom->Clone();
@@ -108,4 +114,20 @@
         newtxt->SetTextAlign(12);
     }
+
+    fArrowX = new TArrow(-fRange*.9, -fRange*.9, -fRange*.6, -fRange*.9, 0.025);
+    fArrowY = new TArrow(-fRange*.9, -fRange*.9, -fRange*.9, -fRange*.6, 0.025);
+
+    TString text;
+    text += (int)(fRange*.3);
+    text += "mm";
+
+    fLegRadius = new TText(-fRange*.85, -fRange*.85, text);
+    text = "";
+    text += (float)((int)(fRange*.3*geom->GetConvMm2Deg()*10))/10;
+    text += "°";
+    text = text.Strip(TString::kLeading);
+    fLegDegree = new TText(-fRange*.85, -fRange*.75, text);
+    fLegRadius->SetTextSize(0.04);
+    fLegDegree->SetTextSize(0.04);
 }
 
@@ -124,8 +146,14 @@
     delete fLegText;
 
+    delete fArrowX;
+    delete fArrowY;
+
+    delete fLegRadius;
+    delete fLegDegree;
+
     // delete fGeomCam;
 
-    if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this &&
-        fIsAllocated)
+    // Maybe harmfull! Don't exchange the order!
+    if (fIsAllocated && fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
     {
         fDrawingPad->RecursiveRemove(this);
@@ -134,13 +162,61 @@
 }
 
-inline void MCamDisplay::SetPixColor(const MCerPhotPix &pix, const Int_t i)
-{
-    //
-    // Fixme: Divide pnum by the (real) area of the pixel
-    //
-    const Float_t ratio = (*fGeomCam)[0].GetA()/(*fGeomCam)[i].GetA();
+inline void MCamDisplay::SetPixColor(const MCerPhotPix &pix, const Int_t i, Float_t min, Float_t max)
+{
+    //
+    // Fixme: Use absolute value per mm^2. Needs another scaling algorithm.
+    //
+    const Float_t ratio = fGeomCam->GetPixRatio(i);
     const Float_t pnum  = ratio*pix.GetNumPhotons();
 
-    (*this)[pix.GetPixId()].SetFillColor(GetColor(pnum));
+    (*this)[pix.GetPixId()].SetFillColor(GetColor(pnum, min, max));
+}
+
+inline void MCamDisplay::SetPixColorPedestal(const MPedestalPix &pix, const Int_t i, Float_t min, Float_t max)
+{
+    //
+    // Fixme: Use absolute value per mm^2. Needs another scaling algorithm.
+    //
+    const Float_t ratio = fGeomCam->GetPixRatio(i);
+    const Float_t pnum  = ratio*pix.GetMean();
+
+    (*this)[i].SetFillColor(GetColor(pnum, min, max));
+}
+
+inline void MCamDisplay::SetPixColorError(const MCerPhotPix &pix, const Int_t i, Float_t min, Float_t max)
+{
+    //
+    // Fixme: Use absolute value per mm^2. Needs another scaling algorithm.
+    //
+    const Float_t ratio = fGeomCam->GetPixRatio(i);
+    const Float_t pnum  = ratio*pix.GetErrorPhot();
+
+    (*this)[pix.GetPixId()].SetFillColor(GetColor(pnum, min, max));
+}
+
+inline void MCamDisplay::SetPixColorRatio(const MCerPhotPix &pix, Float_t min, Float_t max)
+{
+    //
+    // Fixme: Use absolute value per mm^2. Needs another scaling algorithm.
+    //
+    const Float_t pnum  = pix.GetNumPhotons()/pix.GetErrorPhot();
+    (*this)[pix.GetPixId()].SetFillColor(GetColor(pnum, min, max));
+}
+
+inline void MCamDisplay::SetPixColorLevel(const MCerPhotPix &pix, Float_t lvl1, Float_t lvl2)
+{
+    const Int_t maxcolidx = kItemsLegend-1;
+
+    MHexagon &hex = (*this)[pix.GetPixId()];
+
+    const Float_t r = pix.GetNumPhotons()/pix.GetErrorPhot();
+
+    if (r>lvl1)
+        hex.SetFillColor(fColors[4*maxcolidx/5]);
+    else
+        if (r>lvl2)
+            hex.SetFillColor(fColors[maxcolidx/2]);
+        else
+            hex.SetFillColor(fColors[maxcolidx/5]);
 }
 
@@ -189,4 +265,11 @@
     //
     gPad->Range(-fRange, -y, x, y);
+
+    //
+    // Make sure, that the correct aspect is always displayed also
+    // if - by chance - there is not update for the pad after the
+    // Paint function was called.
+    //
+    gPad->Update();
 }
 
@@ -359,4 +442,10 @@
     }
 
+    fArrowX->Draw();
+    fArrowY->Draw();
+
+    fLegRadius->Draw();
+    fLegDegree->Draw();
+
     //
     // initialize and draw legend
@@ -433,4 +522,119 @@
         return;
 
+    Draw();
+
+    fDrawingPad->cd();
+
+    for (int i=0; i<kItemsLegend; i++)
+        GetBox(i)->SetFillColor(fColors[i]);
+
+    //
+    // Reset pixel colors to default value
+    //
+    Reset();
+
+    //
+    //  if the autoscale is true, set the values for the range for
+    //  each event
+    //
+    Float_t min = 0;
+    Float_t max = 50;
+    if (fAutoScale)
+    {
+        min = event->GetNumPhotonsMin(fGeomCam);
+        max = event->GetNumPhotonsMax(fGeomCam);
+
+        if (max < 20.)
+            max = 20.;
+
+        UpdateLegend(min, max);
+    }
+
+    //
+    //   update the colors in the picture
+    //
+    const Int_t entries = event->GetNumPixels();
+
+    for (Int_t i=0; i<entries; i++)
+    {
+        const MCerPhotPix &pix = (*event)[i];
+
+        if (!pix.IsPixelUsed())
+            continue;
+
+        SetPixColor(pix, i, min, max);
+    }
+
+    //
+    // Update display physically
+    //
+    fDrawingPad->Modified();
+    fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to draw the number of photo electron into the
+// camera.
+//
+void MCamDisplay::DrawPedestals(const MPedestalCam *event)
+{
+    if (!event)
+        return;
+
+    Draw();
+
+    fDrawingPad->cd();
+
+    for (int i=0; i<kItemsLegend; i++)
+        GetBox(i)->SetFillColor(fColors[i]);
+
+    //
+    // Reset pixel colors to default value
+    //
+    Reset();
+
+    //
+    //  if the autoscale is true, set the values for the range for
+    //  each event
+    //
+    Float_t min = 0;
+    Float_t max = 50;
+    if (fAutoScale)
+    {
+        min = event->GetMeanMin(fGeomCam);
+        max = event->GetMeanMax(fGeomCam);
+
+        if (max < 20.)
+            max = 20.;
+
+        UpdateLegend(min, max);
+    }
+
+    //
+    //   update the colors in the picture
+    //
+    const Int_t entries = event->GetSize();
+
+    for (Int_t i=0; i<entries; i++)
+        SetPixColorPedestal((*event)[i], i, min, max);
+
+    //
+    // Update display physically
+    //
+    fDrawingPad->Modified();
+    fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to draw the error of number of photo electron
+// into the camera.
+//
+void MCamDisplay::DrawErrorPhot(const MCerPhotEvt *event)
+{
+    if (!event)
+        return;
+
     if (!fDrawingPad)
         Draw();
@@ -450,13 +654,15 @@
     //  each event
     //
+    Float_t min = 0;
+    Float_t max = 50;
     if (fAutoScale)
     {
-        fMinPhe = event->GetNumPhotonsMin(fGeomCam);
-        fMaxPhe = event->GetNumPhotonsMax(fGeomCam);
-
-        if (fMaxPhe < 20.)
-            fMaxPhe = 20.;
-
-        UpdateLegend();
+        min = event->GetErrorPhotMin(fGeomCam);
+        max = event->GetErrorPhotMax(fGeomCam);
+
+        if (max < 20.)
+            max = 20.;
+
+        UpdateLegend(min, max);
     }
 
@@ -473,5 +679,5 @@
             continue;
 
-        SetPixColor(pix, i);
+        SetPixColorError(pix, i, min, max);
     }
 
@@ -481,4 +687,116 @@
     fDrawingPad->Modified();
     fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to draw the ratio of the number of photons
+// divided by its error
+//
+void MCamDisplay::DrawRatio(const MCerPhotEvt *event)
+{
+    if (!event)
+        return;
+
+    if (!fDrawingPad)
+        Draw();
+
+    fDrawingPad->cd();
+
+    for (int i=0; i<kItemsLegend; i++)
+        GetBox(i)->SetFillColor(fColors[i]);
+
+    //
+    // Reset pixel colors to default value
+    //
+    Reset();
+
+    //
+    //  if the autoscale is true, set the values for the range for
+    //  each event
+    //
+    Float_t min = 0;
+    Float_t max = 20;
+    if (fAutoScale)
+    {
+        min = event->GetRatioMin();
+        max = event->GetRatioMax();
+
+        UpdateLegend(min, max);
+    }
+
+    //
+    //   update the colors in the picture
+    //
+    const Int_t entries = event->GetNumPixels();
+
+    for (Int_t i=0; i<entries; i++)
+    {
+        const MCerPhotPix &pix = (*event)[i];
+
+        if (!pix.IsPixelUsed())
+            continue;
+
+        SetPixColorRatio(pix, min, max);
+    }
+
+    //
+    // Update display physically
+    //
+    fDrawingPad->Modified();
+    fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// Draw the colors in respect to the cleaning levels
+//
+void MCamDisplay::DrawLevels(const MCerPhotEvt *event, Float_t lvl1, Float_t lvl2)
+{
+    if (!event)
+        return;
+
+    if (!fDrawingPad)
+        Draw();
+
+    fDrawingPad->cd();
+
+    for (int i=0; i<kItemsLegend; i++)
+        GetBox(i)->SetFillColor(fColors[i]);
+
+    //
+    // Reset pixel colors to default value
+    //
+    Reset();
+
+    //
+    //   update the colors in the picture
+    //
+    const Int_t entries = event->GetNumPixels();
+
+    for (Int_t i=0; i<entries; i++)
+    {
+        const MCerPhotPix &pix = (*event)[i];
+
+        if (!pix.IsPixelUsed())
+            continue;
+
+        SetPixColorLevel(pix, lvl1, lvl2);
+    }
+
+    //
+    // Update display physically
+    //
+    fDrawingPad->Modified();
+    fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// Draw the colors in respect to the cleaning levels
+//
+void MCamDisplay::DrawLevels(const MCerPhotEvt *event, const MImgCleanStd &clean)
+{
+    DrawLevels(event, clean.GetCleanLvl1(), clean.GetCleanLvl2());
 }
 
@@ -504,5 +822,5 @@
 //   with 0 up to 49.
 //
-Int_t MCamDisplay::GetColor(Float_t val)
+Int_t MCamDisplay::GetColor(Float_t val, Float_t min, Float_t max)
 {
     //
@@ -511,8 +829,8 @@
     const Int_t maxcolidx = kItemsLegend-1;
 
-    if (val >= fMaxPhe)
+    if (val >= max)
         return fColors[maxcolidx];
 
-    if (val <= fMinPhe)
+    if (val <= min)
         return fColors[0];
 
@@ -520,5 +838,5 @@
     // calculate the color index
     //
-    const Float_t ratio  = (val-fMinPhe) / (fMaxPhe-fMinPhe);
+    const Float_t ratio  = (val-min) / (max-min);
     const Int_t   colidx = (Int_t)(ratio*maxcolidx + .5);
 
@@ -531,5 +849,5 @@
 //    Display
 //
-void MCamDisplay::UpdateLegend()
+void MCamDisplay::UpdateLegend(Float_t minphe, Float_t maxphe)
 {
     char text[10];
@@ -537,5 +855,5 @@
     for (Int_t i=0; i<kItemsLegend; i+=3)
     {
-        const Float_t val = fMinPhe + (Float_t)i/kItemsLegend * (fMaxPhe-fMinPhe) ;
+        const Float_t val = minphe + (Float_t)i/kItemsLegend * (maxphe-minphe) ;
 
         sprintf(text, "%5.1f", val);
Index: /trunk/MagicSoft/Mars/mgui/MCamDisplay.h
===================================================================
--- /trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 1539)
+++ /trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 1540)
@@ -11,4 +11,5 @@
 class TBox;
 class TText;
+class TArrow;
 class TVirtualPad;
 
@@ -17,4 +18,7 @@
 class MCerPhotEvt;
 class MCerPhotPix;
+class MImgCleanStd;
+class MPedestalPix;
+class MPedestalCam;
 
 class MCamDisplay : public TObject
@@ -28,8 +32,11 @@
     Float_t        fRange;       // the range in millimeters of the present geometry
 
-    Float_t        fMinPhe;      // The minimal number of Phe
-    Float_t        fMaxPhe;      // The maximum number of Phe
+    Int_t          fColors[50];
 
-    Int_t          fColors[50];
+    TArrow        *fArrowX;      // Coordinate System
+    TArrow        *fArrowY;      // Coordinate System
+
+    TText         *fLegRadius;   // Coordinate System
+    TText         *fLegDegree;   // Coordinate System
 
     TClonesArray  *fPixels;      // array of all hexagons
@@ -47,8 +54,12 @@
     MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
 
-    void  SetPixColor(const MCerPhotPix &pix, const Int_t i);
-    Int_t GetColor(Float_t wert);
+    void  SetPixColor(const MCerPhotPix &pix, const Int_t i, Float_t min, Float_t max);
+    void  SetPixColorRatio(const MCerPhotPix &pix, Float_t min, Float_t max);
+    void  SetPixColorLevel(const MCerPhotPix &pix, Float_t lvl1, Float_t lvl2);
+    void  SetPixColorError(const MCerPhotPix &pix, const Int_t i, Float_t min, Float_t max);
+    void  SetPixColorPedestal(const MPedestalPix &pix, Int_t i, Float_t min, Float_t max);
+    Int_t GetColor(Float_t val, Float_t min, Float_t max);
 
-    void UpdateLegend();
+    void UpdateLegend(Float_t min, Float_t max);
     void Paint(Option_t *option="");
 
@@ -59,4 +70,9 @@
     void SetAutoScale(Bool_t input=kTRUE) { fAutoScale = input; }
     void DrawPhotNum(const MCerPhotEvt *event);
+    void DrawRatio(const MCerPhotEvt *event);
+    void DrawLevels(const MCerPhotEvt *event, Float_t lvl1, Float_t lvl2);
+    void DrawErrorPhot(const MCerPhotEvt *event);
+    void DrawLevels(const MCerPhotEvt *event, const MImgCleanStd &clean);
+    void DrawPedestals(const MPedestalCam *event);
 
     void DrawPixelNumbers();
Index: /trunk/MagicSoft/Mars/mhist/MHHillasSrc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHHillasSrc.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/mhist/MHHillasSrc.cc	(revision 1540)
@@ -155,11 +155,11 @@
 void MHHillasSrc::SetMm2Deg(Float_t mmdeg)
 {
-    if (mmdeg<0)
-    {
-        *fLog << warn << dbginf << "Warning - Conversion factor < 0 - nonsense. Ignored." << endl;
+    if (mmdeg<=0)
+    {
+        *fLog << warn << dbginf << "Warning - Conversion factor <= 0 - nonsense. Ignored." << endl;
         return;
     }
 
-    if (fMm2Deg>=0)
+    if (fMm2Deg>0)
         *fLog << warn << dbginf << "Warning - Conversion factor already set. Overwriting" << endl;
 
Index: /trunk/MagicSoft/Mars/mhist/MHStarMap.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHStarMap.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/mhist/MHStarMap.cc	(revision 1540)
@@ -119,5 +119,5 @@
     {
         float r = geom ? geom->GetMaxRadius() : 600;
-        r *= 2./3;
+        r *= 5./6;
         if (!fUseMmScale)
             r *= fMm2Deg;
Index: /trunk/MagicSoft/Mars/mmain/MMars.cc
===================================================================
--- /trunk/MagicSoft/Mars/mmain/MMars.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/mmain/MMars.cc	(revision 1540)
@@ -111,16 +111,25 @@
 }
 
-void MMars::CreateTextButton(TGVerticalFrame *tab, const char *text,
-                             const UInt_t id, TGLayoutHints *hints) const
+#include <TGLabel.h>
+
+void MMars::CreateTextButton(TGVerticalFrame *tab,
+                             const char *text, const char *descr,
+                             const UInt_t id) const
 {
     //
     // Create the button
     //
-    TGTextButton *button = new TGTextButton(tab, text, id);
+    TGHorizontalFrame *frame  = new TGHorizontalFrame(tab, 1, 1);
+    TGTextButton      *button = new TGTextButton(frame, text, id);
+    TGLabel           *label  = new TGLabel(frame, descr);
+    TGLayoutHints     *hints1 = new TGLayoutHints(kLHintsLeft|kLHintsCenterY|kLHintsExpandX, 5, 5, 2, 2);
 
     //
     // Add button for 'auto-delete'
     //
+    fList->Add(hints1);
     fList->Add(button);
+    fList->Add(label);
+    fList->Add(frame);
 
     //
@@ -132,5 +141,7 @@
     // Add button with corresponding layout to containing frame
     //
-    tab->AddFrame(button, hints);
+    tab->AddFrame(frame,    hints1);
+    frame->AddFrame(button, hints1);
+    frame->AddFrame(label,  hints1);
 }
 
@@ -143,5 +154,5 @@
     fList->Add(laytabs);
 
-    TGTab *tabs = new TGTab(low, 400, 400);
+    TGTab *tabs = new TGTab(low, 1, 1);
     fList->Add(tabs);
     low->AddFrame(tabs, laytabs);
@@ -152,28 +163,25 @@
     TGCompositeFrame *tf = tabs->AddTab("Control");
 
-    TGVerticalFrame *tab1 = new TGVerticalFrame(tf, 300, 100);
-    TGVerticalFrame *tab2 = new TGVerticalFrame(tf, 300, 100);
-
-    fList->Add(tab1);
-    fList->Add(tab2);
-
-    TGLayoutHints *laytabx = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
-    fList->Add(laytabx);
-
-    tf->AddFrame(tab1, laytabx);
-    tf->AddFrame(tab2, laytabx);
-
-    TGLayoutHints *laybut = new TGLayoutHints(kLHintsTop|kLHintsCenterX, 10, 10, 10, 10);
-    fList->Add(laybut);
-
-    CreateTextButton(tab2, "Event Display",  kButEvtDisplay,    laybut);
-    CreateTextButton(tab2, "Data Check",     kButDataCheck,  laybut);
-    CreateTextButton(tab2, "Analysis",       kButAnalysis,    laybut);
-    CreateTextButton(tab2, "Monte Carlo",    kButMonteCarlo, laybut);
-    CreateTextButton(tab2, "Camera Display", kButCameraDisplay, laybut);
+    TGLayoutHints   *laytab = new TGLayoutHints(kLHintsCenterY|kLHintsExpandX);
+    TGVerticalFrame *tab    = new TGVerticalFrame(tf, 1, 1);
+    fList->Add(laytab);
+    fList->Add(tab);
+
+    CreateTextButton(tab, "Event Display",  "Historgrams: Pix per Event",
+                     kButEvtDisplay);
+    CreateTextButton(tab, "Data Check",     "Histograms: Pix per Run",
+                     kButDataCheck);
+    CreateTextButton(tab, "Analysis",       "Calculate image parameters",
+                     kButAnalysis);
+    CreateTextButton(tab, "Monte Carlo",    "Calculate MC stuff",
+                     kButMonteCarlo);
+    CreateTextButton(tab, "Camera Display", "Display Cerenekov Photons",
+                     kButCameraDisplay);
+
+    tf->AddFrame(tab, laytab);
 }
 
 MMars::MMars()
-: TGMainFrame(gClient->GetRoot(), 330, 400, kVerticalFrame|kFixedSize)
+: TGMainFrame(gClient->GetRoot(), 400, 400, kVerticalFrame)
 {
     //
@@ -191,6 +199,6 @@
     // create and layout the frame/contents
     //
-    TGHorizontalFrame *top = new TGHorizontalFrame(this, 300, 100);
-    TGHorizontalFrame *low = new TGHorizontalFrame(this, 300, 100);
+    TGHorizontalFrame *top = new TGHorizontalFrame(this, 1, 1);
+    TGHorizontalFrame *low = new TGHorizontalFrame(this, 1, 1);
 
     TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
@@ -203,24 +211,21 @@
     CreateBottomFrame(low);
 
-    TGLayoutHints *layout = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
-    fList->Add(layout);
-
-    AddFrame(top,     layout);
-    AddFrame(linesep, layout);
-    AddFrame(low,     layout);
-
-    //    CreateTopFrame(fTop2);
-    //    CreateBottomFrame(fTop3);
+    TGLayoutHints *layout1 = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
+    TGLayoutHints *layout2 = new TGLayoutHints(kLHintsTop|kLHintsExpandX|kLHintsExpandY);
+    fList->Add(layout1);
+    fList->Add(layout2);
+
+    AddFrame(top,     layout1);
+    AddFrame(linesep, layout1);
+    AddFrame(low,     layout2);
 
     //
     //   Map the window, set up the layout, etc.
-    //   kFixedSize seems to be ignored
-    //
-    SetWMSizeHints(GetWidth(), GetHeight(), GetWidth(), GetHeight(), 0, 0);  // set the smallest and biggest size of the Main frame
+    //
     Move(rand()%100, rand()%100);
 
+    Layout();
+
     MapSubwindows();
-
-    Layout();
 
     SetWindowName("MARS Main Window");
Index: /trunk/MagicSoft/Mars/mmain/MMars.h
===================================================================
--- /trunk/MagicSoft/Mars/mmain/MMars.h	(revision 1539)
+++ /trunk/MagicSoft/Mars/mmain/MMars.h	(revision 1540)
@@ -21,5 +21,5 @@
 
     void CreateTextButton(TGVerticalFrame *tab, const char *text,
-                          const UInt_t id, TGLayoutHints *hints) const;
+                          const char *descr, const UInt_t id) const;
 
     void CreateMenuBar();
Index: /trunk/MagicSoft/Mars/mmain/MProgressBar.cc
===================================================================
--- /trunk/MagicSoft/Mars/mmain/MProgressBar.cc	(revision 1539)
+++ /trunk/MagicSoft/Mars/mmain/MProgressBar.cc	(revision 1540)
@@ -53,4 +53,6 @@
     fList->SetOwner();
 
+    //SetMWMHints(0, 0, 0);
+
     SetWMSizeHints(150, 15, 640, 480, 10, 10); // set the smallest and biggest size of the Main frame
     Move(rand()%100+50, rand()%100+50);
