Index: /trunk/MagicSoft/Mars/ganymed.cc
===================================================================
--- /trunk/MagicSoft/Mars/ganymed.cc	(revision 6889)
+++ /trunk/MagicSoft/Mars/ganymed.cc	(revision 6890)
@@ -49,5 +49,6 @@
     gLog << "   -b                        Batch mode (no graphical output to screen)" << endl<<endl;
     gLog << " Operation Mode:" << endl;
-    gLog << "   --wobble                  Wobble Mode" << endl << endl;
+    gLog << "   --wobble                  Force wobble mode (overwrites dataset)" << endl;
+    gLog << "   --no-wobble               Force normal mode (overwrites dataset)" << endl << endl;
     gLog << " Options:" << endl;
     gLog.Usage();
@@ -112,18 +113,26 @@
     kDebugEnv = arg.GetIntAndRemove("--debug-env=", kDebugEnv);
 
-    const Bool_t  kQuit         = arg.HasOnlyAndRemove("-q");
-    const Bool_t  kBatch        = arg.HasOnlyAndRemove("-b");
-    const Bool_t  kOverwrite    = arg.HasOnlyAndRemove("-f");
-    //const Bool_t  kForceExec  = arg.HasOnlyAndRemove("-ff");
-
-    const Bool_t  kModeWobble   = arg.HasOnlyAndRemove("--wobble");
-
-    const Int_t   kNumAnalysis  = arg.GetIntAndRemove("--n=", -1);
-    const TString kOutpath      = arg.GetStringAndRemove("--out=",  ".");
-    const TString kOutfile      = arg.GetStringAndRemove("--outf=",  "");
-    const Bool_t  kWriteSummary = arg.HasOnlyAndRemove("--sum");
-    const TString kNameSummary  = arg.GetStringAndRemove("--sum=");
-    const Bool_t  kWriteResult  = arg.HasOnlyAndRemove("--res");
-    const TString kNameResult   = arg.GetStringAndRemove("--res=");
+    const Bool_t  kQuit          = arg.HasOnlyAndRemove("-q");
+    const Bool_t  kBatch         = arg.HasOnlyAndRemove("-b");
+    const Bool_t  kOverwrite     = arg.HasOnlyAndRemove("-f");
+    //const Bool_t  kForceExec   = arg.HasOnlyAndRemove("-ff");
+
+    const Bool_t  kWobbleModeOn  = arg.HasOnlyAndRemove("--wobble");
+    const Bool_t  kWobbleModeOff = arg.HasOnlyAndRemove("--no-wobble");
+
+    const Int_t   kNumAnalysis   = arg.GetIntAndRemove("--n=", -1);
+    const TString kOutpath       = arg.GetStringAndRemove("--out=",  ".");
+    const TString kOutfile       = arg.GetStringAndRemove("--outf=",  "");
+    const Bool_t  kWriteSummary  = arg.HasOnlyAndRemove("--sum");
+    const TString kNameSummary   = arg.GetStringAndRemove("--sum=");
+    const Bool_t  kWriteResult   = arg.HasOnlyAndRemove("--res");
+    const TString kNameResult    = arg.GetStringAndRemove("--res=");
+
+    if (kWobbleModeOn && kWobbleModeOff)
+    {
+        gLog << err << "ERROR - Wobble mode options are exclusive." << endl;
+        Usage();
+        return 2;
+    }
 
     if (arg.GetNumOptions()>0)
@@ -194,4 +203,10 @@
         return 1;
     }
+
+    Bool_t iswobble = seq.IsWobbleMode();
+    if (kWobbleModeOn)
+        iswobble = kTRUE;
+    if (kWobbleModeOff)
+        iswobble = kFALSE;
 
     //
@@ -219,5 +234,5 @@
     job.SetNameResultFile(kNameResult);
     job.EnableWriteOnly(kWriteOnly);
-    job.EnableWobbleMode(kModeWobble);
+    job.EnableWobbleMode(iswobble);
     if (kWriteSummary) // Don't change flag set in SetNameSummaryFile
         job.EnableStorageOfSummary();
Index: /trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 6889)
+++ /trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 6890)
@@ -263,4 +263,18 @@
 
     return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the memory currently used by this process (VmSize)
+// which contains shared memory, data memory and private memory.
+//
+UInt_t MEvtLoop::GetMemoryUsage()
+{
+    const TString path = Form("/proc/%d/status", gSystem->GetPid());
+    if (gSystem->AccessPathName(path, kFileExists))
+        return 0;
+
+    return TEnv(path).GetValue("VmSize", 0);
 }
 
@@ -400,4 +414,6 @@
         return kFALSE;
 
+    const UInt_t mem0 = GetMemoryUsage();
+
     //
     //   loop over all events and process all tasks for
@@ -514,4 +530,9 @@
     if (numcnts>0)
         *fLog << " --> " << numcnts/clock.RealTime() << " Events/s";
+
+
+    const UInt_t mem1 = GetMemoryUsage();
+    if (mem1>mem0)
+        *fLog << endl << "Mem  - Loss: " << mem1-mem0 << "kB" << endl;
 
     *fLog << endl << endl;
Index: /trunk/MagicSoft/Mars/mbase/MEvtLoop.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 6889)
+++ /trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 6890)
@@ -40,4 +40,5 @@
 
     Bool_t ProcessGuiEvents(Int_t num);
+    static UInt_t GetMemoryUsage();
 
 public:
Index: /trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 6889)
+++ /trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 6890)
@@ -64,4 +64,5 @@
 
 #include <TH1.h>                  // TH1::AddDirectory
