Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 1476)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 1477)
@@ -30,4 +30,25 @@
    * mhist/MH3.[h,cc]:
      - implemented default constructor
+
+   * manalysis/MHillasSrcCalc.[h,cc], manalysis/MImgCleanStd.[h,cc],
+     manalysis/MSrcPosCam.[h,cc], mbase/MParList.[h,cc], mbase/MTask.h,
+     mbase/MTaskList.[h,cc], mfileio/MReadTree.[h,cc], 
+     mfileio/MWriteRootFile.[h,cc], mhist/MBinning.[h,cc], 
+     mhist/MFillH.[h,cc], mhist/MH3.[h,cc]:
+     - renamed SavePrimitive to StreamPrimitive
+     - implemented more accurate streaming
+     - removed some "//!" from the data members
+
+   * mbase/MParContainer.[h,cc]:
+     - new virtual function StreamPrimitive
+     - implemented flag whether this container has been streamed already
+
+   * mbase/MTask.[h,cc]:
+     - corrected streaming of primitive to stream filters correctly
+     - increased version number to 1
+
+   * mhist/MBinning.[h,cc]:
+     - move SetEdges and SetEdgesLog to the source file
+     - implemented a flag telling something about the type of the binning
 
 
Index: /trunk/MagicSoft/Mars/NEWS
===================================================================
--- /trunk/MagicSoft/Mars/NEWS	(revision 1476)
+++ /trunk/MagicSoft/Mars/NEWS	(revision 1477)
@@ -65,6 +65,9 @@
      instead of removing it completely from the analysis
 
-   - started a first implementation to be able to write the eventloop/
-     eventloop setup to a file (root-file, root-macro)
+   - Implemented the possibility to save the whole eventloop with
+     its setup to a file. This information can be read and from
+     it you can (re)create a Macro. See MEvtLoop::Read, MEvtLoop::Write
+     and MEvtLoop::MakeMacro. If you find something not working, please
+     report - this stuff is still in a beta phase.
 
 
Index: /trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.cc	(revision 1476)
+++ /trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.cc	(revision 1477)
@@ -37,4 +37,5 @@
 #include "MParList.h"
 
+#include "MSrcPosCam.h"
 #include "MHillasSrc.h"
 
@@ -103,8 +104,27 @@
 // gui elements to a macro-file.
 //
-void MHillasSrcCalc::SavePrimitive(ofstream &out, Option_t *o)
+void MHillasSrcCalc::StreamPrimitive(ofstream &out) const
 {
-    out << "   MHillasSrcCalc " << ToLower(fName) << "(\"";
-    out << fSrcName << "\", \"" << fHillasName << "\", \"";
-    out << fName << "\", \"" << fTitle << "\");" << endl;
+    if (fHillas)
+        fHillas->SavePrimitive(out);
+
+    if (fSrcPos)
+        fSrcPos->SavePrimitive(out);
+
+    if (fHillasSrc)
+        fHillasSrc->SavePrimitive(out);
+
+    out << "   MHillasSrcCalc " << ToLower(fName) << "(";
+
+    if (fSrcPos)
+        out << "&" << ToLower(fSrcPos->GetName());
+    else
+        out << "\"" << fSrcName << "\"";
+
+    if (fHillasSrc)
+        out << "&" << ToLower(fHillasSrc->GetName());
+    else
+        out << "\"" << fHillasName << "\"";
+
+    out << ", \"" << fName << "\", \"" << fTitle << "\");" << endl;
 }
