Index: trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 1473)
+++ trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 1474)
@@ -52,6 +52,5 @@
 //                                                                          //
 // You can create a macro from a completely setup eventloop by:             //
-//   ofstream fout("mymacro.C");                                            //
-//   evtloop.SavePrimitive(fout);                                           //
+//   evtloop.MakeMacro("mymacro.C");                                        //
 //                                                                          //
 // You will always need to check the macro, it will not run, but it         //
@@ -66,9 +65,10 @@
 //   evtloop.Read("MyEvtloopKey");                                          //
 //                                                                          //
-// To lookup the information write it to a file using SavePrimite           //
+// To lookup the information write it to a file using MakeMacro             //
 //                                                                          //
 //////////////////////////////////////////////////////////////////////////////
 #include "MEvtLoop.h"
 
+#include <time.h>
 #include <fstream.h>     // ofstream, SavePrimitive
 #include <iostream.h>
@@ -292,4 +292,60 @@
 }
 
+void MEvtLoop::MakeMacro(const char *filename="evtloop.C")
+{
+    TString name(filename);
+
+    if (!name.EndsWith(".C"))
+        name += ".C";
+
+    time_t t = time(NULL);
+
+    ofstream fout(name);
+    fout <<
+        "/* ======================================================================== *\\" << endl <<
+        "!" << endl <<
+        "! *" << endl <<
+        "! * This file is part of MARS, the MAGIC Analysis and Reconstruction" << endl <<
+        "! * Software. It is distributed to you in the hope that it can be a useful" << endl <<
+        "! * and timesaving tool in analysing Data of imaging Cerenkov telescopes." << endl <<
+        "! * It is distributed WITHOUT ANY WARRANTY." << endl <<
+        "! *" << endl <<
+        "! * Permission to use, copy, modify and distribute this software and its" << endl <<
+        "! * documentation for any purpose is hereby granted without fee," << endl <<
+        "! * provided that the above copyright notice appear in all copies and" << endl <<
+        "! * that both that copyright notice and this permission notice appear" << endl <<
+        "! * in supporting documentation. It is provided \"as is\" without express" << endl <<
+        "! * or implied warranty." << endl <<
+        "! *" << endl <<
+        "!" << endl <<
+        "!" << endl <<
+        "!   Author(s): Thomas Bretz et al. <mailto:tbretz@astro.uni-wuerzburg.de>" << endl <<
+        "!" << endl <<
+        "!   Copyright: MAGIC Software Development, 2000-2002" << endl <<
+        "!" << endl <<
+        "!" << endl <<
+        "\\* ======================================================================== */" << endl << endl <<
+        "// ------------------------------------------------------------------------" << endl <<
+        "//" << endl <<
+        "//     This macro was automatically created on" << endl<<
+        "//             " << ctime(&t) <<
+        "//        with the MEvtLoop::MakeMacro tool." << endl <<
+        "//" << endl <<
+        "// ------------------------------------------------------------------------" << endl << endl <<
+        "void " << name(0, name.Length()-2) << "()" << endl <<
+        "{" << endl;
+
+    SavePrimitive(fout);
+
+    fout << "}" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+
+//
 void MEvtLoop::SavePrimitive(ofstream &out, Option_t *)
 {
@@ -297,6 +353,34 @@
 
     out << "   MEvtLoop evtloop;" << endl;
-    out << "   evtloop.SetParList(&" << ToLower(fParList->GetName()) << ")" << endl;
+    out << "   evtloop.SetParList(&" << ToLower(fParList->GetName()) << ");" << endl;
     out << "   if (!evtloop.Eventloop())" << endl;
     out << "      return;" << endl;
 }
+
+Int_t MEvtLoop::Read(const char *name)
+{
+    Int_t n = 0;
+    TObjArray list;
+
+    n += TObject::Read(name);
+    n += list.Read((TString)name+"_names");
+
+    fParList->SetNames(list);
+
+    return n;
+}
+
+Int_t MEvtLoop::Write(const char *name, Int_t option, Int_t bufsize)
+{
+    Int_t n = 0;
+
+    TObjArray list;
+    list.SetOwner();
+
+    fParList->GetNames(list);
+
+    n += list.Write((TString)name+"_names", kSingleKey);
+    n += TObject::Write(name, option, bufsize);
+
+    return n;
+}
Index: trunk/MagicSoft/Mars/mbase/MEvtLoop.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 1473)
+++ trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 1474)
@@ -46,5 +46,10 @@
     Bool_t Eventloop(Int_t maxcnt=-1, const char *tlist="MTaskList");
 
+    void MakeMacro(const char *filename="evtloop.C");
+
     void SavePrimitive(ofstream &out, Option_t *o="");
+
+    Int_t Read(const char *name);
+    Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0);
 
     ClassDef(MEvtLoop, 1) // Class to execute the tasks in a tasklist
Index: trunk/MagicSoft/Mars/mbase/MParContainer.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 1473)
+++ trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 1474)
@@ -39,7 +39,8 @@
 #include <fstream.h>     // ofstream, AsciiWrite
 
+#include <TROOT.h>       // TROOT::Identlevel
 #include <TClass.h>      // IsA
+#include <TObjArray.h>   // TObjArray
 #include <TBaseClass.h>  // GetClassPointer
-#include <TROOT.h>       // TROOT::Identlevel
 #include <TMethodCall.h> // TMethodCall, AsciiWrite
 #include <TDataMember.h> // TDataMember, AsciiWrite
