Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 2122)
+++ trunk/MagicSoft/Mars/Changelog	(revision 2123)
@@ -1,4 +1,35 @@
                                                  -*-*- END OF LINE -*-*-
+ 2003/05/20: Thomas Bretz
+
+   * mbase/MLog.h:
+     - added Separator member function
+     
+   * mfileio/MReadMarsFile.cc:
+     - moved output in Notify to MReadTree::Notify
+     - call MReadTree:Notify in Notify
+     
+   * mfileio/MReadTree.[h,cc]:
+     - do not try to delete a Baddress if it is NULL ("*")
+     - added CheckBranchSize member function
+     - added the size consistency check to Notify
+     
+   * mfileio/MWriteRootFile.cc:
+     - mini changes to Print-output
+     
+   * mfilter/MF.[h,cc]:
+     - added Print-function
+     
+   * mraw/MRawEvtPixelIter.h:
+     - removed wrong EOL characters
+
+
+     
  2003/05/19: Thomas Bretz
+
+   * mgui/MCamDisplay.cc:
+     - removed an unused variable.
+
+   * Makefile.rules:
+     - fixed Mr.Proper
 
    * mbase/MEvtLoop.cc, mbase/MParList.cc, mbase/MTaskList.cc,
Index: trunk/MagicSoft/Mars/mbase/MLog.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MLog.h	(revision 2122)
+++ trunk/MagicSoft/Mars/mbase/MLog.h	(revision 2123)
@@ -171,4 +171,23 @@
     void SetNoColors(Bool_t flag=kTRUE) { flag ? SetBit(eNoColors) : ResetBit(eNoColors); }
 
+    void Separator(TString str="", int outlvl=0)
+    {
+        if (!str.IsNull())
+        {
+            const Int_t l = (78-str.Length())/2-3;
+            str.Prepend("={ ");
+            str.Prepend('-', l);
+            str.Append(" }=");
+            str.Append('-', l);
+        }
+        if (str.Length()<78)
+            str.Append('-', 78-str.Length());
+
+        const int save = fOutputLevel;
+        SetOutputLevel(outlvl);
+        (*this) << str << endl;
+        fOutputLevel = save;
+    }
+
     ClassDef(MLog, 0) // This is what we call 'The logging system'
 };
Index: trunk/MagicSoft/Mars/mfileio/MReadMarsFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadMarsFile.cc	(revision 2122)
+++ trunk/MagicSoft/Mars/mfileio/MReadMarsFile.cc	(revision 2123)
@@ -142,7 +142,6 @@
     }
 
-    *fLog << inf << "MReadMarsFile: Switching to #" << GetFileIndex();
-    *fLog << " '" << GetFileName() << "' (before event #";
-    *fLog << GetNumEntry()-1 << ")" << endl;
+    if (!MReadTree::Notify())
+        return kFALSE;
 
     if (fDisplay)
Index: trunk/MagicSoft/Mars/mfileio/MReadTree.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadTree.cc	(revision 2122)
+++ trunk/MagicSoft/Mars/mfileio/MReadTree.cc	(revision 2123)
@@ -138,5 +138,6 @@
     TChainElement *element = NULL;
     while ((element=(TChainElement*)Next()))
-        delete (MParContainer**)element->GetBaddress();
+        if (element->GetBaddress())
+            delete (MParContainer**)element->GetBaddress();
 
     //
@@ -155,4 +156,51 @@
 // --------------------------------------------------------------------------
 //