Index: /trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.h	(revision 1476)
+++ /trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.h	(revision 1477)
@@ -13,10 +13,12 @@
 {
 private:
-    MHillas    *fHillas;     //! Pointer to the source independant hillas parameters
-    MSrcPosCam *fSrcPos;     //! Pointer to the source position
-    MHillasSrc *fHillasSrc;  //! Pointer to the output container for the source dependant parameters
+    MHillas    *fHillas;     // Pointer to the source independant hillas parameters
+    MSrcPosCam *fSrcPos;     // Pointer to the source position
+    MHillasSrc *fHillasSrc;  // Pointer to the output container for the source dependant parameters
 
     TString     fSrcName;
     TString     fHillasName;
+
+    void StreamPrimitive(ofstream &out) const;
 
 public:
@@ -27,6 +29,4 @@
     Bool_t Process();
 
-    void SavePrimitive(ofstream &out, Option_t *o="");
-
     ClassDef(MHillasSrcCalc, 1) // task to calculate the source position depandant hillas parameters
 };
Index: /trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc	(revision 1476)
+++ /trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc	(revision 1477)
@@ -414,5 +414,5 @@
 // gui elements to a macro-file.
 //
-void MImgCleanStd::SavePrimitive(ofstream &out, Option_t *o)
+void MImgCleanStd::StreamPrimitive(ofstream &out) const
 {
     out << "   MImgCleanStd " << ToLower(fName) << "(";
Index: /trunk/MagicSoft/Mars/manalysis/MImgCleanStd.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MImgCleanStd.h	(revision 1476)
+++ /trunk/MagicSoft/Mars/manalysis/MImgCleanStd.h	(revision 1477)
@@ -21,4 +21,5 @@
 
     void CreateGuiElements(MGGroupFrame *f);
+    void StreamPrimitive(ofstream &out) const;
 
 public:
@@ -34,5 +35,4 @@
 
     void Print(Option_t *o="") const;
-    void SavePrimitive(ofstream &out, Option_t *o="");
 
     Bool_t ProcessMessage(Int_t msg, Int_t submsg, Long_t param1, Long_t param2);
Index: /trunk/MagicSoft/Mars/manalysis/MSrcPosCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MSrcPosCam.cc	(revision 1476)
+++ /trunk/MagicSoft/Mars/manalysis/MSrcPosCam.cc	(revision 1477)
@@ -88,5 +88,5 @@
 // gui elements to a macro-file.
 //
-void MSrcPosCam::SavePrimitive(ofstream &out, Option_t *o)
+void MSrcPosCam::StreamPrimitive(ofstream &out) const
 {
     out << "   MSrcPosCam " << ToLower(fName) << "(\"";
Index: /trunk/MagicSoft/Mars/manalysis/MSrcPosCam.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MSrcPosCam.h	(revision 1476)
+++ /trunk/MagicSoft/Mars/manalysis/MSrcPosCam.h	(revision 1477)
@@ -11,4 +11,6 @@
     Float_t fX; // [mm] x position of source in camera
     Float_t fY; // [mm] y position of source in camera
+
+    void StreamPrimitive(ofstream &out) const;
 
 public:
@@ -29,6 +31,4 @@
     //void AsciiWrite(ofstream &fout) const;
 
-    void SavePrimitive(ofstream &out, Option_t *o="");
-
     ClassDef(MSrcPosCam, 1) // container to store source position in the camera plain
 };
Index: /trunk/MagicSoft/Mars/mbase/MParContainer.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 1476)
+++ /trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 1477)
@@ -80,5 +80,5 @@
     fTitle = rhs.fTitle;
 
-    fLog         = rhs.fLog;
+    fLog = rhs.fLog;
     fReadyToSave = rhs.fReadyToSave;
 
@@ -123,5 +123,5 @@
     cont.fTitle = fTitle;
 
-    cont.fLog         = fLog;
+    cont.fLog = fLog;
     cont.fReadyToSave = fReadyToSave;
 }
@@ -168,4 +168,5 @@
 {
     fName = name;
+    ResetBit(kIsSavedAsPrimitive);
     if (gPad && TestBit(kMustCleanup)) gPad->Modified();
 }
@@ -180,4 +181,5 @@
     fName  = name;
     fTitle = title;
