Index: /trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc
===================================================================
--- /trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc	(revision 3993)
+++ /trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc	(revision 3994)
@@ -30,42 +30,56 @@
 //   MPedCalcPedRun
 //
-// This task takes a pedestal run file and fills MPedestalCam during
-// the Process() with the pedestal and rms computed in an event basis.
-// In the PostProcess() MPedestalCam is finally filled with the pedestal
-// mean and rms computed in a run basis.
-// More than one run (file) can be merged
-//
-//
-// Actually, MPedCalcPedRun applies the following formula (1):
-// 
-// PedRMS = Sqrt(  (sum(x_i^2) - sum(x_i)^2/n) / n-1 / 14 )
-// 
-// where x_i is the sum of 14 FADC slices and sum means the sum over all
-// events, n is the number of events.
-// 
-// For a high number of events, this formula is equivalent to formula (2):
-// 
-// PedRMS = Sqrt(  (<x_i*x_i> - <x_i>*<x_i>) / 14  )
-// 
-// where <> is the mean over all events and x_i again the sum over the 14
-// slices.
-// 
-// If you assume statistical equivalence of all slices (say, all have equal
-// offset and are not correlated and fluctuate Gaussian), it should also be
-// equivalent to (old formula) (3):
-// 
-// PedRMS = Sqrt(  (<p_i*p_i> - <p_i>*<p_i>) ) 
-// 
-// which is the RMS per slice of a single slice (p_i) and 
-// <> the mean over the total number of measurements, i.e. n*14.
-// 
-// If we assume that at least our pairs fluctuate independently and Gaussian,
-// then we can use the actual formula (1) in order to get 
-// fluctuations of pairs by the transformation:
-// 
-// PedRMS/pair = PedRMS (form. (3)) * Sqrt(2)
-// 
-// (However, we know that our slice-to-slice fluctuations are not Gaussian
-// (and moreover asymmetric) and that they are also correlated.)
+//  This task takes a pedestal run file and fills MPedestalCam during
+//  the Process() with the pedestal and rms computed in an event basis.
+//  In the PostProcess() MPedestalCam is finally filled with the pedestal
+//  mean and rms computed in a run basis.
+//  More than one run (file) can be merged
+//
+//  MPedCalcPedRun applies the following formula (1):
+// 
+//  Pedestal per slice = sum(x_i) / n / slices
+//  PedRMS per slice   = Sqrt(  ( sum(x_i^2) - sum(x_i)^2/n ) / n-1 / slices )
+// 
+//  where x_i is the sum of "slices" FADC slices and sum means the sum over all
+//  events. "n" is the number of events, "slices" is the number of summed FADC samples.
+// 
+//  Note that the slice-to-slice fluctuations are not Gaussian, but Poissonian, thus 
+//  asymmetric and they are correlated.
+// 
+//  It is important to know that the Pedestal per slice and PedRMS per slice depend 
+//  on the number of used FADC slices, as seen in the following plots:
+//
+//Begin_Html
+/*
+<img src="images/PedestalStudyInner.gif">
+*/
+//End_Html
+//
+//Begin_Html
+/*
+<img src="images/PedestalStudyOuter.gif">
+*/
+//
+// The plots have the following meaning:
+// 
+// 1) The calculated mean pedestal per slice (from MPedCalcPedRun)
+// 2) The fitted mean pedestal per slice     (from MHPedestalCam)
+// 3) The calculated pedestal RMS per slice  (from MPedCalcPedRun)
+// 4) The fitted sigma of the pedestal distribution per slice
+//                                           (from MHPedestalCam)
+// 5) The relative difference between calculation and histogram fit
+//    for the mean
+// 6) The relative difference between calculation and histogram fit
+//    for the sigma or RMS, respectively.
+// 
+// The calculated means do not change significantly except for the case of 2 slices, 
+// however the RMS changes from 5.7 per slice in the case of 2 extracted slices 
+// to 8.3 per slice in the case of 26 extracted slices. This change is very significant.
+// 
+// The plots have been produced on run 20123. You can reproduce them using
+// the macro pedestalstudies.C
+// 
+//  Usage of this class: 
+//  ====================
 // 
 //  Call: SetRange(higainfirst, higainlast, logainfirst, logainlast) 
@@ -87,5 +101,4 @@
 //   fLoGainWindowSize = fgLoGainWindowSize = 0
 //
-// 
 //  Input Containers:
 //   MRawEvtData
@@ -96,4 +109,5 @@
 //   MPedestalCam
 //
+//  See also: MPedestalCam, MPedestalPix, MHPedestalCam, MExtractor
 //
 /////////////////////////////////////////////////////////////////////////////
