Index: trunk/MagicSoft/Mars/mhist/MBinning.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MBinning.h	(revision 1214)
+++ trunk/MagicSoft/Mars/mhist/MBinning.h	(revision 1215)
@@ -20,8 +20,9 @@
     void SetEdges(const TArrayD &arr)
     {
+        fEdges = arr;/*
         const Int_t nbins = arr.GetSize();
         fEdges.Set(nbins);
-        for (int i=0; i<=nbins; i++)
-            fEdges[i] = (*(TArrayD*)(&arr))[i];
+        for (int i=0; i<nbins; i++)
+            fEdges[i] = (*(TArrayD*)(&arr))[i];*/
     }
 
Index: trunk/MagicSoft/Mars/mhist/MH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MH.cc	(revision 1214)
+++ trunk/MagicSoft/Mars/mhist/MH.cc	(revision 1215)
@@ -197,6 +197,10 @@
 void MH::SetBinning(TH1 *h, const TAxis *binsx)
 {
-    MBinning bx;
-    bx.SetEdges(*((TAxis*)binsx)->GetXbins()); // FIXME: Root!
+    const Int_t nx = binsx->GetNbins();
+
+    TArrayD bx(nx+1);
+    for (int i=0; i<nx; i++) bx[i] = binsx->GetBinLowEdge(i+1);
+    bx[nx] = binsx->GetXmax();
+
     SetBinning(h, &bx);
 }
@@ -204,8 +208,14 @@
 void MH::SetBinning(TH1 *h, const TAxis *binsx, const TAxis *binsy)
 {
-    MBinning bx;
-    MBinning by;
-    bx.SetEdges(*((TAxis*)binsx)->GetXbins()); // FIXME: Root!
-    by.SetEdges(*((TAxis*)binsy)->GetXbins()); // FIXME: Root!
+    const Int_t nx = binsx->GetNbins();
+    const Int_t ny = binsy->GetNbins();
+
+    TArrayD bx(nx+1);
+    TArrayD by(ny+1);
+    for (int i=0; i<nx; i++) bx[i] = binsx->GetBinLowEdge(i+1);
+    for (int i=0; i<ny; i++) by[i] = binsy->GetBinLowEdge(i+1);
+    bx[nx] = binsx->GetXmax();
+    by[ny] = binsy->GetXmax();
+
     SetBinning(h, &bx, &by);
 }
@@ -213,10 +223,18 @@
 void MH::SetBinning(TH1 *h, const TAxis *binsx, const TAxis *binsy, const TAxis *binsz)
 {
-    MBinning bx;
-    MBinning by;
-    MBinning bz;
-    bx.SetEdges(*((TAxis*)binsx)->GetXbins()); // FIXME: Root!
-    by.SetEdges(*((TAxis*)binsy)->GetXbins()); // FIXME: Root!
-    bz.SetEdges(*((TAxis*)binsz)->GetXbins()); // FIXME: Root!
+    const Int_t nx = binsx->GetNbins();
+    const Int_t ny = binsy->GetNbins();
+    const Int_t nz = binsz->GetNbins();
+
+    TArrayD bx(nx+1);
+    TArrayD by(ny+1);
+    TArrayD bz(nz+1);
+    for (int i=0; i<nx; i++) bx[i] = binsx->GetBinLowEdge(i+1);
+    for (int i=0; i<ny; i++) by[i] = binsy->GetBinLowEdge(i+1);
+    for (int i=0; i<nz; i++) bz[i] = binsz->GetBinLowEdge(i+1);
+    bx[nx] = binsx->GetXmax();
+    by[ny] = binsy->GetXmax();
+    bz[nz] = binsz->GetXmax();
+
     SetBinning(h, &bx, &by, &bz);
 }
Index: trunk/MagicSoft/Mars/mhist/MHAlphaEnergyTheta.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHAlphaEnergyTheta.cc	(revision 1214)
+++ trunk/MagicSoft/Mars/mhist/MHAlphaEnergyTheta.cc	(revision 1215)
@@ -102,4 +102,5 @@
 
     fHist.Fill(hil.GetAlpha(), fEnergy->GetEnergy(), fMcEvt->GetTheta()*kRad2Deg);
+
     return kTRUE;
 }
