Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 1217)
+++ trunk/MagicSoft/Mars/Changelog	(revision 1218)
@@ -1,3 +1,31 @@
                                                                   -*-*- END -*-*-
+
+ 2002/02/21: Thomas Bretz
+ 
+   * manalysis/MHillas.[h,cc]:
+     - changed fMeanx and fMeany to fMeanX and fMeanY to match the names
+       of the getter functions, needed by TDataMember::GetterMethod
+     - commented out WriteAscii (replaced by more general in MParContainer
+       and MWriteAsciiFile)
+
+    * manalysis/MHillasSrc.[h,cc], mmc/MMcEvt.[hxx, cxx]:
+      - commented out WriteAscii (replaced by more general in MParContainer
+        and MWriteAsciiFile)
+     
+    * mbase/MFilterList.cc:
+      - removed a nonsens comment
+    
+    * mbase/MGList.cc:
+      - relay on the bugfix for DynamicCast
+    
+    * mbase/MParContainer.[h,cc]:
+      - implemented WriteDataMember to have a more general interface
+        for readable output.
+      - changed ofstream to a more general ostream
+  
+    * mbase/MWriteAsciiFile.[cc,h]:
+      - generalized ascii writer to be able to write single data members
+
+
 
  2002/02/13: Thomas Bretz
Index: trunk/MagicSoft/Mars/macros/MagicHillas.C
===================================================================
--- trunk/MagicSoft/Mars/macros/MagicHillas.C	(revision 1217)
+++ trunk/MagicSoft/Mars/macros/MagicHillas.C	(revision 1218)
@@ -104,5 +104,5 @@
     MFillH hfill2s("HistSource  [MHHillasSrc]", "HillasSource");
     MFillH hfill2a("HistAntiSrc [MHHillasSrc]", "HillasAntiSrc");
-
+/*
     MWriteRootFile write("hillas.root");
     write.AddContainer("MHillas",       "Hillas");
@@ -110,4 +110,9 @@
     write.AddContainer("HillasAntiSrc", "Hillas");
     write.AddContainer("MHStarMap");
+*/
+    MWriteAsciiFile write("hillas.txt");
+    write.AddContainer("MHillas", "fLength");
+    write.AddContainer("MHillas", "fWidth");
+    write.AddContainer("MHillas");
 
     tlist.AddToList(&read);
@@ -135,6 +140,8 @@
     // Execute your analysis
     //
-    if (!evtloop.Eventloop())
+    if (!evtloop.Eventloop(5))
         return;
+
+    return;
 
     tlist.PrintStatistics();
Index: trunk/MagicSoft/Mars/manalysis/MHillas.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MHillas.cc	(revision 1217)
+++ trunk/MagicSoft/Mars/manalysis/MHillas.cc	(revision 1218)
@@ -36,6 +36,6 @@
 // fDelta    angle of major axis wrt x-axis
 // fSize     total sum of pixels
-// fMeanx    x of center of ellipse
-// fMeany    y of center of ellipse
+// fMeanX    x of center of ellipse
+// fMeanY    y of center of ellipse
 //
 /////////////////////////////////////////////////////////////////////////////
@@ -89,6 +89,6 @@
     fDelta  = 0;
     fSize   = 0;
-    fMeanx  = 0;
-    fMeany  = 0;
+    fMeanX  = 0;
+    fMeanY  = 0;
 
     Clear();
