Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 3611)
+++ trunk/MagicSoft/Mars/Changelog	(revision 3612)
@@ -22,4 +22,5 @@
  
    * mcalib/MHGausEvents.[h,cc]
+   * mcalib/MHCalibrationChargePix.[h,cc]
      - updated and enlarged documentation
 
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.cc	(revision 3611)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.cc	(revision 3612)
@@ -56,9 +56,34 @@
 const Axis_t  MHCalibrationChargePix::fgAbsTimeFirst    = -0.5;
 const Axis_t  MHCalibrationChargePix::fgAbsTimeLast     = 14.5;
-
 const Float_t MHCalibrationChargePix::fgPickupLimit     = 5.;
 // --------------------------------------------------------------------------
 //
 // Default Constructor. 
+//
+// Sets: 
+// - the default number for fChargeNbins  (fgChargeNbins)
+// - the default number for fChargeFirst  (fgChargeFirst)
+// - the default number for fChargeLast   (fgChargeLast)
+// - the default number for fAbsTimeNbins (fgAbstTimeNbins)
+// - the default number for fAbsTimeFirst (fgAbsTimeFirst)
+// - the default number for fAbsTimeLast  (fgAbsTimeLast)
+// - the default number for fPickupLimit  (fgPickupLimit)
+//
+// - the default name of the  fHGausHist ("HCalibrationCharge")
+// - the default title of the fHGausHist ("Distribution of Summed FADC slices Pixel ")
+// - the default x-axis title for fHGausHist ("Sum FADC Slices")
+// - the default y-axis title for fHGausHist ("Nr. of events")
+//
+// - the default name of the  fHAbsTime ("HAbsTimePixel")
+// - the default title of the fHAbsTime ("Distribution of Absolute Arrival Times Pixel ")
+// - the default x-axis title for fHAbsTime ("Absolute Arrival Time [FADC slice nr]")
+// - the default y-axis title for fHAbsTime ("Nr. of events"); 
+// - the default directory of the fHAbsTime (NULL)
+//
+// Initializes:
+// - fHAbsTime()
+// - fPixId to -1
+// - all variables to 0.
+// - all flags to kFALSE
 //
 MHCalibrationChargePix::MHCalibrationChargePix(const char *name, const char *title)
@@ -67,5 +92,5 @@
   
   fName  = name  ? name  : "MHCalibrationChargePix";
-  fTitle = title ? title : "Fill the FADC sums of calibration events and perform the fits";
+  fTitle = title ? title : "Statistics of the FADC sums of calibration events";
 
   SetChargeNbins();
@@ -96,4 +121,10 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Sets:
+// - fHGausHist.SetBins(fChargeNbins,fChargeFirst,fChargeLast);
+// - fHAbsTime.SetBins(fAbsTimeNbins,fAbsTimeFirst,fAbsTimeLast);
+//
 void MHCalibrationChargePix::Init()
 {
@@ -103,5 +134,12 @@
 }
 
-
+// --------------------------------------------------------------------------
+//
+// Sets:
+// - all variables to 0., except fPixId to -1
+// - all flags to kFALSE
+// 
+// - executes MHGausEvents::Clear()
+//
 void MHCalibrationChargePix::Clear(Option_t *o)
 {
@@ -117,10 +155,19 @@
 }
 
-
+// --------------------------------------------------------------------------
+//
+// Empty function to overload MHGausEvents::Reset()
+//
 void MHCalibrationChargePix::Reset()
 {
 }
 
