Index: /trunk/MagicSoft/Mars/mbadpixels/MBadPixelsIntensityCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbadpixels/MBadPixelsIntensityCam.cc	(revision 5051)
+++ /trunk/MagicSoft/Mars/mbadpixels/MBadPixelsIntensityCam.cc	(revision 5052)
@@ -43,5 +43,5 @@
 #include "MBadPixelsIntensityCam.h"
 
-#include <TClonesArray.h>
+#include <TOrdCollection.h>
 
 #include "MGeomCam.h"
@@ -64,5 +64,5 @@
   fTitle = title ? title : "Base container for the Intensity Calibration";
   
-  fCams = new TObjArray;
+  fCams = new TOrdCollection;
   fCams->SetOwner();
 
@@ -139,14 +139,35 @@
 // -------------------------------------------------------------------
 //
-// Calls TClonesArray::ExpandCreate() for fCams
-//
-void MBadPixelsIntensityCam::InitSize(const UInt_t n)
-{
-
-  fCams->Expand(n);
-
-  for (Int_t i=0; i<fCams->GetSize(); i++)
-    (*fCams)[i] = new MBadPixelsCam;
-}
+// Initialize the objects inside the TOrdCollection using the 
+// function Add().
+//
+// InitSize can only increase the size, but not shrink. 
+// 
+// It can be called more than one time. New Containers are 
+// added only from the current size to the argument i.
+//
+void MBadPixelsIntensityCam::InitSize(const UInt_t i)
+{
+
+  const UInt_t save = GetSize();
+
+  if (i==save)
+    return;
+  
+  if (i>save)
+    Add(save,i);
+}
+
+// -------------------------------------------------------------------
+//
+// Add MBadPixelsCams in the ranges from - to. In order to initialize
+// from MBadPixelsCam derived containers, overwrite this function
+//
+void MBadPixelsIntensityCam::Add(const UInt_t from, const UInt_t to)
+{
+  for (UInt_t i=from; i<to; i++)
+    fCams->AddAt(new MBadPixelsCam,i);
+}
+
 
 // -------------------------------------------------------------------
@@ -166,10 +187,10 @@
 // --------------------------------------------------------------------------
 //
-// Returns the current size of the TClonesArray fCams 
+// Returns the current size of the TOrdCollection fCams 
 // independently if the MBadPixelsCam is filled with values or not.
 //
 Int_t MBadPixelsIntensityCam::GetSize() const 
 {
-  return fCams->GetEntries();
+  return fCams->GetSize();
 }
 
@@ -180,5 +201,5 @@
 MBadPixelsPix &MBadPixelsIntensityCam::operator[](Int_t i)
 {
-  return (*GetCam(GetSize()-1))[i];
+  return (*GetCam())[i];
 }
 
@@ -189,5 +210,5 @@
 const MBadPixelsPix &MBadPixelsIntensityCam::operator[](Int_t i) const 
 {
-  return (*GetCam(GetSize()-1))[i];
+  return (*GetCam())[i];
 }
 
@@ -199,5 +220,5 @@
 MBadPixelsCam *MBadPixelsIntensityCam::GetCam(Int_t i)
 {
-  return static_cast<MBadPixelsCam*>(fCams->UncheckedAt(i==-1 ? GetSize()-1 : i));
+  return static_cast<MBadPixelsCam*>(i==-1 ? fCams->Last() : fCams->At(i));
 }
 
@@ -208,5 +229,5 @@
 const MBadPixelsCam *MBadPixelsIntensityCam::GetCam(Int_t i) const 
 {
-  return static_cast<MBadPixelsCam*>(fCams->UncheckedAt(i==-1 ? GetSize()-1 : i));
+  return static_cast<MBadPixelsCam*>(i==-1 ? fCams->Last() : fCams->At(i));
 }
 
Index: /trunk/MagicSoft/Mars/mbadpixels/MBadPixelsIntensityCam.h
===================================================================
--- /trunk/MagicSoft/Mars/mbadpixels/MBadPixelsIntensityCam.h	(revision 5051)
+++ /trunk/MagicSoft/Mars/mbadpixels/MBadPixelsIntensityCam.h	(revision 5052)
@@ -12,16 +12,14 @@
 #endif
 
-class TObjArray;
+class TOrdCollection;
 class MGeomCam;
 class MBadPixelsIntensityCam : public MParContainer, public MCamEvent
 {
 private:
+
+  TOrdCollection *fCams;        //-> Array of MBadPixelsCams, one per pulse colour and intensity
+
+  void Add(const UInt_t from, const UInt_t to);
   
-  void InitSize( const UInt_t n );
-  
-protected:  
-
-  TObjArray *fCams;        //-> Array of MBadPixelsCams, one per pulse colour and intensity
-
 public:
 
@@ -70,5 +68,6 @@
   
   // Inits
-  void  Init   ( const MGeomCam &geom );
+  void Init   ( const MGeomCam &geom );
+  void InitSize( const UInt_t i );
 
   Bool_t GetPixelContent ( Double_t &val, Int_t idx, const MGeomCam &cam,Int_t type=0) const;
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.cc	(revision 5051)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.cc	(revision 5052)
@@ -359,5 +359,5 @@
 MCalibrationCam *MCalibrationIntensityCam::GetCam(Int_t i)
 {
-  return static_cast<MCalibrationCam*>(fCams->Last());
+  return static_cast<MCalibrationCam*>(i==-1 ? fCams->Last() : fCams->At(i));
 }
 
@@ -368,5 +368,5 @@
 const MCalibrationCam *MCalibrationIntensityCam::GetCam(Int_t i) const 
 {
-  return static_cast<MCalibrationCam*>(fCams->Last());
+  return static_cast<MCalibrationCam*>(i==-1 ? fCams->Last() : fCams->At(i));
 }
 
