Index: trunk/MagicSoft/Mars/mpedestal/MPedestalCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedestalCam.cc	(revision 4793)
+++ trunk/MagicSoft/Mars/mpedestal/MPedestalCam.cc	(revision 4794)
@@ -36,4 +36,5 @@
 
 #include <TArrayI.h>
+#include <TArrayF.h>
 #include <TArrayD.h>
 
@@ -326,11 +327,18 @@
 // in the calculation of the size average.
 //
-Float_t MPedestalCam::GetAveragedPedPerArea(const MGeomCam &geom, const UInt_t ai, MBadPixelsCam *bad)
+// Returns a TArrayF of dimension 2: 
+// arr[0]: averaged pedestal (default: -1.)
+// arr[1]: Error (rms) of averaged pedestal (default: 0.)
+//
+// ATTENTION: THE USER HAS TO DELETE THE RETURNED TARRAYF ACCORDINGLY
+//
+TArrayF *MPedestalCam::GetAveragedPedPerArea(const MGeomCam &geom, const UInt_t ai, MBadPixelsCam *bad)
 {
 
   const Int_t np = GetSize();
 
-  Double_t mean = 0.;
-  Int_t    nr   = 0;
+  Double_t mean  = 0.;
+  Double_t mean2 = 0.;
+  Int_t    nr    = 0;
 
   for (int i=0; i<np; i++)
@@ -346,10 +354,15 @@
       const MPedestalPix &pix = (*this)[i];
       
-      mean += pix.GetPedestal();
-      nr   ++;
-      
-    }
-
-  return mean/nr;
+      mean  += pix.GetPedestal();
+      mean2 += pix.GetPedestal()*pix.GetPedestal();
+      nr    ++;
+      
+    }
+
+  TArrayF *arr = new TArrayF(2);
+  arr->AddAt(nr   ? mean/nr : -1.,0);
+  arr->AddAt(nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0. ,1);
+
+  return arr;
 }
 
@@ -362,11 +375,18 @@
 // in the calculation of the size average.
 //
-Float_t MPedestalCam::GetAveragedRmsPerArea(const MGeomCam &geom, const UInt_t ai, MBadPixelsCam *bad)
+// Returns a TArrayF of dimension 2: 
+// arr[0]: averaged pedestal RMS (default: -1.)
+// arr[1]: Error (rms) of averaged pedestal RMS (default: 0.)
+//
+// ATTENTION: THE USER HAS TO DELETE THE RETURNED TARRAYF ACCORDINGLY
+//
+TArrayF *MPedestalCam::GetAveragedRmsPerArea(const MGeomCam &geom, const UInt_t ai, MBadPixelsCam *bad)
 {
 
   const Int_t np = GetSize();
 
-  Double_t rms = 0.;
-  Int_t    nr  = 0;
+  Double_t rms  = 0.;
+  Double_t rms2 = 0.;
+  Int_t    nr   = 0;
 
   for (int i=0; i<np; i++)
@@ -382,9 +402,14 @@
       const MPedestalPix &pix = (*this)[i];
       
-      rms += pix.GetPedestalRms();
-      nr  ++;
-    }
-
-  return rms/nr;
+      rms  += pix.GetPedestalRms();
+      rms2 += pix.GetPedestalRms()*pix.GetPedestalRms();
+      nr   ++;
+    }
+
+  TArrayF *arr = new TArrayF(2);
+  arr->AddAt(nr   ? rms/nr : -1.,0);
+  arr->AddAt(nr>1 ? TMath::Sqrt((rms2 - rms*rms/nr)/(nr-1)) : 0. ,1);
+
+  return arr;
 }
 
@@ -397,5 +422,11 @@
 // in the calculation of the size average.
 //
-Float_t MPedestalCam::GetAveragedPedPerSector(const MGeomCam &geom, const UInt_t sec, MBadPixelsCam *bad)
+// Returns a TArrayF of dimension 2: 
+// arr[0]: averaged pedestal (default: -1.)
+// arr[1]: Error (rms) of averaged pedestal (default: 0.)
+//
+// ATTENTION: THE USER HAS TO DELETE THE RETURNED TARRAYF ACCORDINGLY
+//
+TArrayF *MPedestalCam::GetAveragedPedPerSector(const MGeomCam &geom, const UInt_t sec, MBadPixelsCam *bad)
 {
 
@@ -403,4 +434,5 @@
 
   Double_t mean = 0.;
+  Double_t mean2 = 0.;
   Int_t    nr   = 0;
 
@@ -417,10 +449,15 @@
       const MPedestalPix &pix = (*this)[i];
       
-      mean += pix.GetPedestal();
-      nr   ++;
-      
-    }
-
-  return mean/nr;
+      mean  += pix.GetPedestal();
+      mean2 += pix.GetPedestal()*pix.GetPedestal();
+      nr    ++;
+      
+    }
+
+  TArrayF *arr = new TArrayF(2);
+  arr->AddAt(nr   ? mean/nr : -1.,0);
+  arr->AddAt(nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0. ,1);
+
+  return arr;
 }
 
@@ -433,11 +470,18 @@
 // in the calculation of the size average.
 //
-Float_t MPedestalCam::GetAveragedRmsPerSector(const MGeomCam &geom, const UInt_t sec, MBadPixelsCam *bad)
+// Returns a TArrayF of dimension 2: 
+// arr[0]: averaged pedestal RMS (default: -1.)
+// arr[1]: Error (rms) of averaged pedestal RMS (default: 0.)
+//
+// ATTENTION: THE USER HAS TO DELETE THE RETURNED TARRAYF ACCORDINGLY
+//
+TArrayF *MPedestalCam::GetAveragedRmsPerSector(const MGeomCam &geom, const UInt_t sec, MBadPixelsCam *bad)
 {
 
   const Int_t np = GetSize();
 
-  Double_t rms = 0.;
-  Int_t    nr  = 0;
+  Double_t rms  = 0.;
+  Double_t rms2 = 0.;
+  Int_t    nr   = 0;
 
   for (int i=0; i<np; i++)
@@ -453,10 +497,16 @@
       const MPedestalPix &pix = (*this)[i];
       
-      rms += pix.GetPedestalRms();
-      nr  ++;
-      
-    }
-
-  return rms/nr;
+      rms  += pix.GetPedestalRms();
+      rms2 += pix.GetPedestalRms()*pix.GetPedestalRms();
+      nr   ++;
+      
+    }
+
+  TArrayF *arr = new TArrayF(2);
+  arr->AddAt(nr   ? rms/nr : -1.,0);
+  arr->AddAt(nr>1 ? TMath::Sqrt((rms2 - rms*rms/nr)/(nr-1)) : 0. ,1);
+
+  return arr;
+  
 }
 
Index: trunk/MagicSoft/Mars/mpedestal/MPedestalCam.h
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedestalCam.h	(revision 4793)
+++ trunk/MagicSoft/Mars/mpedestal/MPedestalCam.h	(revision 4794)
@@ -14,5 +14,5 @@
 class MPedestalPix;
 class MBadPixelsCam;
-
+class TArrayF;
 class MPedestalCam : public MParContainer, public MCamEvent
 {
@@ -44,8 +44,8 @@
   ULong_t             GetTotalEntries  ()                      const { return fTotalEntries; }
 
-  Float_t GetAveragedPedPerArea  ( const MGeomCam &geom, const UInt_t ai=0,  MBadPixelsCam *bad=NULL );
-  Float_t GetAveragedPedPerSector( const MGeomCam &geom, const UInt_t sec=0, MBadPixelsCam *bad=NULL );  
-  Float_t GetAveragedRmsPerArea  ( const MGeomCam &geom, const UInt_t ai=0,  MBadPixelsCam *bad=NULL );
-  Float_t GetAveragedRmsPerSector( const MGeomCam &geom, const UInt_t sec=0, MBadPixelsCam *bad=NULL );  
+  TArrayF *GetAveragedPedPerArea  ( const MGeomCam &geom, const UInt_t ai=0,  MBadPixelsCam *bad=NULL );
+  TArrayF *GetAveragedPedPerSector( const MGeomCam &geom, const UInt_t sec=0, MBadPixelsCam *bad=NULL );  
+  TArrayF *GetAveragedRmsPerArea  ( const MGeomCam &geom, const UInt_t ai=0,  MBadPixelsCam *bad=NULL );
+  TArrayF *GetAveragedRmsPerSector( const MGeomCam &geom, const UInt_t sec=0, MBadPixelsCam *bad=NULL );  
   
         MPedestalPix &operator[]       ( Int_t i             );