+    ResetBit(kIsSavedAsPrimitive);
     if (gPad && TestBit(kMustCleanup)) gPad->Modified();
 }
@@ -190,4 +192,5 @@
 {
     fTitle = title;
+    ResetBit(kIsSavedAsPrimitive);
     if (gPad && TestBit(kMustCleanup)) gPad->Modified();
 }
@@ -356,5 +359,18 @@
 void MParContainer::SavePrimitive(ofstream &out, Option_t *o)
 {
-    out << "   // SavePrimitive not overloaded... using default." << endl;
+    if (IsSavedAsPrimitive())
+        return;
+
+    StreamPrimitive(out);
+    SetBit(kIsSavedAsPrimitive);
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates the string written by SavePrimitive and returns it.
+//
+void MParContainer::StreamPrimitive(ofstream &out) const
+{
+    out << "   // Using MParContainer::StreamPrimitive" << endl;
     out << "   " << ClassName() << " " << ToLower(fName) << "(\"";
     out << fName << "\", \"" << fTitle << "\");" << endl;
Index: /trunk/MagicSoft/Mars/mbase/MParContainer.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MParContainer.h	(revision 1476)
+++ /trunk/MagicSoft/Mars/mbase/MParContainer.h	(revision 1477)
@@ -34,6 +34,12 @@
     MLog   *fLog;         // The general log facility for this object, initialized with the global object
 
+    virtual void StreamPrimitive(ofstream &out) const;
+
 private:
     Bool_t  fReadyToSave; // should be set to true if the contents of the container is changed somehow
+
+    enum {
+        kIsSavedAsPrimitive = BIT(15)
+    };
 
 public:
@@ -67,4 +73,5 @@
     virtual Bool_t IsReadyToSave() const             { return fReadyToSave; }
     virtual void   SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; }
+    virtual Bool_t IsSavedAsPrimitive() const        { return TestBit(kIsSavedAsPrimitive); }
 
     TMethodCall *GetterMethod(const char *name) const;
Index: /trunk/MagicSoft/Mars/mbase/MParList.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MParList.cc	(revision 1476)
+++ /trunk/MagicSoft/Mars/mbase/MParList.cc	(revision 1477)
@@ -666,5 +666,5 @@
 // gui elements to a macro-file.
 //
-void MParList::SavePrimitive(ofstream &out, Option_t *o)
+void MParList::StreamPrimitive(ofstream &out) const
 {
     out << "   MParList " << ToLower(fName) << "(\"";
@@ -677,4 +677,5 @@
     {
         cont->SavePrimitive(out, "");
+
         out << "   " << ToLower(fName) << ".AddToList(&";
         out << ToLower(cont->GetName()) << ");" << endl << endl;
@@ -691,15 +692,5 @@
 {
     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);
-    }
-
-}
-
+    fContainer->ForEach(MParContainer, SetNames)(arr);
+}
+
Index: /trunk/MagicSoft/Mars/mbase/MParList.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MParList.h	(revision 1476)
+++ /trunk/MagicSoft/Mars/mbase/MParList.h	(revision 1477)
@@ -32,4 +32,6 @@
 
     enum { kIsOwner = BIT(14) };
+
+    void StreamPrimitive(ofstream &out) const;
 
 public:
@@ -78,5 +80,4 @@
 
     void Print(Option_t *t = NULL) const;
-    void SavePrimitive(ofstream &out, Option_t *o="");
 
     void GetNames(TObjArray &arr) const;
Index: /trunk/MagicSoft/Mars/mbase/MTask.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 1476)
+++ /trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 1477)
@@ -265,12 +265,21 @@
 // --------------------------------------------------------------------------
 //