@@ -347,4 +348,10 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
 void MParContainer::SavePrimitive(ofstream &out, Option_t *o="")
 {
@@ -354,2 +361,17 @@
 }
 
+void MParContainer::GetNames(TObjArray &arr) const
+{
+    arr.AddLast(new TNamed(fName, fTitle));
+}
+
+void MParContainer::SetNames(TObjArray &arr)
+{
+    TNamed *name = (TNamed*)arr.First();
+
+    fName  = name->GetName();
+    fTitle = name->GetTitle();
+
+    delete arr.Remove(name);
+    arr.Compress();
+}
Index: trunk/MagicSoft/Mars/mbase/MParContainer.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParContainer.h	(revision 1473)
+++ trunk/MagicSoft/Mars/mbase/MParContainer.h	(revision 1474)
@@ -77,4 +77,7 @@
     virtual Bool_t AsciiWrite(ostream &out) const;
 
+    virtual void GetNames(TObjArray &arr) const;
+    virtual void SetNames(TObjArray &arr);
+
     ClassDef(MParContainer, 0)  //The basis for all parameter containers
 };
Index: trunk/MagicSoft/Mars/mbase/MParList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParList.cc	(revision 1473)
+++ trunk/MagicSoft/Mars/mbase/MParList.cc	(revision 1474)
@@ -660,7 +660,14 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
 void MParList::SavePrimitive(ofstream &out, Option_t *o="")
 {
-    out << "   MParList " << ToLower(fName) << ";" << endl << endl;
+    out << "   MParList " << ToLower(fName) << "(\"";
+    out << fName << "\", \"" << fTitle << "\");" << endl << endl;
 
     TIter Next(fContainer);
@@ -674,2 +681,25 @@
     }
 }
+
+void MParList::GetNames(TObjArray &arr) const
+{
+    MParContainer::GetNames(arr);
+    fContainer->ForEach(MParContainer, GetNames)(arr);
+}
+
+void MParList::SetNames(TObjArray &arr)
+{
+    MParContainer::SetNames(arr);
+    cout << fContainer << endl;
+    //    fContainer->ForEach(MParContainer, SetNames)(arr);
+    TIter Next(fContainer);
+
+    MParContainer *cont = NULL;
+    while ((cont=(MParContainer*)Next()))
+    {
+        cout << cont << " " << cont->GetName() << endl;
+        cont->SetNames(arr);
+    }
+
+}
+
Index: trunk/MagicSoft/Mars/mbase/MParList.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParList.h	(revision 1473)
+++ trunk/MagicSoft/Mars/mbase/MParList.h	(revision 1474)
@@ -80,4 +80,7 @@
     void SavePrimitive(ofstream &out, Option_t *o="");
 
+    void GetNames(TObjArray &arr) const;
+    void SetNames(TObjArray &arr);
+
     ClassDef(MParList, 1) // list of parameter containers (MParContainer)
 };
Index: trunk/MagicSoft/Mars/mbase/MTask.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 1473)
+++ trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 1474)
@@ -60,10 +60,11 @@
 //   - PostProcess():  executed after the eventloop. Here you can close    //
 //                     output files, start display of the run parameter,   //
-//                     etc. PostProcess should be executed only if         //
+//                     etc. PostProcess is only executed in case of        //
 //                     PreProcess was successfull (returned kTRUE)         //
 //                                                                         //
 /////////////////////////////////////////////////////////////////////////////
-
 #include "MTask.h"
+
+#include <fstream.h>
 
 #include "MLog.h"
@@ -262,2 +263,14 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MTask::SavePrimitive(ofstream &out, Option_t *o="")
+{
+    MParContainer::SavePrimitive(out);
+    if (fFilter)
+        out << "   " << ToLower(fName) << ".SetFilter(&" << ToLower(fFilter->GetName()) <<");" << endl;
+}
Index: trunk/MagicSoft/Mars/mbase/MTask.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTask.h	(revision 1473)
+++ trunk/MagicSoft/Mars/mbase/MTask.h	(revision 1474)
@@ -71,4 +71,5 @@
     const MFilter *GetFilter() const      { return fFilter; }
     virtual void PrintStatistics(const Int_t lvl=0) const;
+    virtual void SavePrimitive(ofstream &out, Option_t *o="");
 
     UInt_t GetNumExecutions() { return fNumExecutions; }
Index: trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 1473)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 1474)
@@ -514,8 +514,14 @@
 }
 
-
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
 void MTaskList::SavePrimitive(ofstream &out, Option_t *o="")
 {
-    out << "   MTaskList " << ToLower(fName) << ";" << endl << endl;
+    out << "   MTaskList " << ToLower(fName) << "(\"";
+    out << fName << "\", \"" << fTitle << "\");" << endl << endl;
 
     TIter Next(fTasks);
@@ -529,2 +535,15 @@
     }
 }
+
+void MTaskList::GetNames(TObjArray &arr) const
+{
+    MParContainer::GetNames(arr);
+    fTasks->ForEach(MParContainer, GetNames)(arr);
+}
+
+void MTaskList::SetNames(TObjArray &arr)
+{
+    MParContainer::SetNames(arr);
+    fTasks->ForEach(MParContainer, SetNames)(arr);
+}
+
Index: trunk/MagicSoft/Mars/mbase/MTaskList.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 1473)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 1474)
@@ -60,4 +60,7 @@
     const TList *GetList() const { return fTasks; }
 
+    void GetNames(TObjArray &arr) const;
+    void SetNames(TObjArray &arr);
+
     ClassDef(MTaskList, 1) //collection of tasks to be performed in the eventloop
 };
