Index: trunk/MagicSoft/Mars/mfileio/MReadReports.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadReports.cc	(revision 7001)
+++ trunk/MagicSoft/Mars/mfileio/MReadReports.cc	(revision 7115)
@@ -165,5 +165,5 @@
 // To be done: A flag(?) telling whether the headers can be skipped.
 //
-void MReadReports::AddTree(const char *tree, const char *time, Bool_t master)
+void MReadReports::AddTree(const char *tree, const char *time, Type_t master)
 {
     /*
@@ -176,15 +176,17 @@
     */
 
-    if (master && TestBit(kHasMaster))
+    if (master==kMaster && TestBit(kHasMaster))
     {
         *fLog << warn << GetDescriptor() << " already has a master tree... ignored." << endl;
-        master = kFALSE;
-    }
-
-    MReadTree *t = master ? new MReadMarsFile(tree) : new MReadTree(tree);
+        master = kStandard;
+    }
+
+    MReadTree *t = master==kMaster ? new MReadMarsFile(tree) : new MReadTree(tree);
     t->SetName(tree);
     t->SetTitle(time?time:"");
-    if (master)
+    if (master==kMaster)
         SetBit(kHasMaster);
+    if (master==kRequired)
+        t->SetBit(kIsRequired);
 
     if (!fEnableAutoScheme)
@@ -219,4 +221,25 @@
 
     return n;
+}
+
+// --------------------------------------------------------------------------
+//
+// Count the number of required trees and store the number if fNumRequired.
+// Reset the kIsProcessed bit.
+//
+void MReadReports::ForceRequired()
+{
+    fNumRequired = 0;
+
+    TIter Next(fTrees->GetList());
+    TObject *o=0;
+    while ((o=Next()))
+        if (o->TestBit(kIsRequired))
+        {
+            o->ResetBit(kIsProcessed);
+            fNumRequired++;
+        }
+
+    *fLog << dbg << "Number of required trees: " << fNumRequired << endl;
 }
 
@@ -297,5 +320,80 @@
     fPosEntry.Set(i);
 
+    // Force that with the next call to Process the required events are read
+    ForceRequired();
+    //fFirstReInit=kTRUE;
+
+    // Preprocess all tasks in fTrees
     return fTrees->CallPreProcess(plist);
+}
+
+// --------------------------------------------------------------------------
+//
+// If this is not the first ReInit after PreProcess force the required
+// trees to be read first (call FirstRequired())
+//
+/*
+Bool_t MReadReports::ReInit(MParList *plist)
+{
+    if (!fFirstReInit)
+        ForceRequired();
+    fFirstReInit=kFALSE;
+    return kTRUE;
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+// Return the number of the tree which is the next one to be read.
+// The condition for this decision is the time-stamp.
+//
+Int_t MReadReports::FindNextTime()
+{
+    TIter NextC(fChains);
+    TChain *c=0;
+
+    Int_t nmin=0;
+    MTime tmin(**GetTime((TChain*)NextC()));
+
+    Int_t i=0;
+
+    while ((c=(TChain*)NextC()))
+    {
+        MTime &t = **GetTime(c);
+        i++;
+
+        if (t >= tmin)
+            continue;
+
+        tmin = t;
+        nmin = i;
+    }
+    return nmin;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the number of the tree which is the next one to be read.
+// The condition for this decision kIsRequired but not kIsProcessed is set.
+//
+Int_t MReadReports::FindNextRequired()
+{
+    Int_t n = 0;
+
+    TIter Next(fTrees->GetList());
+    TObject *o=0;
+    while ((o=Next()))
+    {
+        if (o->TestBit(kIsRequired) && !o->TestBit(kIsProcessed))
+        {
+            o->SetBit(kIsProcessed);
+            fNumRequired--;
+            *fLog << dbg << "Reading from tree " << n << " " << o->GetName() << endl;
+            return n;
+        }
+        n++;
+    }
+
+    return -1;
 }
 
@@ -312,62 +410,4 @@
 // --------------------------------------------------------------------------
 //
-// Do not use if fChains->GetSize()==0 !!!
-//
-Int_t MReadReports::FindNextTime()
-{
-    Int_t i=0;
-
-    TIter NextC(fChains);
-    TChain *c=0;
-
-    Int_t nmin=0;
-    MTime tmin(**GetTime((TChain*)NextC()));
-
-    while ((c=(TChain*)NextC()))
-    {
-        MTime &t = **GetTime(c);
-        i++;
-
-        if (t >= tmin)
-            continue;
-
-        tmin = t;
-        nmin = i;
-    }
-    return nmin;
-}
-
-/*
-Bool_t MReadReports::Notify()
-{
-    Bool_t same = kTRUE;
-    for (int i=1; i<fPosTree.GetSize(); i++)
-        if (fPosTree[i]!=fPosTree[0])
-        {
-            same = kFALSE;
-            break;
-        }
-
-    Int_t tn = chain->GetTreeNumber();
-
-    Bool_t read=kFALSE;
-    if (fPosTree[nmin] != tn)
-    {
-        fPosTree[nmin] = tn;
-        read = kTRUE;
-    }
-
-    if (!same || !read)
-        return kTRUE;
-
-
-    *fLog << dbg << "Read Run Headers!" << endl;
-
-    return kTRUE;
-}
-*/
-
-// --------------------------------------------------------------------------
-//
 // Check which is the next tree to read from. Read an event from this tree.
 // Sets the StreamId accordingly.
