Index: trunk/MagicSoft/Mars/mraw/MRawCrateData.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawCrateData.cc	(revision 3734)
+++ trunk/MagicSoft/Mars/mraw/MRawCrateData.cc	(revision 3800)
@@ -63,4 +63,9 @@
 }
 
+void MRawCrateData::SkipEvt(istream &fin, UShort_t ver)
+{
+    fin.seekg(ver>1?11:10);
+}
+
 // --------------------------------------------------------------------------
 //
Index: trunk/MagicSoft/Mars/mraw/MRawCrateData.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawCrateData.h	(revision 3734)
+++ trunk/MagicSoft/Mars/mraw/MRawCrateData.h	(revision 3800)
@@ -29,4 +29,5 @@
 
     void ReadEvt(istream& fin, UShort_t ver);
+    void SkipEvt(istream& fin, UShort_t ver);
 
     ClassDef(MRawCrateData, 2) //Container to store the Raw CRATE DATA
Index: trunk/MagicSoft/Mars/mraw/MRawEvtData.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 3734)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 3800)
@@ -523,4 +523,18 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Make sure, that you skip the whole event. This function only skips a part
+// of the event - see MRawRead::SkipEvent
+//
+void MRawEvtData::SkipEvt(istream &fin)
+{
+    const UShort_t nlo  = fRunHeader->GetNumSamplesLoGain();
+    const UShort_t nhi  = fRunHeader->GetNumSamplesHiGain();
+    const UShort_t npic = fRunHeader->GetNumPixInCrate();
+
+    fin.seekg((nhi+nlo)*npic, ios::cur);
+}
+
 Bool_t MRawEvtData::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
 {
Index: trunk/MagicSoft/Mars/mraw/MRawEvtData.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtData.h	(revision 3734)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtData.h	(revision 3800)
@@ -71,4 +71,5 @@
 
     void ReadEvt(istream &fin);
+    void SkipEvt(istream &fin);
 
     Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
Index: trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc	(revision 3734)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc	(revision 3800)
@@ -310,6 +310,6 @@
         if (!DecodeTime(abstime))
         {
-            *fLog << err << "ERROR - Event time in event header invalid... abort." << endl;
-            return kFALSE;
+            *fLog << warn << "WARNING - Event time in event header invalid... abort." << endl;
+            return kCONTINUE;
         }
 
@@ -331,4 +331,9 @@
 
     return !fin.eof();
+}
+
+void MRawEvtHeader::SkipEvt(istream &fin, UShort_t ver)
+{
+    fin.seekg(36+fPixLoGainOn->GetSize(), ios::cur);
 }
 
Index: trunk/MagicSoft/Mars/mraw/MRawEvtHeader.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtHeader.h	(revision 3734)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtHeader.h	(revision 3800)
@@ -66,4 +66,5 @@
 
     int ReadEvt(istream& fin, UShort_t ver);
+    void SkipEvt(istream& fin, UShort_t ver);
 
     ClassDef(MRawEvtHeader, 1) // Parameter Conatiner for raw EVENT HEADER
Index: trunk/MagicSoft/Mars/mraw/MRawFileRead.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawFileRead.cc	(revision 3734)
+++ trunk/MagicSoft/Mars/mraw/MRawFileRead.cc	(revision 3800)
@@ -24,17 +24,20 @@
 
 //////////////////////////////////////////////////////////////////////////////
-//                                                                          //
-//  MRawFileRead                                                            //
-//                                                                          //
-//  This tasks reads the raw binary file like specified in the TDAS???      //
-//  and writes the data in the corresponding containers which are           //
-//  either retrieved from the parameter list or created and added.          //
-//                                                                          //
-//  Input Containers:                                                       //
-//   -/-                                                                    //
-//                                                                          //
-//  Output Containers:                                                      //
-//   MRawRunHeader, MRawEvtHeader, MRawEvtData, MRawCrateArray, MRawEvtTime //
-//                                                                          //
+//
+//  MRawFileRead
+//
+//  This tasks reads the raw binary file like specified in the TDAS???
+//  and writes the data in the corresponding containers which are
+//  either retrieved from the parameter list or created and added.
+//
+//  Use SetInterleave() if you don't want to read all events, eg
+//    SetInterleave(5) reads only each 5th event.
+//
+//  Input Containers:
+//   -/-
+//
+//  Output Containers:
+//   MRawRunHeader, MRawEvtHeader, MRawEvtData, MRawCrateArray, MRawEvtTime
+//
 //////////////////////////////////////////////////////////////////////////////
 #include "MRawFileRead.h"
@@ -43,4 +46,6 @@
 #include <fstream>
 
+#include <TSystem.h>
+
 #include "MLog.h"
 #include "MLogManip.h"
@@ -48,4 +53,5 @@
 #include "MTime.h"
 #include "MParList.h"
+
 #include "MRawRunHeader.h"
 #include "MRawEvtHeader.h"
@@ -95,10 +101,13 @@
 //
 MRawFileRead::MRawFileRead(const char *fname, const char *name, const char *title)
-    : fFileName(fname), fIn(NULL)
+    : fFileNames(NULL), fNumFile(0), fIn(NULL), fParList(NULL), fInterleave(1)
 {
     fName  = name  ? name  : "MRawFileRead";
     fTitle = title ? title : "Read task to read DAQ binary files";
 
-    fIn = new ifstream;
+    fFileNames = new TList;
+    fFileNames->SetOwner();
+
+    AddFile(fname);
 }
 
@@ -109,5 +118,130 @@
 MRawFileRead::~MRawFileRead()
 {
-    delete fIn;
+    delete fFileNames;
+    if (fIn)
+        delete fIn;
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a new file to a list of files to be processed, Returns the number
+// of files added. (We can enhance this with a existance chack and
+// wildcard support)
+//
+Int_t MRawFileRead::AddFile(const char *fname)
+{
+    TNamed *name = new TNamed(fname, "");
+    fFileNames->AddLast(name);
+    return 1;
+
+}
+
+// --------------------------------------------------------------------------
+//
+// This opens the next file in the list and deletes its name from the list.
+//
+Bool_t MRawFileRead::OpenNextFile()
+{
+    //
+    // open the input stream and check if it is really open (file exists?)
+    //
+    if (fIn)
+        delete fIn;
+    fIn = NULL;
+
+    //
+    // Check for the existance of a next file to read
+    //
+    TObject *file = fFileNames->At(fNumFile);
+    if (!file)
+        return kFALSE;
+
+    //
+    // open the file which is the first one in the chain
+    //
+    const char *name = file->GetName();
+
+    const char *expname = gSystem->ExpandPathName(name);
+    fIn = new ifstream(expname);
+
+    const Bool_t noexist = !(*fIn);
+    if (noexist)
+    {
+        *fLog << err << "Cannot open file " << expname << ": ";
+        *fLog << strerror(errno) << endl;
+    }
+    else
+        *fLog << inf << "Open file: '" << name << "'" << endl;
+
+    delete [] expname;
+
+    if (noexist)
+        return kFALSE;
+
+    fNumFile++;
+
+    //
+    // Read RUN HEADER (see specification) from input stream
+    //
+    if (!fRawRunHeader->ReadEvt(*fIn))
+        return kFALSE;
+
+    if (!(*fIn))
+    {
+        *fLog << err << "Error: Accessing file '" << name << "'" << endl;
+        return kFALSE;
+    }
+
+    //
+    // Print Run Header
+    //
+    fRawRunHeader->Print();
+    *fRawEvtTime = fRawRunHeader->GetRunStart();
+
+    fNumEvents += fRawRunHeader->GetNumEvents();
+
+    //
+    // Give the run header information to the 'sub-classes'
+    // Run header must be valid!
+    //
+    fRawEvtHeader->Init(fRawRunHeader, fRawEvtTime);
+    fRawEvtData  ->Init(fRawRunHeader, fRawCrateArray);
+
+    //
+    // Search for MTaskList
+    //
+    MTask *tlist = (MTask*)fParList->FindObject("MTaskList");
+    if (!tlist)
+    {
+        *fLog << err << dbginf << "MTaskList not found... abort." << endl;
+        return kFALSE;
+    }
+
+    //
+    // A new file has been opened and new headers have been read.
+    //  --> ReInit tasklist
+    //
+    return tlist->ReInit(fParList);
+}
+
+// --------------------------------------------------------------------------
+//
+// Return file name of current file.
+//
+const TString MRawFileRead::GetFileName() const
+{
+    const TObject *file = fFileNames->At(fNumFile-1);
+    return file ? file->GetName() : "";
+}
+
+// --------------------------------------------------------------------------
+//
+// Restart with the first file
+//
+Bool_t MRawFileRead::Rewind()
+{
+    fNumFile=0;
+    fNumEvents=0;
+    return OpenNextFile();
 }
 
@@ -130,4 +264,6 @@
 Int_t MRawFileRead::PreProcess(MParList *pList)
 {
+    fParList = pList;
+
     //
     // open the input stream
@@ -135,39 +271,12 @@
     // successfull
     //
-    fIn->open(fFileName);
-    if (!(*fIn))
-    {
-        *fLog << err << "Cannot open file " << fFileName << ": ";
-        *fLog << strerror(errno) << endl;
-        return kFALSE;
-    }
-
     if (!MRawRead::PreProcess(pList))
         return kFALSE;
 
     //
-    // Read RUN HEADER (see specification) from input stream
-    //
-    if (!fRawRunHeader->ReadEvt(*fIn))
-        return kFALSE;
-
-    if (!(*fIn))
-    {
-        *fLog << err << "Error: Accessing file '" << fFileName << "'" << endl;
-        return kFALSE;
-    }
-    //if (fRawRunHeader->GetMagicNumber()!=kMagicNumber)
-    //    return kFALSE;
-
-    fRawRunHeader->Print();
-
-    *fRawEvtTime = fRawRunHeader->GetRunStart();
-
-    //
-    // Give the run header information to the 'sub-classes'
-    // Run header must be valid!
-    //
-    fRawEvtHeader->Init(fRawRunHeader, fRawEvtTime);
-    fRawEvtData  ->Init(fRawRunHeader, fRawCrateArray);
+    // Now open next (first) file
+    //
+    if (!Rewind())
+        return kFALSE;
 
     return kTRUE;
@@ -184,5 +293,29 @@
 Int_t MRawFileRead::Process()
 {
-    return ReadEvent(*fIn);
+    while (1)
+    {
+        //
+        // skip events if requested
+        //
+        if (fInterleave>1 && GetNumExecutions()%fInterleave>0 && fIn->peek()!=EOF)
+        {
+            SkipEvent(*fIn);
+            return kCONTINUE;
+        }
+
+        //
+        // Read a single event from file
+        //
+        const Bool_t rc = ReadEvent(*fIn);
+        if (rc!=kFALSE)
+            return rc;
+
+        //
+        // If an event could not be read from file try to open new file
+        //
+        if (!OpenNextFile())
+            return kFALSE;
+    }
+    return kTRUE;
 }
 
@@ -195,16 +328,14 @@
 Int_t MRawFileRead::PostProcess()
 {
-    fIn->close();
-
     //
     // Sanity check for the number of events
     //
-    if (fRawRunHeader->GetNumEvents()==GetNumExecutions()-1 || GetNumExecutions()==0)
+    if (fNumEvents==GetNumExecutions()-1 || GetNumExecutions()==0)
         return kTRUE;
 
     *fLog << warn << dec;
     *fLog << "Warning - number of read events (" << GetNumExecutions()-1;
-    *fLog << ") doesn't match number in run header (";
-    *fLog << fRawRunHeader->GetNumEvents() << ")." << endl;
+    *fLog << ") doesn't match number in run header(s) (";
+    *fLog << fNumEvents << ")." << endl;
 
     return kTRUE;
Index: trunk/MagicSoft/Mars/mraw/MRawFileRead.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawFileRead.h	(revision 3734)
+++ trunk/MagicSoft/Mars/mraw/MRawFileRead.h	(revision 3800)
@@ -6,9 +6,21 @@
 #endif
 
+class TList;
+class MTaskList;
+
 class MRawFileRead : public MRawRead
 {
 private:
-    TString   fFileName;
-    ifstream *fIn;        //! buffered input stream (file to read from)
+    TList     *fFileNames; // list of file names
+    UInt_t     fNumFile;   //! number of next file
+    UInt_t     fNumEvents; //! input stream (file to read from)
+
+    ifstream  *fIn;        //! input stream (file to read from)
+
+    MParList  *fParList;   //! tasklist to call ReInit from
+
+    UInt_t     fInterleave;
+
+    Bool_t OpenNextFile();
 
     Int_t PreProcess(MParList *pList);
@@ -20,5 +32,10 @@
     ~MRawFileRead();
 
-    const TString &GetFileName() const { return fFileName; }
+    void SetInterleave(UInt_t i) { fInterleave = i; }
+
+    const TString GetFileName() const;
+
+    Int_t  AddFile(const char *fname);
+    Bool_t Rewind();
 
     ClassDef(MRawFileRead, 0)	// Task to read the raw data binary file
Index: trunk/MagicSoft/Mars/mraw/MRawFileWrite.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawFileWrite.h	(revision 3734)
+++ trunk/MagicSoft/Mars/mraw/MRawFileWrite.h	(revision 3800)
@@ -37,5 +37,5 @@
                   const Option_t *opt="RECREATE",
                   const char *ftitle="Untitled",
-                  const Int_t comp=1,
+                  const Int_t comp=2,
                   const char *name=NULL, const char *title=NULL);
     ~MRawFileWrite();
Index: trunk/MagicSoft/Mars/mraw/MRawRead.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawRead.cc	(revision 3734)
+++ trunk/MagicSoft/Mars/mraw/MRawRead.cc	(revision 3800)
@@ -66,4 +66,5 @@
 //
 MRawRead::MRawRead(const char *name, const char *title)
+    : fForceMode(kFALSE)
 {
     fName  = name  ? name  : "MRawRead";
@@ -161,9 +162,13 @@
 
     //
-    //  Read in the next EVENT HEADER (see specification),
+    // Read in the next EVENT HEADER (see specification),
     // if there is no next event anymore stop eventloop
     //
-    if (!fRawEvtHeader->ReadEvt(fin, ver))
-        return kFALSE;
+    const Bool_t rc = fRawEvtHeader->ReadEvt(fin, ver);
+    if (rc==kCONTINUE && fForceMode==kFALSE)
+    {
+        *fLog << err << "Problem found reading the event header... abort." << endl;
+        return kFALSE;
+    }
 
     //
@@ -203,7 +208,23 @@
         CreateFakeTime();
 
-    // FIXME: For all other runs we should enhance the precision
-    //        of the time-stamp by using the FADCClockTick
+    if (rc==kCONTINUE && fForceMode==kTRUE)
+        return kCONTINUE;
 
     return kTRUE;
 }
+
+void MRawRead::SkipEvent(istream &fin)
+{
+    //
+    //  Get file format version
+    //
+    const UShort_t ver = fRawRunHeader->GetFormatVersion();
+    fRawEvtHeader->SkipEvt(fin, ver);
+
+    const UShort_t nc = fRawRunHeader->GetNumCrates();
+    for (int i=0; i<nc; i++)
+    {
+        fRawCrateArray->GetEntry(i)->SkipEvt(fin, ver);
+        fRawEvtData->SkipEvt(fin);
+    }
+}
Index: trunk/MagicSoft/Mars/mraw/MRawRead.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawRead.h	(revision 3734)
+++ trunk/MagicSoft/Mars/mraw/MRawRead.h	(revision 3800)
@@ -22,7 +22,10 @@
     MTime          *fRawEvtTime;    // raw evt time information container to fill from file
 
+    Bool_t          fForceMode;     // Force mode skipping defect events
+
     void CreateFakeTime() const;
 
     Bool_t ReadEvent(istream &fin);
+    void   SkipEvent(istream &fin);
     Int_t  PreProcess(MParList *pList);
 
@@ -33,4 +36,6 @@
     MRawRead(const char *name=NULL, const char *title=NULL);
 
+    void SetForceMode(Bool_t b=kTRUE) { fForceMode = b; }
+
     ClassDef(MRawRead, 0)	// Task to read the raw data binary file
 };