@@ -101,5 +101,5 @@
 void MHillas::Print(Option_t *) const
 {
-    Double_t atg = atan2(fMeany, fMeanx)*kRad2Deg;
+    Double_t atg = atan2(fMeanY, fMeanX)*kRad2Deg;
 
     if (atg<0)
@@ -110,6 +110,6 @@
     *fLog << " - Length   [mm]  = " << fLength << endl;
     *fLog << " - Width    [mm]  = " << fWidth  << endl;
-    *fLog << " - Meanx    [mm]  = " << fMeanx  << endl;
-    *fLog << " - Meany    [mm]  = " << fMeany  << endl;
+    *fLog << " - Meanx    [mm]  = " << fMeanX  << endl;
+    *fLog << " - Meany    [mm]  = " << fMeanY  << endl;
     *fLog << " - Delta    [deg] = " << fDelta*kRad2Deg << endl;
     *fLog << " - atg(y/x) [deg] = " << atg     << endl;
@@ -125,5 +125,5 @@
 {
      fEllipse->SetLineWidth(2);
-     fEllipse->PaintEllipse(fMeanx, fMeany, fLength, fWidth,
+     fEllipse->PaintEllipse(fMeanX, fMeanY, fLength, fWidth,
                             0, 360, fDelta*kRad2Deg+180);
 }
@@ -143,5 +143,5 @@
     Clear();
 
-    fEllipse = new TEllipse(fMeanx, fMeany, fLength, fWidth,
+    fEllipse = new TEllipse(fMeanX, fMeanY, fLength, fWidth,
                             0, 360, fDelta*kRad2Deg+180);
 
@@ -155,9 +155,9 @@
      fEllipse->SetR2(fWidth);
      fEllipse->SetTheta(fDelta*kRad2Deg+180);
-     fEllipse->SetX1(fMeanx);
-     fEllipse->SetY1(fMeany);
+     fEllipse->SetX1(fMeanX);
+     fEllipse->SetY1(fMeanY);
 
      fEllipse->SetLineWidth(2);
-     fEllipse->PaintEllipse(fMeanx, fMeany, fLength, fWidth,
+     fEllipse->PaintEllipse(fMeanX, fMeanY, fLength, fWidth,
                             0, 360, fDelta*kRad2Deg+180);
 
@@ -216,6 +216,6 @@
     // -----------------------------------------------------
     //
-    fMeanx = 0;
-    fMeany = 0;
+    fMeanX = 0;
+    fMeanY = 0;
     fSize  = 0;
 
@@ -236,6 +236,6 @@
 
         fSize  += nphot;		             // [counter]
-        fMeanx += nphot * gpix.GetX();               // [mm]
-        fMeany += nphot * gpix.GetY();               // [mm]
+        fMeanX += nphot * gpix.GetX();               // [mm]
+        fMeanY += nphot * gpix.GetY();               // [mm]
 
         npix++;
@@ -248,6 +248,6 @@
         return kFALSE;
 
-    fMeanx /= fSize;                                 // [mm]
-    fMeany /= fSize;                                 // [mm]
+    fMeanX /= fSize;                                 // [mm]
+    fMeanY /= fSize;                                 // [mm]
 
     //
@@ -267,6 +267,6 @@
 
         const MGeomPix &gpix = geom[pix.GetPixId()];
-        const float dx = gpix.GetX() - fMeanx;       // [mm]
-        const float dy = gpix.GetY() - fMeany;       // [mm]
+        const float dx = gpix.GetX() - fMeanX;       // [mm]
+        const float dy = gpix.GetY() - fMeanY;       // [mm]
 
         const float nphot = pix.GetNumPhotons();     // [#phot]
@@ -311,10 +311,10 @@
     fin >> fDelta;
     fin >> fSize;
-    fin >> fMeanx;
-    fin >> fMeany;
-}
-
-// --------------------------------------------------------------------------
-//
+    fin >> fMeanX;
+    fin >> fMeanY;
+}
+
+// --------------------------------------------------------------------------
+/*
 void MHillas::AsciiWrite(ofstream &fout) const
 {
@@ -323,5 +323,6 @@
     fout << fDelta  << " ";
     fout << fSize   << " ";
-    fout << fMeanx  << " ";
-    fout << fMeany;
-}
+    fout << fMeanX  << " ";
+    fout << fMeanY;
+}
+*/
Index: trunk/MagicSoft/Mars/manalysis/MHillas.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MHillas.h	(revision 1217)
+++ trunk/MagicSoft/Mars/manalysis/MHillas.h	(revision 1218)
@@ -19,6 +19,6 @@
     Float_t   fDelta;    // [rad]       angle of major axis with x-axis
     Float_t   fSize;     // [#CerPhot]  sum of content of all pixels (number of Cherenkov photons)
-    Float_t   fMeanx;    // [mm]        x-coordinate of center of ellipse
-    Float_t   fMeany;    // [mm]        y-coordinate of center of ellipse
+    Float_t   fMeanX;    // [mm]        x-coordinate of center of ellipse
+    Float_t   fMeanY;    // [mm]        y-coordinate of center of ellipse
 
     Float_t   fSinDelta; //! [1] sin of Delta (to be used in derived classes)
@@ -53,9 +53,9 @@
     Float_t GetDelta() const  { return fDelta; }
     Float_t GetSize() const   { return fSize; }
-    Float_t GetMeanX() const  { return fMeanx; }
-    Float_t GetMeanY() const  { return fMeany; }
+    Float_t GetMeanX() const  { return fMeanX; }
+    Float_t GetMeanY() const  { return fMeanY; }
 
     virtual void AsciiRead(ifstream &fin);
-    virtual void AsciiWrite(ofstream &fout) const;
+    //virtual void AsciiWrite(ofstream &fout) const;
 
     ClassDef(MHillas, 1) // Storage Container for Hillas Parameter
Index: trunk/MagicSoft/Mars/manalysis/MHillasSrc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MHillasSrc.cc	(revision 1217)
+++ trunk/MagicSoft/Mars/manalysis/MHillasSrc.cc	(revision 1218)
@@ -101,7 +101,8 @@
 //
 // overloaded MParContainer to write MHillasSrc to an ascii file
-//
+/*
 void MHillasSrc::AsciiWrite(ofstream &fout) const
 {
     fout << fAlpha << " " << fDist;
 }
+*/
Index: trunk/MagicSoft/Mars/manalysis/MHillasSrc.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MHillasSrc.h	(revision 1217)
+++ trunk/MagicSoft/Mars/manalysis/MHillasSrc.h	(revision 1218)
@@ -37,5 +37,5 @@
 
     virtual void AsciiRead(ifstream &fin);
-    virtual void AsciiWrite(ofstream &fout) const;
+    //virtual void AsciiWrite(ofstream &fout) const;
 
     ClassDef(MHillasSrc, 1) // Container to hold source position dependant parameters
Index: trunk/MagicSoft/Mars/mbase/MFilterList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MFilterList.cc	(revision 1217)
+++ trunk/MagicSoft/Mars/mbase/MFilterList.cc	(revision 1218)
@@ -143,6 +143,4 @@
     const char *name = filter->GetName();
 
-    // FIXME: We agreed to put the task into list in an ordered way.
-
     if (fFilters.FindObject(filter))
     {
Index: trunk/MagicSoft/Mars/mbase/MGList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MGList.cc	(revision 1217)
+++ trunk/MagicSoft/Mars/mbase/MGList.cc	(revision 1218)
@@ -98,6 +98,8 @@
     //      Is this another bug in root?
     //
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,07)
     if (!obj->IsA()->InheritsFrom(TGWidget::Class()))
         return NULL;
+#endif
 
     return (TGWidget*)obj->IsA()->DynamicCast(TGWidget::Class(), obj);
Index: trunk/MagicSoft/Mars/mbase/MParContainer.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 1217)
+++ trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 1218)
@@ -214,4 +214,51 @@
 // --------------------------------------------------------------------------
 //
