Index: trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc	(revision 2106)
+++ trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc	(revision 2117)
@@ -549,7 +549,12 @@
     // Check for the existence of a next file to read
     //
-    TNamed *file = (TNamed*)fFileNames->First();
-    if (!file)
-        return kFALSE;
+    if (fNumFile >= (UInt_t)fFileNames->GetSize())
+        return kFALSE;
+
+    TNamed *file = (TNamed*)fFileNames->At(fNumFile);
+
+    //TNamed *file = (TNamed*)fFileNames->GetFirst();
+    //if (!file)
+    //    return kFALSE;
 
     //
@@ -565,18 +570,16 @@
     // Remove this file from the list of pending files
     //
-    fFileNames->Remove(file);
+    //fFileNames->Remove(file);
 
     *fLog << inf << "Open file: '" << name << "'" << endl;
 
     if (!CheckHeader(fname))
-    {
-        *fLog << "OpenNextFile : CheckHeader(fname) is FALSE" << endl;
-        return kFALSE;
-    }
+        return kFALSE;
+
+    fNumFile++;
 
     fIn = new ifstream(fname);
 
     *fLog << inf << "-----------------------------------------------------------------------" << endl;
-
 
     switch (ReadRunHeader())
@@ -690,100 +693,111 @@
 }
 
