Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 1480)
+++ trunk/MagicSoft/Mars/Changelog	(revision 1481)
@@ -1,8 +1,49 @@
                                                                   -*-*- END -*-*-
 
+ 2002/08/05: Thomas Bretz
+
+   * mbase/MEvtLoop.[h,cc]:
+     - added a warning in case of duplicate names in the lists
+     - added orresponding member functions (HasDuplicateNames)
+     - added some sanity checks, checking for an open file
+
+   * mbase/MFilter.[h,cc]:
+     - added GetRule virtual member function
+
+   * mbase/MFilterList.[h,cc]:
+     - added GetRule 
+     - added StreamPrimitive
+     - added name and title to the constructor
+     - set version number to 1
+
+   * mbase/MTask.h:
+     - removed const qualifiers from fFilter (seems, that the root io
+       doesn't like it)
+
+   * mdata/MDataChain.[h,cc], mdata/MDataList.[h,cc], mdata/MDataMember.[h,cc],
+     mdata/MDataValue.[h,cc]:
+     - set class version to 1
+     - added default constructor if missing
+     - added fDataMember to MDataMember (formaly fName isn't stored)
+
+   * mfilter/MF.[h,cc], mfilter/MFAlpha.[h,cc], mfilter/MFDataMember.[h,cc],
+     mfilter/MFParticleId.[h,cc], mfilter/MFTriggerLvl1.[h,cc]:
+     - added StreamPrimitive
+     - removed const qualifiers from data members
+     - added the "!" to the data member storing the result
+     - added GetRule
+
+   * mhist/MFillH.[h,cc]:
+     - fixed some small bugs in StreamPrimitive
+
+   * mhist/MH3.[h,cc]:
+     - added the missing const-qualifier of StreamPrimitive
+
+
+
  2002/08/06: Wolfgang Wittek
 
    * mbase/MTask.cc :
-     - redefinition of default argument in MTask:SavePrimitive removed
+     - redefinition of default argument in MTask::SavePrimitive removed
 
 
Index: trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 1480)
+++ trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 1481)
@@ -70,9 +70,10 @@
 #include "MEvtLoop.h"
 
-#include <time.h>
-#include <fstream.h>     // ofstream, SavePrimitive
+#include <time.h>           // time_t
+#include <fstream.h>        // ofstream, SavePrimitive
 #include <iostream.h>
 
-#include <TSystem.h>
+#include <TFile.h>          // gFile
+#include <TSystem.h>        // gSystem
 #include <TStopwatch.h>
 #include <TGProgressBar.h>
@@ -352,31 +353,162 @@
 // 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 *)
 {
-    fParList->SavePrimitive(out);
+    if (HasDuplicateNames("MEvtLoop::SavePrimitive"))
+    {
+        out << "   // !" << endl;
+        out << "   // ! WARNING - Your eventloop (MParList, MTaskList, ...) contains more than" << endl;
+        out << "   // ! one object (MParContainer, MTask, ...) with the same name. The created macro" << endl;
+        out << "   // ! may need manual intervention before it can be used." << endl;
+        out << "   // !" << endl;
+        out << endl;
+    }
+
+    if (fParList)
+        fParList->SavePrimitive(out);
 
     out << "   MEvtLoop evtloop;" << endl;
-    out << "   evtloop.SetParList(&" << ToLower(fParList->GetName()) << ");" << endl;
+    if (fParList)
+        out << "   evtloop.SetParList(&" << ToLower(fParList->GetName()) << ");" << endl;
+    else
+        out << "   // fParList empty..." << endl;
     out << "   if (!evtloop.Eventloop())" << endl;
     out << "      return;" << endl;
 }
 