+//  Write out a data member given as a TDataMember object to an output stream.
+//
+Bool_t MParContainer::WriteDataMember(ostream &out, TDataMember *member) const
+{
+    if (!member)
+        return kFALSE;
+
+    if (!member->IsPersistent())
+        return kFALSE;
+
+    /*const*/ TMethodCall *call = member->GetterMethod(); //FIXME: Root
+    if (!call)
+        return kFALSE;
+
+    switch (call->ReturnType())
+    {
+    case TMethodCall::kLong:
+        Long_t l;
+        call->Execute((void*)this, l); // FIXME: const, root
+        out << l << " ";
+        return kTRUE;
+
+    case TMethodCall::kDouble:
+        Double_t d;
+        call->Execute((void*)this, d); // FIXME: const, root
+        out << d << " ";
+        return kTRUE;
+
+    case TMethodCall::kOther:
+        /* someone may want to enhance this? */
+        return kFALSE;
+    }
+
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Write out a data member given by name to an output stream.
+//
+Bool_t MParContainer::WriteDataMember(ostream &out, const char *member) const
+{
+    return WriteDataMember(out, IsA()->GetDataMember(member));
+}
+
+// --------------------------------------------------------------------------
+//
 //  If you want to use Ascii-Input/-Output (eg. MWriteAsciiFile) of a
 //  container, you may overload this function. If you don't overload it
@@ -221,5 +268,5 @@
 //  floating point (Float_t, Double_t, ...) type are written.
 //
-void MParContainer::AsciiWrite(ofstream &fout) const
+void MParContainer::AsciiWrite(ostream &out) const
 {
     // *fLog << warn << "To use the the ascii output of " << GetName();
@@ -230,30 +277,4 @@
     TIter Next(IsA()->GetListOfDataMembers());
     while ((data=(TDataMember*)Next()))
-    {
-        if (!data->IsPersistent())
-            continue;
-
-        /*const*/ TMethodCall *call = data->GetterMethod(); //FIXME: Root
-        if (!call)
-            continue;
-
-        switch (call->ReturnType())
-        {
-        case TMethodCall::kLong:
-            Long_t l;
-            call->Execute((void*)this, l); // FIXME: const, root
-            fout << l << " ";
-            continue;
-
-        case TMethodCall::kDouble:
-            Double_t d;
-            call->Execute((void*)this, d); // FIXME: const, root
-            fout << d << " ";
-            continue;
-
-        case TMethodCall::kOther:
-            /* someone may want to enhance this? */
-            continue;
-        }
-    }
-}
+        WriteDataMember(out, data);
+}
Index: trunk/MagicSoft/Mars/mbase/MParContainer.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParContainer.h	(revision 1217)
+++ trunk/MagicSoft/Mars/mbase/MParContainer.h	(revision 1218)
@@ -22,4 +22,6 @@
 class ofstream;
 class ifstream;
