Index: trunk/MagicSoft/Mars/mhcalib/MHGausEvents.cc
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHGausEvents.cc	(revision 5115)
+++ trunk/MagicSoft/Mars/mhcalib/MHGausEvents.cc	(revision 5135)
@@ -88,4 +88,5 @@
 #include <TCanvas.h>
 #include <TStyle.h>
+#include <TRandom.h>
 
 #include "MFFT.h"
@@ -151,5 +152,9 @@
   fHGausHist.UseCurrentStyle();
   fHGausHist.SetDirectory(NULL);
-  fHGausHist.GetYaxis()->CenterTitle();
+  //  TAxis *xaxe = fHGausHist.GetXaxis();
+  //  xaxe->Set(100,0.,100.);
+  TAxis *yaxe = fHGausHist.GetYaxis();
+  //  yaxe->SetDefaults();
+  yaxe->CenterTitle();
 }
 
@@ -173,8 +178,4 @@
 {
 
-  // delete histograms
-  if (fHPowerProbability)
-    delete fHPowerProbability;
-
   //
   // The next two lines are important for the case that 
@@ -193,4 +194,8 @@
       delete fFExpFit;
   
+  // delete histograms
+  if (fHPowerProbability)
+    delete fHPowerProbability;
+
   // delete arrays
   if (fPowerSpectrum)  
@@ -203,4 +208,5 @@
   if (fGraphPowerSpectrum)
     delete fGraphPowerSpectrum;
+
 
 }