+// --------------------------------------------------------------------------
+//
+// Get a list of all conmtainer names which are somehow part of the
+// eventloop. Chack for duplicate members and print a warning if
+// duplicates are found. Return kTRUE if duplicates are found, otherwise
+// kFALSE;
+//
+Bool_t MEvtLoop::HasDuplicateNames(TObjArray &arr, const TString txt) const
+{
+    arr.Sort();
+
+    TIter Next(&arr);
+    TObject *obj;
+    TString name;
+    Bool_t found = kFALSE;
+    while ((obj=Next()))
+    {
+        if (name==obj->GetName())
+        {
+            if (!found)
+            {
+                *fLog << warn << endl;
+                *fLog << " ! WARNING (" << txt << ")" << endl;
+                *fLog << " ! Your eventloop (MParList, MTaskList, ...) contains more than" << endl;
+                *fLog << " ! one object (MParContainer, MTask, ...) with the same name." << endl;
+                *fLog << " ! Creating a macro from it using MEvtLoop::MakeMacro may create" << endl;
+                *fLog << " ! a macro which needs manual intervention before it can be used." << endl;
+                found = kTRUE;
+            }
+            *fLog << " ! Please rename: " << obj->GetName() << endl;
+        }
+        name = obj->GetName();
+    }
+
+    return found;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get a list of all conmtainer names which are somehow part of the
+// eventloop. Chack for duplicate members and print a warning if
+// duplicates are found. Return kTRUE if duplicates are found, otherwise
+// kFALSE;
+//
+Bool_t MEvtLoop::HasDuplicateNames(const TString txt) const
+{
+    if (!fParList)
+        return kFALSE;
+
+    TObjArray list;
+    list.SetOwner();
+
+    fParList->GetNames(list);
+
+    return HasDuplicateNames(list, txt);
+}
+
+// --------------------------------------------------------------------------
+//
+// Reads a saved eventloop from a file. The default name is "Evtloop".
+// Therefor an open file must exist (See TFile for more information)
+//
+//  eg:
+//        TFile file("myfile.root", "READ");
+//        MEvtLoop evtloop;
+//        evtloop.Read();
+//        evtloop.MakeMacro("mymacro");
+//
 Int_t MEvtLoop::Read(const char *name)
 {
+    if (!gFile)
+    {
+        *fLog << err << "MEvtloop::Read: No file found. Please create a TFile first." << endl;
+        return 0;
+    }
+
+    if (!gFile->IsOpen())
+    {
+        *fLog << err << "MEvtloop::Read: File not open. Please open the TFile first." << endl;
+        return 0;
+    }
+
     Int_t n = 0;
     TObjArray list;
 
     n += TObject::Read(name);
+
+    if (n==0)
+    {
+        *fLog << err << "MEvtloop::Read: No objects read." << endl;
+        return 0;
+    }
+
     n += list.Read((TString)name+"_names");
 
     fParList->SetNames(list);
 
+    HasDuplicateNames(list, "MEvtLoop::Read");
+
     return n;
 }
 
+// --------------------------------------------------------------------------
+//
+// Writes a eventloop to a file. The default name is "Evtloop".
+// Therefor an open file must exist (See TFile for more information)
+//
+//  eg:
+//        TFile file("myfile.root", "RECREATE");
+//        MEvtLoop evtloop;
+//        evtloop.Write();
+//        file.Close();
+//
 Int_t MEvtLoop::Write(const char *name, Int_t option, Int_t bufsize)
 {
+    if (!gFile)
+    {
+        *fLog << err << "MEvtloop::Write: No file found. Please create a TFile first." << endl;
+        return 0;
+    }
+
+    if (!gFile->IsOpen())
+    {
+        *fLog << err << "MEvtloop::Write: File not open. Please open the TFile first." << endl;
+        return 0;
+    }
+
+    if (!gFile->IsWritable())
+    {
+        *fLog << err << "MEvtloop::Write: File not writable." << endl;
+        return 0;
+    }
+
     Int_t n = 0;
 
@@ -386,6 +518,15 @@
     fParList->GetNames(list);
 
+    n += TObject::Write(name, option, bufsize);
+
+    if (n==0)
+    {
+        *fLog << err << "MEvtloop::Read: No objects written." << endl;
+        return 0;
+    }
+
     n += list.Write((TString)name+"_names", kSingleKey);
-    n += TObject::Write(name, option, bufsize);
+
+    HasDuplicateNames(list, "MEvtLoop::Write");
 
     return n;
Index: trunk/MagicSoft/Mars/mbase/MEvtLoop.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 1480)
+++ trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 1481)
@@ -27,4 +27,7 @@
 
     enum { kIsOwner = BIT(14) };
+
+    Bool_t HasDuplicateNames(const TString txt) const;
+    Bool_t HasDuplicateNames(TObjArray &arr, const TString txt) const;
 
 public:
Index: trunk/MagicSoft/Mars/mbase/MFilter.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MFilter.cc	(revision 1480)
+++ trunk/MagicSoft/Mars/mbase/MFilter.cc	(revision 1481)
@@ -98,2 +98,7 @@
     return kTRUE;
 }
+
+TString MFilter::GetRule() const
+{
+    return "<GetRule not available for " + fName + ">";
+}
Index: trunk/MagicSoft/Mars/mbase/MFilter.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MFilter.h	(revision 1480)
+++ trunk/MagicSoft/Mars/mbase/MFilter.h	(revision 1481)
@@ -19,4 +19,6 @@
     virtual Bool_t PostProcess();
 