-
+// --------------------------------------------------------------------------
+//
+// - 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
+//
 void MHCalibrationChargePix::ChangeHistId(Int_t id)
 {
@@ -144,4 +191,8 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// returns fHGausHist.Integral("width")
+//
 const Float_t MHCalibrationChargePix::GetIntegral() const 
 { 
@@ -159,9 +210,14 @@
 }
 
-Bool_t MHCalibrationChargePix::IsExcluded()      const
+const Bool_t MHCalibrationChargePix::IsExcluded()      const
 {
   return TESTBIT(fFlags,kExcluded);
 }
 
+// --------------------------------------------------------------------------
+//
+// Fills fHAbsTime with t
+// Returns kFALSE, if overflow or underflow occurred, else kTRUE
+//
 Bool_t MHCalibrationChargePix::FillAbsTime(Float_t t)
 {
@@ -169,5 +225,13 @@
 }
 
-
+// -----------------------------------------------------------------------------
+// 
+// Default draw:
+//
+// The following options can be chosen:
+//
+// "": displays the fHGausHist and the fHAbsTime
+// "all": executes additionally MHGausEvents::Draw(), with options
+//
 void MHCalibrationChargePix::Draw(const Option_t *opt)
 {
@@ -240,4 +304,11 @@
 }
 
+// -----------------------------------------------------------------------------
+// 
+// Repeats the Gauss fit in a smaller range, defined by: 
+// 
+// min = GetMean() - fPickupLimit * GetSigma();
+// max = GetMean() + fPickupLimit * GetSigma();
+//
 Bool_t MHCalibrationChargePix::RepeatFit(const Option_t *option)
 {
@@ -279,4 +350,13 @@
 }
 
+
+// -----------------------------------------------------------------------------
+// 
+// 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()
 {
@@ -287,12 +367,12 @@
   //
   SetMean     ( fHGausHist.GetMean() );
-  SetMeanErr  ( fHGausHist.GetRMS() / fHGausHist.GetEntries() );
+  SetMeanErr  ( fHGausHist.GetRMS() / TMath::Sqrt(fHGausHist.GetEntries()) );
   SetSigma    ( fHGausHist.GetRMS() );
-  SetSigmaErr ( fHGausHist.GetRMS() / fHGausHist.GetEntries() / 2. );
+  SetSigmaErr ( fHGausHist.GetRMS() / TMath::Sqrt(fHGausHist.GetEntries()) / 2. );
 }
 
 void MHCalibrationChargePix::CountPickup()
 {
-    fPickup  = (Int_t)GetHGausHist()->Integral(GetHGausHist()->GetXaxis()->FindBin(GetMean()+fPickupLimit*GetSigma()),
+   fPickup  = (Int_t)GetHGausHist()->Integral(GetHGausHist()->GetXaxis()->FindBin(GetMean()+fPickupLimit*GetSigma()),
 					       GetHGausHist()->GetXaxis()->GetLast(), 
 					       "width");
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.h	(revision 3611)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.h	(revision 3612)
@@ -12,35 +12,33 @@
 private:
 
-  static const Int_t   fgChargeNbins;
-  static const Axis_t  fgChargeFirst;
-  static const Axis_t  fgChargeLast;  
-
-  static const Int_t   fgAbsTimeNbins;
-  static const Axis_t  fgAbsTimeFirst;
-  static const Axis_t  fgAbsTimeLast;
-
-  static const Float_t fgPickupLimit;
+  static const Int_t   fgChargeNbins;        // Default for fChargeNBins  (now set to: 2000  )
+  static const Axis_t  fgChargeFirst;        // Default for fChargeFirst  (now set to: -0.5  )
+  static const Axis_t  fgChargeLast;         // Default for fChargeLast   (now set to: 1999.5)
+  static const Int_t   fgAbsTimeNbins;       // Default for fAbsTimeNbins (now set to: 15    )
+  static const Axis_t  fgAbsTimeFirst;       // Default for fAbsTimeFirst (now set to: -0.5  )
+  static const Axis_t  fgAbsTimeLast;        // Default for fAbsTimeLast  (now set to: 14.5  )
+  static const Float_t fgPickupLimit;        // Default for fPickupLimit  (now set to:  5.   )
 
 protected:
 
-  Int_t    fPixId;
+  Int_t    fPixId;         // The pixel ID
 
-  TH1F     fHAbsTime;          // Histogram to hold the absolute arrival times in number of FADC slices
+  TH1F     fHAbsTime;      // Histogram to hold the absolute arrival times in number of FADC slices
                           
-  Int_t    fChargeNbins;
-  Axis_t   fChargeFirst;
-  Axis_t   fChargeLast;
+  Int_t    fChargeNbins;   // Number of  bins used for the fHGausHist
+  Axis_t   fChargeFirst;   // Lower bound bin used for the fHGausHist
+  Axis_t   fChargeLast;    // Upper bound bin used for the fHGausHist
 
-  Int_t    fAbsTimeNbins;
-  Axis_t   fAbsTimeFirst;
-  Axis_t   fAbsTimeLast;
+  Int_t    fAbsTimeNbins;  // Number of  bins used for the fHAbsTime 
+  Axis_t   fAbsTimeFirst;  // Lower bound bin used for the fHAbsTime
+  Axis_t   fAbsTimeLast;   // Upper bound bin used for the fHAbsTime
 
-  Float_t    fPickupLimit;      // The limit in number of sigmas from the fitted mean above which events are considered as pickup
+  Float_t  fPickupLimit;   // Upper number of sigmas from the fitted mean above which events are considered as pickup
 
-  Float_t  fSaturated;
-  Float_t  fPickup;
+  Float_t  fSaturated;     // Number of events classified as saturated
+  Float_t  fPickup;        // Number of events classified as pick-up
 
-  Byte_t   fFlags;
-  enum     { kExcluded };
+  Byte_t   fFlags;         // Bit-field for the flags
+  enum     { kExcluded };  // Possible bits to be set
 
 public:
@@ -54,31 +52,31 @@
   virtual void ChangeHistId(Int_t i);
   
-  // Setters
-  virtual void SetChargeNbins(const Int_t  bins =fgChargeNbins)    { fChargeNbins = bins; }
-  virtual void SetChargeFirst(const Axis_t first=fgChargeFirst)    { fChargeFirst = first; }
-  virtual void SetChargeLast( const Axis_t last =fgChargeLast)     { fChargeLast  = last; }
+  // Setters 
+  virtual void SetChargeNbins(const Int_t  bins =fgChargeNbins)    { fChargeNbins = bins;   }
+  virtual void SetChargeFirst(const Axis_t first=fgChargeFirst)    { fChargeFirst = first;  }
+  virtual void SetChargeLast( const Axis_t last =fgChargeLast)     { fChargeLast  = last;   }
   
-  virtual void SetAbsTimeNbins(const Int_t  bins =fgAbsTimeNbins)  { fAbsTimeNbins = bins; }
+  virtual void SetAbsTimeNbins(const Int_t  bins =fgAbsTimeNbins)  { fAbsTimeNbins = bins;  }
   virtual void SetAbsTimeFirst(const Axis_t first=fgAbsTimeFirst)  { fAbsTimeFirst = first; }
-  virtual void SetAbsTimeLast( const Axis_t last =fgAbsTimeLast)   { fAbsTimeLast  = last; }
+  virtual void SetAbsTimeLast( const Axis_t last =fgAbsTimeLast)   { fAbsTimeLast  = last;  }
 
-  virtual void SetPickupLimit( const Float_t  lim =fgPickupLimit)    { fPickupLimit  = lim; }
+  virtual void SetPickupLimit( const Float_t  lim =fgPickupLimit)  { fPickupLimit  = lim;   }
 
-  void SetSaturated      ( const Float_t f    )                   { fSaturated += f; }
-  void SetExcluded       ( const Bool_t b=kTRUE );
+  void SetSaturated          ( const Float_t f    )                { fSaturated += f;      }
+  void SetExcluded           ( const Bool_t b=kTRUE );
 
   // Getters
-  TH1F *GetHAbsTime()                       { return &fHAbsTime;  }
-  const TH1F *GetHAbsTime()           const { return &fHAbsTime;  }
+  TH1F *GetHAbsTime()                         { return &fHAbsTime;  }
+  const TH1F *GetHAbsTime()             const { return &fHAbsTime;  }
 
-  const Float_t  GetIntegral()        const;
+  const Float_t  GetIntegral()          const;
   
-  const Float_t  GetAbsTimeMean()     const;
-  const Float_t  GetAbsTimeRms()      const;
+  const Float_t  GetAbsTimeMean(  )     const;
+  const Float_t  GetAbsTimeRms()        const;
 
-  const Float_t    GetSaturated()       const { return fSaturated;   }
-  const Float_t    GetPickup()          const { return fPickup;      }
+  const Float_t  GetSaturated()         const { return fSaturated;   }
+  const Float_t  GetPickup()            const { return fPickup;      }
 
-  Bool_t   IsExcluded()         const;
+  const Bool_t   IsExcluded()          const;
 
   // Fill histos
@@ -95,5 +93,5 @@
   void CountPickup();
 
-  ClassDef(MHCalibrationChargePix, 1)     // Base class for charge calibrated pixel
+  ClassDef(MHCalibrationChargePix, 1)     // Base Histogram class for a Calibration Pixel
 };
 