+
+class TDataMember;
 
 class MParContainer : public TObject
@@ -64,6 +66,9 @@
     virtual void   SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; }
 
+    Bool_t WriteDataMember(ostream &out, const char *member) const;
+    Bool_t WriteDataMember(ostream &out, TDataMember *member) const;
+
     virtual void AsciiRead(ifstream &fin);
-    virtual void AsciiWrite(ofstream &fout) const;
+    virtual void AsciiWrite(ostream &out) const;
 
     ClassDef(MParContainer, 0)  //The basis for all parameter containers
Index: trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc	(revision 1217)
+++ trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc	(revision 1218)
@@ -44,4 +44,8 @@
 #include <fstream.h>
 
+#include <TClass.h>      // IsA
+#include <TMethodCall.h> // TMethodCall, AsciiWrite
+#include <TDataMember.h> // TDataMember, AsciiWrite
+
 #include "MLog.h"
 #include "MLogManip.h"
@@ -81,5 +85,6 @@
     Init(filename, name, title);
 
-    AddContainer(contname);
+    if (contname)
+        AddContainer(contname);
 }
 
@@ -100,5 +105,6 @@
     Init(filename, name, title);
 
-    AddContainer(cont);
+    if (cont)
+        AddContainer(cont);
 }
 
@@ -111,4 +117,5 @@
 {
     fContNames.SetOwner();
+    fMembers.SetOwner();
 
     delete fOut;
@@ -130,12 +137,22 @@
     Int_t num = fContainer.GetEntries();
 
-    TIter Next(&fContainer);
-
-    while ((cont=(MParContainer*)Next()))
+    TIter NextCont(&fContainer);
+    TIter NextMemb(&fMembers);
+
+    while ((cont=(MParContainer*)NextCont()))
     {
+        const TObject *memb = NextMemb();
+
         if (!cont->IsReadyToSave())
             continue;
 
-        cont->AsciiWrite(*fOut);
+        if (memb->GetName()[0]=='\0')
+            cont->AsciiWrite(*fOut);
+        else
+        {
+            if (!cont->WriteDataMember(*fOut, memb->GetName()))
+                continue;
+        }
+
         *fOut << " ";
         written = kTRUE;
@@ -183,5 +200,5 @@
         }
 
-        AddContainer(cont);
+        AddContainer(cont, obj->GetTitle());
     }
 
@@ -193,8 +210,12 @@
 // Add another container (by name) to be written to the ascii file.
 // The container will be output one after each other in one line.
-//
-void MWriteAsciiFile::AddContainer(const char *cname)
-{
-    TNamed *named = new TNamed(cname, "");
+// If you want to write only one data member of the container
+// specify the name of the data member (eg. fAlpha) Make sure,
+// that a "GetteMethod" for this data type exists (strif the f and
+// replace it by Get)
+//
+void MWriteAsciiFile::AddContainer(const char *cname, const char *member)
+{
+    TNamed *named = new TNamed(cname, member);
     fContNames.AddLast(named);
 }
@@ -204,8 +225,15 @@
 // Add another container (by pointer) to be written to the ascii file.
 // The container will be output one after each other in one line.
-//
-void MWriteAsciiFile::AddContainer(MParContainer *cont)
+// If you want to write only one data member of the container
+// specify the name of the data member (eg. fAlpha) Make sure,
+// that a "GetteMethod" for this data type exists (strif the f and
+// replace it by Get)
+//
+void MWriteAsciiFile::AddContainer(MParContainer *cont, const char *member)
 {
     fContainer.AddLast(cont);
-}
-
+
+    TNamed *named = new TNamed(member, "");
+    fMembers.AddLast(named);
+}
+