+// This check whether all branches in the tree have the same size. If
+// this is not the case the events in the different branches cannot
+// be ordered correctly.
+//
+Bool_t MReadTree::CheckBranchSize()
+{
+    TArrayI entries(fChain->GetStatus()->GetSize());
+    Int_t num=0;
+
+    // Loop over all branches which have a corresponding container
+    TIter Next(fChain->GetStatus());
+
+    TChainElement *element = NULL;
+    while ((element=(TChainElement*)Next()))
+    {
+        // Get branch name and find pointer to corresponding branch
+        const TString name = element->GetName();
+        const TBranch *b = fChain->FindBranch(name);
+
+        // Skip element without corresponding branches (like "*")
+        if (!b)
+            continue;
+
+        entries[num++] = (Int_t)b->GetEntries();
+    }
+
+    // Check the number of entries of the branches pair-wise
+    for (int i=0; i<num; i++)
+        for (int j=i; j<num; j++)
+        {
+            if (entries[i]==entries[j])
+                continue;
+
+            *fLog << err << "ERROR - File corrupttion detected:" << endl;
+            *fLog << "  Due to several circumstances (such at a bug in MReadTree or wrong" << endl;
+            *fLog << "  usage of the file UPDATE mode) you may have produced a file in which" << endl;
+            *fLog << "  at least two branches in the same tree (" << fChain->GetName() << ") have different" << endl;
+            *fLog << "  number of entries. Sorry, but this file (" << GetFileName() << ")" << endl;
+            *fLog << "  is unusable." << endl;
+            return kFALSE;
+        }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
 //  If the owner flag is set all TObjects which are scheduled via
 //  AddNotify are deleted by the destructor of MReadTree
@@ -171,6 +219,13 @@
 Bool_t MReadTree::Notify()
 {
-    *fLog << inf << GetDescriptor() << ": Notify '" << fChain->GetName();
-    *fLog << "' (before processing event #" << GetNumEntry()-1 << ")" << endl;
+    //
+    // Do a consistency check for all branches
+    //
+    if (!CheckBranchSize())
+        return kFALSE;
+
+    *fLog << inf << GetDescriptor() << ": Switching to #" << GetFileIndex();
+    *fLog << " '" << GetFileName() << "' (before event #";
+    *fLog << GetNumEntry()-1 << ")" << endl;
 
     //fNotify->Notify();
@@ -542,4 +597,5 @@
 
     Int_t num=0;
+
     //
     // loop over all tasks for processing
@@ -622,4 +678,10 @@
 
     //
+    // Do a consistency check for all branches
+    //
+//    if (!CheckBranchSize())
+//        return kFALSE;
+
+    //
     // If auto enabling scheme isn't disabled, do auto enabling
     //
Index: trunk/MagicSoft/Mars/mfileio/MReadTree.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadTree.h	(revision 2122)
+++ trunk/MagicSoft/Mars/mfileio/MReadTree.h	(revision 2123)
@@ -33,4 +33,6 @@
     void EnableBranches(MParList *plist);
     void EnableBranchChoosing();
+
+    Bool_t CheckBranchSize();
 
     virtual void SetReadyToSave(Bool_t flag=kTRUE);
Index: trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 2122)
+++ trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 2123)
@@ -140,10 +140,16 @@
 void MWriteRootFile::Print(Option_t *) const
 {
-    *fLog << all << underline << "File: " << GetFileName() << ":" << endl;
+    *fLog << all << underline << "File: " << GetFileName() << endl;
+
+    if (fTrees.GetEntries()==0)
+    {
+        *fLog << " No contents." << endl;
+        return;
+    }
 
     TTree *t = NULL;
     TIter Next(&fTrees);
     while ((t=(TTree*)Next()))
-        *fLog << t->GetName() << ": \t" << t->GetEntries() << " entries." << endl;
+        *fLog << " " << t->GetName() << ": \t" << t->GetEntries() << " entries." << endl;
     *fLog << endl;
 }
Index: trunk/MagicSoft/Mars/mfilter/MF.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MF.cc	(revision 2122)
+++ trunk/MagicSoft/Mars/mfilter/MF.cc	(revision 2123)
@@ -473,2 +473,8 @@
 }
 
+void MF::Print(Option_t *opt) const
+{
+    *fLog << all << underline << GetDescriptor() << endl;
+    fF->Print();
+    *fLog << endl << endl;
+}
Index: trunk/MagicSoft/Mars/mfilter/MF.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MF.h	(revision 2122)
+++ trunk/MagicSoft/Mars/mfilter/MF.h	(revision 2123)
@@ -41,4 +41,6 @@
     Bool_t PostProcess();
 
+    void Print(Option_t *opt="") const;
+
     ClassDef(MF, 0) // A Filter for cuts in any data member
 };
Index: trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.h	(revision 2122)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.h	(revision 2123)
