Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 5006)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 5007)
@@ -32,4 +32,7 @@
 
  2004/09/14: Markus Gaug
+
+   * mhcalib/MHGausEvents.cc
+     - some changes in Draw for the case that there is no histogram
 
    * manalysis/MHPedestalPix.[h,cc]
Index: /trunk/MagicSoft/Mars/mhbase/MH.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 5006)
+++ /trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 5007)
@@ -1181,4 +1181,14 @@
     const Int_t size = array.GetSize();
 
+    TH1I *h1=0;
+
+    //check if histogram with identical name exist
+    TObject *h1obj = gROOT->FindObject(name);
+    if (h1obj && h1obj->InheritsFrom("TH1I"))
+    {
+        h1 = (TH1I*)h1obj;
+        h1->Reset();
+    }
+
     Double_t min = size>0 ? array[0] : 0;
     Double_t max = size>0 ? array[0] : 1;
@@ -1193,9 +1203,12 @@
     Int_t newbins = 0;
     FindGoodLimits(nbins, newbins, min, max, kFALSE);
-    
-    TH1I *h1 = new TH1I(name, title, nbins, min, max);
-    h1->SetXTitle("");
-    h1->SetYTitle("Counts");
-    h1->SetDirectory(NULL);
+
+    if (!h1)
+    {
+        h1 = new TH1I(name, title, nbins, min, max);
+        h1->SetXTitle("");
+        h1->SetYTitle("Counts");
+        h1->SetDirectory(gROOT);
+    }
 
     // Second loop to fill the histogram
@@ -1217,4 +1230,14 @@
     Double_t max = size>0 ? array[0] : 1;
 
+    TH1I *h1=0;
+
+    //check if histogram with identical name exist
+    TObject *h1obj = gROOT->FindObject(name);
+    if (h1obj && h1obj->InheritsFrom("TH1I"))
+    {
+        h1 = (TH1I*)h1obj;
+        h1->Reset();
+    }
+
     // first loop over array to find the min and max
     for (Int_t i=1; i<size;i++)
@@ -1227,9 +1250,12 @@
     FindGoodLimits(nbins, newbins, min, max, kFALSE);
 
-    TH1I *h1 = new TH1I(name, title, newbins, min, max);
-    h1->SetXTitle("");
-    h1->SetYTitle("Counts");
-    h1->SetDirectory(NULL);
-
+    if (!h1)
+    {
+      h1 = new TH1I(name, title, newbins, min, max);
+      h1->SetXTitle("");
+      h1->SetYTitle("Counts");
+      h1->SetDirectory(gROOT);
+    }
+    
     // Second loop to fill the histogram
     for (Int_t i=0;i<size;i++)
@@ -1246,6 +1272,5 @@
                        const char* name, const char* title)
 {
-    const TArrayF arr(array.GetSize(), array.GetArray());
-    return ProjectArray(arr, nbins, name, title);
+    return ProjectArray(TArrayF(array.GetSize(),array.GetArray()), nbins, name, title);
 }
 
@@ -1256,6 +1281,5 @@
 TH1I* MH::ProjectArray(const MArrayD &array, Int_t nbins, const char* name, const char* title)
 {
-    const TArrayD arr(array.GetSize(), array.GetArray());
-    return ProjectArray(arr, nbins, name, title);
+    return ProjectArray(TArrayD(array.GetSize(),array.GetArray()), nbins, name, title);
 }
 
Index: /trunk/MagicSoft/Mars/mhcalib/MHGausEvents.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhcalib/MHGausEvents.cc	(revision 5006)
+++ /trunk/MagicSoft/Mars/mhcalib/MHGausEvents.cc	(revision 5007)
@@ -386,5 +386,5 @@
   fPowerSpectrum     = fourier.PowerSpectrumDensity(&fEvents);
   fHPowerProbability = ProjectArray(*fPowerSpectrum, fPowerProbabilityBins,
-                                    Form("%s%s","PowerProbability",GetName()),
+                                    Form("%s%s","PowerProb",GetName()),
                                     "Probability of Power occurrance");
   fHPowerProbability->SetXTitle("P(f)");
@@ -521,46 +521,42 @@
 
   if (option.Contains("events"))
-    {
-      option.ReplaceAll("events","");
-      win += 1;
-    }
+    win += 1;
   if (option.Contains("fourier"))
-    {
-      option.ReplaceAll("fourier","");
-      win += 2;
-    }
-  
+    win += 2;
+  if (IsEmpty())
+    win--;
+
   pad->SetBorderMode(0);
   pad->Divide(1,win);
-  pad->cd(1);
-
-  if (!IsEmpty() && !IsOnlyOverflow() && !IsOnlyUnderflow())
-    gPad->SetLogy();
+
+  Int_t cwin = 1;
 
   gPad->SetTicks();
 
-  fHGausHist.Draw(option);
-
-  if (fFGausFit)
-    {
-      fFGausFit->SetLineColor(IsGausFitOK() ? kGreen : kRed);
-      fFGausFit->Draw("same");
-    }
-  switch (win)
-    {
-    case 2:
-      pad->cd(2);
+  if (!IsEmpty())
+    {
+      pad->cd(cwin++);
+
+      if (!IsOnlyOverflow() && !IsOnlyUnderflow())
+        gPad->SetLogy();
+
+      fHGausHist.Draw(option);
+      
+      if (fFGausFit)
+        {
+          fFGausFit->SetLineColor(IsGausFitOK() ? kGreen : kRed);
+          fFGausFit->Draw("same");
+        }
+    }
+  
+  if (option.Contains("events"))
+    {
+      pad->cd(cwin++);
       DrawEvents();
-      break;
-    case 3:
-      pad->cd(2);
-      DrawPowerSpectrum(*pad,3);
-      break;
-    case 4:
-      pad->cd(2);
-      DrawEvents();
-      pad->cd(3);
-      DrawPowerSpectrum(*pad,4);
-      break;
+    }
+  if (option.Contains("fourier"))      
+    {
+      pad->cd(cwin++);
+      DrawPowerSpectrum(*pad,cwin);
     }
 }