-// 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)
+// First call MParContainer::SavePrimitive which should stream the primitive
+// to the output stream. Then, if a filter is set, stream first the filter
+// and afterwards set the filter for this task.
+//
+void MTask::SavePrimitive(ofstream &out, Option_t *o="")
 {
     MParContainer::SavePrimitive(out);
-    if (fFilter)
-        out << "   " << ToLower(fName) << ".SetFilter(&" << ToLower(fFilter->GetName()) <<");" << endl;
-}
+    if (!fFilter)
+        return;
+
+    /*
+     If we don't stream filter which are not in the task list itself
+     (which means: alrteady streamed) we may be able to use the
+     primitive streamer as some kind of validity check for the macros
+
+     fFilter->SavePrimitive(out);
+     out << "   " << ToLower(fName) << ".SetFilter(&" << ToLower(fFilter->GetName()) <<");" << endl;
+     */
+}
Index: /trunk/MagicSoft/Mars/mbase/MTask.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MTask.h	(revision 1476)
+++ /trunk/MagicSoft/Mars/mbase/MTask.h	(revision 1477)
@@ -22,10 +22,10 @@
 {
 private:
-    TList *fListOfBranches; // List of Branch names for auto enabeling scheme
+    TList *fListOfBranches; //! List of Branch names for auto enabeling scheme
 
     const MFilter *fFilter; // Filter for conditional task execution
 
-    Bool_t fIsPreprocessed; // Indicates the success of the PreProcessing (set by MTaskList)
-    UInt_t fNumExecutions;  // Number of Excutions
+    Bool_t fIsPreprocessed; //! Indicates the success of the PreProcessing (set by MTaskList)
+    UInt_t fNumExecutions;  //! Number of Excutions
 
     virtual Bool_t PreProcess(MParList *pList);
@@ -71,5 +71,4 @@
     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; }
@@ -83,5 +82,7 @@
     const TList *GetListOfBranches() const { return fListOfBranches; }
 
-    ClassDef(MTask, 0) //Abstract base class for a task
+    void SavePrimitive(ofstream &out, Option_t *o="");
+
+    ClassDef(MTask, 1) //Abstract base class for a task
 };
 
Index: /trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 1476)
+++ /trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 1477)
@@ -520,5 +520,5 @@
 // gui elements to a macro-file.
 //
-void MTaskList::SavePrimitive(ofstream &out, Option_t *o)
+void MTaskList::StreamPrimitive(ofstream &out) const
 {
     out << "   MTaskList " << ToLower(fName) << "(\"";
Index: /trunk/MagicSoft/Mars/mbase/MTaskList.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 1476)
+++ /trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 1477)
@@ -33,4 +33,6 @@
     Bool_t CheckClassForProcess(TClass *cls);
 
+    void StreamPrimitive(ofstream &out) const;
+
 public:
     MTaskList(const char *name=NULL, const char *title=NULL);
@@ -56,6 +58,4 @@
     void SetOwner(Bool_t enable=kTRUE);
 
-    void SavePrimitive(ofstream &out, Option_t *o="");
-
     const TList *GetList() const { return fTasks; }
 
Index: /trunk/MagicSoft/Mars/mfileio/MReadTree.cc
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MReadTree.cc	(revision 1476)
+++ /trunk/MagicSoft/Mars/mfileio/MReadTree.cc	(revision 1477)
@@ -783,5 +783,5 @@
 // gui elements to a macro-file.
 //
-void MReadTree::SavePrimitive(ofstream &out, Option_t *o)
+void MReadTree::StreamPrimitive(ofstream &out) const
 {
     TString name = ToLower(fName);
Index: /trunk/MagicSoft/Mars/mfileio/MReadTree.h
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MReadTree.h	(revision 1476)
+++ /trunk/MagicSoft/Mars/mfileio/MReadTree.h	(revision 1477)
@@ -36,4 +36,5 @@
 
     virtual void SetReadyToSave(Bool_t flag=kTRUE);
+    virtual void StreamPrimitive(ofstream &out) const;
 
     enum { kIsOwner = BIT(14) };
@@ -72,5 +73,4 @@
 
     virtual Bool_t Notify();
-    virtual void   SavePrimitive(ofstream &out, Option_t *o="");
 
     ClassDef(MReadTree, 1)	// Reads a tree from file(s)
Index: /trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 1476)
+++ /trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 1477)
@@ -403,5 +403,5 @@
 // gui elements to a macro-file.
 //