-// --------------------------------------------------------------------------
-//
-// Open the first file in the list. Check for the output containers or create
-// them if they don't exist.
-//
-// Initialize the size of the MPedestalCam container to 127 pixels (CT1 camera)
-//
-Bool_t MCT1ReadPreProc::PreProcess(MParList *pList)
-{
-
-    fParList = pList;
-
-    //
-    //  look for the HourAngle container in the plist
-    //
-    fHourAngle = (MParameterD*)pList->FindCreateObj("MParameterD", "HourAngle");
-    if (!fHourAngle)
-        return kFALSE;
-    fHourAngle->SetTitle("Store the CT1 hour angle [deg]");
-
-    //
-    //  look for the ThetaOrig container in the plist
-    //
-    fThetaOrig = (MParameterD*)pList->FindCreateObj("MParameterD", "ThetaOrig");
-    if (!fThetaOrig)
-        return kFALSE;
-    fThetaOrig->SetTitle("Store the original CT1 zenith angle [rad]");
-
-    //
-    //  look for the MCerPhotEvt class in the plist
-    //
-    fNphot = (MCerPhotEvt*)pList->FindCreateObj("MCerPhotEvt");
-    if (!fNphot)
-        return kFALSE;
-
-    //
-    //  look for the pedestal class in the plist
-    //
-    fPedest = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
-    if (!fPedest)
-        return kFALSE;
-
-    //
-    //  look for the time class in the plist
-    //
-    fTime = (MTime*)pList->FindCreateObj("MTime");
-    if (!fTime)
-        return kFALSE;
-
-    //
-    //  look for the pedestal class in the plist
-    //
-    fBlinds = (MBlindPixels*)pList->FindCreateObj("MBlindPixels");
-    if (!fBlinds)
-        return kFALSE;
-
-    //
-    //  look for the source position in the camera
-    //
-    fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam");
-    if (!fSrcPos)
-        return kFALSE;
-
-    //
-    //  look for the camera geometry
-    //
-    fGeom = (MGeomCam*)pList->FindCreateObj("MGeomCamCT1", "MGeomCam");
-    if (!fGeom)
-        return kFALSE;
-
-    //
-    //  look for the mc event class
-    //
-    fMcEvt = (MMcEvt*)pList->FindCreateObj("MMcEvt");
-    if (!fMcEvt)
-        return kFALSE;
-
-    //
-    //  look for the mc trigger class
-    //
-    fMcTrig = (MMcTrig*)pList->FindCreateObj("MMcTrig");
-    if (!fMcTrig)
-        return kFALSE;
-
-    //
-    //  look for the raw run header class
-    //
-    fRawRunHeader = (MRawRunHeader*)pList->FindCreateObj("MRawRunHeader");
-    if (!fRawRunHeader)
-        return kFALSE;
-
-    fBinningT = (MBinning*)pList->FindObject("BinningTheta");
-
+Bool_t MCT1ReadPreProc::Rewind()
+{
     fNumFilterEvts = 0;
     fNumEvents     = 0;
     fNumRuns       = 0;
+    fNumFile       = 0;
+    if (fIn)
+        delete fIn;
+
+    fIn=NULL;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Open the first file in the list. Check for the output containers or create
+// them if they don't exist.
+//
+// Initialize the size of the MPedestalCam container to 127 pixels (CT1 camera)
+//
+Bool_t MCT1ReadPreProc::PreProcess(MParList *pList)
+{
+    fParList = pList;
+
+    //
+    //  look for the HourAngle container in the plist
+    //
+    fHourAngle = (MParameterD*)pList->FindCreateObj("MParameterD", "HourAngle");
+    if (!fHourAngle)
+        return kFALSE;
+    fHourAngle->SetTitle("Store the CT1 hour angle [deg]");
+
+    //
+    //  look for the ThetaOrig container in the plist
+    //
+    fThetaOrig = (MParameterD*)pList->FindCreateObj("MParameterD", "ThetaOrig");
+    if (!fThetaOrig)
+        return kFALSE;
+    fThetaOrig->SetTitle("Store the original CT1 zenith angle [rad]");
+
+    //
+    //  look for the MCerPhotEvt class in the plist
+    //
+    fNphot = (MCerPhotEvt*)pList->FindCreateObj("MCerPhotEvt");
+    if (!fNphot)
+        return kFALSE;
+
+    //
+    //  look for the pedestal class in the plist
+    //
+    fPedest = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
+    if (!fPedest)
+        return kFALSE;
+
+    //
+    //  look for the time class in the plist
+    //
+    fTime = (MTime*)pList->FindCreateObj("MTime");
+    if (!fTime)
+        return kFALSE;
+
+    //
+    //  look for the pedestal class in the plist
+    //
+    fBlinds = (MBlindPixels*)pList->FindCreateObj("MBlindPixels");
+    if (!fBlinds)
+        return kFALSE;
+
+    //
+    //  look for the source position in the camera
+    //
+    fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam");
+    if (!fSrcPos)
+        return kFALSE;
+
+    //
+    //  look for the camera geometry
+    //
+    fGeom = (MGeomCam*)pList->FindCreateObj("MGeomCamCT1", "MGeomCam");
+    if (!fGeom)
+        return kFALSE;
+
+    //
+    //  look for the mc event class
+    //
+    fMcEvt = (MMcEvt*)pList->FindCreateObj("MMcEvt");
+    if (!fMcEvt)
+        return kFALSE;
+
+    //
+    //  look for the mc trigger class
+    //
+    fMcTrig = (MMcTrig*)pList->FindCreateObj("MMcTrig");
+    if (!fMcTrig)
+        return kFALSE;
+
+    //
+    //  look for the raw run header class
+    //
+    fRawRunHeader = (MRawRunHeader*)pList->FindCreateObj("MRawRunHeader");
+    if (!fRawRunHeader)
+        return kFALSE;
+
+    fBinningT = (MBinning*)pList->FindObject("BinningTheta");
+
+    Rewind();
 
     fPedest->InitSize(iMAXNUMPIX);
@@ -1115,4 +1129,7 @@
     }
 
+    delete fIn;
+    fIn = NULL;
+
     return GetSelector() ? GetSelector()->CallPostProcess() : kTRUE;
 }
Index: trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h	(revision 2106)
+++ trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h	(revision 2117)
@@ -50,4 +50,5 @@
     Bool_t fIsMcFile;       // Flag whether current run is a MC run
 
+    UInt_t fNumFile;
     UInt_t fNumEvents;      // number of events counted in all runs in all files
     UInt_t fNumEventsInRun; // number of events in the counted in th ecurrent run
@@ -76,4 +77,6 @@
     Bool_t PostProcess();
 
+    Bool_t Rewind();
+
 public:
     MCT1ReadPreProc(const char *filename=NULL,
Index: trunk/MagicSoft/Mars/mfileio/MRead.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MRead.cc	(revision 2106)
+++ trunk/MagicSoft/Mars/mfileio/MRead.cc	(revision 2117)
@@ -41,4 +41,10 @@
 
 ClassImp(MRead);
+
+Bool_t MRead::Rewind()
+{
+    *fLog << err << "ERROR - Rewind() not implemented for " << GetDescriptor() << endl;
+    return kFALSE;
+}
 
 // --------------------------------------------------------------------------
Index: trunk/MagicSoft/Mars/mfileio/MRead.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MRead.h	(revision 2106)
+++ trunk/MagicSoft/Mars/mfileio/MRead.h	(revision 2117)
@@ -17,4 +17,5 @@
 
     virtual UInt_t GetEntries() = 0;
+    virtual Bool_t Rewind();
 
     void SetSelector(MFilter *f) { fSelector = f; }
Index: trunk/MagicSoft/Mars/mfileio/MReadMarsFile.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadMarsFile.h	(revision 2106)
+++ trunk/MagicSoft/Mars/mfileio/MReadMarsFile.h	(revision 2117)
@@ -26,4 +26,6 @@
     Int_t AddFile(const char *fname, Int_t entries=-1);
 
+    Bool_t Rewind() { if (fRun) fRun->Rewind(); MReadTree::Rewind(); return kTRUE; }
+
     ClassDef(MReadMarsFile, 1)	// Reads a tree from file(s) and the information from the 'RunHeader'-tree
 };
Index: trunk/MagicSoft/Mars/mfileio/MReadTree.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadTree.cc	(revision 2106)
+++ trunk/MagicSoft/Mars/mfileio/MReadTree.cc	(revision 2117)
@@ -131,5 +131,6 @@
     //
     // Delete all the pointers to pointers to the objects where the
-    // branche data gets stored.
+    // branche data gets stored. FIXME: When PreProcessed twice this
+    // creates a memory leak!
     //
     TIter Next(fChain->GetStatus());
@@ -239,6 +240,6 @@
     if (numfiles>0)
         SetBit(kChainWasChanged);
-
-    *fLog << warn << "WARNING: '" << fname << "' not added to " << GetDescriptor() << endl;
+    else
+        *fLog << warn << "WARNING: '" << fname << "' not added to " << GetDescriptor() << endl;
 
     return numfiles;
Index: trunk/MagicSoft/Mars/mfileio/MReadTree.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadTree.h	(revision 2106)
+++ trunk/MagicSoft/Mars/mfileio/MReadTree.h	(revision 2117)
@@ -57,19 +57,20 @@
     UInt_t GetEntries();
 
-    TString    GetFileName() const;
-    Int_t      GetFileIndex() const;
+    TString GetFileName() const;
+    Int_t   GetFileIndex() const;
 
-    virtual void   AddNotify(TObject *obj);
-    virtual void   SetOwner(Bool_t flag=kTRUE);
-    virtual void   Print(Option_t *opt="") const;
+    virtual void AddNotify(TObject *obj);
+    virtual void SetOwner(Bool_t flag=kTRUE);
 
-    virtual Int_t  AddFile(const char *fname, Int_t entries=-1);
-    virtual Int_t  AddFiles(const MReadTree &read);
+    virtual Int_t AddFile(const char *fname, Int_t entries=-1);
+    virtual Int_t AddFiles(const MReadTree &read);
 
-    virtual Bool_t PreProcess(MParList *pList);
-    virtual Bool_t Process();
-    virtual Bool_t PostProcess();
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+    Bool_t PostProcess();
 
-    virtual Bool_t Notify();
+    Bool_t Notify();
+    Bool_t Rewind() { SetEventNum(0); return kTRUE; }
+    void   Print(Option_t *opt="") const;
 
     ClassDef(MReadTree, 1)	// Reads a tree from file(s)
