Index: /trunk/MagicSoft/Mars/mfileio/MReadFiles.cc
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MReadFiles.cc	(revision 9031)
+++ /trunk/MagicSoft/Mars/mfileio/MReadFiles.cc	(revision 9032)
@@ -30,4 +30,6 @@
 #include "MReadFiles.h"
 
+#include <errno.h>
+
 #include <TObjString.h>
 
Index: /trunk/MagicSoft/Mars/mfileio/MReadFiles.h
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MReadFiles.h	(revision 9031)
+++ /trunk/MagicSoft/Mars/mfileio/MReadFiles.h	(revision 9032)
@@ -20,21 +20,23 @@
     MParList *fParList;    //! Parlist for reinitialization
 
+    virtual Bool_t AnalyzeHeader(MParList &plist)=0;
+    virtual Bool_t ReadHeader()=0;
+    virtual Int_t  ReadEvent()=0;
+
 protected:
     MZlib    *fIn;         // the inputfile
 
+    // MReadFiles
     Bool_t ReadLine(TString &line);
 
     UInt_t GetNumLine() const { return fNumLine; }
 
+    Bool_t OpenNextFile(Int_t num=-1);
+    Bool_t CheckFile(TString name) const;
+
+    // MTask
     Int_t  PreProcess(MParList *pList);
     Int_t  Process();
-
-private:
-    Bool_t OpenNextFile();
-    Bool_t CheckFile(TString name) const;
-
-    virtual Bool_t AnalyzeHeader(MParList &plist)=0;
-    virtual Bool_t ReadHeader()=0;
-    virtual Int_t  ReadEvent()=0;
+    Int_t  PostProcess();
 
 public:
Index: /trunk/MagicSoft/Mars/mfileio/MReadRflFile.cc
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MReadRflFile.cc	(revision 9031)
+++ /trunk/MagicSoft/Mars/mfileio/MReadRflFile.cc	(revision 9032)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 5/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2003
+!   Copyright: MAGIC Software Development, 2000-2008
 !
 !
@@ -31,8 +31,4 @@
 /////////////////////////////////////////////////////////////////////////////
 #include "MReadRflFile.h"
-
-#include <errno.h>
-
-#include <TSystem.h>
 
 #include "structures_rfl.h"
@@ -236,5 +232,5 @@
 }
 
-Int_t MReadRflFile::Process()
+Int_t MReadRflFile::ReadEvent()
 {
     for (;;)
@@ -246,6 +242,8 @@
 
         case kEndOfFile:
-            if (!OpenNextFile())
-                return kFALSE;
+            Close();
+            return kCONTINUE; // FIXME: CHECK
+//            if (!OpenNextFile())
+//                return kFALSE;
             /* FALLTHROU */
         case kStartOfRun:
@@ -265,4 +263,35 @@
 }
 
+/*
+Int_t MReadRflFile::Process()
+{
+    for (;;)
+    {
+        switch (EvalFlag())
+        {
+        case kError:
+            return kFALSE;
+
+        case kEndOfFile:
+            if (!OpenNextFile())
+                return kFALSE;
+            // FALLTHROU
+        case kStartOfRun:
+        case kEndOfRun:
+            continue;
+
+        case kStartOfEvtData:
+            break;
+        }
+        break;
+    }
+
+    if (!ReadEvtHeader())
+        return kFALSE;
+
+    return ReadEvtData();
+}
+*/
+
 Int_t MReadRflFile::PreProcess(MParList *plist)
 {
@@ -279,73 +308,20 @@
         return kFALSE;
 
-    Rewind();
-
-    return OpenNextFile();
-}
-
-// --------------------------------------------------------------------------
-//
-// This opens the next file in the list and deletes its name from the list.
-//
-Bool_t MReadRflFile::OpenNextFile()
-{
-    //
-    // open the input stream and check if it is really open (file exists?)
-    //
-    if (fIn)
-        delete fIn;
-    fIn = NULL;
-
-    //
-    // Check for the existence of a next file to read
-    //
-    if (fNumFile >= (UInt_t)fFileNames->GetSize())
-    {
-        *fLog << inf << GetDescriptor() << ": No unread files anymore..." << endl;
-        return kFALSE;
-    }
-
-    TNamed *file = (TNamed*)fFileNames->At(fNumFile);
-
-    //TNamed *file = (TNamed*)fFileNames->GetFirst();
-    //if (!file)
-    //    return kFALSE;
-
-    //
-    // open the file which is the first one in the chain
-    //
-    fFileName = file->GetName();
-    TString expname = fFileName;
-    gSystem->ExpandPathName(expname);
-
-    //
-    // Remove this file from the list of pending files
-    //
-    //fFileNames->Remove(file);
-
-    *fLog << inf << "Open file: '" << fFileName << "'" << endl;
-
-    fIn = new MZlib(expname);
-    if (!*fIn)
-    {
-        *fLog << err << "Cannot open file " << expname << ": ";
-        *fLog << strerror(errno) << endl;
-        return kFALSE;
-    }
-
-    *fLog << inf;
-    fLog->Separator(fFileName);
-
+    return MReadFiles::PreProcess(plist);
+}
+
+Bool_t MReadRflFile::ReadHeader()
+{
     fCurrentVersion = ReadVersion();
     if (fCurrentVersion<0)
     {
-        cout << "ERROR reading signature." << endl;
-        return kFALSE;
-    }
-    cout << "Version " << fCurrentVersion << endl << endl;
-
-    fNumFile++;
+        *fLog << err << "ERROR reading signature." << endl;
+        return kFALSE;
+    }
+    *fLog << inf << "Version " << fCurrentVersion << endl << endl;
+
     return kTRUE;
 }