-void MWriteRootFile::SavePrimitive(ofstream &out, Option_t *o)
+void MWriteRootFile::StreamPrimitive(ofstream &out) const
 {
     out << "   MWriteRootFile " << ToLower(fName) << "(\"";
@@ -416,7 +416,13 @@
     while ((entry=(MRootFileBranch*)Next()))
     {
-        out << "   " << ToLower(fName) << ".AddContainer(\"";
-        out << entry->GetContName() << "\", \"";
-        out << entry->GetName() << "\", \"";
+        if  (entry->GetContainer())
+        {
+            entry->GetContainer()->SavePrimitive(out);
+            out << "&" << ToLower(entry->GetContainer()->GetName());
+        }
+        else
+            out << "\"" << entry->GetContName() << "\"";
+
+        out << ", \"" << entry->GetName() << "\", \"";
         out << entry->GetTitle() << "\");" << endl;
     }
Index: /trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h	(revision 1476)
+++ /trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h	(revision 1477)
@@ -19,5 +19,5 @@
     TBranch       *fBranch;     //!
 
-    MParContainer *fContainer;  //!
+    MParContainer *fContainer;
     TString        fContName;
 
@@ -74,4 +74,6 @@
     const char *GetFileName() const;
 
+    void StreamPrimitive(ofstream &out) const;
+
 public:
     MWriteRootFile();
@@ -92,5 +94,4 @@
 
     void Print(Option_t *t=NULL) const;
-    void SavePrimitive(ofstream &out, Option_t *o="");
 
     ClassDef(MWriteRootFile, 1)	// Class to write one container to a root file
Index: /trunk/MagicSoft/Mars/mhist/MBinning.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MBinning.cc	(revision 1476)
+++ /trunk/MagicSoft/Mars/mhist/MBinning.cc	(revision 1477)
@@ -50,6 +50,39 @@
 
     SetEdges(10, 0, 1);
+
+    fType = kIsDefault;
 }
 
+// --------------------------------------------------------------------------
+//
+// Specify the number of bins (not the number of edges), the lowest and
+// highest Edge.
+//
+void MBinning::SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up)
+{
+    const Double_t binsize = (up-lo)/nbins;
+    fEdges.Set(nbins+1);
+    for (int i=0; i<=nbins; i++)
+            fEdges[i] = binsize*i + lo;
+
+    fType = kIsLinear;
+}
+
+// --------------------------------------------------------------------------
+//
+// Specify the number of bins (not the number of edges), the lowest and
+// highest Edge.
+//
+void MBinning::SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up)
+{
+    // if (lo==0) ...
+
+    const Double_t binsize = log10(up/lo)/nbins;
+    fEdges.Set(nbins+1);
+    for (int i=0; i<=nbins; i++)
+        fEdges[i] = pow(10, binsize*i) * lo;
+
+    fType = kIsLogarithmic;
+}
 
 // --------------------------------------------------------------------------
@@ -70,11 +103,26 @@
 // gui elements to a macro-file.
 //