@@ -522,8 +528,17 @@
     {
       pad->cd(cwin++);
-      DrawPowerSpectrum(*pad,cwin);
-    }
-}
-
+      DrawPowerSpectrum();
+      pad->cd(cwin);
+      DrawPowerProjection();
+    }
+}
+
+// -----------------------------------------------------------------------------
+// 
+// DrawEvents:
+//
+// Will draw the graph with the option "A", unless the option:
+// "SAME" has been chosen 
+//
 void MHGausEvents::DrawEvents(Option_t *opt)
 {
@@ -551,22 +566,59 @@
 
 
-void MHGausEvents::DrawPowerSpectrum(TVirtualPad &pad, Int_t i)
-{
-  
+// -----------------------------------------------------------------------------
+// 
+// DrawPowerSpectrum
+//
+// Will draw the fourier spectrum of the events sequence with the option "A", unless the option:
+// "SAME" has been chosen 
+//
+void MHGausEvents::DrawPowerSpectrum(Option_t *option)
+{
+
+  TString opt(option);
+  
+  if (!fPowerSpectrum)
+    CreateFourierSpectrum();
+
   if (fPowerSpectrum)
     {
       if (!fGraphPowerSpectrum)
         CreateGraphPowerSpectrum();
+
+      if (!fGraphPowerSpectrum)
+        return;
       
-      fGraphPowerSpectrum->Draw("AL");          
-      fGraphPowerSpectrum->SetBit(kCanDelete);
-    }
-  
-  pad.cd(i);
+      if (opt.Contains("same"))
+        {
+          opt.ReplaceAll("same","");      
+          fGraphPowerSpectrum->Draw(opt+"L");
+        }
+      else
+        {
+          fGraphPowerSpectrum->Draw(opt+"AL");  
+          fGraphPowerSpectrum->SetBit(kCanDelete);
+        }
+    }
+}
+
+// -----------------------------------------------------------------------------
+// 
+// DrawPowerProjection
+//
+// Will draw the projection of the fourier spectrum onto the power probability axis
+// with the possible options of TH1D
+//
+void MHGausEvents::DrawPowerProjection(Option_t *option)
+{
+  
+  TString opt(option);
+
+  if (!fHPowerProbability)
+    CreateFourierSpectrum();
 
   if (fHPowerProbability && fHPowerProbability->GetEntries() > 0)
     {
       gPad->SetLogy();
-      fHPowerProbability->Draw();
+      fHPowerProbability->Draw(opt.Data());
       if (fFExpFit)
         {
@@ -772,5 +824,7 @@
 void MHGausEvents::InitBins()
 {
+  //  const TAttAxis att(fHGausHist.GetXaxis());
   fHGausHist.SetBins(fNbins,fFirst,fLast);
+  //  att.Copy(fHGausHist.GetXaxis());
 }
 
@@ -904,2 +958,19 @@
 }
 
+// ----------------------------------------------------------------------------
+//
+// Simulates Gaussian events and fills them  into the histogram and the array
+// In order to do a fourier analysis, call CreateFourierSpectrum()
+//
+void  MHGausEvents::SimulateGausEvents(const Float_t mean, const Float_t sigma, const Int_t nevts)
+{
+
+  if (!IsEmpty())
+    *fLog << warn << "The histogram is already filled, will superimpose simulated events on it..." << endl;
+  
+  for (Int_t i=0;i<nevts;i++) {
+    const Double_t ran = gRandom->Gaus(mean,sigma);
+    FillHistAndArray(ran);
+  }
+  
+}
Index: trunk/MagicSoft/Mars/mhcalib/MHGausEvents.h
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHGausEvents.h	(revision 5115)
+++ trunk/MagicSoft/Mars/mhcalib/MHGausEvents.h	(revision 5135)
@@ -33,5 +33,5 @@
 protected:
 
-  Float_t  fEventFrequency;              // Event frequency in Hertz (to be set)
+  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
@@ -65,6 +65,4 @@
   Float_t  fProbLimit;                 // Probability limit for judgement if fit is OK 
 
-  void DrawPowerSpectrum(TVirtualPad &pad, Int_t i);  // Draw graph of fPowerSpectrum and fHPowerProbability
-
   // Setters
   void  SetBinsAfterStripping   ( const Int_t nbins=0   )                    { fBinsAfterStripping  =nbins; }
@@ -79,8 +77,24 @@
   void Reset();  
 
+  void CreateFourierSpectrum();    
+  void CreateGraphEvents();        
+  void CreateGraphPowerSpectrum(); 
+
   // Draws
-  void Draw(Option_t *option="");       // Default Draw 
-  void DrawEvents(Option_t *option="");   // Draw graph of fEvents
+  void Draw(Option_t *option="");       
+  void DrawEvents(Option_t *option=""); 
+  void DrawPowerSpectrum(Option_t *option="");   
+  void DrawPowerProjection(Option_t *option=""); 
 
+  // Fill
+  void   FillArray       ( const Float_t f ); 
+  Bool_t FillHist        ( const Float_t f ); 
+  Bool_t FillHistAndArray( const Float_t f ); 
+  
+  // Fits
+  Bool_t FitGaus(  Option_t *option="RQ0",
+                   const Double_t xmin=0., 
+	           const Double_t xmax=0.);   
+  
   // Inits
   virtual void InitBins();
@@ -128,16 +142,6 @@
   const Bool_t IsOnlyUnderflow()         const;  
 
-  // Fill
-  void   FillArray       ( const Float_t f );     // Fill only the array fEvents 
-  Bool_t FillHist        ( const Float_t f );     // Fill only the histogram HGausHist 
-  Bool_t FillHistAndArray( const Float_t f );     // Fill bothe the array fEvents and the histogram HGausHist
-  
-  // Fits
-  Bool_t FitGaus(  Option_t *option="RQ0",
-                   const Double_t xmin=0., 
-	           const Double_t xmax=0.);       // Fit the histogram HGausHist with a Gaussian
-  
   // Prints
-  virtual void Print(const Option_t *o="") const; // Default Print
+  void Print(const Option_t *o="") const;     
   
   // Setters
@@ -158,9 +162,8 @@
   void  SetSigmaErr         ( const Double_t d                   ) { fSigmaErr       = d;   }
 
-  void CreateFourierSpectrum();                   // Create the fourier spectrum out of fEvents
-  void CreateGraphEvents();        // Create the TGraph fGraphEvents of fEvents 
-  void CreateGraphPowerSpectrum(); // Create the TGraph fGraphPowerSpectrum out of fPowerSpectrum
+  // Simulates
+  void  SimulateGausEvents(const Float_t mean, const Float_t sigma, const Int_t nevts=4096);
 
-  ClassDef(MHGausEvents, 1) // Base class for events with Gaussian distributed values
+  ClassDef(MHGausEvents, 2) // Base class for events with Gaussian distributed values
 };
 
