Index: trunk/MagicSoft/Mars/mhist/MHFadcCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHFadcCam.cc	(revision 2331)
+++ trunk/MagicSoft/Mars/mhist/MHFadcCam.cc	(revision 2333)
@@ -49,9 +49,9 @@
 //  creates an a list of histograms for all pixels and both gain channels
 //
-MHFadcCam::MHFadcCam(MHFadcPix::Type_t t, const char *name, const char *title)
+MHFadcCam::MHFadcCam(const Int_t n, MHFadcPix::Type_t t, const char *name, const char *title)
     : fNumHiGains(-1), fNumLoGains(-1), fType(t)
 {
     //
-    //   set the name and title of this object
+    // set the name and title of this object
     //
     fName  = name  ? name  : "MHFadcCam";
@@ -59,12 +59,12 @@
 
     //
-    //   loop over all Pixels and create two histograms
-    //   one for the Low and one for the High gain
-    //   connect all the histogram with the container fHist
+    // loop over all Pixels and create two histograms
+    // one for the Low and one for the High gain
+    // connect all the histogram with the container fHist
     //
-    fArray = new TObjArray(577);
+    fArray = new TObjArray(n);
 
-    for (Int_t i=0; i<577; i++)
-        (*fArray)[i] = new MHFadcPix(i+1, fType);
+    for (Int_t i=0; i<n; i++)
+        (*fArray)[i] = new MHFadcPix(i, fType);
 }
 
@@ -82,7 +82,12 @@
 TObject *MHFadcCam::Clone(const char *) const
 {
-    MHFadcCam *cam = new MHFadcCam;
+    const Int_t n = fArray->GetSize();
 
-    for (int i=0; i<577; i++)
+    //
+    // FIXME, this might be done faster and more elegant, by direct copy.
+    //
+    MHFadcCam *cam = new MHFadcCam(n);
+
+    for (int i=0; i<n; i++)
     {
         delete (*cam->fArray)[i];
@@ -100,4 +105,6 @@
 Bool_t MHFadcCam::Fill(const MRawEvtData *par)
 {
+    const Int_t n = fArray->GetSize();
+
     if (fType==MHFadcPix::kSlices)
     {
@@ -113,8 +120,8 @@
 
         //
-        // First call
+        // First call with nhi!=0
         //
         if (fNumHiGains<0)
-            for (int i=0; i<577; i++)
+            for (int i=0; i<n; i++)
                 (*this)[i].Init(nhi, nlo);
         else
@@ -136,5 +143,5 @@
     }
 
-    for (int i=0; i<577; i++)
+    for (int i=0; i<n; i++)
         if (!(*this)[i].Fill(*par))
             return kFALSE;
@@ -145,5 +152,6 @@
 void MHFadcCam::ResetHistograms()
 {
-    for (Int_t i=0; i<577; i++)
+    const Int_t n = fArray->GetSize();
+    for (Int_t i=0; i<n; i++)
         ResetEntry(i);
 }
@@ -154,3 +162,2 @@
     GetHistLo(i)->Reset();
 }
-
Index: trunk/MagicSoft/Mars/mhist/MHFadcCam.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHFadcCam.h	(revision 2331)
+++ trunk/MagicSoft/Mars/mhist/MHFadcCam.h	(revision 2333)
@@ -33,5 +33,5 @@
 
 public:
-    MHFadcCam(MHFadcPix::Type_t t=MHFadcPix::kValue, const char *name=NULL, const char *title=NULL);
+    MHFadcCam(const Int_t n=577, MHFadcPix::Type_t t=MHFadcPix::kValue, const char *name=NULL, const char *title=NULL);
     ~MHFadcCam();
 
Index: trunk/MagicSoft/Mars/mhist/MHFadcPix.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHFadcPix.cc	(revision 2331)
+++ trunk/MagicSoft/Mars/mhist/MHFadcPix.cc	(revision 2333)
@@ -48,14 +48,14 @@
 // Creates the histograms for lo and hi gain of one pixel
 //
-MHFadcPix::MHFadcPix(UInt_t pixid, Type_t t)
+MHFadcPix::MHFadcPix(Int_t pixid, Type_t t)
     : fPixId(pixid), fType(t)
 {
-    fHistHi.SetName(pixid ? Form("HiGain%03d", pixid) : "HiGain");
-    fHistHi.SetTitle(pixid ? Form("Hi Gain Pixel #%d", pixid) : "Hi Gain Samples");
+    fHistHi.SetName(pixid>=0 ? Form("HiGain%03d", pixid) : "HiGain");
+    fHistHi.SetTitle(pixid>=0 ? Form("Hi Gain Pixel #%d", pixid) : "Hi Gain Samples");
     fHistHi.SetDirectory(NULL);
     fHistHi.UseCurrentStyle();
 
-    fHistLo.SetName(pixid ? Form("LoGain%03d", pixid) : "LoGain");
-    fHistLo.SetTitle(pixid ? Form("Lo Gain Pixel #%d", pixid) : "Lo Gain Samples");
+    fHistLo.SetName(pixid>=0 ? Form("LoGain%03d", pixid) : "LoGain");
+    fHistLo.SetTitle(pixid>=0 ? Form("Lo Gain Pixel #%d", pixid) : "Lo Gain Samples");
     fHistLo.SetDirectory(NULL);
     fHistLo.UseCurrentStyle();
Index: trunk/MagicSoft/Mars/mhist/MHFadcPix.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHFadcPix.h	(revision 2331)
+++ trunk/MagicSoft/Mars/mhist/MHFadcPix.h	(revision 2333)
@@ -26,5 +26,5 @@
 
 public:
-    MHFadcPix(UInt_t pixid=0, Type_t t=kValue);
+    MHFadcPix(Int_t pixid=-1, Type_t t=kValue);
 
     TH1F *GetHistHi() { return &fHistHi; }