+    virtual TString GetRule() const;
+
     ClassDef(MFilter, 0)		// Abstract base class for the filters
 };
Index: trunk/MagicSoft/Mars/mbase/MFilterList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MFilterList.cc	(revision 1480)
+++ trunk/MagicSoft/Mars/mbase/MFilterList.cc	(revision 1481)
@@ -31,4 +31,6 @@
 #include "MFilterList.h"
 
+#include <fstream.h>
+
 #include <TString.h>
 
@@ -53,6 +55,9 @@
 //      lor, ||  : is a logical or
 //
-MFilterList::MFilterList(const char *type)
-{
+MFilterList::MFilterList(const char *type, const char *name, const char *title)
+{
+    fName  = name  ? name  : "MFilterList";
+    fTitle = title ? title : "List combining filters logically.";
+
     fFilterType = kEAnd;
 
@@ -236,10 +241,60 @@
 void MFilterList::Print(Option_t *opt) const
 {
+    *fLog << all << GetRule(opt) << flush;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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 MFilterList::StreamPrimitive(ofstream &out) const
+{
+    out << "   MFilterList " << ToLower(fName) << "(\"";
+
+    switch (fFilterType)
+    {
+    case kEAnd:
+        out << "&";
+        break;
+
+    case kEOr:
+        out  << "|";
+        break;
+
+    case kEXor:
+        out  << "^";
+        break;
+
+    case kELAnd:
+        out << "&&";
+        break;
+
+    case kELOr:
+        out << "||";
+        break;
+    }
+
+    out << fName << "\", \"" << fName << "\", \"" << fTitle << "\");" << endl << endl;
+
+    TIter Next(&fFilters);
+
+    TObject *cont = NULL;
+    while ((cont=Next()))
+    {
+        cont->SavePrimitive(out, "");
+
+        out << "   " << ToLower(fName) << ".AddToList(&";
+        out << ToLower(cont->GetName()) << ");" << endl << endl;
+    }
+}
+
+TString MFilterList::GetRule(Option_t *opt) const
+{
     TString str(opt);
     const Bool_t verbose = str.Contains("V", TString::kIgnoreCase);
 
-    //*fLog << all << "(" << GetName() << "=" << (int)fFilterType << ")";
-
-    *fLog << all << "(";
+    TString ret = "(";
 
     TIter Next(&fFilters);
@@ -251,10 +306,7 @@
     //
     if (!filter)
-    {
-        *fLog << "<empty>)" << flush;
-        return;
-    }
-
-    filter->Print();
+        return "<empty>";
+
+    ret += filter->GetRule();
 
     while ((filter=(MFilter*)Next()))
@@ -263,28 +315,27 @@
         {
         case kEAnd:
-            *fLog << (verbose?" and ":" & ");
+            ret += (verbose?" and ":" & ");
             break;
 
         case kEOr:
-            *fLog << (verbose?" or ":" | ");
+            ret += (verbose?" or ":" | ");
             break;
 
         case kEXor:
-            *fLog << (verbose?" xor ":" ^ ");
+            ret += (verbose?" xor ":" ^ ");
             break;
 
         case kELAnd:
-            *fLog << (verbose?" land ":" && ");
+            ret += (verbose?" land ":" && ");
             break;
 
         case kELOr:
-            *fLog << (verbose?" lor ":" || ");
+            ret += (verbose?" lor ":" || ");
             break;
         }
 
-        filter->Print();
-    }
-
-    *fLog << ")" << flush;
-}
-
+        ret += filter->GetRule();
+    }
+
+    return ret+")";
+}
Index: trunk/MagicSoft/Mars/mbase/MFilterList.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MFilterList.h	(revision 1480)
+++ trunk/MagicSoft/Mars/mbase/MFilterList.h	(revision 1481)
@@ -29,6 +29,8 @@
     enum { kIsOwner = BIT(14) };
 
+    void StreamPrimitive(ofstream &out) const;
+
 public:
-    MFilterList(const char *type="&&");
+    MFilterList(const char *type="&&", const char *name=NULL, const char *title=NULL);
     MFilterList(MFilterList &ts);
     ~MFilterList()
@@ -48,6 +50,7 @@
 
     void Print(Option_t *opt = "") const;
+    TString GetRule(Option_t *opt="") const;
 
-    ClassDef(MFilterList, 0)		// List to combine several filters logically
+    ClassDef(MFilterList, 1)		// List to combine several filters logically
 };
 
Index: trunk/MagicSoft/Mars/mbase/MTask.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTask.h	(revision 1480)
+++ trunk/MagicSoft/Mars/mbase/MTask.h	(revision 1481)
@@ -24,5 +24,5 @@
     TList *fListOfBranches; //! List of Branch names for auto enabeling scheme
 
