Index: trunk/MagicSoft/Mars/macros/MagicHillas.C
===================================================================
--- trunk/MagicSoft/Mars/macros/MagicHillas.C	(revision 2376)
+++ trunk/MagicSoft/Mars/macros/MagicHillas.C	(revision 2377)
@@ -41,11 +41,4 @@
 
     //
-    // The geometry container must be created by yourself to make sure
-    // that you don't choos a wrong geometry by chance
-    //
-    MGeomCamMagic geomcam;
-    plist.AddToList(&geomcam);
-
-    //
     // Use this if you want to change the binning of one of
     // the histograms. You can use:
@@ -86,4 +79,6 @@
     MReadMarsFile read("Events", filename);
     read.DisableAutoScheme();
+
+    MGeomApply geomapl;
 
     MMcPedestalCopy pcopy;
@@ -127,4 +122,5 @@
 
     tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
     tlist.AddToList(&pcopy);
     tlist.AddToList(&pnsb);
Index: trunk/MagicSoft/Mars/macros/pedestalvstime.C
===================================================================
--- trunk/MagicSoft/Mars/macros/pedestalvstime.C	(revision 2376)
+++ trunk/MagicSoft/Mars/macros/pedestalvstime.C	(revision 2377)
@@ -39,7 +39,4 @@
     //
 
-    MGeomCamMagic geom;
-    plist.AddToList(&geom);
-
     // First Task: Read file with image parameters
     // (created with the star.C macro)
@@ -48,7 +45,10 @@
     read.DisableAutoScheme();
 
+    MGeomApply geomapl;
+
     MCerPhotAnal2 ncalc;
 
     tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
     tlist.AddToList(&ncalc);
 
Index: trunk/MagicSoft/Mars/macros/pixfirerate.C
===================================================================
--- trunk/MagicSoft/Mars/macros/pixfirerate.C	(revision 2376)
+++ trunk/MagicSoft/Mars/macros/pixfirerate.C	(revision 2377)
@@ -61,10 +61,4 @@
     plist.AddToList(&tlist);
 
-    // The geometry container must be created by yourself to make sure
-    // that you don't choose a wrong geometry by mistake
-    //
-    MGeomCamMagic geomcam;
-    plist.AddToList(&geomcam);
-
     //
     // Now setup the tasks and tasklist:
@@ -75,4 +69,7 @@
     read.AddFile(filename);
     tlist.AddToList(&read);
+
+    MGeomApply geomapl;
+    tlist.AddToList(&geomapl);
 
     Double_t threshold[] = { 10, 20, 100, 200, -1 };
Index: trunk/MagicSoft/Mars/macros/pixsatrate.C
===================================================================
--- trunk/MagicSoft/Mars/macros/pixsatrate.C	(revision 2376)
+++ trunk/MagicSoft/Mars/macros/pixsatrate.C	(revision 2377)
@@ -61,10 +61,4 @@
     plist.AddToList(&tlist);
 
-    // The geometry container must be created by yourself to make sure
-    // that you don't choose a wrong geometry by mistake
-    //
-    MGeomCamMagic geomcam;
-    plist.AddToList(&geomcam);
-
     //
     // Now setup the tasks and tasklist:
@@ -75,4 +69,7 @@
     read.AddFile(filename);
     tlist.AddToList(&read);
+
+    MGeomApply geomapl;
+    tlist.AddToList(&geomapl);
 
     MHTriggerLvl0 trighi(254, "SaturationHi", "Saturation Rate of Hi Gains");
Index: trunk/MagicSoft/Mars/macros/plot.C
===================================================================
--- trunk/MagicSoft/Mars/macros/plot.C	(revision 2376)
+++ trunk/MagicSoft/Mars/macros/plot.C	(revision 2377)
@@ -23,5 +23,5 @@
 !
 \* ======================================================================== */
-#include <MH.h>
+
 // -------------------------------------------------------------------------
 //
Index: trunk/MagicSoft/Mars/macros/readCT1.C
===================================================================
--- trunk/MagicSoft/Mars/macros/readCT1.C	(revision 2376)
+++ trunk/MagicSoft/Mars/macros/readCT1.C	(revision 2377)
@@ -62,4 +62,5 @@
 
     MCT1ReadAscii read(fname);
+    MGeomApply    geomapl;
     MClone        clone("MCerPhotEvt");
     MImgCleanStd  clean;
Index: trunk/MagicSoft/Mars/macros/readMagic.C
===================================================================
--- trunk/MagicSoft/Mars/macros/readMagic.C	(revision 2376)
+++ trunk/MagicSoft/Mars/macros/readMagic.C	(revision 2377)
@@ -50,5 +50,4 @@
     MParList plist;
 
-    MGeomCamMagic geomcam;
     MHillas       hillas;
     MHillasExt    hillasext;
@@ -56,5 +55,4 @@
     MTaskList     tlist;
 
-    plist.AddToList(&geomcam);
     plist.AddToList(&hillas);
     plist.AddToList(&hillasext);
@@ -65,4 +63,5 @@
     read.DisableAutoScheme();
 
+    MGeomApply geomapl;
     MPrint print1("MMcEvt");
     MPrint print2("MRawEvtHeader");
@@ -80,4 +79,5 @@
 
     tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
     tlist.AddToList(&print1);
     tlist.AddToList(&print2);
Index: trunk/MagicSoft/Mars/macros/starplot.C
===================================================================
--- trunk/MagicSoft/Mars/macros/starplot.C	(revision 2376)
+++ trunk/MagicSoft/Mars/macros/starplot.C	(revision 2377)
@@ -42,11 +42,4 @@
 
     //
-    // The geometry container must be created by yourself to make sure
-    // that you don't choos a wrong geometry by chance
-    //
-    MGeomCamMagic geomcam;
-    plist.AddToList(&geomcam);
-
-    //
     // Use this if you want to change the binning of one of
     // the histograms. You can use:
@@ -79,4 +72,6 @@
     read.DisableAutoScheme();
 
+    MGeomApply geomapl;
+
     MFillH hfill1("MHHillas", "MHillas");
     MFillH hfill2("MHHillasExt");
@@ -86,4 +81,5 @@
 
     tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
     tlist.AddToList(&hfill1);
     tlist.AddToList(&hfill2);
Index: trunk/MagicSoft/Mars/macros/status.C
===================================================================
--- trunk/MagicSoft/Mars/macros/status.C	(revision 2376)
+++ trunk/MagicSoft/Mars/macros/status.C	(revision 2377)
@@ -57,11 +57,4 @@
     plist.AddToList(&tlist);
 