+#include <TEnv.h>                 // TEnv
 #include <TLine.h>                // TLine
 #include <TText.h>                // TText
@@ -239,8 +240,12 @@
     MGPopupMenu *sizemenu = new MGPopupMenu(gClient->GetRoot());
     sizemenu->AddEntry("Fit to 640x&480",   kSize640);
+    sizemenu->AddEntry("Fit to 768x&576",   kSize768);
     sizemenu->AddEntry("Fit to 800x&600",   kSize800);
     sizemenu->AddEntry("Fit to 960x7&20",   kSize960);
     sizemenu->AddEntry("Fit to 1024x&768",  kSize1024);
+    sizemenu->AddEntry("Fit to 1152x&864",  kSize1152);
     sizemenu->AddEntry("Fit to 1280x&1024", kSize1280);
+    sizemenu->AddEntry("Fit to 1400x1050",  kSize1400);
+    sizemenu->AddEntry("Fit to 1600x1200",  kSize1600);
     sizemenu->Associate(this);
 
@@ -524,7 +529,7 @@
     //       a = (-1+-sqrt(1+4))/2 = sqrt(5)/2-1/2 = 0.618
     //
-    Int_t p[2] = {38, 62};
-
-    fStatusBar->SetParts(p, 2);
+    Int_t p[] = {38-2, 62-8, 10};
+
+    fStatusBar->SetParts(p, 3);
 
     TGLayoutHints *layb = new TGLayoutHints(kLHintsNormal|kLHintsExpandX, 5, 4, 0, 3);
@@ -539,9 +544,9 @@
 // Change the text in the status line 1
 //
-void MStatusDisplay::SetStatusLine1(const char *txt)
+void MStatusDisplay::SetStatusLine(const char *txt, Int_t i)
 {
     if (gROOT->IsBatch())
         return;
-    fStatusBar->SetText(txt, 0);
+    fStatusBar->SetText(txt, i);
 
     // FIXME: This is a workaround, because TApplication::Run is not
@@ -555,23 +560,4 @@
 // --------------------------------------------------------------------------
 //
-// Change the text in the status line 2
-//
-void MStatusDisplay::SetStatusLine2(const char *txt)
-{
-    if (gROOT->IsBatch())
-        return;
-
-    fStatusBar->SetText(txt, 1);
-
-    // FIXME: This is a workaround, because TApplication::Run is not
-    //        thread safe against ProcessEvents. We assume, that if
-    //        we are not in the Main-Thread ProcessEvents() is
-    //        called by the TApplication Event Loop...
-    if (!TThread::Self()/*gApplication->InheritsFrom(TRint::Class())*/)
-        gClient->ProcessEventsFor(fStatusBar);
-}
-
-// --------------------------------------------------------------------------
-//
 // Display information about the name of a container
 //
@@ -643,5 +629,5 @@
     // set the smallest and biggest size of the Main frame
     // and move it to its appearance position
-    SetWMSizeHints(570, 480, 1280, 980, 1, 1);
+    SetWMSizeHints(570, 480, 2048, 1536, 1, 1);
     MoveResize(rand()%100+570, rand()%100+480, 570, 480);
 
@@ -1264,18 +1250,29 @@
         return kTRUE;
 
-    case kSize640:
+    case kSize640:  
         Resize(570, 480);
         return kTRUE;
-    case kSize800:
+    case kSize768:  
+        Resize(700, 576);
+        return kTRUE;
+    case kSize800:  
         Resize(740, 600);
         return kTRUE;
-    case kSize960:
+    case kSize960:  
         Resize(880, 700);
         return kTRUE;
-    case kSize1024:
+    case kSize1024: 
         Resize(980, 768);
         return kTRUE;
-    case kSize1280:
+    case kSize1152:
+        Resize(1080, 864);
+    case kSize1280: 
         Resize(1280, 980);
+        return kTRUE;
+    case kSize1400:
+        Resize(1350, 1050);
+        return kTRUE;
+    case kSize1600:
+        Resize(1550, 1400);
         return kTRUE;
 
@@ -1527,5 +1524,6 @@
 void MStatusDisplay::CloseWindow()
 {
-    Close();
+    if (Close())
+        delete this;
 }
 
@@ -1552,4 +1550,36 @@
 // --------------------------------------------------------------------------
 //
+// Update the memory display in the status bar
+//
+void MStatusDisplay::UpdateMemory() const
+{
+    const TString path = MString::Form("/proc/%d/status", gSystem->GetPid());
+    if (gSystem->AccessPathName(path, kFileExists))
+        return;
+
+    TEnv env(path);
+    const UInt_t kb = env.GetValue("VmSize", 0);
+    if (kb==0)
+        return;
+
+    char type = 'k';
+    Float_t val = kb;
+
+    if (val>999)
+    {
+        type = 'M';
+        val /= 1024;
+    }
+    if (val>999)
+    {
+        type = 'G';
+        val /= 1024;
+    }
+    const TString txt = MString::Form("%.1f%c", val, type);
+    fStatusBar->SetText(txt, 2);
+}
+
+// --------------------------------------------------------------------------
+//
 // Updates the canvas (if existing) in the currenly displayed Tab.
 // The update intervall is controlled by StartUpdate and StopUpdate
@@ -1559,4 +1589,6 @@
     if (gROOT->IsBatch())
         return kTRUE;
+
+    UpdateMemory();
 
     const Int_t c = fTab->GetCurrent();
@@ -2480,5 +2512,5 @@
     {
         if (Close())
-        delete this;
+            delete this;
 //        Close();
         return kTRUE;
Index: /trunk/MagicSoft/Mars/mbase/MStatusDisplay.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MStatusDisplay.h	(revision 6889)
+++ /trunk/MagicSoft/Mars/mbase/MStatusDisplay.h	(revision 6890)
@@ -46,5 +46,6 @@
         kTabSaveAsC, kTabPrint, kTabNext, kTabPrevious, kTabRemove,
         // kSize
-        kSize640, kSize800, kSize960, kSize1024, kSize1280,
+        kSize640, kSize768, kSize800, kSize960, kSize1024, kSize1152,
+        kSize1280, kSize1400, kSize1600,
         // kLog
         kLogCopy, kLogClear, kLogSelect, kLogFind, kLogSave, kLogAppend,
@@ -117,4 +118,5 @@
     Bool_t HandleTimer(TTimer *timer=NULL);
     void UpdateTab(TGCompositeFrame *f);
+    void UpdateMemory() const;
 
     void DrawClonePad(TCanvas &newc, TCanvas &oldc) const;
@@ -127,4 +129,5 @@
 
     void RemoveTab(int i);
+    void SetStatusLine(const char *txt, Int_t idx);
 
     TRootEmbeddedCanvas *GetEmbeddedCanvas(TGCompositeFrame *cf) const;
@@ -143,6 +146,6 @@
      TGProgressBar *GetBar() const { return (TGProgressBar*)fBar; }
 
-     void SetStatusLine1(const char *txt);
-     void SetStatusLine2(const char *txt);
+     void SetStatusLine1(const char *txt) { SetStatusLine(txt, 0); }
+     void SetStatusLine2(const char *txt) { SetStatusLine(txt, 1); }
      void SetStatusLine2(const MParContainer &cont);
 
Index: /trunk/MagicSoft/Mars/mhbase/MH.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 6889)
+++ /trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 6890)
@@ -664,11 +664,11 @@
     Double_t min = FLT_MAX;
 
