Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 3624)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 3625)
@@ -27,4 +27,10 @@
    * manalysis/MGeomApply.cc
      - add average pixels per sector
+
+   * mcalib/MHGausEvents.[h,cc]
+   * mcalib/MHCalibrationChargePix.[h,cc]
+   * mcalib/MHCalibrationRelTimePix.[h,cc]
+     - moved BypassFit() function to MHGausEvents
+
 
  2004/03/31: Markus Gaug
Index: /trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.cc	(revision 3624)
+++ /trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.cc	(revision 3625)
@@ -848,5 +848,6 @@
       *fLog << warn << "Saturated Hi Gain histogram in pixel: " << pix.GetPixId() << endl;
       pix.SetHiGainSaturation();
-      //      return;
+      hist.CreateFourierSpectrum();
+      return;
     }
     
@@ -917,5 +918,6 @@
       bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation ); 
       bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
-      //      return;
+      hist.CreateFourierSpectrum();
+      return;
     }
 
Index: /trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.cc	(revision 3624)
+++ /trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.cc	(revision 3625)
@@ -140,5 +140,6 @@
 // - all flags to kFALSE
 // 
-// - executes MHGausEvents::Clear()
+// Executes:
+// - MHGausEvents::Clear()
 //
 void MHCalibrationChargePix::Clear(Option_t *o)
@@ -165,8 +166,10 @@
 // --------------------------------------------------------------------------
 //
-// - Set fPixId to id
-// - Add id to name and title of this
-// - Add id to names of fHGausHist and fHAbsTime
-// - Add id to the titles of fHGausHist and fHAbsTime
+// Set fPixId to id
+//
+// Add id to names and titles of: 
+// - this
+// - fHGausHist
+// - fHAbsTime
 //
 void MHCalibrationChargePix::ChangeHistId(Int_t id)
@@ -185,8 +188,16 @@
 }
 
-
+// --------------------------------------------------------------------------
+//
+// Set Excluded bit from outside
+//
 void MHCalibrationChargePix::SetExcluded(const Bool_t b)
 {
     b ? SETBIT(fFlags,kExcluded) : CLRBIT(fFlags,kExcluded);
+}
+
+const Bool_t MHCalibrationChargePix::IsExcluded()      const
+{
+  return TESTBIT(fFlags,kExcluded);
 }
 
@@ -200,4 +211,8 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// returns fHAbsTime.GetMean()
+//
 const Float_t MHCalibrationChargePix::GetAbsTimeMean() const 
 {
@@ -205,12 +220,11 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// returns fHAbsTime.GetRMS()
+//
 const Float_t MHCalibrationChargePix::GetAbsTimeRms()  const 
 {
   return fHAbsTime.GetRMS();
-}
-
-const Bool_t MHCalibrationChargePix::IsExcluded()      const
-{
-  return TESTBIT(fFlags,kExcluded);
 }
 
@@ -351,24 +365,4 @@
 
 
-// -----------------------------------------------------------------------------
-// 
-// Bypasses the Gauss fit by taking mean and RMS from the histogram
-//
-// Errors are determined in the following way:
-// MeanErr  = RMS / Sqrt(entries)
-// SigmaErr = RMS / (2.*Sqrt(entries) )
-//
-void MHCalibrationChargePix::BypassFit()
-{
-
-  //
-  // In case, we do not obtain reasonable values 
-  // with the fit, we take the histogram values
-  //
-  SetMean     ( fHGausHist.GetMean() );
-  SetMeanErr  ( fHGausHist.GetRMS() / TMath::Sqrt(fHGausHist.GetEntries()) );
-  SetSigma    ( fHGausHist.GetRMS() );
-  SetSigmaErr ( fHGausHist.GetRMS() / TMath::Sqrt(fHGausHist.GetEntries()) / 2. );
-}
 
 void MHCalibrationChargePix::CountPickup()
Index: /trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.h	(revision 3624)
+++ /trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.h	(revision 3625)
@@ -84,5 +84,4 @@
 
   // Fits
-  void   BypassFit();
   Bool_t RepeatFit(const Option_t *option="RQ0");
   
Index: /trunk/MagicSoft/Mars/mcalib/MHCalibrationRelTimeCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MHCalibrationRelTimeCam.cc	(revision 3624)
+++ /trunk/MagicSoft/Mars/mcalib/MHCalibrationRelTimeCam.cc	(revision 3625)
@@ -168,5 +168,5 @@
           MHCalibrationRelTimePix &hist = (*this)[i];
           hist.ChangeHistId(i);
-          hist.InitBins();
+          hist.Init();
           hist.SetEventFrequency(fPulserFrequency);
         }