-    //
-    // The geometry container must be created by yourself to make sure
-    // that you don't choose a wrong geometry by mistake
-    //
-    MGeomCamMagic geomcam;
-    plist.AddToList(&geomcam);
-
     /*
      MSrcPosCam src;
@@ -79,4 +72,6 @@
     // ------------- user change -----------------
     read.AddFile(fname);
+
+    MGeomApply        geomapl;
 
     MMcPedestalCopy   pcopy;
@@ -117,4 +112,5 @@
 
     tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
     tlist.AddToList(&pcopy);
     tlist.AddToList(&pnsb);
Index: trunk/MagicSoft/Mars/macros/sumevents.C
===================================================================
--- trunk/MagicSoft/Mars/macros/sumevents.C	(revision 2376)
+++ trunk/MagicSoft/Mars/macros/sumevents.C	(revision 2377)
@@ -39,7 +39,4 @@
     //
 
-    MGeomCamMagic geom;
-    plist.AddToList(&geom);
-
     // First Task: Read file with image parameters
     // (created with the star.C macro)
@@ -48,7 +45,9 @@
     read.DisableAutoScheme();
 
+    MGeomApply geomapl;
     MCerPhotAnal2 ncalc;
 
     tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
     tlist.AddToList(&ncalc);
 
Index: trunk/MagicSoft/Mars/macros/sumeventserr.C
===================================================================
--- trunk/MagicSoft/Mars/macros/sumeventserr.C	(revision 2376)
+++ trunk/MagicSoft/Mars/macros/sumeventserr.C	(revision 2377)
@@ -39,7 +39,4 @@
     //
 
-    MGeomCamMagic geom;
-    plist.AddToList(&geom);
-
     // First Task: Read file with image parameters
     // (created with the star.C macro)
@@ -51,7 +48,9 @@
     //MCerPhotCalc  ncalc;
     //MCerPhotAnal  ncalc;
+    MGeomApply geomapl;
     MCerPhotAnal2 ncalc;
 
     tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
     tlist.AddToList(&ncalc);
 
Index: trunk/MagicSoft/Mars/macros/sumeventsrms.C
===================================================================
--- trunk/MagicSoft/Mars/macros/sumeventsrms.C	(revision 2376)
+++ trunk/MagicSoft/Mars/macros/sumeventsrms.C	(revision 2377)
@@ -39,7 +39,4 @@
     //
 
-    MGeomCamMagic geom;
-    plist.AddToList(&geom);
-
     // First Task: Read file with image parameters
     // (created with the star.C macro)
@@ -48,4 +45,5 @@
     read.DisableAutoScheme();
 
+    MGeomApply geomapl;
     MPedestalSum  ncalc;
     //MCerPhotCalc  ncalc;
@@ -54,4 +52,5 @@
 
     tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
     tlist.AddToList(&ncalc);
 
Index: trunk/MagicSoft/Mars/macros/sumpedestalrms.C
===================================================================
--- trunk/MagicSoft/Mars/macros/sumpedestalrms.C	(revision 2376)
+++ trunk/MagicSoft/Mars/macros/sumpedestalrms.C	(revision 2377)
@@ -39,7 +39,4 @@
     //
 
-    MGeomCamMagic geom;
-    plist.AddToList(&geom);
-
     // First Task: Read file with image parameters
     // (created with the star.C macro)
@@ -48,7 +45,9 @@
     read.DisableAutoScheme();
 
+    MGeomApply geomapl;
     MCerPhotAnal2 ncalc;
 
     tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
     tlist.AddToList(&ncalc);
 
Index: trunk/MagicSoft/Mars/macros/sumpedestals.C
===================================================================
--- trunk/MagicSoft/Mars/macros/sumpedestals.C	(revision 2376)
+++ trunk/MagicSoft/Mars/macros/sumpedestals.C	(revision 2377)
@@ -39,7 +39,4 @@
     //
 
-    MGeomCamMagic geom;
-    plist.AddToList(&geom);
-
     // First Task: Read file with image parameters
     // (created with the star.C macro)
@@ -48,7 +45,9 @@
     read.DisableAutoScheme();
 
+    MGeomApply geomapl;
     MCerPhotAnal2 ncalc;
 
     tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
     tlist.AddToList(&ncalc);
 
Index: trunk/MagicSoft/Mars/macros/threshold.C
===================================================================
--- trunk/MagicSoft/Mars/macros/threshold.C	(revision 2376)
+++ trunk/MagicSoft/Mars/macros/threshold.C	(revision 2377)
@@ -16,7 +16,7 @@
 !
 !
-!   Author(s): Thomas Bretz  12/2000 (tbretz@uni-sw.gwdg.de)
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2001
+!   Copyright: MAGIC Software Development, 2000-2003
 !
 !
Index: trunk/MagicSoft/Mars/macros/trigrate.C
===================================================================
--- trunk/MagicSoft/Mars/macros/trigrate.C	(revision 2376)
+++ trunk/MagicSoft/Mars/macros/trigrate.C	(revision 2377)
@@ -16,24 +16,24 @@
 !
 !
-!   Author(s): Thomas Bretz  12/2000 (tbretz@uni-sw.gwdg.de)
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
 !   Copyright: MAGIC Software Development, 2000-2001
 !
-!   Modified 4/7/2002, Abelardo Moralejo:
-!   Added one optional input parameter: a camera .root file containing
-!   pure NSB events. One such file is generated running the camera over an
-!   "empty" reflector file, with the NSB option on, and asking the camera
-!   program (see camera program manual) to do the simulation even if no 
-!   photoelectron from the shower arrives at the camera. One also needs to
-!   write to the output file all the events, both triggered and untriggered
-!   (see again camera manual). These nsb camera files must contain the same 
-!   trigger conditions as the proton file.
-!
-!   If no nsb file is supplied, the macro will assume no triggers from 
-!   pure NSB fluctuations.
-!
 \* ======================================================================== */
 
-
+/*
+ !   Modified 4/7/2002, Abelardo Moralejo:
+ !   Added one optional input parameter: a camera .root file containing
+ !   pure NSB events. One such file is generated running the camera over an
+ !   "empty" reflector file, with the NSB option on, and asking the camera
+ !   program (see camera program manual) to do the simulation even if no
+ !   photoelectron from the shower arrives at the camera. One also needs to
+ !   write to the output file all the events, both triggered and untriggered
+ !   (see again camera manual). These nsb camera files must contain the same
+ !   trigger conditions as the proton file.
+ !
+ !   If no nsb file is supplied, the macro will assume no triggers from
+ !   pure NSB fluctuations.
+ */
 
 Float_t GetNSBEvents(TString name, Float_t *BgR, int dim)
