Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 4993)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 4994)
@@ -30,4 +30,19 @@
      - added readIPR
 		
+
+ 2004/09/14: Markus Gaug
+
+   * mhbase/MH.cc
+     - took out the search for histogram with the same name in 
+       ProjectARray. Always create new histogram whihc has to be 
+       deleted afterwards.
+
+   * mhcalib/MHGausEvents.[h,cc]
+     - put fEventFrequency back from MHCalibraionPix.
+     - always delete fHPowerProbability, if existing. 
+ 
+   * mhcalib/MHCalibrationPix.[h,cc]
+     - take out fEventFrequency
+
 
  2004/09/14: Thomas Bretz
Index: /trunk/MagicSoft/Mars/mhbase/MH.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 4993)
+++ /trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 4994)
@@ -1181,14 +1181,4 @@
     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;
@@ -1203,12 +1193,9 @@
     Int_t newbins = 0;
     FindGoodLimits(nbins, newbins, min, max, kFALSE);
-
-    if (!h1)
-    {
-        h1 = new TH1I(name, title, nbins, min, max);
-        h1->SetXTitle("");
-        h1->SetYTitle("Counts");
-        h1->SetDirectory(gROOT);
-    }
+    
+    TH1I *h1 = new TH1I(name, title, nbins, min, max);
+    h1->SetXTitle("");
+    h1->SetYTitle("Counts");
+    h1->SetDirectory(NULL);
 
     // Second loop to fill the histogram
@@ -1226,13 +1213,4 @@
 {
     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;
@@ -1249,11 +1227,8 @@
     FindGoodLimits(nbins, newbins, min, max, kFALSE);
 
-    if (!h1)
-    {
-        h1 = new TH1I(name, title, newbins, min, max);
-        h1->SetXTitle("");
-        h1->SetYTitle("Counts");
-        h1->SetDirectory(gROOT);
-    }
+    TH1I *h1 = new TH1I(name, title, newbins, min, max);
+    h1->SetXTitle("");
+    h1->SetYTitle("Counts");
+    h1->SetDirectory(NULL);
 
     // Second loop to fill the histogram
Index: /trunk/MagicSoft/Mars/mhcalib/MHCalibrationPix.h
===================================================================
--- /trunk/MagicSoft/Mars/mhcalib/MHCalibrationPix.h	(revision 4993)
+++ /trunk/MagicSoft/Mars/mhcalib/MHCalibrationPix.h	(revision 4994)
@@ -15,9 +15,4 @@
 protected:
 
-  Float_t  fEventFrequency;              // Event frequency in Hertz (to be set)
-
-  Float_t *CreateEventXaxis(Int_t n);    // Create an x-axis for the Event TGraphs
-  Float_t *CreatePSDXaxis  (Int_t n);    // Create an x-axis for the PSD TGraphs
-  
   Float_t  fBlackoutLimit;               // Lower nr sigmas from mean until event is considered blackout
   Int_t    fSaturated;                   // Number of events classified as saturated
@@ -34,10 +29,6 @@
   //  TObject *Clone(const char* name="") const;
   
-  void  CreateGraphEvents();          // Create the TGraph fGraphEvents of fEvents                    
-  void  CreateGraphPowerSpectrum();   // Create the TGraph fGraphPowerSpectrum out of fPowerSpectrum
-
   // Getters
   const Double_t GetBlackout       () const;  
-  const Float_t  GetEventFrequency () const { return fEventFrequency; }
   const Double_t GetPickup         () const;
   const Int_t    GetPixId          () const { return fPixId;          }
@@ -51,5 +42,4 @@
   void  AddSaturated        ( const Int_t    i                   ) { fSaturated     += i;   }
   void  SetBlackoutLimit    ( const Float_t  lim=fgBlackoutLimit ) { fBlackoutLimit  = lim; }
-  void  SetEventFrequency   ( const Float_t  f                   ) { fEventFrequency = f;   }
   void  SetPickupLimit      ( const Float_t  lim=fgPickupLimit   ) { fPickupLimit    = lim; }
   void  SetPixId            ( const Int_t    i                   ) { fPixId          = i;   }
Index: /trunk/MagicSoft/Mars/mhcalib/MHGausEvents.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhcalib/MHGausEvents.cc	(revision 4993)
+++ /trunk/MagicSoft/Mars/mhcalib/MHGausEvents.cc	(revision 4994)
@@ -127,5 +127,6 @@
 //
 MHGausEvents::MHGausEvents(const char *name, const char *title)
-    : fHPowerProbability(NULL), 
+    : fEventFrequency(0), 
+      fHPowerProbability(NULL), 
       fPowerSpectrum(NULL),
       fFGausFit(NULL), fFExpFit(NULL),
@@ -173,10 +174,10 @@
   // delete histograms
   if (fHPowerProbability)
-    if (gROOT->FindObject(fHPowerProbability->GetName()))
-      delete fHPowerProbability;
+    delete fHPowerProbability;
   
   // delete fits
   if (fFGausFit)
     delete fFGausFit; 
+
   if (fFExpFit)
     delete fFExpFit;
@@ -189,6 +190,8 @@
   if (fGraphEvents)
     delete fGraphEvents;
+
   if (fGraphPowerSpectrum)
     delete fGraphPowerSpectrum;
+
 }
       
@@ -199,5 +202,5 @@
 // Sets:
 // - all other pointers to NULL
-// - all variables to 0.
+// - all variables to 0. and keep fEventFrequency
 // - all flags to kFALSE
 // 