-    const MFilter *fFilter; // Filter for conditional task execution
+    MFilter *fFilter;       // Filter for conditional task execution
 
     Bool_t fIsPreprocessed; //! Indicates the success of the PreProcessing (set by MTaskList)
@@ -68,5 +68,5 @@
     virtual ~MTask();
 
-    void SetFilter(const MFilter *filter) { fFilter=filter; }
+    void SetFilter(MFilter *filter) { fFilter=filter; }
     const MFilter *GetFilter() const      { return fFilter; }
     virtual void PrintStatistics(const Int_t lvl=0) const;
Index: trunk/MagicSoft/Mars/mdata/MDataChain.cc
===================================================================
--- trunk/MagicSoft/Mars/mdata/MDataChain.cc	(revision 1480)
+++ trunk/MagicSoft/Mars/mdata/MDataChain.cc	(revision 1481)
@@ -496,22 +496,22 @@
     switch (fOperatorType)
     {
-    case kEAbs:      str += "abs"   ; break;
-    case kELog:      str += "log"   ; break;
-    case kELog10:    str += "log10" ; break;
-    case kESin:      str += "sin"   ; break;
-    case kECos:      str += "cos"   ; break;
-    case kETan:      str += "tan"   ; break;
-    case kESinH:     str += "sinh"  ; break;
-    case kECosH:     str += "cosh"  ; break;
-    case kETanH:     str += "tanh"  ; break;
-    case kEASin:     str += "asin"  ; break;
-    case kEACos:     str += "acos"  ; break;
-    case kEATan:     str += "atan"  ; break;
-    case kESqrt:     str += "sqrt"  ; break;
-    case kEExp:      str += "exp"   ; break;
-    case kEPow10:    str += "pow10" ; break;
-    case kESgn:      str += "sgn"   ; break;
-    case kENegative: str += "-"     ; break;
-    case kEPositive: str += "+"     ; break;
+    case kEAbs:      str += "abs"  ; break;
+    case kELog:      str += "log"  ; break;
+    case kELog10:    str += "log10"; break;
+    case kESin:      str += "sin"  ; break;
+    case kECos:      str += "cos"  ; break;
+    case kETan:      str += "tan"  ; break;
+    case kESinH:     str += "sinh" ; break;
+    case kECosH:     str += "cosh" ; break;
+    case kETanH:     str += "tanh" ; break;
+    case kEASin:     str += "asin" ; break;
+    case kEACos:     str += "acos" ; break;
+    case kEATan:     str += "atan" ; break;
+    case kESqrt:     str += "sqrt" ; break;
+    case kEExp:      str += "exp"  ; break;
+    case kEPow10:    str += "pow10"; break;
+    case kESgn:      str += "sgn"  ; break;
+    case kENegative: str += "-"    ; break;
+    case kEPositive: str += "+"    ; break;
     case kENoop:
         break;
Index: trunk/MagicSoft/Mars/mdata/MDataChain.h
===================================================================
--- trunk/MagicSoft/Mars/mdata/MDataChain.h	(revision 1480)
+++ trunk/MagicSoft/Mars/mdata/MDataChain.h	(revision 1481)
@@ -67,5 +67,5 @@
     TString GetRule() const;
 
-    ClassDef(MDataChain, 0) // A chain/concatenation of MData objects
+    ClassDef(MDataChain, 1) // A chain/concatenation of MData objects
 };
 
Index: trunk/MagicSoft/Mars/mdata/MDataList.cc
===================================================================
--- trunk/MagicSoft/Mars/mdata/MDataList.cc	(revision 1480)
+++ trunk/MagicSoft/Mars/mdata/MDataList.cc	(revision 1481)
@@ -38,16 +38,20 @@
 // --------------------------------------------------------------------------
 //
+//   Default Constructor. Not for usage!
+//
+MDataList::MDataList()
+{
+    fSign = kENone;
+}
+
+// --------------------------------------------------------------------------
+//
 //   Constructor.
 //
-//   Specify the boolean operation which is used to evaluate the
-//   result of this list. If no operation is specified "land" is
-//   used.
+//   Specify the operation which is used to evaluate the
+//   result of this list.
 //
 //   Options:
-//      and, &   : is a bitwise and
-//      or, |    : is a bitwise or
-//      xor, ^   : is a bitwise exclusive or
-//      land, && : is a logical and
-//      lor, ||  : is a logical or
+//      *,  /,  -,  +
 //
 MDataList::MDataList(char type)