@@ -138,5 +138,5 @@
     if (dim < 0)
       ((MHMcRate*)(hists[0]))->SetTriggerCondNum((Short_t)(-dim));
-    else if (dim > 0)
+    if (dim > 0)
       for (Short_t i = from ; i <= to; i++)
 	((MHMcRate*)(hists[i-1]))->SetTriggerCondNum(i);
Index: trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h	(revision 2376)
+++ trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h	(revision 2377)
@@ -19,4 +19,5 @@
 #pragma link C++ class MMcPedestalCopy+;
 #pragma link C++ class MMcPedestalNSBAdd+;
+#pragma link C++ class MGeomApply+;
 
 #pragma link C++ class MHadronness+;
Index: trunk/MagicSoft/Mars/manalysis/MBlindPixelCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MBlindPixelCalc.cc	(revision 2376)
+++ trunk/MagicSoft/Mars/manalysis/MBlindPixelCalc.cc	(revision 2377)
@@ -303,4 +303,10 @@
     fPixels->Clear();
 
+    if (!fGeomCam->InheritsFrom("MGeomCamMagic"))
+    {
+        *fLog << warn << "MBlindPixelCalc::ReInit: Warning - Starfield only implemented for Magic standard Camera... no action." << endl;
+        return kTRUE;
+    }
+
     //
     // Set as blind some particular pixels because of a particular
Index: trunk/MagicSoft/Mars/manalysis/MBlindPixels.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MBlindPixels.h	(revision 2376)
+++ trunk/MagicSoft/Mars/manalysis/MBlindPixels.h	(revision 2377)
@@ -21,7 +21,11 @@
     void AdoptPixels(Char_t pixels[577]) { fPixels.Adopt(577, pixels); }
 
+    void AdoptPixels(const TArrayC &pixels) { fPixels = pixels; }
+
     void Clear(Option_t *o="")  { fPixels.Reset(); }
 
     Bool_t IsBlind(UShort_t id) const { return fPixels.GetSize() && ((TArrayC)fPixels)[id]; }
+
+    void InitSize(UShort_t i) { fPixels.Set(i); }
 
     ClassDef(MBlindPixels, 1) // container to store blind pixels
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc	(revision 2376)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc	(revision 2377)
@@ -48,4 +48,5 @@
 #include "MLogManip.h"
 
+#include "MGeomCam.h"
 #include "MMcRunHeader.hxx"
 
@@ -174,5 +175,5 @@
 void MCerPhotCalc::ScalePedestals()
 {
-    Int_t n = 577; //FIXME: fPedestals->GetNumPixel();
+    const Int_t n = fPedestals->GetSize();
 
     for (int idx=0; idx<n; idx++)
@@ -186,6 +187,5 @@
         const Double_t offset = fEnableFix ? ped.GetPedestal()-0.5 : ped.GetPedestal();
 
-        ped.Set(offset*fSumWeights,
-		ped.GetPedestalRms()*fSumQuadWeights);
+        ped.Set(offset*fSumWeights, ped.GetPedestalRms()*fSumQuadWeights);
     }
 
@@ -205,13 +205,13 @@
 //        ScalePedestals();
 
+    const Int_t n = fWeight.GetSize();
+
     MRawEvtPixelIter pixel(fRawEvt);
 
-    Int_t SaturatedPixels = 0;
+    Int_t saturatedpixels = 0;
 
     while (pixel.Next())
     {
         const UInt_t idx = pixel.GetPixelId();
-        MPedestalPix &ped = (*fPedestals)[idx];
-
 	//
 	// sanity check (old MC files sometimes have pixids>577)
@@ -219,7 +219,9 @@
         if (!fPedestals->CheckBounds(idx))
         {
-	    *fLog << inf << "Pixel Index larger than camera... skipping event." << endl;
+	    *fLog << inf << "Pixel Index out of MPedestalCam bounds... skipping event." << endl;
 	    return kCONTINUE;
-	}
+        }
+
+        MPedestalPix &ped = (*fPedestals)[idx];
 
         //
@@ -230,5 +232,5 @@
         Int_t i;
         Double_t nphot = 0;
-        for (i=0; i<fWeight.GetSize(); i++)
+        for (i=0; i<n; i++)
         {
             if (ptr[i]==0xff)
@@ -237,7 +239,7 @@
         }
 
-	Bool_t SaturatedLG = kFALSE;
-
-        if (i<fWeight.GetSize())
+	Bool_t saturatedlg = kFALSE;
+
+        if (i<n)
         {
 	    nphot = 0;
@@ -250,10 +252,10 @@
             }
 
-            for (i=0; i<fWeight.GetSize(); i++)
+            for (i=0; i<n; i++)
             {
-	      if (ptr[i]==0xff)
-		SaturatedLG = kTRUE;
-
-	      nphot += ptr[i]*fWeight[i];
+                if (ptr[i]==0xff)
+                    saturatedlg = kTRUE;
+
+                nphot += ptr[i]*fWeight[i];
             }
 
@@ -266,20 +268,10 @@
         fCerPhotEvt->AddPixel(idx, nphot, 0);
 
-	if (SaturatedLG)
-	  SaturatedPixels ++;
-    }
-
-    switch(SaturatedPixels)
-      {
-      case 0:
-	break;
-      case 1:
-	*fLog << warn << "WARNING: 1 pixel had saturating low gains..." << endl;
-	break;
-      default:
-	*fLog << warn << "WARNING: " << SaturatedPixels << " pixels had saturating low gains..." << endl;
-	break;
-      }
-
+	if (saturatedlg)
+	  saturatedpixels++;
+    }
+
+    if (saturatedpixels>0)
+        *fLog << warn << "WARNING: " << saturatedpixels << " pixel(s) had saturating low gains..." << endl;
 
     fCerPhotEvt->FixSize();
Index: trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc	(revision 2376)
+++ trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc	(revision 2377)
@@ -126,7 +126,5 @@
         return kFALSE;
 
-    const int num = fMcPed->GetNumPixel();
-
-    fPedCam->InitSize(num);
+    const int num = fPedCam->GetSize();
 
     for (int i=0; i<num; i++)