Index: /trunk/MagicSoft/Mars/mcalib/MHCalibrationRelTimeCam.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MHCalibrationRelTimeCam.h	(revision 3624)
+++ /trunk/MagicSoft/Mars/mcalib/MHCalibrationRelTimeCam.h	(revision 3625)
@@ -50,5 +50,5 @@
   void DrawPixelContent(Int_t idx) const;
   
-  ClassDef(MHCalibrationRelTimeCam, 1)	// Storage Container for all pedestal information of the camera
+  ClassDef(MHCalibrationRelTimeCam, 1)	// Histogram class for camera relative time calibration
 };
 
Index: /trunk/MagicSoft/Mars/mcalib/MHCalibrationRelTimePix.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MHCalibrationRelTimePix.cc	(revision 3624)
+++ /trunk/MagicSoft/Mars/mcalib/MHCalibrationRelTimePix.cc	(revision 3625)
@@ -47,4 +47,20 @@
 // Default Constructor. 
 //
+// Sets: 
+// - the default number for fChargeNbins  (fgChargeNbins)
+// - the default number for fChargeFirst  (fgChargeFirst)
+// - the default number for fChargeLast   (fgChargeLast)
+//
+// - the default name of the  fHGausHist ("HCalibrationRelTime")
+// - the default title of the fHGausHist ("Distribution of Relative Arrival Times Pixel ")
+// - the default x-axis title for fHGausHist ("FADC Slice")
+// - the default y-axis title for fHGausHist ("Nr. of events")
+//
+// Initializes:
+// - fPixId to -1
+//
+// Executes:
+// - MHGausEvents::Clear()
+//
 MHCalibrationRelTimePix::MHCalibrationRelTimePix(const char *name, const char *title) 
     : fPixId(-1)
@@ -59,16 +75,21 @@
 
   // Create a large number of bins, later we will rebin
-  fHGausHist.SetName("HCalibrationRelTimeCharge");
+  fHGausHist.SetName("HCalibrationRelTime");
   fHGausHist.SetTitle("Distribution of Relative Arrival Times Pixel ");
   fHGausHist.SetXTitle("FADC Slice");
   fHGausHist.SetYTitle("Nr. of events");
-  fHGausHist.Sumw2();
+
+  Clear();
 
 }
 