Index: trunk/MagicSoft/Mars/mdata/MDataList.h
===================================================================
--- trunk/MagicSoft/Mars/mdata/MDataList.h	(revision 1480)
+++ trunk/MagicSoft/Mars/mdata/MDataList.h	(revision 1481)
@@ -29,4 +29,5 @@
 
 public:
+    MDataList();
     MDataList(char type);
     MDataList(MDataList &ts);
@@ -49,5 +50,5 @@
     TString GetRule() const;
 
-    ClassDef(MDataList, 0) // A concatenation of MData objects by one operator
+    ClassDef(MDataList, 1) // A concatenation of MData objects by one operator
 };
 
Index: trunk/MagicSoft/Mars/mdata/MDataMember.cc
===================================================================
--- trunk/MagicSoft/Mars/mdata/MDataMember.cc	(revision 1480)
+++ trunk/MagicSoft/Mars/mdata/MDataMember.cc	(revision 1481)
@@ -36,6 +36,7 @@
 //
 /////////////////////////////////////////////////////////////////////////////
+#include "MDataMember.h"
 
-#include "MDataMember.h"
+#include <fstream.h>
 
 #include <TMethodCall.h>
@@ -59,4 +60,6 @@
     fObject = obj;
     fCall   = call;
+
+    fDataMember = (TString)obj->GetName() + "." + call->GetName();
 }
 
@@ -72,4 +75,6 @@
     fObject = obj;
     fCall   = obj->GetterMethod(call);
+
+    fDataMember = (TString)obj->GetName() + "." + call;
 }
 
@@ -82,5 +87,5 @@
     if (!fCall)
     {
-        *fLog << err << "No TMethodCall for " << fName << " of ";
+        *fLog << err << "No TMethodCall for " << fDataMember << " of ";
         *fLog << fObject->GetName() << " available... returning 0." << endl;
         return 0;
@@ -100,5 +105,5 @@
 
     default:
-        *fLog << err << "DataMember " << fName << " of ";
+        *fLog << err << "DataMember " << fDataMember << " of ";
         *fLog << fObject->GetName() << " neither int nor float... returning 0." << endl;
         return 0;
@@ -120,6 +125,6 @@
         return kTRUE;
 
-    TString cname(fName);
-    TString mname(fName);
+    TString cname(fDataMember);
+    TString mname(fDataMember);
 
     const char *dot = strrchr(cname, '.');
@@ -167,4 +172,4 @@
 TString MDataMember::GetRule() const
 {
-    return fName;
+    return fDataMember;
 }
Index: trunk/MagicSoft/Mars/mdata/MDataMember.h
===================================================================
--- trunk/MagicSoft/Mars/mdata/MDataMember.h	(revision 1480)
+++ trunk/MagicSoft/Mars/mdata/MDataMember.h	(revision 1481)
@@ -15,12 +15,15 @@
 {
 private:
+    TString fDataMember;
+
     MParContainer *fObject;
     TMethodCall   *fCall;
 
 public:
-    MDataMember(const char *member) : fObject(NULL), fCall(NULL)
+    MDataMember(const char *member=NULL) : fObject(NULL), fCall(NULL)
     {
-        fName = member;
+        fDataMember = member;
     }
+
     MDataMember(MParContainer *obj, TMethodCall *call);
     MDataMember(MParContainer *obj, const TString call);
@@ -35,5 +38,5 @@
     TString GetRule() const;
 
-    ClassDef(MDataMember, 0) // MData object corresponding to a single data member of a Mars container
+    ClassDef(MDataMember, 1) // MData object corresponding to a single data member of a Mars container
 };
 
Index: trunk/MagicSoft/Mars/mdata/MDataValue.h
===================================================================
--- trunk/MagicSoft/Mars/mdata/MDataValue.h	(revision 1480)
+++ trunk/MagicSoft/Mars/mdata/MDataValue.h	(revision 1481)
@@ -31,5 +31,5 @@
     TString GetRule() const;
 
-    ClassDef(MDataValue, 0) // MData object corresponding to a single value
+    ClassDef(MDataValue, 1) // MData object corresponding to a single value
 };
 
Index: trunk/MagicSoft/Mars/mfilter/MF.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MF.cc	(revision 1480)
+++ trunk/MagicSoft/Mars/mfilter/MF.cc	(revision 1481)
@@ -71,6 +71,7 @@
 #include "MF.h"
 
+#include <ctype.h>        // isalnum, ...
 #include <stdlib.h>       // strtod, ...
-#include <ctype.h>        // isalnum, ...
+#include <fstream.h>      // ofstream, ...
 
 #include <TMethodCall.h>
@@ -368,2 +369,8 @@
     return fFilter->IsExpressionTrue();
 }
