Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 2469)
+++ trunk/MagicSoft/Mars/Changelog	(revision 2470)
@@ -84,4 +84,7 @@
    * mraw/MRawFileWrite.cc:
      - automatically add .root extension
+
+   * star.cc:
+     - added
 
 
Index: trunk/MagicSoft/Mars/Makefile
===================================================================
--- trunk/MagicSoft/Mars/Makefile	(revision 2469)
+++ trunk/MagicSoft/Mars/Makefile	(revision 2470)
@@ -20,5 +20,5 @@
 #
 
-PROGRAMS = readraw merpp mars
+PROGRAMS = readraw merpp star mars
 SOLIB    = mars.so
 CINT     = M
Index: trunk/MagicSoft/Mars/macros/star.C
===================================================================
--- trunk/MagicSoft/Mars/macros/star.C	(revision 2469)
+++ trunk/MagicSoft/Mars/macros/star.C	(revision 2470)
@@ -47,8 +47,4 @@
     plist.AddToList(&tlist);
 
-    MSrcPosCam src;
-    src.SetReadyToSave();
-    plist.AddToList(&src);
-
     //
     // Now setup the tasks and tasklist:
@@ -76,13 +72,4 @@
     // ------------- user change -----------------
     MWriteRootFile write("starfile.root");
-    write.AddContainer("MMcEvt",        "Events");
-    write.AddContainer("MSigmabar",     "Events");
-    write.AddContainer("MHillas",       "Events");
-    write.AddContainer("MHillasExt",    "Events");
-    write.AddContainer("MHillasSrc",    "Events");
-    write.AddContainer("MNewImagePar",  "Events");
-    write.AddContainer("MRawRunHeader", "RunHeaders");
-    write.AddContainer("MMcRunHeader",  "RunHeaders");
-    write.AddContainer("MSrcPosCam",    "RunHeaders");
 
     tlist.AddToList(&read);
@@ -97,4 +84,20 @@
     tlist.AddToList(&scalc);
     tlist.AddToList(&write);
+
+    // ------------- user change -----------------
+    // You may use the "UPDATE" option in the constructor
+    // of MWriteRootFile to update an existing file.
+    //
+    // tlist.SetSerialNumber(1); // Serial number of telescope
+
+    write.AddContainer(write.AddSerialNumber("MMcEvt"),       "Events");
+    write.AddContainer(write.AddSerialNumber("MSigmabar"),    "Events");
+    write.AddContainer(write.AddSerialNumber("MHillas"),      "Events");
+    write.AddContainer(write.AddSerialNumber("MHillasExt"),   "Events");
+    write.AddContainer(write.AddSerialNumber("MHillasSrc"),   "Events");
+    write.AddContainer(write.AddSerialNumber("MNewImagePar"), "Events");
+    write.AddContainer(write.AddSerialNumber("MSrcPosCam"),   "RunHeaders");
+    write.AddContainer("MRawRunHeader", "RunHeaders");
+    write.AddContainer("MMcRunHeader",  "RunHeaders");
 
     //
Index: trunk/MagicSoft/Mars/manalysis/MBlindPixelCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MBlindPixelCalc.cc	(revision 2469)
+++ trunk/MagicSoft/Mars/manalysis/MBlindPixelCalc.cc	(revision 2470)
@@ -59,8 +59,10 @@
 //
 //  Input Containers:
-//   MCerPhotEvt[, MBlindPixels]
+//   MCerPhotEvt
+//   [MBlindPixels]
 //
 //  Output Containers:
-//   MCerPhotEvt, MBlindPixels
+//   MCerPhotEvt
+//   MBlindPixels
 //
 /////////////////////////////////////////////////////////////////////////////
@@ -112,11 +114,11 @@
 {
     if (TESTBIT(fFlags, kUseBlindPixels))
-        fPixels = (MBlindPixels*)pList->FindObject("MBlindPixels");
+        fPixels = (MBlindPixels*)pList->FindObject(AddSerialNumber("MBlindPixels"));
     else
-        fPixels = (MBlindPixels*)pList->FindCreateObj("MBlindPixels");
+        fPixels = (MBlindPixels*)pList->FindCreateObj(AddSerialNumber("MBlindPixels"));
     if (!fPixels)
 	return kFALSE; 
     
-    fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+    fEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber("MCerPhotEvt"));
     if (!fEvt)
     {
@@ -124,5 +126,5 @@
         return kFALSE;
     }
-    fPed = (MPedestalCam*)pList->FindObject("MPedestalCam");
+    fPed = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
     if (!fEvt)
     {
@@ -131,5 +133,5 @@
     }
 
-    fGeomCam = (MGeomCam*)pList->FindObject("MGeomCam");
+    fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
     if (!fGeomCam)
         *fLog << warn << dbginf << "No camera geometry available... can't use interpolation." << endl;
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc	(revision 2469)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc	(revision 2470)
@@ -35,5 +35,7 @@
 //
 //  Input Containers:
-//   MRawRunHeader, MRawEvtData, MPedestalCam
+//   MRawEvtData
+//   MPedestalCam
+//   [MRawRunHeader]
 //
 //  Output Containers:
@@ -99,5 +101,5 @@
     }
 
-    fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
+    fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
     if (!fRawEvt)
     {
@@ -106,5 +108,5 @@
     }
 
