Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 4381)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 4382)
@@ -45,4 +45,10 @@
     - fixed a bug causing a segmentation violation in the destructor 
       (array dimension was not respected correctly)
+
+  * mcalib/MHGausEvents.cc
+    - removed an inconsistency in the naming of fHPowerProbability which 
+      can cause a memory leak (I hope, this was the cause of some of the 
+      leaks we had, but I'm not sure).
+    - removed the setting of fPixId to -1 in the Clear()
 
 
Index: /trunk/MagicSoft/Mars/mcalib/MHGausEvents.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MHGausEvents.cc	(revision 4381)
+++ /trunk/MagicSoft/Mars/mcalib/MHGausEvents.cc	(revision 4382)
@@ -179,6 +179,7 @@
 
   // delete histograms
-  if (fHPowerProbability)
-    delete fHPowerProbability;
+//  if (fHPowerProbability)
+//      if (gROOT->FindObject(fHPowerProbability->GetName()))
+//	  delete fHPowerProbability;
   
   // delete fits
@@ -226,10 +227,10 @@
   
   fCurrentSize       = 0;
-  fPixId             = -1;
 
   if (fHPowerProbability)
     {
-      delete fHPowerProbability;
-      fHPowerProbability = NULL;
+	if (gROOT->FindObject(fHPowerProbability->GetName()))
+	    delete fHPowerProbability;
+	fHPowerProbability = NULL;
     }
   
@@ -324,5 +325,5 @@
 {
 
-  Float_t *xaxis = new Float_t[n];
+  Float_t *xaxis = new Float_t[n];  fHPowerProbability->SetDirectory(NULL);
 
   if (fEventFrequency)
@@ -342,5 +343,5 @@
 // Create the fourier spectrum using the class MFFT.
 // The result is projected into a histogram and fitted by an exponential
-// 
+//   fHPowerProbability->SetDirectory(NULL);
 void MHGausEvents::CreateFourierSpectrum()
 {
@@ -386,5 +387,5 @@
   fPowerSpectrum     = fourier.PowerSpectrumDensity(&fEvents);
   fHPowerProbability = ProjectArray(*fPowerSpectrum, fPowerProbabilityBins,
-	                            Form("%s%s","PowerProbability",GetName()),
+                                    Form("%s%s","PowerProbability",GetName()),
                                     "Probability of Power occurrance");
   fHPowerProbability->SetXTitle("P(f)");
@@ -392,4 +393,5 @@
   fHPowerProbability->GetYaxis()->CenterTitle();
   fHPowerProbability->SetDirectory(NULL);
+  fHPowerProbability->SetBit(kCanDelete);  
   //
   // First guesses for the fit (should be as close to reality as possible, 