+
+void MF::StreamPrimitive(ofstream &out) const
+{
+    out << "   MF " << ToLower(fName) << "";
+}
+
Index: trunk/MagicSoft/Mars/mfilter/MF.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MF.h	(revision 1480)
+++ trunk/MagicSoft/Mars/mfilter/MF.h	(revision 1481)
@@ -24,4 +24,6 @@
     MFilter *ParseString(TString txt, Int_t level);
 
+    void StreamPrimitive(ofstream &out) const;
+
 public:
     MF(const char *text, const char *name=NULL, const char *title=NULL);
Index: trunk/MagicSoft/Mars/mfilter/MFAlpha.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFAlpha.cc	(revision 1480)
+++ trunk/MagicSoft/Mars/mfilter/MFAlpha.cc	(revision 1481)
@@ -28,12 +28,13 @@
 //                                                                         //
 /////////////////////////////////////////////////////////////////////////////
-
 #include "MFAlpha.h"
 
 #include <math.h>
+#include <fstream.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
 
 #include "MParList.h"
-#include "MLog.h"
-#include "MLogManip.h"
 
 #include "MHillasSrc.h"
@@ -53,5 +54,5 @@
 // --------------------------------------------------------------------------
 //
-MFAlpha::MFAlpha(const MHillasSrc *hillas, const char type, const Float_t val,
+MFAlpha::MFAlpha(MHillasSrc *hillas, const char type, const Float_t val,
                  const char *name, const char *title) : fHillas(hillas)
 {
@@ -111,2 +112,17 @@
 }
 
+void MFAlpha::StreamPrimitive(ofstream &out) const
+{
+    if (fHillas)
+        fHillas->SavePrimitive(out);
+
+    out << "   MFParticleId " << ToLower(fName) << "(";
+
+    if (fHillas)
+        out << "&" << ToLower(fHillas->GetName());
+    else
+        out << "\"" << fContName << "\"";
+
+    out << ", '" << (fFilterType==kELowerThan?"<":">") << "', " << fValue << ");" << endl;
+
+}
Index: trunk/MagicSoft/Mars/mfilter/MFAlpha.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFAlpha.h	(revision 1480)
+++ trunk/MagicSoft/Mars/mfilter/MFAlpha.h	(revision 1481)
@@ -18,5 +18,5 @@
 {
 private:
-    const MHillasSrc *fHillas;
+    MHillasSrc *fHillas;
     TString fContName;
 
@@ -24,5 +24,5 @@
     FilterType_t fFilterType;
 
-    Bool_t  fResult;
+    Bool_t  fResult; //!
     Float_t fValue; // [deg]
 
@@ -30,8 +30,10 @@
               const char *name, const char *title);
 
+    void StreamPrimitive(ofstream &out) const;
+
 public:
-    MFAlpha(const char       *cname="MHillas", const char type='>', const Float_t deg=15,
+    MFAlpha(const char *cname="MHillas", const char type='>', const Float_t deg=15,
             const char *name=NULL, const char *title=NULL);
-    MFAlpha(const MHillasSrc *hillas,          const char type='>', const Float_t deg=15,
+    MFAlpha(MHillasSrc *hillas, const char type='>', const Float_t deg=15,
             const char *name=NULL, const char *title=NULL);
 
@@ -40,5 +42,5 @@
     Bool_t Process();
 
-    ClassDef(MFAlpha, 0) // A Filter for cuts in fabs(alpha)
+    ClassDef(MFAlpha, 1) // A Filter for cuts in fabs(alpha)
 };
 
Index: trunk/MagicSoft/Mars/mfilter/MFDataMember.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFDataMember.cc	(revision 1480)
+++ trunk/MagicSoft/Mars/mfilter/MFDataMember.cc	(revision 1481)
@@ -42,6 +42,7 @@
 //
 /////////////////////////////////////////////////////////////////////////////
+#include "MFDataMember.h"
 
-#include "MFDataMember.h"
+#include <fstream.h>
 
 #include <TMethodCall.h>
@@ -97,5 +98,21 @@
 void MFDataMember::Print(Option_t *) const
 {
-    fData.Print();
-    *fLog << (fFilterType==kELowerThan?"<":">") << fValue << flush;
+    *fLog << GetRule() << flush;
 }
+
+void MFDataMember::StreamPrimitive(ofstream &out) const
+{
+    out << "   MFDataMember " << ToLower(fName) << "(\"";
+    out << fData.GetRule() << "\", '";
+    out << (fFilterType==kELowerThan?"<":">");
+    out << "', " << fValue << ");" << endl;
+}
+
+TString MFDataMember::GetRule() const
+{
+    TString ret = fData.GetRule();
+    ret += fFilterType==kELowerThan?"<":">";
+    ret += fValue;
+    return ret;
+}
+
Index: trunk/MagicSoft/Mars/mfilter/MFDataMember.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFDataMember.h	(revision 1480)
+++ trunk/MagicSoft/Mars/mfilter/MFDataMember.h	(revision 1481)
@@ -25,6 +25,8 @@
     FilterType_t fFilterType;
 
-    Bool_t  fResult;
+    Bool_t  fResult;           //!
     Double_t fValue;
+
+    void StreamPrimitive(ofstream &out) const;
 
 public:
@@ -37,6 +39,7 @@
 
     void Print(Option_t *opt = "") const;
+    TString GetRule() const;
 
-    ClassDef(MFDataMember, 0) // A Filter for cuts in any data member
+    ClassDef(MFDataMember, 1) // A Filter for cuts in any data member
 };
 
Index: trunk/MagicSoft/Mars/mfilter/MFParticleId.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFParticleId.cc	(revision 1480)
+++ trunk/MagicSoft/Mars/mfilter/MFParticleId.cc	(revision 1481)
@@ -25,13 +25,19 @@
 /////////////////////////////////////////////////////////////////////////////
 //                                                                         //
-//   MFParticleId                                                         //
+//   MFParticleId                                                          //
+//                                                                         //
+//  A filter to choose between different particle types, identified by     //
+//  their monte carlo particle type. For a list of idetifiers see          //
+//  mbase/MAGIC.h                                                          //
 //                                                                         //
 /////////////////////////////////////////////////////////////////////////////
-
 #include "MFParticleId.h"
 
-#include "MParList.h"
+#include <fstream.h>
+
 #include "MLog.h"
 #include "MLogManip.h"
+
+#include "MParList.h"
 
 #include "MMcEvt.hxx"
@@ -51,5 +57,5 @@
 // --------------------------------------------------------------------------
 //
-MFParticleId::MFParticleId(const MMcEvt *mcevt, const char type, const Int_t val,
+MFParticleId::MFParticleId(MMcEvt *mcevt, const char type, const Int_t val,
                            const char *name, const char *title) : fMcEvt(mcevt)
 {
@@ -117,2 +123,38 @@
 }
 
+void MFParticleId::StreamPrimitive(ofstream &out) const
+{
+    if (fMcEvt)
+        fMcEvt->SavePrimitive(out);
+
+    out << "   MFParticleId " << ToLower(fName) << "(";
+
+    if (fMcEvt)
+        out << "&" << ToLower(fMcEvt->GetName());
+    else
+        out << "\"" << fContName << "\"";
+
+    out << ", '" << (fFilterType==kEEqual?"=":"!") << "', ";
+
+    switch (fValue)
+    {
+    case kGAMMA:
+        out << "kGAMMA";
+        break;
+    case kPROTON:
+        out << "kPROTON";
+        break;
+    case kHELIUM:
+        out << "kHELIUM";
+        break;
+    case kOXYGEN:
+        out << "kOXYGEN";
+        break;
+    case kIRON:
+        out << "kIRON";
+        break;
+    default:
+        out << fValue;
+    }
+    out << ");" << endl;
+}
Index: trunk/MagicSoft/Mars/mfilter/MFParticleId.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFParticleId.h	(revision 1480)
+++ trunk/MagicSoft/Mars/mfilter/MFParticleId.h	(revision 1481)
@@ -18,5 +18,5 @@
 {
 private:
-    const MMcEvt *fMcEvt;
+    MMcEvt *fMcEvt;
     TString fContName;
 
@@ -24,5 +24,5 @@
     FilterType_t fFilterType;
 
-    Bool_t fResult;
+    Bool_t fResult;    //!
     Int_t  fValue;
 
@@ -30,8 +30,10 @@
               const char *name, const char *title);
 
+    void StreamPrimitive(ofstream &out) const;
+
 public:
     MFParticleId(const char *cname="MMcEvt", const char type='=', const Int_t val=0,
                  const char *name=NULL, const char *title=NULL);
-    MFParticleId(const MMcEvt *mcevt, const char type='=', const Int_t val=0,
+    MFParticleId(MMcEvt *mcevt, const char type='=', const Int_t val=0,
                  const char *name=NULL, const char *title=NULL);
 
@@ -40,5 +42,5 @@
     Bool_t Process();
 
-    ClassDef(MFParticleId, 0)		// A Filter for the Level 1 Trigger
+    ClassDef(MFParticleId, 1)		// A Filter for the Level 1 Trigger
 };
 
Index: trunk/MagicSoft/Mars/mfilter/MFTriggerLvl1.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFTriggerLvl1.cc	(revision 1480)
+++ trunk/MagicSoft/Mars/mfilter/MFTriggerLvl1.cc	(revision 1481)
@@ -28,10 +28,12 @@
 //                                                                         //
 /////////////////////////////////////////////////////////////////////////////
-
 #include "MFTriggerLvl1.h"
 
-#include "MParList.h"
+#include <fstream.h>
+
 #include "MLog.h"
 #include "MLogManip.h"
+
+#include "MParList.h"
 
 #include "MMcTrig.hxx"
@@ -51,5 +53,5 @@
 // --------------------------------------------------------------------------
 //
-MFTriggerLvl1::MFTriggerLvl1(const MMcTrig *mctrig, const char type, const Int_t val,
+MFTriggerLvl1::MFTriggerLvl1(MMcTrig *mctrig, const char type, const Int_t val,
                              const char *name, const char *title) : fMcTrig(mctrig)
 {
@@ -116,2 +118,17 @@
 }
 
+void MFTriggerLvl1::StreamPrimitive(ofstream &out) const
+{
+    if (fMcTrig)
+        fMcTrig->SavePrimitive(out);
+
+    out << "   MFTriggerLvl1 " << ToLower(fName) << "(";
+
+    if (fMcTrig)
+        out << "&" << ToLower(fMcTrig->GetName());
+    else
+        out << "\"" << fContName << "\"";
+
+    out << ", '" << (fFilterType==kELowerThan?"<":">") << "', " << fValue << ");" << endl;
+
+}
Index: trunk/MagicSoft/Mars/mfilter/MFTriggerLvl1.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFTriggerLvl1.h	(revision 1480)
+++ trunk/MagicSoft/Mars/mfilter/MFTriggerLvl1.h	(revision 1481)
@@ -18,11 +18,11 @@
 {
 private:
-    const MMcTrig *fMcTrig;
+    MMcTrig *fMcTrig;
     TString fContName;
 
     typedef enum { kELowerThan, kEGreaterThan } FilterType_t;
-    FilterType_t fFilterType;
+    FilterType_t fFilterType; 
 
-    Bool_t fResult;
+    Bool_t fResult;             //!
     Int_t  fValue;
 
@@ -30,8 +30,10 @@
               const char *name, const char *title);
 
+    void StreamPrimitive(ofstream &out) const;
+
 public:
     MFTriggerLvl1(const char *cname="MMcTrig", const char type='>', const Int_t val=0,
                   const char *name=NULL, const char *title=NULL);
-    MFTriggerLvl1(const MMcTrig *mctrig,       const char type='>', const Int_t val=0,
+    MFTriggerLvl1(MMcTrig *mctrig, const char type='>', const Int_t val=0,
                   const char *name=NULL, const char *title=NULL);
 
@@ -40,5 +42,5 @@
     Bool_t Process();
 
-    ClassDef(MFTriggerLvl1, 0)		// A Filter for the Level 1 Trigger
+    ClassDef(MFTriggerLvl1, 1) // A Filter for the Level 1 Trigger
 };
 
Index: trunk/MagicSoft/Mars/mhist/MFillH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MFillH.cc	(revision 1480)
+++ trunk/MagicSoft/Mars/mhist/MFillH.cc	(revision 1481)
@@ -364,10 +364,10 @@
     else
         out << "\"" << fHName << "\"";
-    out << ", ";
 
     if (fParContainer)
-        out << "&" << ToLower(fParContainer->GetName());
+        out << ", &" << ToLower(fParContainer->GetName());
     else
-        out << "\"" << fParContainerName << "\"";
+        if (!fParContainerName.IsNull())
+            out << ", \"" << fParContainerName << "\"";
 
     out << ");" << endl;
Index: trunk/MagicSoft/Mars/mhist/MH3.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MH3.cc	(revision 1480)
+++ trunk/MagicSoft/Mars/mhist/MH3.cc	(revision 1481)
@@ -384,5 +384,5 @@
 // gui elements to a macro-file.
 //
-void MH3::StreamPrimitive(ofstream &out)
+void MH3::StreamPrimitive(ofstream &out) const
 {
     TString name = ToLower(fName);
Index: trunk/MagicSoft/Mars/mhist/MH3.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MH3.h	(revision 1480)
+++ trunk/MagicSoft/Mars/mhist/MH3.h	(revision 1481)
@@ -24,5 +24,5 @@
     Double_t    fScale[3];
 
-    void StreamPrimitive(ofstream &out);
+    void StreamPrimitive(ofstream &out) const;
 
 public:
