Index: trunk/MagicSoft/Mars/mpedestal/MPedestalCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedestalCam.cc	(revision 4783)
+++ trunk/MagicSoft/Mars/mpedestal/MPedestalCam.cc	(revision 4784)
@@ -320,8 +320,152 @@
 // --------------------------------------------------------------------------
 //
+// Calculates the average pedestal for pixel sizes. 
+// The geometry container is used to get the necessary
+// geometry information (area index) If the bad pixel
+// container is given all pixels which have the flag 'kUnsuitableRun' are ignored
+// in the calculation of the size average.
+//
+Float_t MPedestalCam::GetAveragedPedPerArea(const MGeomCam &geom, const UInt_t ai, MBadPixelsCam *bad)
+{
+
+  const Int_t np = GetSize();
+
+  Double_t mean = 0.;
+  Int_t    nr   = 0;
+
+  for (int i=0; i<np; i++)
+    {
+      if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        continue; 
+      
+      const UInt_t aidx = geom[i].GetAidx();
+      
+      if (ai != aidx)
+        continue;
+
+      const MPedestalPix &pix = (*this)[i];
+      
+      mean += pix.GetPedestal();
+      nr   ++;
+      
+    }
+
+  return mean/nr;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculates the average pedestal rms for pixel sizes. 
+// The geometry container is used to get the necessary
+// geometry information (area index) If the bad pixel
+// container is given all pixels which have the flag 'kUnsuitableRun' are ignored
+// in the calculation of the size average.
+//
+Float_t MPedestalCam::GetAveragedRmsPerArea(const MGeomCam &geom, const UInt_t ai, MBadPixelsCam *bad)
+{
+
+  const Int_t np = GetSize();
+
+  Double_t rms = 0.;
+  Int_t    nr  = 0;
+
+  for (int i=0; i<np; i++)
+    {
+      if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        continue; 
+      
+      const UInt_t aidx = geom[i].GetAidx();
+      
+      if (ai != aidx)
+        continue;
+
+      const MPedestalPix &pix = (*this)[i];
+      
+      rms += pix.GetPedestalRms();
+      nr  ++;
+    }
+
+  return rms/nr;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculates the average pedestal for camera sectors. 
+// The geometry container is used to get the necessary
+// geometry information (area index) If the bad pixel
+// container is given all pixels which have the flag 'kUnsuitableRun' are ignored
+// in the calculation of the size average.
+//
+Float_t MPedestalCam::GetAveragedPedPerSector(const MGeomCam &geom, const UInt_t sec, MBadPixelsCam *bad)
+{
+
+  const Int_t np = GetSize();
+
+  Double_t mean = 0.;
+  Int_t    nr   = 0;
+
+  for (int i=0; i<np; i++)
+    {
+      if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        continue;
+      
+      const UInt_t sector = geom[i].GetSector();
+      
+      if (sec != sector)
+        continue;
+
+      const MPedestalPix &pix = (*this)[i];
+      
+      mean += pix.GetPedestal();
+      nr   ++;
+      
+    }
+
+  return mean/nr;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculates the average pedestal rms for camera sectors. 
+// The geometry container is used to get the necessary
+// geometry information (area index) If the bad pixel
+// container is given all pixels which have the flag 'kUnsuitableRun' are ignored
+// in the calculation of the size average.
+//
+Float_t MPedestalCam::GetAveragedRmsPerSector(const MGeomCam &geom, const UInt_t sec, MBadPixelsCam *bad)
+{
+
+  const Int_t np = GetSize();
+
+  Double_t rms = 0.;
+  Int_t    nr  = 0;
+
+  for (int i=0; i<np; i++)
+    {
+      if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        continue;
+      
+      const UInt_t sector = geom[i].GetSector();
+      
+      if (sec != sector)
+        continue;
+
+      const MPedestalPix &pix = (*this)[i];
+      
+      rms += pix.GetPedestalRms();
+      nr  ++;
+      
+    }
+
+  return rms/nr;
+}
+
+
+// --------------------------------------------------------------------------
+//
 // Calculates the avarage pedestal and pedestal rms for all sectors
 // and pixel sizes. The geometry container is used to get the necessary
 // geometry information (sector number, size index) If the bad pixel
-// container is given all pixels which have the flag 'bad' are ignored
+// container is given all pixels which have the flag 'kUnsuitableRun' are ignored
 // in the calculation of the sector and size average.
 //
Index: trunk/MagicSoft/Mars/mpedestal/MPedestalCam.h
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedestalCam.h	(revision 4783)
+++ trunk/MagicSoft/Mars/mpedestal/MPedestalCam.h	(revision 4784)
@@ -43,4 +43,9 @@
   Int_t               GetSize          ()                      const;
   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 );  
   
         MPedestalPix &operator[]       ( Int_t i             );
@@ -58,5 +63,5 @@
   // Setters
   void SetTotalEntries(const ULong_t n) { fTotalEntries = n; }
-
+  
   Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
   void DrawPixelContent(Int_t idx) const;