-    fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
+    fPedestals = (MPedestalCam*)pList->FindCreateObj(AddSerialNumber("MPedestalCam"));
     if (!fPedestals)
     {
@@ -113,5 +115,5 @@
     }
 
-    fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj("MCerPhotEvt");
+    fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj(AddSerialNumber("MCerPhotEvt"));
     if (!fCerPhotEvt)
         return kFALSE;
Index: trunk/MagicSoft/Mars/manalysis/MGeomApply.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MGeomApply.cc	(revision 2469)
+++ trunk/MagicSoft/Mars/manalysis/MGeomApply.cc	(revision 2470)
@@ -44,5 +44,6 @@
 //
 //  Output Containers:
-//   MPedestalCam, MBlindPixels
+//   [MPedestalCam]
+//   [MBlindPixels]
 //
 //////////////////////////////////////////////////////////////////////////////
@@ -79,9 +80,9 @@
 Int_t MGeomApply::PreProcess(MParList *pList)
 {
-    MGeomCam *cam = (MGeomCam*)pList->FindObject("MGeomCam");
+    MGeomCam *cam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
     if (cam)
         return kTRUE;
 
-    cam = (MGeomCam*)pList->FindCreateObj(fGeomName, "MGeomCam");
+    cam = (MGeomCam*)pList->FindCreateObj(AddSerialNumber(fGeomName), "MGeomCam");
 
     return cam ? kTRUE : kFALSE;
@@ -97,5 +98,5 @@
 Bool_t MGeomApply::ReInit(MParList *pList)
 {
-    MGeomCam *cam = (MGeomCam*)pList->FindObject("MGeomCam");
+    MGeomCam *cam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
     if (!cam)
     {
@@ -104,9 +105,9 @@
     }
 
-    MPedestalCam *ped = (MPedestalCam*)pList->FindObject("MPedestalCam");
+    MPedestalCam *ped = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
     if (ped)
         ped->InitSize(cam->GetNumPixels());
 
-    MBlindPixels *bnd = (MBlindPixels*)pList->FindObject("MBlindPixels");
+    MBlindPixels *bnd = (MBlindPixels*)pList->FindObject(AddSerialNumber("MBlindPixels"));
     if (bnd)
         bnd->InitSize(cam->GetNumPixels());
Index: trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc	(revision 2469)
+++ trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc	(revision 2470)
@@ -33,4 +33,6 @@
 //  Input Containers:
 //   MMcFadcHeader
+//   [MMcRunHeader]
+//   [MRawRunHeader]
 //
 //  Output Containers:
@@ -104,5 +106,12 @@
     // to be done only if this is a MC file.
     //
-    MPedestalCam *pedcam = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
+    MMcFadcHeader *fadc = (MMcFadcHeader*)pList->FindObject(AddSerialNumber("MMcFadcHeader"));
+    if (!fadc)
+    {
+        *fLog << err << dbginf << "MMcFadcHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    MPedestalCam *pedcam = (MPedestalCam*)pList->FindCreateObj(AddSerialNumber("MPedestalCam"));
     if (!pedcam)
         return kFALSE;
@@ -111,11 +120,4 @@
     if (!mcrun)
         *fLog << warn << dbginf << "MMcRunHeader not found... assuming camera<0.7" << endl;
-
-    MMcFadcHeader *fadc = (MMcFadcHeader*)pList->FindObject("MMcFadcHeader");
-    if (!fadc)
-    {
-        *fLog << err << dbginf << "MMcFadcHeader not found... aborting." << endl;
-        return kFALSE;
-    }
 
     const int num = pedcam->GetSize();
Index: trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc	(revision 2469)
+++ trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc	(revision 2470)
@@ -24,30 +24,30 @@
 
 /////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-//  MMcPedestalNSBAdd                                                      //
-//  -----------------                                                      //
-//                                                                         //
-//  This Task adds the contribution of the diffuse NSB to the FADC         //
-//  pedestals. We assume that NSB introduces larger fluctuation but does   //
-//  not change the mean value.                                             //
-//  To be precise we add quadratically to the rms, which is already in     //
-//  MPedestalCam, the NSB contribution.                                    //
-//  The number of photons from the diffuse NSB follows a poisson           // 
-//  distribution with expected mean value X, then its standard deviation   //
-//  is sqrt(X).                                                            //
-//  X is the number of phe per ns so we have to convert in FADC counts per // 
-//  slice:                                                                 //
-//                                                                         //
-//  Y = sqrt(X * FADC_time / Number_of_slices * pixel_size)                //
-//      * Amp_single_phe_response                                          //
-//                                                                         //
-//  Input Containers:                                                      //
-//   MMcFadcHeader                                                         //
-//   MMcRunHeader                                                          //
-//   MRawRunHeader                                                         //
-//                                                                         //
-//  Output Containers:                                                     //
-//   MPedestalCam                                                          //
-//                                                                         //
+//
+//  MMcPedestalNSBAdd
+//  -----------------
+//
+//  This Task adds the contribution of the diffuse NSB to the FADC
+//  pedestals. We assume that NSB introduces larger fluctuation but does
+//  not change the mean value.
+//  To be precise we add quadratically to the rms, which is already in
+//  MPedestalCam, the NSB contribution.
+//  The number of photons from the diffuse NSB follows a poisson
+//  distribution with expected mean value X, then its standard deviation
+//  is sqrt(X).
+//  X is the number of phe per ns so we have to convert in FADC counts per
+//  slice:
+//
+//  Y = sqrt(X * FADC_time / Number_of_slices * pixel_size)
+//      * Amp_single_phe_response
+//
+//  Input Containers:
+//   MMcFadcHeader
+//   MRawRunHeader
+//   [MMcRunHeader]
+//
+//  Output Containers:
+//   MPedestalCam
+//
 /////////////////////////////////////////////////////////////////////////////
 #include "MMcPedestalNSBAdd.h"
@@ -186,9 +186,9 @@
     // is correct.
     //
-    MPedestalCam *pedcam = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
+    MPedestalCam *pedcam = (MPedestalCam*)pList->FindCreateObj(AddSerialNumber("MPedestalCam"));
     if (!pedcam)
 	return kFALSE;
 
-    MMcFadcHeader *fadc = (MMcFadcHeader*)pList->FindObject("MMcFadcHeader");
+    MMcFadcHeader *fadc = (MMcFadcHeader*)pList->FindObject(AddSerialNumber("MMcFadcHeader"));
     if (!fadc)
     {
@@ -197,5 +197,5 @@
     }
 
-    MGeomCam *geom = (MGeomCam*)pList->FindObject("MGeomCam");
+    MGeomCam *geom = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
     if (!geom)
     {
Index: trunk/MagicSoft/Mars/manalysis/MSigmabarCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MSigmabarCalc.cc	(revision 2469)
+++ trunk/MagicSoft/Mars/manalysis/MSigmabarCalc.cc	(revision 2470)
@@ -25,12 +25,23 @@
 
 /////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-//  MSigmabarCalc                                                          //
-//                                                                         //
-//  This task calculates Sigmabar using the MSigmabar container and stores //
-//  its extremal values together with the corresponding Theta values       //
-//  in MSigmabarParam. For the time being, Theta is taken from a Monte     //
-//  Carlo container. This is preliminary and to be changed ASAP.           //
-//                                                                         //
+//
+//  MSigmabarCalc
+//
+//  This task calculates Sigmabar using the MSigmabar container and stores
+//  its extremal values together with the corresponding Theta values       
+//  in MSigmabarParam. For the time being, Theta is taken from a Monte
+//  Carlo container. This is preliminary and to be changed ASAP.
+//
+//  Input Containers:
+//   MGeomCam
+//   MPedestalCam
+//   MRawRunHeader
+//   MMcEvt  (FIXME: Must be replaced by a 'real-data' container)
+//   MCerPhotEvt
+//
+//  Output Containers:
+//   MSigmabar
+//   MSigmabarParam
+//
 /////////////////////////////////////////////////////////////////////////////
 #include "MSigmabarCalc.h"
@@ -72,5 +83,5 @@
 Int_t MSigmabarCalc::PreProcess(MParList *pList)
 {
-    fCam = (MGeomCam*)pList->FindObject("MGeomCam");
+    fCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
     if (!fCam)
     {
@@ -79,5 +90,5 @@
     }
 
-    fPed = (MPedestalCam*)pList->FindObject("MPedestalCam");
+    fPed = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
     if (!fPed)
     {
@@ -94,5 +105,5 @@
 
     // This is needed for determining min/max Theta
-    fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
+    fMcEvt = (MMcEvt*)pList->FindObject(AddSerialNumber("MMcEvt"));
     if (!fMcEvt)
     {
@@ -102,5 +113,5 @@
     }
 
-    fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+    fEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber("MCerPhotEvt"));
     if (!fEvt)
       {
@@ -109,9 +120,11 @@
       }
 
-    fSig = (MSigmabar*)pList->FindCreateObj("MSigmabar");
+    fSig = (MSigmabar*)pList->FindCreateObj(AddSerialNumber("MSigmabar"));
     if (!fSig)
         return kFALSE;
 
-    fSigParam = (MSigmabarParam*)pList->FindCreateObj("MSigmabarParam");
+    // FIXME: This might have to change in a
+    //        'more-than-one-telescope-environment'
+    fSigParam = (MSigmabarParam*)pList->FindCreateObj(AddSerialNumber("MSigmabarParam"));
     if (!fSigParam)
         return kFALSE;
Index: trunk/MagicSoft/Mars/mbase/MParContainer.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 2469)
+++ trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 2470)
@@ -163,4 +163,19 @@
 // --------------------------------------------------------------------------
 //
+// Returns the name of the object. If the name of the object is not the
+// class name it returns the object name and in []-brackets the class name.
+//
+const char *MParContainer::GetDescriptor() const
+{
+    //
+    // Because it returns a (const char*) we cannot return a casted
+    // local TString. The pointer would - immediatly after return -
+    // point to a random memory segment, because the TString has gone.
+    //
+    return fName==ClassName() ? ClassName() : Form("%s [%s]", fName.Data(), ClassName());
+}
+
+// --------------------------------------------------------------------------
+//
 //  Return a unique name for this container. It is created from
 //  the container name and the unique Id. (This is mostly used
Index: trunk/MagicSoft/Mars/mbase/MParContainer.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParContainer.h	(revision 2469)
+++ trunk/MagicSoft/Mars/mbase/MParContainer.h	(revision 2470)
@@ -74,5 +74,5 @@
     virtual void        FillBuffer(char *&buffer);
 
-    virtual const char   *GetDescriptor() const { return fName==ClassName() ? ClassName() : Form("%s [%s]", fName.Data(), ClassName()); }
+    virtual const char   *GetDescriptor() const;
     virtual const TString GetUniqueName() const;
     virtual const char   *GetName() const       { return fName.Data(); }
Index: trunk/MagicSoft/Mars/mbase/MTask.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 2469)
+++ trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 2470)
@@ -24,45 +24,53 @@
 
 /////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-//   MTask                                                                 //
-//                                                                         //
-//   Base class for all tasks which can perfomed in a tasklist             //
-//   For each event processed in the eventloop all the different           //
-//   tasks in the tasklist will be processed.                              //
-//                                                                         //
-//   So all tasks must inherit from this baseclass.                        //
-//                                                                         //
-//   The inheritance from MInputStreamID is used to indicate the           //
-//   type of event that this task is for. If it is "All" it is executed    //
-//   independantly of the actual ID of the task list.                      //
-//                                                                         //
-//   Inside this abstract class, there are three fundamental function:     //
-//                                                                         //
-//   - PreProcess():   executed before the eventloop starts. Here you      //
-//                     can initiate different things, open files, etc.     //
-//                     As an argument this function gets a pointer to the  //
-//                     parameter list. You can stop the execution by       //
-//                     returning kFALSE instead of kTRUE. If an error      //
-//                     occured and you return kFALSE make sure, that       //
-//                     any action is closed correctly and all newly        //
-//                     created object are deleted. The PostProcess in      //
-//                     such a case won't be executed by the Tasklist or    //
-//                     Eventloop.                                          //
-//                                                                         //
-//   - Process():      executed for each event in the eventloop. Do it     //
-//                     one task after the other (as they occur in the      //
-//                     tasklist). Only the tasks with a Stream ID          //
-//                     which matches the actual ID of the tasklist         //
-//                     are executed. A task can return kFALSE to           //
-//                     stop the execuition of the tasklist or              //
-//                     kCONTINUE to skip the pending tasks. If you want    //
-//                     to stop the eventloop and wants the eventloop to    //
-//                     return the status 'failed' return kERROR.           //
-//                                                                         //
-//   - PostProcess():  executed after the eventloop. Here you can close    //
-//                     output files, start display of the run parameter,   //
-//                     etc. PostProcess is only executed in case of        //
-//                     PreProcess was successfull (returned kTRUE)         //
-//                                                                         //
+//
+//   MTask
+//
+//   Base class for all tasks which can perfomed in a tasklist
+//   For each event processed in the eventloop all the different
+//   tasks in the tasklist will be processed.
+//
+//   So all tasks must inherit from this baseclass.
+//
+//   The inheritance from MInputStreamID is used to indicate the
+//   type of event that this task is for. If it is "All" it is executed
+//   independantly of the actual ID of the task list.
+//
+//   Inside this abstract class, there are three fundamental function:
+//
+//   - PreProcess():   executed before the eventloop starts. Here you
+//                     can initiate different things, open files, etc.
+//                     As an argument this function gets a pointer to the
+//                     parameter list. You can stop the execution by
+//                     returning kFALSE instead of kTRUE. If an error
+//                     occured and you return kFALSE make sure, that
+//                     any action is closed correctly and all newly
+//                     created object are deleted. The PostProcess in
+//                     such a case won't be executed by the Tasklist or
+//                     Eventloop.
+//
+//   - Process():      executed for each event in the eventloop. Do it
+//                     one task after the other (as they occur in the
+//                     tasklist). Only the tasks with a Stream ID
+//                     which matches the actual ID of the tasklist
+//                     are executed. A task can return kFALSE to
+//                     stop the execuition of the tasklist or
+//                     kCONTINUE to skip the pending tasks. If you want
+//                     to stop the eventloop and wants the eventloop to
+//                     return the status 'failed' return kERROR.
+//
+//   - PostProcess():  executed after the eventloop. Here you can close
+//                     output files, start display of the run parameter,
+//                     etc. PostProcess is only executed in case of
+//                     PreProcess was successfull (returned kTRUE)
+//
+//  Version 1:
+//  ----------
+//   - first version
+//
+//  Version 2:
+//  ----------
+//   - added fSerialNumber
+//
 /////////////////////////////////////////////////////////////////////////////
 #include "MTask.h"
@@ -286,4 +294,26 @@
 {
     return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the name of the object. If the name of the object is not the
+// class name it returns the object name and in []-brackets the class name.
+// If a serial number is set (!=0) the serial number is added to the
+// name (eg. ;1)
+//
+const char *MTask::GetDescriptor() const
+{
+    //
+    // Because it returns a (const char*) we cannot return a casted
+    // local TString. The pointer would - immediatly after return -
+    // point to a random memory segment, because the TString has gone.
+    //
+    if (fName==ClassName())
+        return fSerialNumber==0 ? ClassName() : Form("%s;%d", ClassName(), fSerialNumber);
+
+    return fSerialNumber>0 ?
+        Form("%s;%d [%s]", fName.Data(), fSerialNumber, ClassName()) :
+        Form("%s [%s]", fName.Data(), ClassName());
 }
 
@@ -327,5 +357,7 @@
      fFilter->SavePrimitive(out);
      */
-     out << "   " << GetUniqueName() << ".SetFilter(&" << fFilter->GetUniqueName() <<");" << endl;
+    out << "   " << GetUniqueName() << ".SetFilter(&" << fFilter->GetUniqueName() <<");" << endl;
+    if (fSerialNumber>0)
+        out << "   " << GetUniqueName() << ".SetSerialNumber(" << fSerialNumber <<");" << endl;
 }
 
Index: trunk/MagicSoft/Mars/mbase/MTask.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTask.h	(revision 2469)
+++ trunk/MagicSoft/Mars/mbase/MTask.h	(revision 2470)
@@ -25,4 +25,5 @@
 
     MFilter *fFilter;       // Filter for conditional task execution
+    Byte_t   fSerialNumber; // Serial number having more than one detector of the same type
 
     Bool_t fIsPreprocessed; //! Indicates the success of the PreProcessing (set by MTaskList)
@@ -68,6 +69,14 @@
     const MFilter *GetFilter() const      { return fFilter; }
     MFilter *GetFilter()  { return fFilter; } // for MContinue only
+
     void SetDisplay(MStatusDisplay *d);
     virtual void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE) const;
+
+    virtual void SetSerialNumber(Byte_t num) { fSerialNumber = num; }
+    Byte_t  GetSerialNumber() const { return fSerialNumber; }
+    TString AddSerialNumber(const char *str) const { TString s(str); if (fSerialNumber==0) return s; s += ";"; s += fSerialNumber; return s; }
+    TString AddSerialNumber(const TString &str) const { return AddSerialNumber((const char*)str); }
+
+    const char *GetDescriptor() const;
 
     UInt_t GetNumExecutions() const { return fNumExecutions; }
@@ -85,5 +94,5 @@
     void SavePrimitive(ofstream &out, Option_t *o="");
 
-    ClassDef(MTask, 1) //Abstract base class for a task
+    ClassDef(MTask, 2) //Abstract base class for a task
 };
 
Index: trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 2469)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 2470)
@@ -145,8 +145,23 @@
 }
 
+// --------------------------------------------------------------------------
+//
+//  Set the display for the all tasks in the list and the tasklist itself.
+//
 void MTaskList::SetDisplay(MStatusDisplay *d)
 {
     fTasks->ForEach(MTask, SetDisplay)(d);
     MTask::SetDisplay(d);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Set the serial number for the all tasks in the list and the tasklist
+//  itself.
+//
+void MTaskList::SetSerialNumber(Byte_t num)
+{
+    fTasks->ForEach(MTask, SetSerialNumber)(num);
+    MTask::SetSerialNumber(num);
 }
 
Index: trunk/MagicSoft/Mars/mbase/MTaskList.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 2469)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 2470)
@@ -47,4 +47,6 @@
     Bool_t AddToList(MTask *task, const char *tType="All");
 