@@ -108,16 +109,24 @@
 {
     if (!gPad)
-        MakeDefCanvas("AlphaEnergyTheta", "Distrib of \\alpha, E, \\Theta");
+        MakeDefCanvas("AlphaEnergyTheta", "Distrib of alpha, E, Theta");
 
     gPad->Divide(2,2);
 
+    TH1 *h;
+
     gPad->cd(1);
-    fHist.Project3D("x")->Draw(opt);
+    h = fHist.Project3D("x");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
 
     gPad->cd(2);
-    fHist.Project3D("y")->Draw(opt);
+    h = fHist.Project3D("y");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
 
     gPad->cd(3);
-    fHist.Project3D("z")->Draw(opt);
+    h = fHist.Project3D("z");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
 
     gPad->cd(4);
@@ -130,5 +139,5 @@
 TObject *MHAlphaEnergyTheta::DrawClone(Option_t *opt) const
 {
-    TCanvas *c = MakeDefCanvas("DiffTimeTheta", "Distrib of \\Delta t, \\Theta");
+    TCanvas *c = MakeDefCanvas("AlphaEnergyTheta", "Distrib of alpha, E, Theta");
     c->Divide(2, 2);
 
@@ -138,12 +147,20 @@
     // FIXME: ProjectionX,Y is not const within root
     //
+    TH1 *h;
+
     c->cd(1);
-    ((TH3*)(&fHist))->Project3D("x")->DrawCopy(opt);
+    h = ((TH3*)(&fHist))->Project3D("x");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
 
     c->cd(2);
-    ((TH3*)(&fHist))->Project3D("y")->DrawCopy(opt);
+    h = ((TH3*)(&fHist))->Project3D("y");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
 
     c->cd(3);
-    ((TH3*)(&fHist))->Project3D("z")->DrawCopy(opt);
+    h = ((TH3*)(&fHist))->Project3D("z");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
 
     c->cd(4);
@@ -158,5 +175,5 @@
 void MHAlphaEnergyTheta::Substract(const TH3D *h1, const TH3D *h2)
 {
-    MH::SetBinning(&fHist, h1);
+    MH::SetBinning(&fHist, (TH1*)h1);
 
     fHist.Sumw2();
Index: trunk/MagicSoft/Mars/mhist/MHAlphaEnergyTime.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHAlphaEnergyTime.cc	(revision 1214)
+++ trunk/MagicSoft/Mars/mhist/MHAlphaEnergyTime.cc	(revision 1215)
@@ -113,16 +113,24 @@
 {
     if (!gPad)
-        MakeDefCanvas("AlphaEnergyTime", "Distrib of \\alpha, E, t");
+        MakeDefCanvas("AlphaEnergyTime", "Distrib of alpha, E, t");
 
     gPad->Divide(2,2);
 
+    TH1 *h;
+
     gPad->cd(1);
-    fHist.Project3D("x")->Draw(opt);
+    h = fHist.Project3D("x");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
 
     gPad->cd(2);
-    fHist.Project3D("y")->Draw(opt);
+    h = fHist.Project3D("y");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
 
     gPad->cd(3);
-    fHist.Project3D("z")->Draw(opt);
+    h = fHist.Project3D("z");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
 
     gPad->cd(4);
@@ -135,5 +143,5 @@
 TObject *MHAlphaEnergyTime::DrawClone(Option_t *opt) const
 {
-    TCanvas *c = MakeDefCanvas("DiffTimeTheta", "Distrib of \\Delta t, t");
+    TCanvas *c = MakeDefCanvas("AlphaEnergyTime", "Distrib of alpha, E, t");
     c->Divide(2, 2);
 
@@ -143,12 +151,20 @@
     // FIXME: ProjectionX,Y is not const within root
     //
+    TH1 *h;
+
     c->cd(1);
-    ((TH3D*)(&fHist))->Project3D("x")->DrawCopy(opt);
+    h = ((TH3D*)(&fHist))->Project3D("x");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
 
     c->cd(2);
-    ((TH3D*)(&fHist))->Project3D("y")->DrawCopy(opt);
+    h = ((TH3D*)(&fHist))->Project3D("y");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
 
     c->cd(3);
-    ((TH3D*)(&fHist))->Project3D("z")->DrawCopy(opt);
+    h = ((TH3D*)(&fHist))->Project3D("z");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
 
     c->cd(4);
@@ -163,5 +179,5 @@
 void MHAlphaEnergyTime::Substract(const TH3D *h1, const TH3D *h2)
 {
-    MH::SetBinning(&fHist, h1);
+    MH::SetBinning(&fHist, (TH1*)h1);
 
     fHist.Sumw2();
Index: trunk/MagicSoft/Mars/mhist/MHEffOnTimeTheta.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHEffOnTimeTheta.cc	(revision 1214)
+++ trunk/MagicSoft/Mars/mhist/MHEffOnTimeTheta.cc	(revision 1215)
@@ -81,11 +81,11 @@
         //new TCanvas(txt, "Title");
 
-        TH1D *h = hist->ProjectionX("dTime-Distribution for fixed Time", i, i);
+        TH1D &h = *hist->ProjectionX("dTime-Distribution for fixed Time", i, i);
 
         //hist->Draw();
         //gPad->SetLogy();
 
-        Double_t Nmdel = h->Integral("width");
-        Double_t mean  = h->GetMean();
+        Double_t Nmdel = h.Integral("width");
+        Double_t mean  = h.GetMean();
 
         TF1 func("Poisson", "[1] * [0] * exp(-[0] *x)",
@@ -101,5 +101,5 @@
         func.SetParName(1, "Nmdel");
 
-        h->Fit("Poisson", "RN");
+        h.Fit("Poisson", "RN");
 
         //func.SetRange(0, 0.1); // Range of Drawing
@@ -113,5 +113,7 @@
         //cout << "t_eff = " << h->Integral()/lambda << "  T(last)=" << time.GetTimeLo()*0.0001 << endl;
 
-        fHist.SetBinContent(i, h->Integral()/lambda);
+        fHist.SetBinContent(i, h.Integral()/lambda);
+
+        delete &h;
     }
 }
@@ -133,5 +135,5 @@
 TObject *MHEffOnTimeTheta::DrawClone(Option_t *opt) const
 {
-    TCanvas *c = MakeDefCanvas("EffOnTimeTheta", "t_{eff} vs. \\Theta");
+    TCanvas *c = MakeDefCanvas("EffOnTimeTheta", "t_eff vs. Theta");
 
     gROOT->SetSelectedPad(NULL);
@@ -148,5 +150,5 @@
 {
     if (!gPad)
-        MakeDefCanvas("EffOnTimeTheta", "t_{eff} vs. \\Theta");
+        MakeDefCanvas("EffOnTimeTheta", "t_eff vs. Theta");
 
     fHist.Draw(opt);
Index: trunk/MagicSoft/Mars/mhist/MHEffOnTimeTime.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHEffOnTimeTime.cc	(revision 1214)
+++ trunk/MagicSoft/Mars/mhist/MHEffOnTimeTime.cc	(revision 1215)
@@ -26,5 +26,5 @@
 //////////////////////////////////////////////////////////////////////////////
 //                                                                          //
-//  MHEffOnTimeTime                                                       //
+//  MHEffOnTimeTime                                                         //
 //                                                                          //
 //                                                                          //
@@ -63,5 +63,5 @@
 
     fHist.SetName("EffOn");
-    fHist.SetTitle("Effective On Time Vs. Theta");
+    fHist.SetTitle("Effective On Time Vs. Time");
 
 
@@ -74,5 +74,5 @@
 TObject *MHEffOnTimeTime::DrawClone(Option_t *opt) const
 {
-    TCanvas *c = MakeDefCanvas("EffOnTimeTheta", "t_{eff} vs. t");
+    TCanvas *c = MakeDefCanvas("EffOnTimeTheta", "t_eff vs. t");
 
     gROOT->SetSelectedPad(NULL);
@@ -89,5 +89,5 @@
 {
     if (!gPad)
-        MakeDefCanvas("EffOnTimeTheta", "t_{eff} vs. t");
+        MakeDefCanvas("EffOnTimeTheta", "t_eff vs. t");
 
     fHist.Draw(opt);
@@ -108,11 +108,11 @@
         //new TCanvas(txt, "Title");
 
-        TH1D *h = hist->ProjectionX("dTime-Distribution for fixed Theta", i, i);
+        TH1D &h = *hist->ProjectionX("dTime-Distribution for fixed Theta", i, i);
 
         //hist->Draw();
         //gPad->SetLogy();
 
-        Double_t Nmdel = h->Integral("width");
-        Double_t mean  = h->GetMean();
+        Double_t Nmdel = h.Integral("width");
+        Double_t mean  = h.GetMean();
 
         TF1 func("Poisson", "[1] * [0] * exp(-[0] *x)",
@@ -128,5 +128,5 @@
         func.SetParName(1, "Nmdel");
 
-        h->Fit("Poisson", "RN");
+        h.Fit("Poisson", "RN");
 
         //func.SetRange(0, 0.1); // Range of Drawing
@@ -140,5 +140,7 @@
         //cout << "t_eff = " << h->Integral()/lambda << "  T(last)=" << time.GetTimeLo()*0.0001 << endl;
 
-        fHist.SetBinContent(i, h->Integral()/lambda);
+        fHist.SetBinContent(i, h.Integral()/lambda);
+
+        delete &h;
     }
 }
Index: trunk/MagicSoft/Mars/mhist/MHTimeDiffTheta.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHTimeDiffTheta.cc	(revision 1214)
+++ trunk/MagicSoft/Mars/mhist/MHTimeDiffTheta.cc	(revision 1215)
@@ -26,5 +26,5 @@
 //////////////////////////////////////////////////////////////////////////////
 //                                                                          //
-//  MHTimeDiffTheta                                                       //
+//  MHTimeDiffTheta                                                         //
 //                                                                          //
 //                                                                          //
@@ -98,5 +98,5 @@
 TObject *MHTimeDiffTheta::DrawClone(Option_t *opt) const
 {
-    TCanvas *c = MakeDefCanvas("DiffTimeTheta", "Distrib \\Delta t, \\Theta");
+    TCanvas *c = MakeDefCanvas("DiffTimeTheta", "Distrib of Delta t, Theta");
     c->Divide(2, 2);
 
@@ -106,10 +106,16 @@
     // FIXME: ProjectionX,Y is not const within root
     //
+    TH1 *h;
+
     c->cd(1);
-    ((TH2*)&fHist)->ProjectionX("ProX", -1, 9999, "E")->DrawCopy(opt);
+    h = ((TH2*)&fHist)->ProjectionX("ProX", -1, 9999, "E");
+    h->DrawCopy(opt);
+    delete h;
     gPad->SetLogy();
 
     c->cd(2);
-    ((TH2*)&fHist)->ProjectionY("ProY", -1, 9999, "E")->DrawCopy(opt);
+    h = ((TH2*)&fHist)->ProjectionY("ProY", -1, 9999, "E");
+    h->DrawCopy(opt);
+    delete h;
 
     c->cd(3);
@@ -125,5 +131,5 @@
 {
     if (!gPad)
-        MakeDefCanvas("DiffTimeTheta", "Distrib \\Delta t, \\Theta");
+        MakeDefCanvas("DiffTimeTheta", "Distrib of Delta t, Theta");
 
     TH1 *h;
Index: trunk/MagicSoft/Mars/mhist/MHTimeDiffTime.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHTimeDiffTime.cc	(revision 1214)
+++ trunk/MagicSoft/Mars/mhist/MHTimeDiffTime.cc	(revision 1215)
@@ -26,5 +26,5 @@
 //////////////////////////////////////////////////////////////////////////////
 //                                                                          //
-//  MHTimeDiffTime                                                       //
+//  MHTimeDiffTime                                                          //
 //                                                                          //
 //                                                                          //
@@ -98,10 +98,16 @@
     // FIXME: ProjectionX,Y is not const within root
     //
+    TH1 *h;
+
     c->cd(1);
-    ((TH2*)&fHist)->ProjectionX("ProX", -1, 9999, "E")->DrawCopy(opt);
+    h = ((TH2*)&fHist)->ProjectionX("ProX", -1, 9999, "E");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
     gPad->SetLogy();
 
     c->cd(2);
-    ((TH2*)&fHist)->ProjectionY("ProY", -1, 9999, "E")->DrawCopy(opt);
+    h = ((TH2*)&fHist)->ProjectionY("ProY", -1, 9999, "E");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
 
     c->cd(3);
@@ -121,10 +127,16 @@
     gPad->Divide(2,2);
 
+    TH1 *h;
+
     gPad->cd(1);
-    fHist.ProjectionX("ProX", -1, 9999, "E")->DrawCopy(opt);
+    h = fHist.ProjectionX("ProX", -1, 9999, "E");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
     gPad->SetLogy();
 
     gPad->cd(2);
-    fHist.ProjectionY("ProY", -1, 9999, "E")->DrawCopy(opt);
+    h = fHist.ProjectionY("ProY", -1, 9999, "E");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
 
     gPad->cd(3);