Index: trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc	(revision 2376)
+++ trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc	(revision 2377)
@@ -207,7 +207,5 @@
         return kFALSE;
 
-    const int num = fFadc->GetNumPixel();
-    
-    fPedCam->InitSize(num);
+    const int num = fPedCam->GetSize();
 
     for (int i=0; i<num; i++)
Index: trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc	(revision 2376)
+++ trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc	(revision 2377)
@@ -53,8 +53,8 @@
     fTitle = title ? title : "Storage container for all Pedestal Information in the camera";
 
-    fArray = new TClonesArray("MPedestalPix", 577);
+    fArray = new TClonesArray("MPedestalPix", 1);
 
-    for (int i=0; i<577; i++)
-        new ((*fArray)[i]) MPedestalPix;
+//    for (int i=0; i<577; i++)
+//        new ((*fArray)[i]) MPedestalPix;
 }
 
Index: trunk/MagicSoft/Mars/manalysis/Makefile
===================================================================
--- trunk/MagicSoft/Mars/manalysis/Makefile	(revision 2376)
+++ trunk/MagicSoft/Mars/manalysis/Makefile	(revision 2377)
@@ -35,4 +35,5 @@
            MMcPedestalCopy.cc \
            MMcPedestalNSBAdd.cc \
+           MGeomApply.cc \
            MCurrents.cc \
            MEnergyEst.cc \
Index: trunk/MagicSoft/Mars/mbase/MArgs.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MArgs.cc	(revision 2376)
+++ trunk/MagicSoft/Mars/mbase/MArgs.cc	(revision 2377)
@@ -28,4 +28,6 @@
 // MArgs
 //
+// This is a helper class for executables to parse command line arguments
+//
 //////////////////////////////////////////////////////////////////////////////
 #include "MArgs.h"