@@ -377,5 +417,10 @@
     while (fChains->GetSize())
     {
-        const Int_t nmin=FindNextTime();
+        const Int_t nmin=FindNext();
+        if (nmin<0)
+        {
+            *fLog << err << "MReadReports::Process: ERROR - Determination of next tree failed... abort." << endl;
+            return kERROR;
+        }
 
         TChain *chain = (TChain*)fChains->At(nmin);
Index: trunk/MagicSoft/Mars/mfileio/MReadReports.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadReports.h	(revision 7001)
+++ trunk/MagicSoft/Mars/mfileio/MReadReports.h	(revision 7115)
@@ -17,4 +17,11 @@
 class MReadReports : public MRead
 {
+public:
+    enum Type_t {
+        kStandard,
+        kMaster,
+        kRequired
+    };
+
 private:
     MTaskList *fTrees;    // Hold the trees which are scheduled for reading
@@ -25,11 +32,17 @@
 
     Bool_t     fEnableAutoScheme;
+    Int_t      fNumRequired;
+    //Bool_t     fFirstReInit;
 
+    void    ForceRequired();
     MTime** GetTime(TChain *c) const;
     Int_t   FindNextTime();
+    Int_t   FindNextRequired();
+    Int_t   FindNext() { return fNumRequired==0 ? FindNextTime() : FindNextRequired(); }
 
     UInt_t  GetEntries();
     TString GetFullFileName() const;
 
+    //Bool_t  ReInit(MParList *plist);
     Int_t   PreProcess(MParList *plist);
     Int_t   Process();
@@ -37,5 +50,7 @@
 
     enum {
-        kHasMaster = BIT(14)
+        kHasMaster   = BIT(14),
+        kIsRequired  = BIT(22),
+        kIsProcessed = BIT(23)
     };
 
@@ -44,6 +59,6 @@
     ~MReadReports(); 
 
-    void  AddTree(const char *tree, const char *time=NULL, Bool_t master=kFALSE);
-    void  AddTree(const char *tree, Bool_t master)
+    void  AddTree(const char *tree, const char *time=NULL, Type_t master=kStandard);
+    void  AddTree(const char *tree, Type_t master)
     {
         AddTree(tree, NULL, master);
Index: trunk/MagicSoft/Mars/mfileio/MReadTree.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadTree.h	(revision 7001)
+++ trunk/MagicSoft/Mars/mfileio/MReadTree.h	(revision 7115)
@@ -31,4 +31,6 @@
 
     enum { kChainWasChanged = BIT(14) };
+    // MReadReports::kIsRequired  = BIT(22)
+    // MReadReports::kIsProcessed = BIT(23)
 
 private:
@@ -47,4 +49,6 @@
 
     enum { kIsOwner = BIT(14) };
+    // MReadReports::kIsRequired  = BIT(22)
+    // MReadReports::kIsProcessed = BIT(23)
 
 public:
