Index: trunk/MagicSoft/Mars/mbase/MReadTree.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MReadTree.cc	(revision 705)
+++ trunk/MagicSoft/Mars/mbase/MReadTree.cc	(revision 706)
@@ -18,8 +18,10 @@
 
 #include <TFile.h>
-#include <TTree.h>
+#include <TChain.h>
 #include <TObjArray.h>
 
 #include "MLog.h"
+#include "MLogManip.h"
+
 #include "MTime.h"
 #include "MParList.h"
@@ -27,5 +29,5 @@
 ClassImp(MReadTree)
 
-MReadTree::MReadTree(const char *fname, const char *tname,
+MReadTree::MReadTree(const char *tname, const char *fname,
                      const char *name, const char *title)
 {
@@ -36,6 +38,24 @@
     // open the input stream
     //
-    fFileName = fname;
-    fTreeName = tname;
+    fChain = new TChain(tname);
+
+    if (fname)
+        fChain->Add(fname);
+}
+
+MReadTree::~MReadTree()
+{
+    delete fChain;
+}
+
+/*Int_t*/ void MReadTree::AddFile(const char *fname)
+{
+    //
+    // FIXME! A check is missing whether the file already exists or not.
+    //
+    //
+    // returns the number of file which were added
+    //
+    /*return  root >3.0*/ fChain->Add(fname);
 }
 
@@ -45,28 +65,15 @@
     // open file and check if file is really open
     //
-    fFile = new TFile(fFileName, "READ");
-
-    if (!fFile->IsOpen())
-    {
-        *fLog << "MReadTree::PreProcess: ERROR: Cannot open file '";
-        *fLog << fFileName << "'" << endl;
-        return kFALSE;
-    }
-
-    //
-    // try to get the tree and check if it was found
-    //
-    fTree = (TTree*)fFile->Get(fTreeName);
-    if (!fTree)
-    {
-        *fLog << "MReadTree::PreProcess: ERROR: Cannot open tree '";
-        *fLog << fTreeName << "'" << endl;
-        return kFALSE;
-    }
 
     //
     // get number of events in this tree
     //
-    fNumEntries = (UInt_t)fTree->GetEntries();
+    fNumEntries = (UInt_t)fChain->GetEntries();
+
+    if (!fNumEntries)
+    {
+        *fLog << dbginf << "No Entries found in chain (file/s)." << endl;
+        return kFALSE;
+    }
 
     //
@@ -78,6 +85,5 @@
     // output logging information
     //
-    *fLog << "File: '" << fFileName << "'  Tree: '" << fTreeName;
-    *fLog << "' with " << fNumEntries << " Entries opened." << endl;
+    *fLog << fNumEntries << " Entries found in file(s)." << endl;
 
     //
@@ -85,5 +91,5 @@
     // create the Iterator to loop over all branches
     //
-    TIter Next(fTree->GetListOfBranches());
+    TIter Next(fChain->GetListOfBranches());
     TBranch *branch=NULL;
     
@@ -102,4 +108,5 @@
         //
         MParContainer *pcont = pList->FindCreateObj(name);
+        
 
         if (!pcont)
@@ -134,5 +141,5 @@
     // get entry
     //
-    fTree->GetEntry(fNumEntry );
+    fChain->GetEntry(fNumEntry );
 
     fNumEntry ++ ; 
@@ -146,5 +153,5 @@
     // Close File
     //
-    fFile->Close();
+    //fFile->Close();
 
     return kTRUE;
@@ -156,5 +163,5 @@
     // Get the Event with the current EventNumber fNumEntry
     //
-    fTree->GetEntry(fNumEntry);
+    fChain->GetEntry(fNumEntry);
 
     return kTRUE;
