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
 };