@@ -223,9 +226,8 @@
   if (fHPowerProbability)
     {
-	if (gROOT->FindObject(fHPowerProbability->GetName()))
-	    delete fHPowerProbability;
-	fHPowerProbability = NULL;
-    }
-  
+      delete fHPowerProbability;
+      fHPowerProbability = NULL;
+    }
+
   // delete fits
   if (fFGausFit)
@@ -301,4 +303,5 @@
   pix.fHGausHist = fHGausHist;
 
+  pix.fEventFrequency       = fEventFrequency;
   pix.fLast      = fLast;
   pix.fMean      = fMean;
@@ -324,6 +327,10 @@
   Float_t *xaxis = new Float_t[n];  
 
-  for (Int_t i=0;i<n;i++)
-    xaxis[i] = (Float_t)i;
+  if (fEventFrequency)
+    for (Int_t i=0;i<n;i++)
+      xaxis[i] = (Float_t)i/fEventFrequency;
+  else
+    for (Int_t i=0;i<n;i++)
+      xaxis[i] = (Float_t)i;
   
   return xaxis;
@@ -432,4 +439,5 @@
   fGraphEvents = new TGraph(n,CreateEventXaxis(n),fEvents.GetArray());  
   fGraphEvents->SetTitle("Evolution of Events with time");
+  fGraphEvents->GetXaxis()->SetTitle((fEventFrequency) ? "Time [s]" : "Event Nr.");
   fGraphEvents->GetYaxis()->SetTitle(fHGausHist.GetXaxis()->GetTitle());
   fGraphEvents->GetYaxis()->CenterTitle();
@@ -450,4 +458,5 @@
   fGraphPowerSpectrum = new TGraph(n,CreatePSDXaxis(n),fPowerSpectrum->GetArray());  
   fGraphPowerSpectrum->SetTitle("Power Spectrum Density");
+  fGraphPowerSpectrum->GetXaxis()->SetTitle((fEventFrequency) ? "Frequency [Hz]" : "Frequency");
   fGraphPowerSpectrum->GetYaxis()->SetTitle("P(f)");
   fGraphPowerSpectrum->GetYaxis()->CenterTitle();
@@ -465,5 +474,9 @@
   Float_t *xaxis = new Float_t[n];
 
-  for (Int_t i=0;i<n;i++)
+  if (fEventFrequency)
+    for (Int_t i=0;i<n;i++)
+      xaxis[i] = 0.5*(Float_t)i*fEventFrequency/n;
+  else
+    for (Int_t i=0;i<n;i++)
     xaxis[i] = 0.5*(Float_t)i/n;
   
Index: /trunk/MagicSoft/Mars/mhcalib/MHGausEvents.h
===================================================================
--- /trunk/MagicSoft/Mars/mhcalib/MHGausEvents.h	(revision 4993)
+++ /trunk/MagicSoft/Mars/mhcalib/MHGausEvents.h	(revision 4994)
@@ -27,6 +27,11 @@
   const static Float_t  fgProbLimit;            //! Default for fProbLimit            (now set to: 0.001)
   const static Int_t    fgPowerProbabilityBins; //! Default for fPowerProbabilityBins (now set to: 20)
+
+  Float_t *CreateEventXaxis(Int_t n);  // Create an x-axis for the Event TGraphs
+  Float_t *CreatePSDXaxis(Int_t n);    // Create an x-axis for the PSD TGraphs
   
 protected:
+
+  Float_t  fEventFrequency;              // Event frequency in Hertz (to be set)
 
   Int_t    fBinsAfterStripping;        // Bins for the Gauss Histogram after stripping off the zeros at both ends
@@ -60,7 +65,4 @@
   Float_t  fProbLimit;                 // Probability limit for judgement if fit is OK 
 
-  virtual Float_t *CreateEventXaxis(Int_t n);  // Create an x-axis for the Event TGraphs
-  virtual Float_t *CreatePSDXaxis(Int_t n);    // Create an x-axis for the PSD TGraphs
-
   void DrawPowerSpectrum(TVirtualPad &pad, Int_t i);  // Draw graph of fPowerSpectrum and fHPowerProbability
 
@@ -93,5 +95,6 @@
         MArrayF *GetEvents()                   { return &fEvents;            }  
   const MArrayF *GetEvents()             const { return &fEvents;            }
-        TF1     *GetFExpFit()                  { return fFExpFit;            }
+  const Float_t  GetEventFrequency () const { return fEventFrequency; }
+  TF1     *GetFExpFit()                  { return fFExpFit;            }
   const TF1     *GetFExpFit()            const { return fFExpFit;            } 
         TF1     *GetFGausFit()                 { return fFGausFit;           }
@@ -141,4 +144,5 @@
   
   // Setters
+  void  SetEventFrequency   ( const Float_t  f                   ) { fEventFrequency = f;   }
   void  SetExcluded         ( const Bool_t   b=kTRUE             );  
   void  SetExpFitOK         ( const Bool_t   b=kTRUE             );
@@ -157,6 +161,6 @@
 
   void CreateFourierSpectrum();                   // Create the fourier spectrum out of fEvents
-  virtual void     CreateGraphEvents();        // Create the TGraph fGraphEvents of fEvents 
-  virtual void     CreateGraphPowerSpectrum(); // Create the TGraph fGraphPowerSpectrum out of fPowerSpectrum
+  void CreateGraphEvents();        // Create the TGraph fGraphEvents of fEvents 
+  void CreateGraphPowerSpectrum(); // Create the TGraph fGraphPowerSpectrum out of fPowerSpectrum
 
   ClassDef(MHGausEvents, 1) // Base class for events with Gaussian distributed values