-    const TAxis &axex = *((TH1&)h).GetXaxis();
-    const TAxis &axey = *((TH1&)h).GetYaxis();
-    const TAxis &axez = *((TH1&)h).GetZaxis();
-
-    for (int iz=1; iz<=axez.GetNbins(); iz++)
-        for (int iy=1; iy<=axey.GetNbins(); iy++)
-            for (int ix=1; ix<=axex.GetNbins(); ix++)
+    const Int_t nx = h.GetXaxis()->GetNbins();
+    const Int_t ny = h.GetYaxis()->GetNbins();
+    const Int_t nz = h.GetZaxis()->GetNbins();
+
+    for (int iz=1; iz<=nz; iz++)
+        for (int iy=1; iy<=ny; iy++)
+            for (int ix=1; ix<=nx; ix++)
             {
                 const Double_t v = h.GetBinContent(h.GetBin(ix, iy, iz));
Index: /trunk/MagicSoft/Mars/mhbase/MHMatrix.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhbase/MHMatrix.cc	(revision 6889)
+++ /trunk/MagicSoft/Mars/mhbase/MHMatrix.cc	(revision 6890)
@@ -143,5 +143,5 @@
 Int_t MHMatrix::AddColumn(const char *rule)
 {
-    if (fM.IsValid())
+    if (IsValid(fM))
     {
         *fLog << warn << "Warning - matrix is already in use. Can't add a new column... skipped." << endl;
@@ -173,5 +173,5 @@
 void MHMatrix::AddColumns(MDataArray *matrix)
 {
-    if (fM.IsValid())
+    if (IsValid(fM))
     {
         *fLog << warn << "Warning - matrix is already in use. Can't add new columns... skipped." << endl;
@@ -224,5 +224,5 @@
         return;
 
-    if (!fM.IsValid())
+    if (!IsValid(fM))
     {
         fM.ResizeTo(1, fData->GetNumEntries());
@@ -525,7 +525,7 @@
 Double_t MHMatrix::CalcDist(const TVector &evt, Int_t num)
 {
-    if (!fM2.IsValid())
-    {
-        if (!fM.IsValid())
+    if (!IsValid(fM2))
+    {
+        if (!IsValid(fM))
         {
             *fLog << err << "MHMatrix::CalcDist - ERROR: fM not valid." << endl;
@@ -803,5 +803,5 @@
                               Int_t nmaxevts, TMatrix *rest)
 {
-    if (!fM.IsValid())
+    if (!IsValid(fM))
     {
         *fLog << err << dbginf << "Matrix not initialized" << endl;
@@ -1001,5 +1001,5 @@
 Bool_t MHMatrix::DefRefMatrix(Int_t nmaxevts, TMatrix *rest)
 {
-    if (!fM.IsValid())
+    if (!IsValid(fM))
     {
         *fLog << err << dbginf << "Matrix not initialized" << endl;
@@ -1113,5 +1113,5 @@
 Int_t MHMatrix::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
 {
-    if (fM.IsValid())
+    if (IsValid(fM))
     {
         *fLog << err << "ERROR - matrix is already in use. Can't add a new column from TEnv... skipped." << endl;
Index: /trunk/MagicSoft/Mars/mhbase/MHMatrix.h
===================================================================
--- /trunk/MagicSoft/Mars/mhbase/MHMatrix.h	(revision 6889)
+++ /trunk/MagicSoft/Mars/mhbase/MHMatrix.h	(revision 6890)
@@ -44,4 +44,8 @@
 
     void AddRow();
+    Bool_t IsValid(const TMatrix &m) const
+    {
+        return m.GetNrows()>0 && m.IsValid();
+    }
 
     Bool_t SetupFill(const MParList *pList);
@@ -73,5 +77,5 @@
     const TMatrix &GetM() const { return fM; }
 
-    Bool_t IsValid() const { return fM.IsValid(); }
+    Bool_t IsValid() const { return IsValid(fM); }
     Int_t  GetNumRows() const { return fM.GetNrows(); }
 
Index: /trunk/MagicSoft/Mars/mhflux/FluxLinkDef.h
===================================================================
--- /trunk/MagicSoft/Mars/mhflux/FluxLinkDef.h	(revision 6889)
+++ /trunk/MagicSoft/Mars/mhflux/FluxLinkDef.h	(revision 6890)
@@ -10,4 +10,5 @@
 #pragma link C++ class MHEnergyEst+;
 #pragma link C++ class MHFalseSource+;
+#pragma link C++ class MHEnergyEst+;
 #pragma link C++ class MHEffectiveOnTime+;
 
Index: /trunk/MagicSoft/Mars/mhflux/MHAlpha.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhflux/MHAlpha.cc	(revision 6889)
+++ /trunk/MagicSoft/Mars/mhflux/MHAlpha.cc	(revision 6890)
@@ -138,5 +138,5 @@
     MBinning binsa, binse, binst;
     binsa.SetEdges(18, 0, 90);
-    binse.SetEdgesLog(25, 10, 100000);
+    binse.SetEdgesLog(15, 10, 100000);
     binst.SetEdgesCos(50, 0, 60);
     binse.Apply(fHEnergy);
@@ -467,4 +467,5 @@
 
         alpha  = hil->GetAlpha();
+
         if (fHillas)
             size = fHillas->GetSize();
@@ -472,4 +473,7 @@
         theta  = fPointPos ? fPointPos->GetZd()   : 0;
     }
+
+    //if (size>0)
+    //    alpha /= (2.4 + 1.13*(log10((energy-14)/0.37)-5)*(log10((energy-14)/0.37)-5))/15;
 
     // enhance histogram if necessary
@@ -563,4 +567,6 @@
             }
         }
+        else
+            hon->SetMinimum(0);
         FitEnergyBins();
         FitThetaBins();
@@ -748,5 +754,5 @@
     Int_t n = fHAlpha.GetNbinsY();
     Int_t nc = (Int_t)(TMath::Sqrt((Float_t)n-1)+1);
-    c->Divide(nc, nc, 0, 0);
+    c->Divide(nc, nc, 1e-10, 1e-10);
 
     // Do not store the 'final' result in fFit
Index: /trunk/MagicSoft/Mars/mhflux/MHEnergyEst.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhflux/MHEnergyEst.cc	(revision 6889)
+++ /trunk/MagicSoft/Mars/mhflux/MHEnergyEst.cc	(revision 6890)
@@ -147,4 +147,7 @@
 
     fChisq = 0;
+    fHEnergy.Reset();
+    fHImpact.Reset();
+    fHResolution.Reset();
 
     return kTRUE;
@@ -159,13 +162,14 @@
     const Double_t eest  = fEnergy->GetEnergy();
     const Double_t etru  = fMatrix ? GetVal(0) : fMcEvt->GetEnergy();
+    const Double_t imp   = fMatrix ? GetVal(1) : fMcEvt->GetImpact()/100;
     const Double_t theta = fMatrix ? GetVal(2) : fMcEvt->GetTelescopeTheta()*TMath::RadToDeg();
-    const Double_t imp   = fMatrix ? GetVal(1) : fMcEvt->GetImpact()/100;
     const Double_t res   = (eest-etru)/etru;
 
     fHEnergy.Fill(eest, etru, theta, w);
-    fHResolution.Fill(eest, etru, res, w);
-    fHImpact.Fill(imp, res, w);
-
-    fChisq += res*res;
+    fHResolution.Fill(eest, etru, TMath::Abs(res), w);
+    fHImpact.Fill(imp, TMath::Abs(res), w);
+
+    fChisq += TMath::Abs(res);//*res;
+    fBias  += res;
 
     return kTRUE;
@@ -175,8 +179,12 @@
 {
     fChisq /= GetNumExecutions();
-
-    fResult->SetVal(fChisq);
-
-    *fLog << all << "Mean Energy Resoltuion: " << Form("%.1f%%", TMath::Sqrt(fChisq)*100) << endl;
+    fBias  /= GetNumExecutions();
+
+    Double_t res = fChisq; //TMath::Sqrt(fChisq - fBias*fBias);
+
+    fResult->SetVal(TMath::IsNaN(res)?0:res);/// GetNumExecutions());
+
+    *fLog << all << "Mean Energy Resoltuion: " << Form("%.1f%%", fResult->GetVal()*100) << endl;
+    *fLog << all << "Energy Bias at:         " << Form("%.1f%%", fBias*100) << endl;
 
     return kTRUE;
@@ -223,14 +231,14 @@
         {
             pad->GetPad(1)->GetPad(2)->cd(1);
-            /*h =*/ fHImpact.ProjectionX("Impact", -1, 9999, "e");
-
-            pad->GetPad(1)->GetPad(2)->cd(2);
-            if ((hx=(TH1D*)gPad->FindObject("EnergyEst_z")))
+            if ((hx=(TH1D*)gPad->FindObject("EnergyEst_ez")))
             {
-                TH1D *h2 = (TH1D*)fHEnergy.Project3D("dum_z");
+                TH1D *h2 = (TH1D*)fHEnergy.Project3D("dum_ez");
                 hx->Reset();
                 hx->Add(h2);
                 delete h2;
             }
+
+            //pad->GetPad(1)->GetPad(2)->cd(2);
+            ///*h =*/ fHImpact.ProjectionX("Impact", -1, 9999, "e");
         }
     }
@@ -273,7 +281,7 @@
 
     TH1D *hx = 0;
-    if ((hx=(TH1D*)gPad->FindObject("Prof")))
+    if ((hx=(TH1D*)gPad->FindObject(Form("Prof%s", h.GetName()))))
     {
-        hx = hyx->ProfileX("Prof", -1, 9999, "s");
+        hx = hyx->ProfileX(Form("Prof%s", h.GetName()), -1, 9999, "s");
 
         if (logy && hx->GetMaximum()>0)
@@ -287,21 +295,22 @@
     gPad->SetLogx();
 
-    gROOT->GetListOfCleanups()->Add(gPad); // WHY?
+    //gROOT->GetListOfCleanups()->Add(gPad); // WHY?
 
     TH2D *h2 = (TH2D*)h.Project3D(how);
-    TH1D *h1 = h2->ProfileX("Prof", -1, 9999, "s");
-
-    h1->SetDirectory(NULL);
-    //h1->SetBit(kCanDelete);
-    h1->SetLineWidth(2);
-    h1->SetLineColor(kRed); // PROBLEM!
-    h1->SetStats(kFALSE);
-
     h2->SetDirectory(NULL);
     h2->SetBit(kCanDelete);
     h2->SetFillColor(kBlue);
 
-    h1->Draw("E3");
-    h2->Draw("boxsame");
+    TH1D *h1 = h2->ProfileX(Form("Prof%s", h.GetName()), -1, 9999, "s");
+    h1->SetDirectory(NULL);
+    h1->SetBit(kCanDelete);
+    h1->SetLineWidth(2);
+    h1->SetLineColor(kRed);
+    h1->SetFillStyle(4000);
+    h1->SetStats(kFALSE);
+
+ 
+    //h1->Draw("E3");
+    h2->Draw();
     h1->Draw("Chistsame");
 
@@ -323,5 +332,5 @@
 
     pad->SetBorderMode(0);
-    pad->Divide(2, 1, 0, 0);
+    pad->Divide(2, 1, 1e-10, 1e-10);
 
     TH1 *h;
@@ -330,5 +339,5 @@
     gPad->SetBorderMode(0);
 
-    gPad->Divide(1, 2, 0, 0);
+    gPad->Divide(1, 2, 1e-10, 1e-10);
 
     TVirtualPad *pad2 = gPad;
@@ -365,7 +374,7 @@
 
     TVirtualPad *pad3 = gPad;
-    pad3->Divide(2, 1, 0, 0);
+    pad3->Divide(2, 1, 1e-10, 1e-10);
     pad3->cd(1);
-    gPad->SetBorderMode(0);
+    gPad->SetBorderMode(0);/*
     h = fHImpact.ProjectionX("Impact", -1, 9999, "e");
     h->SetBit(TH1::kNoStats);
@@ -374,8 +383,5 @@
     h->SetXTitle("Impact [m]");
     h->SetBit(kCanDelete);
-    h->Draw();
-
-    pad3->cd(2);
-    gPad->SetBorderMode(0);
+    h->Draw();*/
     h = fHEnergy.Project3D("ez");
     h->SetTitle("Distribution of Theta");
@@ -386,8 +392,11 @@
     h->Draw();
 
+    pad3->cd(2);
+    gPad->SetBorderMode(0);
+
     pad->cd(2);
     gPad->SetBorderMode(0);
 
-    gPad->Divide(1, 3, 0, 0);
+    gPad->Divide(1, 3, 1e-10, 1e-10);
     pad2 = gPad;
 
Index: /trunk/MagicSoft/Mars/mhflux/MHEnergyEst.h
===================================================================
--- /trunk/MagicSoft/Mars/mhflux/MHEnergyEst.h	(revision 6889)
+++ /trunk/MagicSoft/Mars/mhflux/MHEnergyEst.h	(revision 6890)
@@ -35,4 +35,5 @@
 
     Double_t fChisq;
+    Double_t fBias;
 
     TH1 *MakePlot(TH3 &h, const char *how);
Index: /trunk/MagicSoft/Mars/mhflux/MHFalseSource.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhflux/MHFalseSource.cc	(revision 6889)
+++ /trunk/MagicSoft/Mars/mhflux/MHFalseSource.cc	(revision 6890)
@@ -410,9 +410,10 @@
 
     // Get projection for range
-    TH2D *p = (TH2D*)src.Project3D("yx_off");
+    TH2D *p = (TH2D*)src.Project3D("yx_off_NULL");
 
     // Reset range
     axe.SetRange(0,9999);
 
+//#if ROOT_VERSION_CODE < ROOT_VERSION(4,02,00)
     // Move contents from projection to h2
     h2->Reset();
@@ -422,4 +423,8 @@
     // Delete p
     delete p;
+/*#else
+    p->Scale(all->GetMaximum());
+    p->Divide(all);
+#endif*/
 
     // Set Minimum as minimum value Greater Than 0
@@ -442,9 +447,10 @@
 
     // Get projection for range
-    TH2D *p = (TH2D*)src.Project3D("yx_on");
+    TH2D *p = (TH2D*)src.Project3D("yx_on_NULL");
 
     // Reset range
     axe.SetRange(0,9999);
 
+//#if ROOT_VERSION_CODE < ROOT_VERSION(4,02,00)
     // Move contents from projection to h3
     h3->Reset();
@@ -454,4 +460,8 @@
     // Delete p
     delete p;
+/*#else
+    p->Scale(all->GetMaximum());
+    p->Divide(all);
+#endif*/
 
     // Set Minimum as minimum value Greater Than 0
@@ -469,6 +479,6 @@
 
     // Get projection for range
-    TH2D *p = (TH2D*)fHist.Project3D(Form("yx_%d", gRandom->Uniform(999999)));
-    p->SetDirectory(0);
+#if ROOT_VERSION_CODE < ROOT_VERSION(4,02,00)
+    TH2D *p = (TH2D*)fHist.Project3D("yx_all");
 
     // Move contents from projection to h3
@@ -476,4 +486,7 @@
     h3->Add(p);
     delete p;
+#else
+    fHist.Project3D("yx_all");
+#endif
 
     // Set Minimum as minimum value Greater Than 0
@@ -518,12 +531,4 @@
     TH2D* h5;
 
-    /*
-     fHistProjAll  = Form("All_%p",  this);
-     fHistProjOn   = Form("On_%p",   this);
-     fHistProjOff  = Form("Off_%p",  this);
-     fHistProjDiff = Form("Diff_%p", this);
-     fHistProjAll  = Form("All_%p",  this);
-     */
-
     // Update projection of all-events
     padsave->GetPad(2)->cd(3);
@@ -559,5 +564,4 @@
         const Int_t nx = h4->GetXaxis()->GetNbins();
         const Int_t ny = h4->GetYaxis()->GetNbins();
-        //const Int_t nr = nx*nx + ny*ny;
 
         Int_t maxx=nx/2;
@@ -566,4 +570,5 @@
         Int_t max = h4->GetBin(nx, ny);
 
+        h4->SetEntries(0);
         for (int ix=1; ix<=nx; ix++)
             for (int iy=1; iy<=ny; iy++)
@@ -651,5 +656,5 @@
     AppendPad("");
 
-    pad->Divide(1, 2, 0, 0.03);
+    pad->Divide(1, 2, 1e-10, 0.03);
 
 //    TObject *catalog = GetCatalog();
@@ -1048,5 +1053,5 @@
     gStyle->SetPalette(1, 0);
 
-    c->Divide(3,2, 0, 0);
+    c->Divide(3,2, 1e-10, 1e-10);
     c->cd(1);
     gPad->SetBorderMode(0);
Index: /trunk/MagicSoft/Mars/mhist/MHHadronness.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHHadronness.cc	(revision 6889)
+++ /trunk/MagicSoft/Mars/mhist/MHHadronness.cc	(revision 6890)
@@ -73,5 +73,5 @@
 #include "MBinning.h"
 #include "MHMatrix.h"
-#include "MHadronness.h"
+#include "MParameters.h"
 
 #include "MLog.h"
@@ -163,5 +163,5 @@
     }
 
-    fHadronness = (MHadronness*)plist->FindObject("MHadronness");
+    fHadronness = (MParameterD*)plist->FindObject("MHadronness");
 
     fGhness->Reset();
@@ -207,7 +207,7 @@
     }
 
-    const MHadronness &had = par ? *(MHadronness*)par : *fHadronness;
-
-    const Double_t h = had.GetHadronness();
+    const MParameterD &had = par ? *(MParameterD*)par : *fHadronness;
+
+    const Double_t h = had.GetVal();
 
     if (TMath::IsNaN(h))
Index: /trunk/MagicSoft/Mars/mhist/MHHadronness.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHHadronness.h	(revision 6889)
+++ /trunk/MagicSoft/Mars/mhist/MHHadronness.h	(revision 6890)
@@ -10,5 +10,5 @@
 class MParList;
 class MMcEvt;
-class MHadronness;
+class MParameterD;
 class MHMatrix;
 
@@ -16,7 +16,7 @@
 {
 private:
-    const MMcEvt *fMcEvt;           //!
-    const MHadronness *fHadronness; //!
-    MHMatrix *fMatrix;        //!
+    const MMcEvt      *fMcEvt;      //!
+    const MParameterD *fHadronness; //!
+    MHMatrix *fMatrix;              //!
     Int_t fMap;                     //!
 
Index: /trunk/MagicSoft/Mars/mimage/ImageLinkDef.h
===================================================================
--- /trunk/MagicSoft/Mars/mimage/ImageLinkDef.h	(revision 6889)
+++ /trunk/MagicSoft/Mars/mimage/ImageLinkDef.h	(revision 6890)
@@ -24,4 +24,5 @@
 #pragma link C++ class MHNewImagePar+;
 #pragma link C++ class MHNewImagePar2+;
+#pragma link C++ class MHVsSize+;
 #pragma link C++ class MStereoPar+;
 #pragma link C++ class MStereoCalc+;
Index: /trunk/MagicSoft/Mars/mimage/MHHillas.cc
===================================================================
--- /trunk/MagicSoft/Mars/mimage/MHHillas.cc	(revision 6889)
+++ /trunk/MagicSoft/Mars/mimage/MHHillas.cc	(revision 6890)
@@ -325,11 +325,26 @@
     fSize->Draw(same?"same":"");
 
-    if (!same)
+    //if (!same)
     {
         pad->cd(4);
         gPad->SetBorderMode(0);
         gPad->SetPad(0.51, 0.01, 0.99, 0.65);
-        SetColors();
-        fCenter->Draw("colz");
+        if (same)
+        {
+            /*
+            TH1 *h = dynamic_cast<TH1*>(gPad->FindObject("Center"));
+            if (h)
+            {
+                h->SetDrawOption("");
+                h->SetMarkerColor(kBlack);
+            }*/
+            fCenter->SetMarkerColor(kGreen);
+            fCenter->Draw("same");
+        }
+        else
+        {
+            //SetColors();
+            fCenter->Draw(/*"colz"*/);
+        }
         if (fGeomCam)
         {
Index: /trunk/MagicSoft/Mars/mimage/MHVsSize.cc
===================================================================
--- /trunk/MagicSoft/Mars/mimage/MHVsSize.cc	(revision 6890)
+++ /trunk/MagicSoft/Mars/mimage/MHVsSize.cc	(revision 6890)
@@ -0,0 +1,303 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  2001 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Wolfgang Wittek  2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHVsSize
+//
+// This class contains histograms for the source independent image parameters
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHVsSize.h"
+
+#include <TH2.h>
+#include <TPad.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MHillas.h"
+#include "MHillasSrc.h"
+#include "MNewImagePar.h"
+#include "MGeomCam.h"
+#include "MBinning.h"
+
+ClassImp(MHVsSize);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Setup four histograms for Width, Length
+//
+MHVsSize::MHVsSize(const char *name, const char *title)
+    : fHillas(NULL), fNewImagePar(NULL), fMm2Deg(1), fUseMmScale(kTRUE)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHVsSize";
+    fTitle = title ? title : "Source independent image parameters";
+
+    fLength.SetNameTitle("Length", "Length vs. Size");
+    fWidth.SetNameTitle( "Width",  "Width vs. Size");
+    fDist.SetNameTitle(  "Dist",   "Dist vs. Size");
+    fConc1.SetNameTitle( "Conc1",  "Conc1 vs. Size");
+
+    fLength.SetDirectory(NULL);
+    fWidth.SetDirectory(NULL);
+    fDist.SetDirectory(NULL);
+    fConc1.SetDirectory(NULL);
+
+    fLength.SetXTitle("Size [phe]");
+    fWidth.SetXTitle("Size [phe]");
+    fDist.SetXTitle("Size [phe]");
+    fConc1.SetXTitle("Size [phe]");
+
+    fLength.SetYTitle("Length [mm]");
+    fWidth.SetYTitle("Width [mm]");
+    fDist.SetYTitle("Distance [mm]");
+    fConc1.SetYTitle("Conc1 [ratio]");
+
+    MBinning binse, binsl, binsd, binsc;
+    binse.SetEdgesLog(50, 10, 1e5);
+    binsl.SetEdges(100,  0, 296.7/2);
+    binsd.SetEdges(100,  0, 445);
+    binsc.SetEdgesLog(100,  1e-5, 5e-3);
+
+    MH::SetBinning(&fLength, &binse, &binsl);
+    MH::SetBinning(&fWidth,  &binse, &binsl);
+    MH::SetBinning(&fDist,   &binse, &binsd);
+    MH::SetBinning(&fConc1,  &binse, &binsc);
+
+    fLength.UseCurrentStyle();
+    fWidth.UseCurrentStyle();
+    fDist.UseCurrentStyle();
+    fConc1.UseCurrentStyle();
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup the Binning for the histograms automatically if the correct
+// instances of MBinning (with the names 'BinningWidth' and 'BinningLength')
+// are found in the parameter list
+// Use this function if you want to set the conversion factor which
+// is used to convert the mm-scale in the camera plain into the deg-scale
+// used for histogram presentations. The conversion factor is part of
+// the camera geometry. Please create a corresponding MGeomCam container.
+//
+Bool_t MHVsSize::SetupFill(const MParList *plist)
+{
+    MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!geom)
+        *fLog << warn << GetDescriptor() << ": No Camera Geometry available. Using mm-scale for histograms." << endl;
+    else
+    {
+        fMm2Deg = geom->GetConvMm2Deg();
+        SetMmScale(kFALSE);
+    }
+
+    fHillas = (MHillas*)plist->FindObject("MHillas");
+    if (!fHillas)
+    {
+        *fLog << err << "MHillas not found... abort." << endl;
+        return kFALSE;
+    }
+
+    fNewImagePar = (MNewImagePar*)plist->FindObject("MNewImagePar");
+    if (!fNewImagePar)
+    {
+        *fLog << err << "MNewImagePar not found... abort." << endl;
+        return kFALSE;
+    }
+
+    /*
+    ApplyBinning(*plist, "Width",  fWidth);
+    ApplyBinning(*plist, "Length", fLength);
+    ApplyBinning(*plist, "Dist",   fDistC);
+    ApplyBinning(*plist, "Delta",  fDelta);
+    ApplyBinning(*plist, "Size",   fSize);
+
+    const MBinning *bins = (MBinning*)plist->FindObject("BinningCamera");
+    if (!bins)
+    {
+        float r = fGeomCam ? fGeomCam->GetMaxRadius() : 600;
+        r *= 0.9;
+        if (!fUseMmScale)
+            r *= fMm2Deg;
+
+        MBinning b;
+        b.SetEdges(61, -r, r);
+        SetBinning(fCenter, &b, &b);
+    }
+    else
+        SetBinning(fCenter, bins, bins);
+    */
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Use this function to setup your own conversion factor between degrees
+// and millimeters. The conversion factor should be the one calculated in
+// MGeomCam. Use this function with Caution: You could create wrong values
+// by setting up your own scale factor.
+//
+void MHVsSize::SetMm2Deg(Float_t mmdeg)
+{
+    if (mmdeg<0)
+    {
+        *fLog << warn << dbginf << "Warning - Conversion factor < 0 - nonsense. Ignored." << endl;
+        return;
+    }
+
+    if (fMm2Deg>=0)
+        *fLog << warn << dbginf << "Warning - Conversion factor already set. Overwriting" << endl;
+
+    fMm2Deg = mmdeg;
+}
+
+// --------------------------------------------------------------------------
+//
+// With this function you can convert the histogram ('on the fly') between
+// degrees and millimeters.
+//
+void MHVsSize::SetMmScale(Bool_t mmscale)
+{
+    if (fUseMmScale == mmscale)
+        return;
+
+    if (fMm2Deg<0)
+    {
+        *fLog << warn << dbginf << "Warning - Sorry, no conversion factor for conversion available." << endl;
+        return;
+    }
+
+    const Double_t scale = mmscale ? 1./fMm2Deg : fMm2Deg;
+    MH::ScaleAxis(&fLength, 1, scale);
+    MH::ScaleAxis(&fWidth,  1, scale);
+    MH::ScaleAxis(&fDist,   1, scale);
+
+    if (mmscale)
+    {
+        fLength.SetYTitle("Length [mm]");
+        fWidth.SetYTitle("Width [mm]");
+        fDist.SetYTitle("Distance [mm]");
+    }
+    else
+    {
+        fLength.SetYTitle("Length [\\circ]");
+        fWidth.SetYTitle("Width [\\circ]");
+        fDist.SetYTitle("Distance [\\circ]");
+    }
+
+    fUseMmScale = mmscale;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histograms with data from a MHillas-Container.
+// Be careful: Only call this with an object of type MHillas
+//
+Bool_t MHVsSize::Fill(const MParContainer *par, const Stat_t w)
+{
+    const MHillasSrc *src = dynamic_cast<const MHillasSrc*>(par);
+    if (!src)
+    {
+        *fLog << err << "MHVsSize::Fill: Pointer (!=NULL) expected." << endl;
+        return kFALSE;
+    }
+
+    const Double_t scale = fUseMmScale ? 1 : fMm2Deg;
+
+    fLength.Fill(fHillas->GetSize(), scale*fHillas->GetLength(),     w);
+    fWidth.Fill( fHillas->GetSize(), scale*fHillas->GetWidth(),      w);
+    fDist.Fill(  fHillas->GetSize(), scale*src->GetDist(),           w);
+    fConc1.Fill( fHillas->GetSize(), scale*fNewImagePar->GetConc1(), w);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates a new canvas and draws the four histograms into it.
+// Be careful: The histograms belongs to this object and won't get deleted
+// together with the canvas.
+//
+void MHVsSize::Draw(Option_t *o)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    TString opt(o);
+    opt.ToLower();
+
+    // FIXME: If same-option given make two independant y-axis!
+    const Bool_t same = opt.Contains("same");
+
+    if (!same)
+        pad->Divide(2,2);
+    else
+    {
+        fDist.SetMarkerColor(kBlue);
+        fConc1.SetMarkerColor(kBlue);
+        fWidth.SetMarkerColor(kBlue);
+        fLength.SetMarkerColor(kBlue);
+    }
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    gPad->SetLogx();
+    fLength.Draw(same?"same":"");
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    gPad->SetLogx();
+    fWidth.Draw(same?"same":"");
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
+    gPad->SetLogx();
+    fDist.Draw(same?"same":"");
+
+    pad->cd(4);
+    gPad->SetBorderMode(0);
+    gPad->SetLogx();
+    gPad->SetLogy();
+    fConc1.Draw(same?"same":"");
+}
+
+void MHVsSize::Paint(Option_t *opt)
+{
+    //SetColors();
+    //MH::Paint();
+}
Index: /trunk/MagicSoft/Mars/mimage/MHVsSize.h
===================================================================
--- /trunk/MagicSoft/Mars/mimage/MHVsSize.h	(revision 6890)
+++ /trunk/MagicSoft/Mars/mimage/MHVsSize.h	(revision 6890)
@@ -0,0 +1,46 @@
+#ifndef MARS_MHVsSize
+#define MARS_MHVsSize
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TH2
+#include <TH2.h>
+#endif
+
+class MHillas;
+class MNewImagePar;
+
+class MHVsSize : public MH
+{
+private:
+    MHillas      *fHillas;  //!
+    MNewImagePar *fNewImagePar; //!
+
+    TH2F fLength;  // Length
+    TH2F fWidth;   // Width
+
+    TH2F fDist;    // Distance to Camera Center
+    TH2F fConc1;   // Angle between Length axis and x-axis
+
+    Float_t fMm2Deg;
+    Bool_t  fUseMmScale;
+
+    void Paint(Option_t *opt="");
+
+public:
+    MHVsSize(const char *name=NULL, const char *title=NULL);
+
+    void SetMmScale(Bool_t mmscale=kTRUE);
+    virtual void SetMm2Deg(Float_t mmdeg);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    void Draw(Option_t *opt=NULL);
+
+    ClassDef(MHVsSize, 1) // Container which holds histograms for image parameters vs size
+};
+
+#endif
Index: /trunk/MagicSoft/Mars/mimage/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/mimage/Makefile	(revision 6889)
+++ /trunk/MagicSoft/Mars/mimage/Makefile	(revision 6890)
@@ -42,4 +42,5 @@
 	   MHNewImagePar.cc \
 	   MHNewImagePar2.cc \
+           MHVsSize.cc \
 	   MStereoPar.cc \
 	   MStereoCalc.cc
