Index: trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc	(revision 2928)
+++ trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc	(revision 2929)
@@ -55,6 +55,4 @@
     fArray = new TClonesArray("MPedestalPix", 1);
 
-//    for (int i=0; i<577; i++)
-//        new ((*fArray)[i]) MPedestalPix;
 }
 
@@ -79,4 +77,16 @@
 // --------------------------------------------------------------------------
 //
+// Check if position i is inside bounds
+//
+Bool_t MPedestalCam::CheckBounds(Int_t i) const
+{
+  return i < GetSize();
+} 
+
+// --------------------------------------------------------------------------
+//
+// This function returns the current size of the TClonesArray 
+// independently if the MPedestalPix is filled with values or not.
+//
 // Get the size of the MPedestalCam
 //
@@ -92,5 +102,8 @@
 MPedestalPix &MPedestalCam::operator[](Int_t i)
 {
-    return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
+  if (!CheckBounds(i))
+    return *static_cast<MPedestalPix*>(NULL);
+
+  return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
 }
 
@@ -101,15 +114,9 @@
 MPedestalPix &MPedestalCam::operator[](Int_t i) const
 {
-    return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
-}
-
-// --------------------------------------------------------------------------
-//
-// Check if position i is inside bounds
-//
-Bool_t MPedestalCam::CheckBounds(Int_t i)
-{
-    return i < fArray->GetEntriesFast();
-} 
+  if (!CheckBounds(i))
+    return *static_cast<MPedestalPix*>(NULL);
+
+  return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
+}
 
 void MPedestalCam::Clear(Option_t *o)
Index: trunk/MagicSoft/Mars/manalysis/MPedestalCam.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedestalCam.h	(revision 2928)
+++ trunk/MagicSoft/Mars/manalysis/MPedestalCam.h	(revision 2929)
@@ -31,5 +31,5 @@
     Float_t GetPedestalMax(const MGeomCam *cam) const;
 
-    Bool_t CheckBounds(Int_t i);
+    Bool_t CheckBounds(Int_t i) const;
 
     void Print(Option_t *o="") const;
Index: trunk/MagicSoft/Mars/manalysis/MPedestalPix.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedestalPix.cc	(revision 2928)
+++ trunk/MagicSoft/Mars/manalysis/MPedestalPix.cc	(revision 2929)
@@ -48,6 +48,6 @@
 void MPedestalPix::Clear(Option_t *o)
 {
-    fPedestal = -1;
-    fPedestalRms = -1;
+    fPedestal = 0.;
+    fPedestalRms = 0.;
 }
 