@@ -46,4 +48,10 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Initializes:
+//  fName: The name of the executable
+//  fArgv: A TList containing all other command line arguments
+//
 MArgs::MArgs(int argc, const char **argv) : fArgc(argc)
 {
@@ -61,4 +69,8 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Deletes fArgv.
+//
 MArgs::~MArgs()
 {
@@ -66,4 +78,8 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Print all arguments parsed.
+//
 void MArgs::Print(const Option_t *o) const
 {
@@ -72,4 +88,10 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Return the Integer corresponding to the command line argument 'name'
+//  eg. executable -argument 5
+//      GetInt("argument") will return 5
+//
 Int_t MArgs::GetInt(const TString name) const
 {
@@ -77,4 +99,11 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Return the floating point value corresponding to the command line argument
+// 'name'
+//  eg. executable -argument 5.7
+//      GetFloat("argument") will return 5.7
+//
 Double_t MArgs::GetFloat(const TString name) const
 {
@@ -82,4 +111,10 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Return the TString corresponding to the command line argument 'name'
+//  eg. executable -argument=last
+//      GetString("-argument=") will return "last"
+//
 TString MArgs::GetString(const TString name) const
 {
@@ -92,4 +127,11 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Return the Integer corresponding to the command line argument 'name'
+//  eg. executable -argument5
+//      GetIntAndRemove("-argument") will return 5
+// and removes the argument from the internal list.
+//
 Int_t MArgs::GetIntAndRemove(const TString name)
 {
@@ -97,4 +139,12 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Return the floating point value corresponding to the command line argument
+// 'name'
+//  eg. executable -argument5.7
+//      GetFloatAndRemove("-argument") will return 5.7
+// and removes the argument from the internal list.
+//
 Double_t MArgs::GetFloatAndRemove(const TString name)
 {
@@ -102,4 +152,11 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Return the TString corresponding to the command line argument 'name'
+//  eg. executable -argument=last
+//      GetStringAndRemove("-argument=") will return "last"
+// and removes the argument from the internal list.
+//
 TString MArgs::GetStringAndRemove(const TString n)
 {
@@ -118,4 +175,11 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Return the Integer corresponding to the i-th argument. This is ment
+// for enumerations like
+//  executable 1 7 2
+//  GetArgumentInt(1) will return 7
+//
 Int_t MArgs::GetArgumentInt(Int_t i) const
 {
@@ -123,4 +187,11 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Return the floating point value corresponding to the i-th argument.
+// This is ment for enumerations like
+//  executable 1.7 7.5 2.3
+//  GetArgumentFloat(1) will return 7.5
+//
 Float_t MArgs::GetArgumentFloat(Int_t i) const
 {
@@ -128,4 +199,12 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Return the TString corresponding to the i-th argument.
+// This is ment for enumerations like
+//  executable file1 file2 file3
+//  GetArgumentStr(1) will return "file2"
+// Only arguments without a trailing '-' are considered
+//
 TString MArgs::GetArgumentStr(Int_t i) const
 {
@@ -146,4 +225,8 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// return the number of arguments without a trainling '-'
+//
 Int_t MArgs::GetNumArguments() const
 {
@@ -159,4 +242,11 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Checks whether an argument beginning with 'n' is existing, eg:
+//  executable -value5
+//  executable -value
+//  HasOption("-value") will return true in both cases
+//
 Bool_t MArgs::Has(const TString n) const
 {
@@ -171,4 +261,14 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Checks whether an argument beginning with 'n' is exists and a
+// corresponding option is available, eg.
+//  executable -value5
+//  HasOption("-value") will return true
+// but:
+//  executable -value
+//  HasOption("-value") will return false
+//
 Bool_t MArgs::HasOption(const TString n) const
 {
Index: trunk/MagicSoft/Mars/mbase/MDirIter.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MDirIter.cc	(revision 2376)
+++ trunk/MagicSoft/Mars/mbase/MDirIter.cc	(revision 2377)
@@ -179,4 +179,8 @@
 }
 
+// --------------------------------------------------------------------------
+//
+//  Returns the concatenation of 'dir' and 'name'
+//
 TString MDirIter::ConcatFileName(const char *dir, const char *name) const
 {
Index: trunk/MagicSoft/Mars/mdatacheck/MGDisplayAdc.cc
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MGDisplayAdc.cc	(revision 2376)
+++ trunk/MagicSoft/Mars/mdatacheck/MGDisplayAdc.cc	(revision 2377)
@@ -99,5 +99,4 @@
     fSlider = new TGVSlider(mid, 250, kSlider1|kScaleBoth, M_VSId1);
     fSlider->Associate(this);
-    fSlider->SetRange(1, 577);
 
     fList->Add(fSlider);
@@ -258,5 +257,5 @@
 
     //
-    // Here the initial display is set to hitogram 0
+    // Here the initial display is set to entry with id 1
     //
     fHistoList->Select(1);
@@ -305,7 +304,10 @@
     const Int_t nhi = fHists->GetEntries();
 
+    Int_t n=1;
     for (Int_t i=0; i<nhi; i++)
         if (fHists->HasHi(i))
-            fHistoList->AddEntry(fHists->GetHistHi(i)->GetName(), i+1);
+            fHistoList->AddEntry(fHists->GetHistHi(i)->GetName(), n++);
+
+    fSlider->SetRange(1, n);
 
     fHistoList->MapSubwindows();
@@ -329,5 +331,5 @@
     fCanvas->Clear();
 
-    const Int_t idx = selected-1;
+    const Int_t idx = fHistoList->GetSelectedEntry()->EntryId(); //selected-1;
 
     if (!fHists->HasHi(idx))
@@ -414,5 +416,5 @@
 
                     if ((parm1==M_BUTTON_PREV && selected==1) ||
-                        (parm1==M_BUTTON_NEXT && selected==577))
+                        (parm1==M_BUTTON_NEXT && selected==fHistoList->GetNumberOfEntries()))
                         return kTRUE;
 
@@ -448,5 +450,5 @@
 
         // Check for the slider movement and synchronise with TGListBox
-        if (parm2<1 || parm2>577)
+        if (parm2<1 || parm2>fHistoList->GetNumberOfEntries())
             return kTRUE;
 
Index: trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.cc	(revision 2376)
+++ trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.cc	(revision 2377)
@@ -38,4 +38,5 @@
 #include "MTaskList.h"           // MTaskList::AddToList
 #include "MHCamera.h"            // MHCamera
+#include "MGeomApply.h"          // MGeomApply
 #include "MHillasCalc.h"         // MHillasCalc
 #include "MHillasSrcCalc.h"      // MHillasSrcCalc
@@ -43,10 +44,10 @@
 #include "MPedestalCam.h"        // MPedestalCam
 #include "MCerPhotEvt.h"         // MCerPhotEvt::GetPixById
-#include "MCerPhotCalc.h"       // MCerPhotCalc
+#include "MCerPhotCalc.h"        // MCerPhotCalc
 #include "MMcPedestalCopy.h"     // MMcPedestalCopy
 #include "MMcPedestalNSBAdd.h"   // MMcPedestalNSBAdd
 #include "MBlindPixelCalc.h"     // MBlindPixelCalc
 #include "MImgCleanStd.h"        // MImgCleanStd
-#include "MGeomCamMagic.h"       // MGeomMagicCam
+//#include "MGeomCamMagic.h"       // MGeomMagicCam
 #include "MRawEvtData.h"         // MRawEvtData
 
@@ -116,9 +117,10 @@
 //  preprocess tasks and read in first event (process)
 //
-MGeomCam *MGCamDisplay::SetupTaskList()
+void /*MGeomCam */MGCamDisplay::SetupTaskList()
 {
     MTaskList *tlist = GetTaskList();
     MParList  *plist = GetParList();
 
+    MGeomApply        *apply = new MGeomApply;
     MMcPedestalCopy   *pcopy = new MMcPedestalCopy;
     MMcPedestalNSBAdd *pdnsb = new MMcPedestalNSBAdd;
@@ -130,4 +132,5 @@
     MHillasSrcCalc    *scalc = new MHillasSrcCalc;
 
+    tlist->AddToList(apply);
     tlist->AddToList(pcopy);
     tlist->AddToList(pdnsb);
@@ -139,13 +142,13 @@
     tlist->AddToList(scalc);
 
-    MGeomCamMagic *geom   = new MGeomCamMagic;
+    // MGeomCamMagic *geom   = new MGeomCamMagic;
     MPedestalCam  *pedest = new MPedestalCam;
     MRawEvtData   *event  = new MRawEvtData;
 
-    plist->AddToList(geom);
+    // plist->AddToList(geom);
     plist->AddToList(pedest);
     plist->AddToList(event);
 
-    return geom;
+    // return NULL;
 }
 
@@ -161,5 +164,5 @@
     // Setup Task list for hillas calculation
     //
-    MGeomCam *geom = SetupTaskList();
+    /*MGeomCam *geom = */SetupTaskList();
 
     //
@@ -181,5 +184,5 @@
     {
         fCanvas2[i]->cd();
-        fDisplay[i] = new MHCamera(*geom);
+        fDisplay[i] = new MHCamera;//(*geom);
         fDisplay[i]->Draw();
         fDisplay[i]->AddNotify(*(MCamEvent*)GetParList()->FindObject("MRawEvtData"));
@@ -221,4 +224,5 @@
 //  together with the hillas ellipse or not.
 //
+#include <iostream.h>
 void MGCamDisplay::UpdateDisplay()
 {
@@ -227,4 +231,14 @@
 
     const MParList *plist = fEvtLoop->GetParList();
+
+    if (!fDisplay[0]->GetGeometry())
+    {
+        MGeomCam *cam = (MGeomCam*)plist->FindObject("MGeomCam");
+        for (int i=0; i<5; i++)
+        {
+            fDisplay[i]->SetGeometry(*cam);
+            cout << "---> Setting geometry for: " << fDisplay[i]->GetName() << endl;
+        }
+    }
 
     //
@@ -257,8 +271,10 @@
     const MPedestalCam *ped   = (MPedestalCam*)plist->FindObject("MPedestalCam");
 
+    const Int_t n = ped->GetSize();
+
     // FIXME: Make this publicly available
-    TArrayD val(577);
-    TArrayC use(577);
-    for (int i=0; i<577;i++)
+    TArrayD val(n);
+    TArrayC use(n);
+    for (int i=0; i<n;i++)
     {
         // FIXME: photon event first!
Index: trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.h
===================================================================
--- trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.h	(revision 2376)
+++ trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.h	(revision 2377)
@@ -25,5 +25,5 @@
     void UpdateDisplay();
 
-    MGeomCam *SetupTaskList();
+    void /*MGeomCam */SetupTaskList();
 
 public:
Index: trunk/MagicSoft/Mars/meventdisp/MGEvtDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/meventdisp/MGEvtDisplay.cc	(revision 2376)
+++ trunk/MagicSoft/Mars/meventdisp/MGEvtDisplay.cc	(revision 2377)
@@ -278,4 +278,5 @@
 
     AddTab("Geometry");
+
     MGeomCamMagic geom;
     MHCamera *display = new MHCamera(geom);
Index: trunk/MagicSoft/Mars/mfileio/MReadCurrents.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadCurrents.cc	(revision 2376)
+++ trunk/MagicSoft/Mars/mfileio/MReadCurrents.cc	(revision 2377)
@@ -24,13 +24,13 @@
 
 /////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MReadCurrents                                                         //
-//                                                                         //
-//  Input Containers:                                                      //
-//   -/-                                                                   //
-//                                                                         //
-//  Output Containers:                                                     //
-//   MCerPhotEvt                                                           //
-//                                                                         //
+//
+// MReadCurrents
+//
+//  Input Containers:
+//   -/-
+//
+//  Output Containers:
+//   MCerPhotEvt
+//
 /////////////////////////////////////////////////////////////////////////////
 #include "MReadCurrents.h"
@@ -63,5 +63,5 @@
 			     const char *name, 
                              const char *title)
-    : fIn(NULL)
+    : fIn(NULL), fNumPixel(577)
 {
     fName  = name  ? name  : "MReadCurrents";
@@ -225,5 +225,5 @@
     fTime->SetTime(h, m, s, ms*1000000);
 
-    for (int i=0; i<577; i++)
+    for (int i=0; i<fNumPixel; i++)
         *fIn >> (*fCurrents)[i];
 
Index: trunk/MagicSoft/Mars/mfileio/MReadCurrents.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadCurrents.h	(revision 2376)
+++ trunk/MagicSoft/Mars/mfileio/MReadCurrents.h	(revision 2377)
@@ -18,4 +18,6 @@
     TList     *fFileNames;   // Array which stores the \0-terminated filenames
 
+    Int_t      fNumPixel;
+
     Bool_t OpenNextFile();
 
@@ -32,4 +34,6 @@
     Int_t Process();
 
+    void SetNumPixel(Int_t i) { fNumPixel=i; }
+
     ClassDef(MReadCurrents, 0)	// Reads a Central Control currents file
 };
Index: trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 2376)
+++ trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 2377)
@@ -96,8 +96,12 @@
     //fTrees.SetOwner();
 
+    TString str(fname);
+    if (!str.EndsWith(".root", TString::kIgnoreCase))
+        str += ".root";
+
     //
     // Open the rootfile
     //
-    fOut = new TFile(fname, opt, ftitle, comp);
+    fOut = new TFile(str, opt, ftitle, comp);
 }
 
Index: trunk/MagicSoft/Mars/mgeom/GeomLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mgeom/GeomLinkDef.h	(revision 2376)
+++ trunk/MagicSoft/Mars/mgeom/GeomLinkDef.h	(revision 2377)
@@ -5,14 +5,17 @@
 #pragma link off all functions;
 
+#pragma link C++ class MGeomPix+;
+#pragma link C++ class MGeomCam+;
 #pragma link C++ class MGeomPMT+;
 #pragma link C++ class MGeomMirror+;
 #pragma link C++ class MGeomCorsikaCT+;
-#pragma link C++ class MGeomPix+;
-#pragma link C++ class MGeomCam+;
+
 #pragma link C++ class MGeomCamCT1+;
 #pragma link C++ class MGeomCamCT1Daniel+;
+
 #pragma link C++ class MGeomCamMagic+;
 #pragma link C++ class MGeomCamMagicHG+;
 #pragma link C++ class MGeomCamMagic919+;
+
 #pragma link C++ class MGeomCamECO1000+;
 #pragma link C++ class MGeomCamECO1000HG+;
Index: trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 2376)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 2377)
@@ -78,13 +78,13 @@
 using namespace std;
 
-// ------------------------------------------------------------------------
-//
-//  Default Constructor. To be used by the root system ONLY.
-//
-MHCamera::MHCamera() : TH1D(), fGeomCam(NULL), fColors(kItemsLegend)
+void MHCamera::Init()
 {
     SetDirectory(NULL);
 
-    fNotify  = NULL;
+    SetLineColor(kGreen);
+    SetMarkerStyle(kFullDotMedium);
+    SetXTitle("Pixel Index");
+
+    fNotify  = new TList;
 
 #if ROOT_VERSION_CODE < ROOT_VERSION(3,01,06)
@@ -97,4 +97,13 @@
 // ------------------------------------------------------------------------
 //
+//  Default Constructor. To be used by the root system ONLY.
+//
+MHCamera::MHCamera() : TH1D(), fGeomCam(NULL), fColors(kItemsLegend)
+{
+    Init();
+}
+
+// ------------------------------------------------------------------------
+//
 //  Constructor. Makes a clone of MGeomCam. Removed the TH1D from the
 // current directory. Calls Sumw2(). Set the histogram line color
@@ -102,20 +111,11 @@
 //
 MHCamera::MHCamera(const MGeomCam &geom, const char *name, const char *title)
-: TH1D(name, title, geom.GetNumPixels(), -0.5, geom.GetNumPixels()-0.5),
-fUsed(geom.GetNumPixels()), fColors(kItemsLegend)
-{
-    fGeomCam = (MGeomCam*)geom.Clone();
-
-    SetDirectory(NULL);
-    Sumw2();
-
-    SetLineColor(kGreen);
-    SetMarkerStyle(kFullDotMedium);
-    SetXTitle("Pixel Index");
-
-    fNotify = new TList;
-
-    //
-    //  create the hexagons of the display
+: fGeomCam(NULL), /*TH1D(name, title, geom.GetNumPixels(), -0.5, geom.GetNumPixels()-0.5),
+fUsed(geom.GetNumPixels()),*/ fColors(kItemsLegend)
+{
+    //fGeomCam = (MGeomCam*)geom.Clone();
+    SetGeometry(geom, name, title);
+    Init();
+
     //
     // root 3.02
@@ -123,16 +123,28 @@
     //    register BIT(8) as kNoContextMenu. If an object has this bit set it will
     //    not get an automatic context menu when clicked with the right mouse button.
-
-    //
-    // Construct all hexagons. Use new-operator with placement
-    //
+}
+
+void MHCamera::SetGeometry(const MGeomCam &geom, const char *name, const char *title)
+{
+    SetNameTitle(name, title);
+
+    TAxis &x = *GetXaxis();
+
+    SetBins(geom.GetNumPixels(), 0, 1);
+    x.Set(geom.GetNumPixels(), -0.5, geom.GetNumPixels()-0.5);
+
+    //SetBins(geom.GetNumPixels(), -0.5, geom.GetNumPixels()-0.5);
+    //Rebuild();
+
+    Sumw2(); // necessary?
+
+    if (fGeomCam)
+        delete fGeomCam;
+    fGeomCam = (MGeomCam*)geom.Clone();
+
+    fUsed.Set(geom.GetNumPixels());
     for (Int_t i=0; i<fNcells-2; i++)
         ResetUsed(i);
 
-#if ROOT_VERSION_CODE < ROOT_VERSION(3,01,06)
-    SetPalette(1, 0);
-#else
-    SetPalette(51, 0);
-#endif
 }
 
@@ -229,4 +241,7 @@
 Int_t MHCamera::Fill(Axis_t x, Axis_t y, Stat_t w)
 {
+    if (fNcells<=1)
+        return -1;
+
     for (Int_t idx=0; idx<fNcells-2; idx++)
     {
@@ -243,4 +258,7 @@
 Stat_t MHCamera::GetMean(Int_t axis) const
 {
+    if (fNcells<=1)
+        return 0;
+
     Stat_t mean = 0;
     for (int i=1; i<fNcells-1; i++)
@@ -252,4 +270,7 @@
 Stat_t MHCamera::GetRMS(Int_t axis) const
 {
+    if (fNcells<=1)
+        return -1;
+
     const Int_t n = fNcells-2;
 
@@ -278,4 +299,7 @@
         return fMinimum;
 
+    if (fNcells<=1)
+        return 0;
+
     Double_t minimum=FLT_MAX;
 
@@ -304,4 +328,7 @@
     if (fMaximum != -1111)
         return fMaximum;
+
+    if (fNcells<=1)
+        return 1;
 
     Double_t maximum=-FLT_MAX;
@@ -491,4 +518,7 @@
 void MHCamera::Paint(Option_t *o)
 {
+    if (fNcells<=1)
+        return;
+
     TString opt(o);
     opt.ToLower();
@@ -585,4 +615,7 @@
 void MHCamera::DrawPixelIndices()
 {
+    if (fNcells<=1)
+        return;
+
     // FIXME: Is this correct?
     for (int i=0; i<kItemsLegend; i++)
@@ -609,4 +642,7 @@
 void MHCamera::DrawSectorIndices()
 {
+    if (fNcells<=1)
+        return;
+
     for (int i=0; i<kItemsLegend; i++)
         fColors[i] = 16;
@@ -637,4 +673,7 @@
 void MHCamera::AddCamContent(const MCamEvent &event, Int_t type)
 {
+    if (fNcells<=1)
+        return;
+
     // FIXME: Security check missing!
     for (Int_t idx=0; idx<fNcells-2; idx++)
@@ -717,4 +756,7 @@
 void MHCamera::CntCamContent(const MCamEvent &event, Double_t threshold, Int_t type)
 {
+    if (fNcells<=1)
+        return;
+
     // FIXME: Security check missing!
     for (Int_t idx=0; idx<fNcells-2; idx++)
@@ -757,4 +799,7 @@
 void MHCamera::FillRandom()
 {
+    if (fNcells<=1)
+        return;
+
     Reset();
 
@@ -775,4 +820,7 @@
 void MHCamera::FillLevels(const MCerPhotEvt &event, Float_t lvl1, Float_t lvl2)
 {
+    if (fNcells<=1)
+        return;
+
     SetCamContent(event, 2);
 
@@ -807,4 +855,7 @@
 void MHCamera::Reset(Option_t *opt)
 {
+    if (fNcells<=1)
+        return;
+
     TH1::Reset(opt);
 
@@ -965,4 +1016,7 @@
 Int_t MHCamera::DistancetoPrimitive(Int_t px, Int_t py)
 {
+    if (fNcells<=1)
+        return 999999;
+
     const Int_t kMaxDiff = 7;
 
@@ -1014,4 +1068,7 @@
 Int_t MHCamera::GetPixelIndex(Int_t px, Int_t py) const
 {
+    if (fNcells<=1)
+        return -1;
+
     Int_t i;
     for (i=0; i<fNcells-2; i++)
Index: trunk/MagicSoft/Mars/mhist/MHCamera.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 2376)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 2377)
@@ -38,4 +38,5 @@
 
     //TGStatusBar   *fStatusBar;
+    void Init();
 
     Int_t GetColor(Float_t val, Float_t min, Float_t max, Bool_t islog);
@@ -72,4 +73,7 @@
     MHCamera(const MGeomCam &geom, const char *name="", const char *title="");
     ~MHCamera();
+
+    void SetGeometry(const MGeomCam &geom, const char *name="", const char *title="");
+    const MGeomCam* GetGeometry() const { return fGeomCam; }
 
     Bool_t IsUsed(Int_t idx) const { return TESTBIT(const_cast<TArrayC&>(fUsed)[idx], kIsUsed); }
Index: trunk/MagicSoft/Mars/mhist/MHCurrents.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCurrents.cc	(revision 2376)
+++ trunk/MagicSoft/Mars/mhist/MHCurrents.cc	(revision 2377)
@@ -53,10 +53,14 @@
 void MHCurrents::Clear(const Option_t *)
 {
+    const Int_t n = fCam ? fCam->GetNumPixels() : 577;
+
     // FIXME: Implement a clear function with setmem
-    for (int i=0; i<577; i++)
+    fSum.Set(n); // also clears memory
+    fRms.Set(n);
+/*    for (int i=0; i<577; i++)
     {
         fSum[i] = 0;
         fRms[i] = 0;
-    }
+    }*/
 
     fEntries = 0;
@@ -69,5 +73,5 @@
 //
 MHCurrents::MHCurrents(const char *name, const char *title)
-    : fSum(577), fRms(577), fCam(NULL), fEvt(NULL), fDispl(NULL)
+    : /*fSum(577), fRms(577), */fCam(NULL), fEvt(NULL), fDispl(NULL)
 {
     //
@@ -113,11 +117,20 @@
 
     fCam = (MGeomCam*)plist->FindObject("MGeomCam");
-    if (!fCam)
-        *fLog << warn << GetDescriptor() << ": No MGeomCam found." << endl;
+    /*
+    if (!fCam)
+        *fLog << warn << GetDescriptor() << ": No MGeomCam found... assuming Magic geometry!" << endl;
+    */
+    if (!fCam)
+    {
+        *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
+        return kFALSE;
+    }
 
     Clear();
 
+    const Int_t n = fSum.GetSize();
+
     MBinning bins;
-    bins.SetEdges(577, -0.5, 576.5);
+    bins.SetEdges(n, -0.5, n-0.5);
     bins.Apply(fHist);
 
@@ -138,5 +151,6 @@
     }
 
-    for (UInt_t idx=0; idx<577; idx++)
+    const Int_t n = fSum.GetSize();
+    for (UInt_t idx=0; idx<n; idx++)
     {
         Float_t val;
@@ -166,5 +180,6 @@
     }
 
-    for (UInt_t i=0; i<577; i++)
+    const Int_t n = fSum.GetSize();
+    for (UInt_t i=0; i<n; i++)
     {
         // calc sdev^2 for pixel index i
Index: trunk/MagicSoft/Mars/mhist/MHFadcCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHFadcCam.cc	(revision 2376)
+++ trunk/MagicSoft/Mars/mhist/MHFadcCam.cc	(revision 2377)
@@ -37,4 +37,7 @@
 #include "MLogManip.h"
 
+#include "MParList.h"
+#include "MGeomCam.h"
+
 #include "MRawEvtData.h"
 #include "MRawEvtPixelIter.h"
@@ -49,5 +52,5 @@
 //  creates an a list of histograms for all pixels and both gain channels
 //
-MHFadcCam::MHFadcCam(const Int_t n, 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)
 {
@@ -63,8 +66,9 @@
     // connect all the histogram with the container fHist
     //
-    fArray = new TObjArray(n);
+    fArray = new TObjArray;
+    fArray->SetOwner();
 
-    for (Int_t i=0; i<n; i++)
-        (*fArray)[i] = new MHFadcPix(i, fType);
+    //    for (Int_t i=0; i<n; i++)
+    //        (*fArray)[i] = new MHFadcPix(i, fType);
 }
 
@@ -87,5 +91,7 @@
     // FIXME, this might be done faster and more elegant, by direct copy.
     //
-    MHFadcCam *cam = new MHFadcCam(n);
+    MHFadcCam *cam = new MHFadcCam(fType);
+
+    cam->fArray->Expand(n);
 
     for (int i=0; i<n; i++)
@@ -95,4 +101,29 @@
     }
     return cam;
+}
+
+// --------------------------------------------------------------------------
+//
+// To setup the object we get the number of pixels from a MGeomCam object
+// in the Parameter list.
+//
+Bool_t MHFadcCam::SetupFill(const MParList *pList)
+{
+    MGeomCam *cam = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!cam)
+    {
+        *fLog << err << "MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
+        return kFALSE;
+    }
+
+    const Int_t n = cam->GetNumPixels();
+
+    fArray->Delete();
+    fArray->Expand(n);
+
+    for (Int_t i=0; i<n; i++)
+        (*fArray)[i] = new MHFadcPix(i, fType);
+
+    return kTRUE;
 }
 
Index: trunk/MagicSoft/Mars/mhist/MHFadcCam.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHFadcCam.h	(revision 2376)
+++ trunk/MagicSoft/Mars/mhist/MHFadcCam.h	(revision 2377)
@@ -33,5 +33,5 @@
 
 public:
-    MHFadcCam(const Int_t n=577, 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();
 
@@ -45,4 +45,5 @@
     const TH1F *GetHistLo(UInt_t i) const { return (*this)[i].GetHistLo(); }
 
+    Bool_t SetupFill(const MParList *pList);
     Bool_t Fill(const MParContainer *par, const Stat_t w=1);
     Bool_t Fill(const MRawEvtData *par);
Index: trunk/MagicSoft/Mars/mhist/MHTriggerLvl0.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHTriggerLvl0.cc	(revision 2376)
+++ trunk/MagicSoft/Mars/mhist/MHTriggerLvl0.cc	(revision 2377)
@@ -100,5 +100,8 @@
     MGeomCam *cam = (MGeomCam*)plist->FindObject("MGeomCam");
     if (!cam)
-        *fLog << warn << GetDescriptor() << ": No MGeomCam found." << endl;
+    {
+        *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
+        return kFALSE;
+    }
 
     if (fSum)
Index: trunk/MagicSoft/Mars/mimage/MImgCleanTGB.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MImgCleanTGB.cc	(revision 2376)
+++ trunk/MagicSoft/Mars/mimage/MImgCleanTGB.cc	(revision 2377)
@@ -257,4 +257,5 @@
 #include <TGFrame.h>      // TGFrame
 #include <TGLabel.h>      // TGLabel
+#include <TArrayC.h>      // TArrayC
 #include <TGTextEntry.h>  // TGTextEntry
 
@@ -481,6 +482,8 @@
     Double_t sdev = sqrt(sq/w2 - mean*mean);
 
-    Byte_t *nb = new Byte_t[1000];
-    memset(nb, 0, 577);
+    TArrayC n(fCam->GetNumPixels());
+    Byte_t *nb = (Byte_t*)n.GetArray();
+    //Byte_t *nb = new Byte_t[1000];
+    //memset(nb, 0, 577);
 
     for (Int_t i=0; i<entries; i++)
@@ -512,6 +515,4 @@
     //CleanStep3(nb, 2, 3);
 
-    delete nb;
-
     return kTRUE;
 }
Index: trunk/MagicSoft/Mars/mmain/MDataCheck.cc
===================================================================
--- trunk/MagicSoft/Mars/mmain/MDataCheck.cc	(revision 2376)
+++ trunk/MagicSoft/Mars/mmain/MDataCheck.cc	(revision 2377)
@@ -23,5 +23,4 @@
 !
 \* ======================================================================== */
-
 #include "MDataCheck.h"
 
@@ -35,9 +34,15 @@
 #include "MTaskList.h"
 #include "MReadTree.h"
+#include "MGeomApply.h"
 #include "MGDisplayAdc.h"
 
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MDataCheck);
+
+using namespace std;
+
 // ---
-
-ClassImp(MDataCheck)
 
 enum {
@@ -120,5 +125,7 @@
     read.DisableAutoScheme();
 
-    MHFadcCam hist(577, t);
+    MGeomApply geomapl;
+
+    MHFadcCam hist(t);
     plist.AddToList(&hist);
 
@@ -126,4 +133,5 @@
 
     tasks.AddToList(&read);
+    tasks.AddToList(&geomapl);
     tasks.AddToList(&fill);
 