+    void SetSerialNumber(Byte_t num);
+
     Bool_t RemoveFromList(MTask *task);
 
Index: trunk/MagicSoft/Mars/mfileio/MReadTree.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadTree.cc	(revision 2469)
+++ trunk/MagicSoft/Mars/mfileio/MReadTree.cc	(revision 2470)
@@ -779,5 +779,5 @@
         if (!c) continue;
         if ((*c)->InheritsFrom(MRawEvtData::Class()))
-            ((MRawEvtData*)(*c))->DeletePixels(kFALSE);
+            static_cast<MRawEvtData*>(*c)->DeletePixels(kFALSE);
 
     }
Index: trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 2469)
+++ trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 2470)
@@ -53,4 +53,5 @@
 static const TString gsDefName  = "MWriteRootFile";
 static const TString gsDefTitle = "Task which writes a root-output file";
+
 // --------------------------------------------------------------------------
 //
Index: trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h	(revision 2469)
+++ trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h	(revision 2470)
@@ -83,5 +83,6 @@
         kFillTree  = BIT(14),
         // TBranch::kAutoDelete = BIT(15)
-        kIsNewTree = BIT(16)
+        // TBranchElement::kDeleteObject = BIT(16)
+        kIsNewTree = BIT(17)
     };
 