-MHCalibrationRelTimePix::~MHCalibrationRelTimePix()
-{
-}
-
+// --------------------------------------------------------------------------
+//
+// Sets:
+// - fPixId to -1
+// 
+// Executes:
+// - MHGausEvents::Clear()
+//
 void MHCalibrationRelTimePix::Clear(Option_t *o)
 {
@@ -80,6 +101,18 @@
 
 
+// --------------------------------------------------------------------------
+//
+// Empty function to overload MHGausEvents::Reset()
+//
+void MHCalibrationRelTimePix::Reset()
+{
+}
 
-void MHCalibrationRelTimePix::InitBins()
+// --------------------------------------------------------------------------
+//
+// Sets:
+// - fHGausHist.SetBins(fChargeNbins,fChargeFirst,fChargeLast);
+//
+void MHCalibrationRelTimePix::Init()
 {
 
@@ -88,5 +121,11 @@
 }
 
-
+// --------------------------------------------------------------------------
+//
+// - Set fPixId to id
+//
+// Add id to names and titles of:
+// - fHGausHist
+//
 void MHCalibrationRelTimePix::ChangeHistId(Int_t id)
 {
@@ -100,21 +139,8 @@
 
 
-void  MHCalibrationRelTimePix::BypassFit()
-{
-
-  //
-  // In case, we do not obtain reasonable values 
-  // with the fit, we take the histogram values
-  //
-  SetMean(      fHGausHist.GetMean()                              );
-  SetMeanErr(   fHGausHist.GetRMS() / fHGausHist.GetEntries()     );
-  SetSigma(     fHGausHist.GetRMS()                               );
-  SetSigmaErr(  fHGausHist.GetRMS() / fHGausHist.GetEntries() /2. );
-
-}
-
 // ----------------------------------------------------------------------
 //
-// Renorm the results from FADC slices to times in ns.
+// Renorm the results from FADC slices to times. 
+// The parameters slicewidth is the inverse of the FADC frequency and has the unit ns.
 //
 void MHCalibrationRelTimePix::Renorm(const Float_t slicewidth)
Index: /trunk/MagicSoft/Mars/mcalib/MHCalibrationRelTimePix.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MHCalibrationRelTimePix.h	(revision 3624)
+++ /trunk/MagicSoft/Mars/mcalib/MHCalibrationRelTimePix.h	(revision 3625)
@@ -24,8 +24,10 @@
 
   MHCalibrationRelTimePix(const char *name=NULL, const char *title=NULL);
-  ~MHCalibrationRelTimePix();
+  ~MHCalibrationRelTimePix() {}
+  
 
   void Clear(Option_t *o="");
-  void InitBins();
+  void Reset();
+  void Init();
   
   // Setters
@@ -34,7 +36,4 @@
   void SetChargeLast( const Axis_t last =fgChargeLast)     { fChargeLast  = last; }
 
-  // Fits
-  void BypassFit();
-  
   // Others
   void ChangeHistId(Int_t i);
Index: /trunk/MagicSoft/Mars/mcalib/MHGausEvents.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MHGausEvents.cc	(revision 3624)
+++ /trunk/MagicSoft/Mars/mcalib/MHGausEvents.cc	(revision 3625)
@@ -544,4 +544,29 @@
 }
 
+// -----------------------------------------------------------------------------
+// 
+// Bypasses the Gauss fit by taking mean and RMS from the histogram
+//
+// Errors are determined in the following way:
+// MeanErr  = RMS / Sqrt(entries)
+// SigmaErr = RMS / (2.*Sqrt(entries) )
+//
+void MHGausEvents::BypassFit()
+{
+
+  const Stat_t entries = fHGausHist.GetEntries();
+  
+  if (entries <= 0.)
+    {
+      *fLog << warn << GetDescriptor() << ": Cannot bypass fit. Number of entries smaller or equal 0" << endl;
+      return;
+    }
+  
+  SetMean     ( fHGausHist.GetMean() );
+  SetMeanErr  ( fHGausHist.GetRMS() / TMath::Sqrt(entries) );
+  SetSigma    ( fHGausHist.GetRMS() );
+  SetSigmaErr ( fHGausHist.GetRMS() / TMath::Sqrt(entries) / 2. );
+}
+
 // -----------------------------------------------------------------------------------
 // 
Index: /trunk/MagicSoft/Mars/mcalib/MHGausEvents.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MHGausEvents.h	(revision 3624)
+++ /trunk/MagicSoft/Mars/mcalib/MHGausEvents.h	(revision 3625)
@@ -58,13 +58,13 @@
   Int_t    fNDFLimit;                  // NDF limit for judgement if fit is OK
 
+  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
+
+  void DrawEvents();                               // Draw graph of fEvents
+  void DrawPowerSpectrum(TVirtualPad &pad, Int_t i);  // Draw graph of fPowerSpectrum and fHPowerProbability
+
   // Setters
   void  SetPowerProbabilityBins ( const Int_t nbins=fgPowerProbabilityBins ) { fPowerProbabilityBins = nbins;  }
   void  SetBinsAfterStripping   ( const Int_t nbins=fgBinsAfterStripping   ) { fBinsAfterStripping   = nbins;  }
-
-  void DrawEvents();                                  // Draw a graph of the array fEvents
-  void DrawPowerSpectrum(TVirtualPad &pad, Int_t i);     // Draw a graph of the array fPowerSpectrum and the hist fHPowerProbability
-  
-  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
 
 public:
@@ -143,8 +143,11 @@
   
   // 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
-
+  Bool_t FitGaus(Option_t *option="RQ0",
+                 const Double_t xmin=0., const Double_t xmax=0.); // Fit the histogram HGausHist with a Gaussian
+  void BypassFit();   // Take mean and RMS from the histogram
+  
+  
   // Draws
-  virtual void Draw(Option_t *option="");     // Default Draw 
+  virtual void Draw(Option_t *option="");        // Default Draw 
   
   // Prints