+
 
 /****************************************************/
@@ -384,62 +360,9 @@
 //
 MReadRflFile::MReadRflFile(const char *fname, const char *name,
-                           const char *title) : fIn(NULL), fEntries(0)
+                           const char *title) : MReadFiles(fname, name, title)
 {
     fName  = name  ? name  : "MRead";
     fTitle = title ? title : "Reads a Reflector output file";
-
-    //
-    // remember file name for opening the file in the preprocessor
-    //
-    fFileNames = new TList;
-    fFileNames->SetOwner();
-
-    if (fname)
-        AddFile(fname);
-}
-
-// --------------------------------------------------------------------------
-//
-// Delete the filename list and the input stream if one exists.
-//
-MReadRflFile::~MReadRflFile()
-{
-    delete fFileNames;
-    if (fIn)
-        delete fIn;
-}
-
-// --------------------------------------------------------------------------
-//
-// Add this file as the last entry in the chain
-//
-Int_t MReadRflFile::AddFile(const char *txt, int)
-{
-    const char *name = gSystem->ExpandPathName(txt);
-
-    TString fname(name);
-    delete [] name;
-/*
-    if (!CheckHeader(fname))
-    {
-        *fLog << warn << "WARNING - Problem reading header... ignored." << endl;
-        return;
-    }
-
-    const Int_t n = GetNumEvents(fname);
-    if (n==0)
-    {
-        *fLog << warn << "WARNING - File contains no data... ignored." << endl;
-        return;
-    }
-
-    fEntries += n;
-
-    *fLog << inf << "File " << txt << " contains " << n << " events (Total=" << fEntries << ")" << endl;
-*/
-    fFileNames->AddLast(new TNamed(txt, ""));
-    return 1;
-}
-
+}
 
 Bool_t MReadRflFile::SearchFor(Int_t runno, Int_t eventno)
@@ -448,7 +371,5 @@
         return kFALSE;
 
-    fNumFile = 0;
-    if (!OpenNextFile())
-        return kFALSE;
+    Rewind();
 
     while (1)
@@ -462,3 +383,5 @@
             return kTRUE;
     }
-}
+
+    Close();
+}
Index: /trunk/MagicSoft/Mars/mfileio/MReadRflFile.h
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MReadRflFile.h	(revision 9031)
+++ /trunk/MagicSoft/Mars/mfileio/MReadRflFile.h	(revision 9032)
@@ -2,19 +2,13 @@
 #define MARS_MReadRflFile
 
-#ifndef ROOT_TArrayF
-#include <TArrayF.h>
+#ifndef MARS_MReadFiles
+#include "MReadFiles.h"
 #endif
 
-#ifndef MARS_MRead
-#include "MRead.h"
-#endif
-
-class MZlib;
-class TList;
 class MRflEvtData;
 class MRflEvtHeader;
 class MRflRunHeader;
 
-class MReadRflFile : public MRead
+class MReadRflFile : public MReadFiles
 {
 private:
@@ -29,17 +23,11 @@
     };
 
-    MZlib *fIn;              // the inputfile
-    TList *fFileNames;       // Array which stores the \0-terminated filenames
-
     MRflEvtData   *fEvtData;    //!
     MRflEvtHeader *fEvtHeader;  //!
     MRflRunHeader *fRunHeader;  //!
 
-    UInt_t  fNumFile;
-    UInt_t  fEntries;           // TO BE IMPLEMENTED
-    TString fFileName;
-
     Float_t fCurrentVersion;    //! Version of currently open rfl file
 
+    // MReadRflFile
     float  ReadVersion();
     Bool_t ReadEvtHeader();
@@ -48,21 +36,15 @@
     Bool_t FlagIsA(const  char *s1, const char *flag);
     Int_t  EvalFlag();
-    Bool_t OpenNextFile();
 
+    // MReadFiles
+    Int_t  ReadEvent();
+    Bool_t ReadHeader();
+
+    // MTask
     Int_t PreProcess(MParList *pList);
-    Int_t Process();
 
 public:
-    MReadRflFile(const char *filename=NULL,
-                 const char *name=NULL,
+    MReadRflFile(const char *filename=NULL, const char *name=NULL,
                  const char *title=NULL);
-
-    ~MReadRflFile();
-
-    Int_t AddFile(const char *fname, int i=0);
-
-    Bool_t Rewind() { fNumFile=0; return kTRUE; }
-    UInt_t GetEntries() { return fEntries; }
-    TString GetFullFileName() const { return fFileName; }
 
     Bool_t SearchFor(Int_t runno, Int_t eventno);