Index: trunk/MagicSoft/Mars/mgeom/MGeomCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mgeom/MGeomCam.cc	(revision 2469)
+++ trunk/MagicSoft/Mars/mgeom/MGeomCam.cc	(revision 2470)
@@ -24,5 +24,5 @@
 \* ======================================================================== */
 
-///////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
 //
 // MGeomCam
@@ -32,4 +32,7 @@
 // interface of how to acccess the geometry information.
 //
+// We use a TObjArray for possible future usage (it is much more flexible
+// than a TClonesArray so that it can store more types of pixels (eg
+// fake pixels which are not really existing)
 //
 // Version 1:
@@ -42,6 +45,5 @@
 //  - added fPixRatioSqrt
 //
-//
-///////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
 #include "MGeomCam.h"
 
@@ -57,4 +59,8 @@
 using namespace std;
 
+// --------------------------------------------------------------------------
+//
+// Default Constructor
+//
 MGeomCam::MGeomCam()
     : fNumPixels(0), fCamDist(0), fConvMm2Deg(0)
@@ -62,6 +68,4 @@
 }
 
-
-
 // --------------------------------------------------------------------------
 //
@@ -86,4 +90,10 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Returns a reference of the i-th entry (the pixel with the software idx i)
+// The access is unchecked (for speed reasons!) accesing non existing
+// entries may crash the program!
+//
 MGeomPix &MGeomCam::operator[](Int_t i)
 {
@@ -91,4 +101,10 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Returns a reference of the i-th entry (the pixel with the software idx i)
+// The access is unchecked (for speed reasons!) accesing non existing
+// entries may crash the program!
+//
 MGeomPix &MGeomCam::operator[](Int_t i) const
 {
@@ -208,4 +224,9 @@
 } 
 
+// --------------------------------------------------------------------------
+//
+//  Create a clone of this container. This is very easy, because we
+//  simply have to create a new object of the same type.
+//
 TObject *MGeomCam::Clone(const char *newname) const
 {
Index: trunk/MagicSoft/Mars/mgeom/MGeomPix.cc
===================================================================
--- trunk/MagicSoft/Mars/mgeom/MGeomPix.cc	(revision 2469)
+++ trunk/MagicSoft/Mars/mgeom/MGeomPix.cc	(revision 2470)
@@ -45,6 +45,5 @@
 //
 //
-// FIXME: According to an agreement we have to change the name 'Id'
-//        to 'idx'
+// FIXME: According to an agreement we have to change the name 'Id' to 'idx'
 //
 ////////////////////////////////////////////////////////////////////////////
@@ -127,9 +126,5 @@
 { 
     //   information about a pixel
-    *fLog << all << "MPixGeom:  x= " << fX
-        << "  y= " << fY
-        << "  d= " << fD
-        << "  A= " << fA
-        << endl ;
+    *fLog << all << "MPixGeom:  x= " << fX << "mm  y= " << fY << "mm ";
+    *fLog << "d= " << fD << "mm  A= " << fA << "mm²" << endl;
 }
-
Index: trunk/MagicSoft/Mars/mimage/MHillasCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MHillasCalc.cc	(revision 2469)
+++ trunk/MagicSoft/Mars/mimage/MHillasCalc.cc	(revision 2470)
@@ -48,8 +48,12 @@
 //
 //  Input Containers:
-//   MCerPhotEvt, MGeomCam[, MHillas]
+//   MCerPhotEvt
+//   MGeomCam
+//   [MHillas]
 //
 //  Output Containers:
-//   [MHillas,] MHillasExt, MNewImagePar
+//   [MHillas]
+//   MHillasExt
+//   MNewImagePar
 //
 /////////////////////////////////////////////////////////////////////////////
@@ -93,5 +97,5 @@
 {
     // necessary
-    fCerPhotEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+    fCerPhotEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber("MCerPhotEvt"));
     if (!fCerPhotEvt)
     {
@@ -101,5 +105,5 @@
 
     // necessary
-    fGeomCam = (MGeomCam*)pList->FindObject("MGeomCam");
+    fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
     if (!fGeomCam)
     {
@@ -110,8 +114,8 @@
     // depend on whether MHillas is an in- or output container
     if (TestFlag(kCalcHillas))
-        fHillas = (MHillas*)pList->FindCreateObj("MHillas", fHilName);
+        fHillas = (MHillas*)pList->FindCreateObj("MHillas", AddSerialNumber(fHilName));
     else
     {
-        fHillas = (MHillas*)pList->FindObject(fHilName, "MHillas");
+        fHillas = (MHillas*)pList->FindObject(AddSerialNumber(fHilName), "MHillas");
         *fLog << err << fHilName << " [MHillas] not found... aborting." << endl;
     }
@@ -122,5 +126,5 @@
     if (TestFlag(kCalcHillasExt))
     {
-        fHillasExt = (MHillasExt*)pList->FindCreateObj("MHillasExt", fHilExtName);
+        fHillasExt = (MHillasExt*)pList->FindCreateObj("MHillasExt", AddSerialNumber(fHilExtName));
         if (!fHillasExt)
             return kFALSE;
@@ -130,5 +134,5 @@
     if (TestFlag(kCalcNewImagePar))
     {
-        fNewImgPar = (MNewImagePar*)pList->FindCreateObj("MNewImagePar", fImgParName);
+        fNewImgPar = (MNewImagePar*)pList->FindCreateObj("MNewImagePar", AddSerialNumber(fImgParName));
         if (!fNewImgPar)
             return kFALSE;
Index: trunk/MagicSoft/Mars/mimage/MHillasSrcCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MHillasSrcCalc.cc	(revision 2469)
+++ trunk/MagicSoft/Mars/mimage/MHillasSrcCalc.cc	(revision 2470)
@@ -29,4 +29,13 @@
 //
 // Task to calculate the source dependant part of the hillas parameters
+//
+// FIXME: Merge with MHillasCalc
+//
+//  Input Containers:
+//   MHillas
+//   [MSrcPosCam]
+//
+//  Output Containers:
+//   MHillasSrc
 //
 //////////////////////////////////////////////////////////////////////////////
@@ -74,5 +83,5 @@
 Int_t MHillasSrcCalc::PreProcess(MParList *pList)
 {
-    fHillas = (MHillas*)pList->FindObject(fHillasInput, "MHillas");
+    fHillas = (MHillas*)pList->FindObject(AddSerialNumber(fHillasInput), "MHillas");
     if (!fHillas)
     {
@@ -81,14 +90,14 @@
     }
 
-    fSrcPos = (MSrcPosCam*)pList->FindObject(fSrcName, "MSrcPosCam");
+    fSrcPos = (MSrcPosCam*)pList->FindObject(AddSerialNumber(fSrcName), "MSrcPosCam");
     if (!fSrcPos)
     {
-        *fLog << warn << fSrcName << " [MSrcPosCam] not found... creating default MSrcPosCam." << endl;
-        fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", fSrcName);
+        *fLog << warn << AddSerialNumber(fSrcName) << " [MSrcPosCam] not found... creating default container." << endl;
+        fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", AddSerialNumber(fSrcName));
         if (!fSrcPos)
             return kFALSE;
     }
 
-    fHillasSrc = (MHillasSrc*)pList->FindCreateObj("MHillasSrc", fHillasName);
+    fHillasSrc = (MHillasSrc*)pList->FindCreateObj("MHillasSrc", AddSerialNumber(fHillasName));
     if (!fHillasSrc)
         return kFALSE;
Index: trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc	(revision 2469)
+++ trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc	(revision 2470)
@@ -244,5 +244,7 @@
 //
 //  Input Containers:
-//   MGeomCam, MCerPhotEvt, MSigmabar
+//   MGeomCam
+//   MCerPhotEvt
+//   [MSigmabar]
 //
 //  Output Containers:
@@ -646,5 +648,5 @@
 Int_t MImgCleanStd::PreProcess (MParList *pList)
 {
-    fCam = (MGeomCam*)pList->FindObject("MGeomCam");
+    fCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
     if (!fCam)
     {
@@ -653,5 +655,5 @@
     }
 
-    fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+    fEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber("MCerPhotEvt"));
     if (!fEvt)
     {
@@ -662,5 +664,5 @@
     if (fCleaningMethod == kDemocratic)
     {
-        fSgb = (MSigmabar*)pList->FindObject("MSigmabar");
+        fSgb = (MSigmabar*)pList->FindObject(AddSerialNumber("MSigmabar"));
         if (!fSgb)
         {
@@ -671,5 +673,5 @@
     else
     {
-        fPed = (MPedestalCam*)pList->FindObject("MPedestalCam");
+        fPed = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
         if (!fPed)
         {
Index: trunk/MagicSoft/Mars/mraw/MRawFileWrite.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawFileWrite.cc	(revision 2469)
+++ trunk/MagicSoft/Mars/mraw/MRawFileWrite.cc	(revision 2470)
@@ -73,5 +73,9 @@
     // Open a rootfile
     //
-    fOut = new TFile(fname, opt, ftitle, comp);
+    TString str(fname);
+    if (!str.EndsWith(".root", TString::kIgnoreCase))
+        str += ".root";
+
+    fOut = new TFile(str, opt, ftitle, comp);
 }
 
Index: trunk/MagicSoft/Mars/star.cc
===================================================================
--- trunk/MagicSoft/Mars/star.cc	(revision 2470)
+++ trunk/MagicSoft/Mars/star.cc	(revision 2470)
@@ -0,0 +1,219 @@
+#include <TSystem.h>
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+/*'
+#include "MLog.h"
+ */
+#include "MLogManip.h"
+
+#include "MArgs.h"
+
+#include "MArray.h"
+#include "MReadMarsFile.h"
+#include "MGeomApply.h"
+#include "MMcPedestalCopy.h"
+#include "MMcPedestalNSBAdd.h"
+#include "MCerPhotCalc.h"
+#include "MBlindPixelCalc.h"
+#include "MSigmabarCalc.h"
+#include "MImgCleanStd.h"
+#include "MHillasCalc.h"
+#include "MHillasSrcCalc.h"
+#include "MWriteRootFile.h"
+
+using namespace std;
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// This is an easy implementation of the Star process
+// (as compilable prog)
+//
+//////////////////////////////////////////////////////////////////////////////
+
+static void StartUpMessage()
+{
+    gLog << all << endl;
+
+    //                1         2         3         4         5
+    //       12345678901234567890123456789012345678901234567890
+    gLog << "==================================================" << endl;
+    gLog << "                 STAR - MARS V" << MARSVER          << endl;
+    gLog << "   MARS - STandard Analysis and Reconstruction"     << endl;
+    gLog << "            Compiled on <" << __DATE__ << ">"       << endl;
+    gLog << "               Using ROOT v" << ROOTVER             << endl;
+    gLog << "==================================================" << endl;
+    gLog << endl;
+}
+
+static void Usage()
+{
+    gLog << all << endl;
+    gLog << "Sorry the usage is:" << endl;
+    gLog << "   star [-a0] [-vn] [-cn] inputfile[.roor] outputfile[.root]" << endl << endl;
+    gLog << "     input file: Merpped or MC root file." << endl;
+    gLog << "     ouput file: Star-file (image parameter file)" << endl;
+    gLog << "     -a0: Do not use Ansii codes." << endl;
+    gLog << "     -cn: Compression level n=1..9 [default=2]" << endl;
+    gLog << "     -vn: Verbosity level n [default=2]" << endl;
+    gLog << "     -u1: Update File (instead or Recreate)" << endl;
+    gLog << "     -tn: Telescope Serial Number n [default=0]" << endl << endl;
+    gLog << " -> Further setup is not possible at the moment, please use" << endl;
+    gLog << "    the star.C root macro instead. Using an input card will" << endl;
+    gLog << "    be implemented in the future." << endl << endl;
+}
+
+int main(const int argc, const char **argv)
+{
+    StartUpMessage();
+
+    //
+    // Evaluate arguments
+    //
+    MArgs arg(argc, argv);
+
+    //
+    // Set verbosity to highest level.
+    //
+    gLog.SetDebugLevel(arg.HasOption("-v") ? arg.GetIntAndRemove("-v") : 2);
+
+    if (arg.HasOption("-a") && arg.GetIntAndRemove("-a")==0)
+        gLog.SetNoColors();
+
+    const int  kComprlvl = arg.HasOption("-c") ? arg.GetIntAndRemove("-c") : 1;
+    const int  kTelIndex = arg.HasOption("-t") ? arg.GetIntAndRemove("-t") : 0;
+    const bool kUpdate   = arg.HasOption("-u") && arg.GetIntAndRemove("-u")==1;
+
+    //
+    // check for the right usage of the program
+    //
+    if (arg.GetNumArguments()!=2)
+    {
+        Usage();
+        return -1;
+    }
+
+    //
+    // This is to make argv[i] more readable insidethe code
+    //
+    TString kNamein  = arg.GetArgumentStr(0);
+    TString kNameout = arg.GetArgumentStr(1);
+
+    if (!kNamein.EndsWith(".root"))
+        kNamein += ".root";
+
+    if (!kNameout.EndsWith(".root"))
+        kNameout += ".root";
+
+    //
+    // Initialize Non-GUI (batch) mode
+    //
+    gROOT->SetBatch();
+
+    //
+    // check whether the given files are OK.
+    //
+    if (gSystem->AccessPathName(kNamein, kFileExists))
+    {
+        gLog << err << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl;
+        return -1;
+    }
+
+    if (!gSystem->AccessPathName(kNameout, kFileExists))
+    {
+        if (!kUpdate)
+            gLog << warn << "Warning: A file '" << kNameout << "' exists." << endl;
+    }
+    else
+        if (!gSystem->AccessPathName(kNameout, kWritePermission))
+        {
+            gLog << err << "Sorry, you don't have write permission for '" << kNameout << "'." << endl;
+            return -1;
+        }
+
+    MArray::Class()->IgnoreTObjectStreamer();
+    MParContainer::Class()->IgnoreTObjectStreamer();
+
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+    MReadMarsFile read("Events", kNamein);
+    read.DisableAutoScheme();
+
+    MGeomApply        apply;
+    MMcPedestalCopy   pcopy;
+    MMcPedestalNSBAdd pnsb;
+    MCerPhotCalc      ncalc;
+    MBlindPixelCalc   blind;
+    MSigmabarCalc     sgcal;
+    MImgCleanStd      clean;
+    MHillasCalc       hcalc;
+    MHillasSrcCalc    scalc; // !!Preliminary!! Will be removed later!
+    MWriteRootFile    write(kNameout, kUpdate?"UPDATE":"RECREATE", "Star output", kComprlvl);
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&apply);
+    tlist.AddToList(&pcopy);
+    tlist.AddToList(&pnsb);
+    tlist.AddToList(&ncalc);
+    tlist.AddToList(&blind);
+    tlist.AddToList(&sgcal);
+    tlist.AddToList(&clean);
+    tlist.AddToList(&hcalc);
+    tlist.AddToList(&scalc);
+    tlist.AddToList(&write);
+
+    //
+    // Set the serial number for all tasks in the current tasklist
+    //
+    tlist.SetSerialNumber(kTelIndex);
+
+    //
+    // Setup tasks
+    //
+    blind.SetUseInterpolation();
+
+    write.AddContainer(write.AddSerialNumber("MMcEvt"),       "Events");
+    write.AddContainer(write.AddSerialNumber("MSigmabar"),    "Events");
+    write.AddContainer(write.AddSerialNumber("MHillas"),      "Events");
+    write.AddContainer(write.AddSerialNumber("MHillasExt"),   "Events");
+    write.AddContainer(write.AddSerialNumber("MHillasSrc"),   "Events");
+    write.AddContainer(write.AddSerialNumber("MNewImagePar"), "Events");
+    write.AddContainer(write.AddSerialNumber("MSrcPosCam"),   "RunHeaders");
+    if (!kUpdate)
+    {
+        write.AddContainer("MRawRunHeader", "RunHeaders");
+        write.AddContainer("MMcRunHeader",  "RunHeaders");
+    }
+
+    //
+    // Create and set up the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+    {
+        gLog << err << "ERROR: Star eventloop failed!" << endl;
+        return -1;
+    }
+
+    // tlist.PrintStatistics();
+
+    gLog << all << "Star finished successfull!" << endl;
+    return 0;
+}