-void MBinning::SavePrimitive(ofstream &out, Option_t *o)
+void MBinning::StreamPrimitive(ofstream &out) const
 {
-    out << "   TArrayD dummy;" << endl;
-    for (int i=0; i<fEdges.GetSize(); i++)
-        out << "   dummy[" << i << "]=" << fEdges[i] << ";" << endl;
     out << "   MBinning " << ToLower(fName) << "(\"";
     out << fName << "\", \"" << fTitle << "\");" << endl;
-    out << "   " << ToLower(fName) << ".SetEdges(dummy);" << endl;
+
+    if (IsDefault())
+        return;
+
+    if (IsLinear() || IsLogarithmic())
+    {
+        out << "   " << ToLower(fName) << ".SetEdges";
+        if (IsLogarithmic())
+            out << "Log";
+        out << "(" << GetNumBins() << ", " << GetEdgeLo() << ", " << GetEdgeHi() << ");" << endl;
+        return;
+    }
+
+    out << "   {" << endl;
+    out << "      TArrayD dummy;" << endl;
+    for (int i=0; i<GetNumEdges(); i++)
+        out << "      dummy[" << i << "]=" << GetEdges()[i] << ";" << endl;
+    out << "      " << ToLower(fName) << ".SetEdges(dummy);" << endl;
+    out << "   }" << endl;
 }
Index: /trunk/MagicSoft/Mars/mhist/MBinning.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MBinning.h	(revision 1476)
+++ /trunk/MagicSoft/Mars/mhist/MBinning.h	(revision 1477)
@@ -17,4 +17,15 @@
     TArrayD fEdges;
 
+    Byte_t  fType;
+
+    void StreamPrimitive(ofstream &out) const;
+
+    enum {
+        kIsDefault,
+        kIsLinear,
+        kIsLogarithmic,
+        kIsUserArray
+    };
+
 public:
     MBinning(const char *name=NULL, const char *title=NULL);
@@ -23,27 +34,13 @@
     {
         fEdges = arr;
+        fType = kIsUserArray;
     }
 
-    void SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up)
-    {
-        const Double_t binsize = (up-lo)/nbins;
-        fEdges.Set(nbins+1);
-        for (int i=0; i<=nbins; i++)
-            fEdges[i] = binsize*i + lo;
-    }
-
-    void SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up)
-    {
-        // if (lo==0) ...
-
-        const Double_t binsize = log10(up/lo)/nbins;
-        fEdges.Set(nbins+1);
-        for (int i=0; i<=nbins; i++)
-            fEdges[i] = pow(10, binsize*i) * lo;
-    }
+    void SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up);
+    void SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up);
 
     // FIXME: ROOT workaround: "operator[] const" missing
-    Double_t GetEdgeLo() const { return (*(TArrayD*)(&fEdges))[0]; }
-    Double_t GetEdgeHi() const { return (*(TArrayD*)(&fEdges))[fEdges.GetSize()-1]; }
+    Double_t GetEdgeLo() const { return ((TArrayD)fEdges)[0]; }
+    Double_t GetEdgeHi() const { return ((TArrayD)fEdges)[fEdges.GetSize()-1]; }
 
     Int_t GetNumEdges() const { return fEdges.GetSize(); }
@@ -52,7 +49,10 @@
     Double_t *GetEdges() const { return fEdges.GetArray(); }
 
+    Bool_t IsLinear() const { return fType==kIsLinear; }
+    Bool_t IsLogarithmic() const { return fType==kIsLogarithmic; }
+    Bool_t IsDefault() const { return fType==kIsDefault; }
+    Bool_t IsUserArray() const { return fType==kIsUserArray; }
+
     void Apply(TH1 &);
-
-    void SavePrimitive(ofstream &out, Option_t *o="");
 
     ClassDef(MBinning, 1) //Container to store the binning of a histogram
Index: /trunk/MagicSoft/Mars/mhist/MFillH.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MFillH.cc	(revision 1476)
+++ /trunk/MagicSoft/Mars/mhist/MFillH.cc	(revision 1477)
@@ -156,5 +156,5 @@
 //
 //
-MFillH::MFillH(const char *hist, const MParContainer *par, const char *name, const char *title)
+MFillH::MFillH(const char *hist, MParContainer *par, const char *name, const char *title)
 {
     Init(name, title);
@@ -192,5 +192,5 @@
 //   derived from MH)
 //
-MFillH::MFillH(MH *hist, const MParContainer *par, const char *name, const char *title)
+MFillH::MFillH(MH *hist, MParContainer *par, const char *name, const char *title)
 {
     Init(name, title);
@@ -350,7 +350,25 @@
 // gui elements to a macro-file.
 //
-void MFillH::SavePrimitive(ofstream &out, Option_t *o)
-{
-    out << "   MFillH " << ToLower(fName) << "(\"";
-    out << fHName << "\", \"" << fParContainerName << "\");" << endl;
-}
+void MFillH::StreamPrimitive(ofstream &out) const
+{
+    if (fH)
+        fH->SavePrimitive(out);
+
+    if (fParContainer)
+        fParContainer->SavePrimitive(out);
+
+    out << "   MFillH " << ToLower(fName) << "(";
+
+    if (fH)
+        out << "&" << ToLower(fH->GetName());
+    else
+        out << "\"" << fHName << "\"";
+    out << ", ";
+
+    if (fParContainer)
+        out << "&" << ToLower(fParContainer->GetName());
+    else
+        out << "\"" << fParContainerName << "\"";
+
+    out << ");" << endl;
+}
Index: /trunk/MagicSoft/Mars/mhist/MFillH.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MFillH.h	(revision 1476)
+++ /trunk/MagicSoft/Mars/mhist/MFillH.h	(revision 1477)
@@ -12,8 +12,8 @@
 {
 private:
-    const MParContainer *fParContainer; //!
+    MParContainer *fParContainer;
     TString fParContainerName;
 
-    MH* fH;                             //!
+    MH* fH;                   
     TString fHName;
 
@@ -23,16 +23,16 @@
     void Init(const char *name, const char *title);
 
+    void StreamPrimitive(ofstream &out) const;
+
 public:
     MFillH();
-    MFillH(const char *hist, const char *par=NULL,     const char *name=NULL, const char *title=NULL);
-    MFillH(const char *hist, const MParContainer *par, const char *name=NULL, const char *title=NULL);
-    MFillH(MH *hist,         const char *par=NULL,     const char *name=NULL, const char *title=NULL);
-    MFillH(MH *hist,         const MParContainer *par, const char *name=NULL, const char *title=NULL);
+    MFillH(const char *hist, const char *par=NULL, const char *name=NULL, const char *title=NULL);
+    MFillH(const char *hist, MParContainer *par,   const char *name=NULL, const char *title=NULL);
+    MFillH(MH *hist,         const char *par=NULL, const char *name=NULL, const char *title=NULL);
+    MFillH(MH *hist,         MParContainer *par,   const char *name=NULL, const char *title=NULL);
 
     Bool_t PreProcess(MParList *pList);
     Bool_t Process();
     Bool_t PostProcess();
-
-    void SavePrimitive(ofstream &out, Option_t *o="");
 
     ClassDef(MFillH, 1) // Task to fill a histogram with data from a parameter container
Index: /trunk/MagicSoft/Mars/mhist/MH3.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MH3.cc	(revision 1476)
+++ /trunk/MagicSoft/Mars/mhist/MH3.cc	(revision 1477)
@@ -384,5 +384,5 @@
 // gui elements to a macro-file.
 //
-void MH3::SavePrimitive(ofstream &out, Option_t *o)
+void MH3::StreamPrimitive(ofstream &out)
 {
     TString name = ToLower(fName);
Index: /trunk/MagicSoft/Mars/mhist/MH3.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MH3.h	(revision 1476)
+++ /trunk/MagicSoft/Mars/mhist/MH3.h	(revision 1477)
@@ -23,4 +23,6 @@
     MDataChain *fData[3];        // Object from which the data is filled
     Double_t    fScale[3];
+
+    void StreamPrimitive(ofstream &out);
 
 public:
@@ -49,6 +51,4 @@
     TObject *DrawClone(Option_t *opt=NULL) const;
 
-    void SavePrimitive(ofstream &out, Option_t *o="");
-
     ClassDef(MH3, 1) // Generalized 1/2/3D-histogram for Mars variables
 };
