Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 5017)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 5018)
@@ -38,4 +38,5 @@
    * mbadpixels/MBadPixelsIntensityCam.[h,cc]
    * mcalib/MCalibrationIntensity*Cam.[h,cc]
+   * mcalib/MCalibration*Cam.[h,cc]
      - replace TClonesArray by TObjArray
 
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCam.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCam.h	(revision 5017)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCam.h	(revision 5018)
@@ -8,5 +8,9 @@
 class MCalibrationBlindCam : public MCalibrationCam
 {
-public:
+private:
+
+  void Add(const UInt_t a, const UInt_t b);
+
+ public:
 
   MCalibrationBlindCam(Int_t nblind=1,const char *name=NULL, const char *title=NULL);
@@ -18,5 +22,5 @@
   void  InitSize ( const UInt_t n );
   
-  ClassDef(MCalibrationBlindCam, 1) // Container Blind Pixels Calibration Results Camera
+  ClassDef(MCalibrationBlindCam, 2) // Container Blind Pixels Calibration Results Camera
 };
 
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationCam.cc	(revision 5017)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationCam.cc	(revision 5018)
@@ -29,5 +29,5 @@
 // Base class for Camera Calibration results. 
 //
-// Contains TClonesArrays for the following objects:
+// Contains TObjArrays for the following objects:
 // - fPixels:         Array of classes derived from MCalibrationPix, one entry 
 //                    per pixel. Has to be created
@@ -42,5 +42,5 @@
 //                    per camera SECTOR. Is created automatically.
 //
-// All TClonesArrays have to enlarged by the corresponding calls to (e.g. in MGeomApply): 
+// All TObjArrays have to enlarged by the corresponding calls to (e.g. in MGeomApply): 
 // - InitSize()
 // - InitAverageAreas()
@@ -50,5 +50,5 @@
 #include "MCalibrationCam.h"
 
-#include <TClonesArray.h>
+#include <TObjArray.h>
 
 #include "MGeomCam.h"
@@ -79,5 +79,5 @@
 // - fNumLoGainFADCSlices to 0.
 //
-// Creates a TClonesArray of MBadPixelsPix containers for the TClonesArray's: 
+// Creates a TObjArray of MBadPixelsPix containers for the TObjArray's: 
 // - fAverageBadAreas
 // - fAverageBadSectors
@@ -88,8 +88,22 @@
 //
 MCalibrationCam::MCalibrationCam(const char *name, const char *title)
-    : fPulserColor(kNONE), 
-      fPixels(NULL), fAverageAreas(NULL), fAverageSectors(NULL),
-      fAverageBadAreas(NULL), fAverageBadSectors(NULL)
-{
+    : fPulserColor(kNONE)
+{
+
+  fPixels = new TObjArray;
+  fPixels->SetOwner();
+
+  fAverageAreas = new TObjArray;
+  fAverageAreas->SetOwner();
+  
+  fAverageSectors = new TObjArray;
+  fAverageSectors->SetOwner();
+
+  fAverageBadAreas = new TObjArray;
+  fAverageBadAreas->SetOwner();
+  
+  fAverageBadSectors = new TObjArray;
+  fAverageBadSectors->SetOwner();
+
 
   fNumHiGainFADCSlices.Set(1);
@@ -99,10 +113,10 @@
 // --------------------------------------------------------------------------
 //
-// Deletes the following TClonesArray's of MCalibrationPix containers (if exist):
+// Deletes the following TObjArray's of MCalibrationPix containers (if exist):
 // - fPixels
 // - fAverageAreas
 // - fAverageSectors
 //  
-// Deletes the following TClonesArray's of MBadPixelsPix containers (if exist):
+// Deletes the following TObjArray's of MBadPixelsPix containers (if exist):
 // - fAverageBadAreas
 // - fAverageBadSectors
@@ -133,5 +147,5 @@
 // --------------------------------------
 //
-// Calls the ForEach macro for the TClonesArray fPixels with the argument Clear()
+// Calls the ForEach macro for the TObjArray fPixels with the argument Clear()
 // 
 // Loops over the fAverageAreas, calling the function Clear() for 
@@ -205,14 +219,42 @@
 // -------------------------------------------------------------------
 //
-// Calls TClonesArray::ExpandCreate() for fPixels
+// Calls TObjArray::ExpandCreate() for fPixels
 //
 void MCalibrationCam::InitSize(const UInt_t i)
 {
-  fPixels->ExpandCreate(i);
-}
+
+  const UInt_t save = GetSize();
+  
+  if (i==save)
+    return;
+  
+  fPixels->Expand(i);
+
+  if (i>save)
+    Add(save,i);
+}
+
+void MCalibrationCam::Add(const UInt_t a, const UInt_t b)
+{
+  for (UInt_t i=a; i<b; i++)
+    (*fPixels)[i] = new MCalibrationPix;
+}
+
+void MCalibrationCam::AddArea(const UInt_t a, const UInt_t b)
+{
+  for (UInt_t i=a; i<b; i++)
+    (*fAverageAreas)[i] = new MCalibrationPix;
+}
+
+void MCalibrationCam::AddSector(const UInt_t a, const UInt_t b)
+{
+  for (UInt_t i=a; i<b; i++)
+    (*fAverageSectors)[i] = new MCalibrationPix;
+}
+
 
 // -------------------------------------------------------------------
 //
-// Calls TClonesArray::ExpandCreate() for:
+// Calls TObjArray::ExpandCreate() for:
 // - fAverageAreas
 // - fAverageBadAreas
@@ -220,19 +262,34 @@
 void MCalibrationCam::InitAverageAreas(const UInt_t i)
 {
-  fAverageAreas->ExpandCreate(i);
-  fAverageBadAreas->ExpandCreate(i);
-
-  for (UInt_t j=0; j<i; j++)
-    GetAverageArea(j).SetPixId(j);
-  
+
+  const UInt_t save = GetAverageAreas();
+
+  if (i==save)
+    return;
+  
+  fAverageAreas->Expand(i);
+  fAverageBadAreas->Expand(i);
+
   fNumUnsuitable.Set(i);
   fNumUnreliable.Set(i);
   fNumHiGainFADCSlices.Set(i);
   fNumLoGainFADCSlices.Set(i);
+
+  if (i < save)
+    return;
+
+  for (UInt_t j=save; j<i; j++)
+    (*fAverageBadAreas)[j] = new MBadPixelsPix;
+  
+  AddArea(save,i);
+
+  for (UInt_t j=save; j<i; j++)
+    GetAverageArea(j).SetPixId(j);
+
 }
 
 // -------------------------------------------------------------------
 //
-// Calls TClonesArray::ExpandCreate() for:
+// Calls TObjArray::ExpandCreate() for:
 // - fAverageSectors
 // - fAverageBadSectors
@@ -240,10 +297,23 @@
 void MCalibrationCam::InitAverageSectors(const UInt_t i)
 {
-  fAverageSectors->ExpandCreate(i);
-  fAverageBadSectors->ExpandCreate(i);
-
-  for (UInt_t j=0; j<i; j++)
+
+  const UInt_t save = GetAverageSectors();
+
+  if (i==save)
+    return;
+  
+  fAverageSectors->Expand(i);
+  fAverageBadSectors->Expand(i);
+
+  if (i < save)
+    return;
+
+  for (UInt_t j=save; j<i; j++)
+    (*fAverageBadSectors)[j] = new MBadPixelsPix;
+  
+  AddSector(save,i);
+
+  for (UInt_t j=save; j<i; j++)
     GetAverageSector(j).SetPixId(j);
-
 }
 
@@ -328,5 +398,5 @@
 // --------------------------------------------------------------------------
 //
-// Returns the current size of the TClonesArray fAverageAreas
+// Returns the current size of the TObjArray fAverageAreas
 // independently if the MCalibrationPix is filled with values or not.
 //
@@ -338,5 +408,5 @@
 // --------------------------------------------------------------------------
 //
-// Returns the current size of the TClonesArray fAverageSectors
+// Returns the current size of the TObjArray fAverageSectors
 // independently if the MCalibrationPix is filled with values or not.
 //
@@ -367,10 +437,10 @@
 // --------------------------------------------------------------------------
 //
-// Returns the current size of the TClonesArray fPixels 
+// Returns the current size of the TObjArray fPixels 
 // independently if the MCalibrationPix is filled with values or not.
 //
 const Int_t MCalibrationCam::GetSize() const
 {
-  return fPixels->GetEntriesFast();
+  return fPixels->GetEntries();
 }
 
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationQECam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationQECam.cc	(revision 5017)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationQECam.cc	(revision 5018)
@@ -75,5 +75,5 @@
 #include "MCalibrationQECam.h"
 
-#include <TClonesArray.h>
+#include <TObjArray.h>
 
 #include "MLog.h"
@@ -93,16 +93,4 @@
 // Default constructor. 
 //
-// Creates a TClonesArray of MCalibrationQEPix containers, initialized to 1 entry, destinated 
-// to hold one container per pixel. Later, a call to MCalibrationQECam::InitSize() 
-// has to be performed (in MGeomApply). 
-//
-// Creates a TClonesArray of MCalibrationQEPix containers, initialized to 1 entry, destinated 
-// to hold one container per pixel AREA. Later, a call to MCalibrationQECam::InitAreas() 
-// has to be performed (in MGeomApply). 
-//
-// Creates a TClonesArray of MCalibrationQEPix containers, initialized to 1 entry, destinated
-// to hold one container per camera SECTOR. Later, a call to MCalibrationQECam::InitSectors() 
-// has to be performed (in MGeomApply). 
-//
 MCalibrationQECam::MCalibrationQECam(const char *name, const char *title)
 {
@@ -110,13 +98,25 @@
     fTitle = title ? title : "Storage container for the calibrated Quantum Efficiency of the camera";
 
-    fPixels             = new TClonesArray("MCalibrationQEPix",1);
-    fAverageAreas       = new TClonesArray("MCalibrationQEPix",1);
-    fAverageSectors     = new TClonesArray("MCalibrationQEPix",1);
-    fAverageBadAreas    = new TClonesArray("MBadPixelsPix",1);
-    fAverageBadSectors  = new TClonesArray("MBadPixelsPix",1);
-
     fFlags.Set(MCalibrationCam::gkNumPulserColors);
 
     Clear();
+}
+
+void MCalibrationQECam::Add(const UInt_t a, const UInt_t b)
+{
+  for (UInt_t i=a; i<b; i++)
+    (*fPixels)[i] = new MCalibrationQEPix;
+}
+
+void MCalibrationQECam::AddArea(const UInt_t a, const UInt_t b)
+{
+  for (UInt_t i=a; i<b; i++)
+    (*fAverageAreas)[i] = new MCalibrationQEPix;
+}
+
+void MCalibrationQECam::AddSector(const UInt_t a, const UInt_t b)
+{
+  for (UInt_t i=a; i<b; i++)
+    (*fAverageSectors)[i] = new MCalibrationQEPix;
 }
 
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationQECam.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationQECam.h	(revision 5017)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationQECam.h	(revision 5018)
@@ -26,4 +26,9 @@
          kPINDiodeMethodValid, kCombinedMethodValid }; // Possible validity bits
 
+  void Add(const UInt_t a, const UInt_t b);
+  void AddArea(const UInt_t a, const UInt_t b);
+  void AddSector(const UInt_t a, const UInt_t b);
+
+  
 protected:
 
@@ -71,5 +76,5 @@
   void    SetPINDiodeMethodValid   ( const Bool_t  b, MCalibrationCam::PulserColor_t col);  
 
-  ClassDef(MCalibrationQECam, 1) // Container Quantum Efficieny Calibration Results Camera
+  ClassDef(MCalibrationQECam, 2) // Container Quantum Efficieny Calibration Results Camera
 };
 
