Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 3335)
+++ trunk/MagicSoft/Mars/Changelog	(revision 3336)
@@ -9,4 +9,5 @@
    * macros/dohtml.C
      - included the path msignals/
+
 
 
@@ -25,4 +26,5 @@
 
 
+
  2004/02/26: Thomas Bretz
 
@@ -84,4 +86,15 @@
    * mfbase/Makefile, mfbase/FBaseLinkDef.h, mfbase/FBaseIncl.h:
      - added
+
+   * merpp.cc:
+     - implemented control of gDebug (root debugging)
+
+   * mfileio/MWriteAsciiFile.[h,cc], mfileio/MWriteFile.[h,cc],
+     mfileio/MWriteRootFile.[h,cc]:
+     - implemented CheckAndWrite return value
+
+   * mfileio/MWriteRootFile.cc:
+     - fixed updating already existing branches (eg concatenating report
+       files)
 
 
Index: trunk/MagicSoft/Mars/macros/dohtml.C
===================================================================
--- trunk/MagicSoft/Mars/macros/dohtml.C	(revision 3335)
+++ trunk/MagicSoft/Mars/macros/dohtml.C	(revision 3336)
@@ -42,8 +42,10 @@
     TString sourcedir;
     sourcedir += "manalysis:";
+    sourcedir += "mastro:";
     sourcedir += "mbase:";
     sourcedir += "mcamera:";
     sourcedir += "mcalib:";
     sourcedir += "mdata:";
+    sourcedir += "mfbase:";
     sourcedir += "mfileio:";
     sourcedir += "mfilter:";
@@ -99,5 +101,2 @@
     html.Convert("pedphotcalc.C",   "MARS - Example to use MPedPhotCalc");
 }
-
-
-
Index: trunk/MagicSoft/Mars/macros/rootlogon.C
===================================================================
--- trunk/MagicSoft/Mars/macros/rootlogon.C	(revision 3335)
+++ trunk/MagicSoft/Mars/macros/rootlogon.C	(revision 3336)
@@ -99,9 +99,10 @@
     gInterpreter->AddIncludePath(dir+"macros");
     gInterpreter->AddIncludePath(dir+"manalysis");
-    gInterpreter->AddIncludePath(dir+"msignal");
+    gInterpreter->AddIncludePath(dir+"mastro");
     gInterpreter->AddIncludePath(dir+"mbase");
     gInterpreter->AddIncludePath(dir+"mcamera");
     gInterpreter->AddIncludePath(dir+"mcalib");
     gInterpreter->AddIncludePath(dir+"mdata");
+    gInterpreter->AddIncludePath(dir+"mfbase");
     gInterpreter->AddIncludePath(dir+"mfileio");
     gInterpreter->AddIncludePath(dir+"mfilter");
@@ -120,4 +121,5 @@
     gInterpreter->AddIncludePath(dir+"mreflector");
     gInterpreter->AddIncludePath(dir+"mreport");
+    gInterpreter->AddIncludePath(dir+"msignal");
     gInterpreter->AddIncludePath(dir+"mtools");
 
Index: trunk/MagicSoft/Mars/merpp.cc
===================================================================
--- trunk/MagicSoft/Mars/merpp.cc	(revision 3335)
+++ trunk/MagicSoft/Mars/merpp.cc	(revision 3336)
@@ -67,13 +67,14 @@
     gLog << "     inputfile.txt:  Magic DC currents file." << endl;
     gLog << "     ouputfile.root: Merpped root file." << endl;
-    gLog << "     -c#:                             Compression level #=1..9 [default=2]" << endl;
-    gLog << "     -v#:                             Verbosity level # [default=2]" << endl;
-    gLog << "     -u, --update:                    Update file" << endl;
-    gLog << "     -a, --no-colors:                 Do not use Ansii color codes" << endl;
+    gLog << "     -c#                              Compression level #=1..9 [default=2]" << endl;
+    gLog << "     -v#                              Verbosity level # [default=2]" << endl;
+    gLog << "     -u, --update                     Update file" << endl;
+    gLog << "     -a, --no-colors                  Do not use Ansii color codes" << endl;
     gLog << "     --sql=mysql://user:password@url  Insert run into database <raw data only>" << endl;
-    gLog << "     --start=yyyy-mm-dd/hh:mm:ss.mmm: Start event time for merpping report files" << endl;
-    gLog << "     --stop=yyyy-mm-dd/hh:mm:ss.mmm:  Stop  event time for merpping report files" << endl;
-    gLog << "     --run=#:                         Only data corresponding to this run number" << endl;
-    gLog << "     -?, -h, --help:                  This help" << endl << endl;
+    gLog << "     --start=yyyy-mm-dd/hh:mm:ss.mmm  Start event time for merpping report files" << endl;
+    gLog << "     --stop=yyyy-mm-dd/hh:mm:ss.mmm   Stop  event time for merpping report files" << endl;
+    gLog << "     --run=#                          Only data corresponding to this run number" << endl;
+    gLog << "     --debug[=n]                      Enable root debugging (Default: gDebug=1)" << endl;
+    gLog << "     -?, -h, --help                   This help" << endl << endl;
     gLog << "   REMARK: At the moment you can process a .raw _or_ a .rep file, only!" << endl << endl;
 }
@@ -114,4 +115,8 @@
 
     gLog.SetDebugLevel(arg.HasOption("-v") ? arg.GetIntAndRemove("-v") : 2);
+
+    gDebug = arg.HasOption("--debug=") ? arg.GetIntAndRemove("--debug=") : 0;
+    if (gDebug==0 && arg.HasOnlyAndRemove("--debug"))
+        gDebug=1;
 
     MTime kTimeStart(AnalyseTime(arg.GetStringAndRemove("--start=")));
Index: trunk/MagicSoft/Mars/mfileio/MWriteAsciiFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteAsciiFile.cc	(revision 3335)
+++ trunk/MagicSoft/Mars/mfileio/MWriteAsciiFile.cc	(revision 3336)
@@ -188,5 +188,5 @@
 // a warning message is print.
 //
-void MWriteAsciiFile::CheckAndWrite() const
+Bool_t MWriteAsciiFile::CheckAndWrite() const
 {
     Bool_t written = kFALSE;
@@ -219,11 +219,12 @@
     }
 
-    if (!written)
-        return;
-
-    *fOut << endl;
-
-    if (num!=0)
-        *fLog << warn << "Warning - given number of objects doesn't fit number of written objects." << endl;
+    if (written)
+    {
+        *fOut << endl;
+
+        if (num!=0)
+            *fLog << warn << "Warning - given number of objects doesn't fit number of written objects." << endl;
+    }
+    return kTRUE;
 }
 
Index: trunk/MagicSoft/Mars/mfileio/MWriteAsciiFile.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteAsciiFile.h	(revision 3335)
+++ trunk/MagicSoft/Mars/mfileio/MWriteAsciiFile.h	(revision 3336)
@@ -21,5 +21,5 @@
     TObjArray fAutoDel; //! List of object to be deleted in the destructor
 
-    virtual void   CheckAndWrite() const;
+    virtual Bool_t CheckAndWrite() const;
     virtual Bool_t IsFileOpen() const;
     virtual Bool_t GetContainer(MParList *pList);
Index: trunk/MagicSoft/Mars/mfileio/MWriteFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteFile.cc	(revision 3335)
+++ trunk/MagicSoft/Mars/mfileio/MWriteFile.cc	(revision 3336)
@@ -78,7 +78,5 @@
     // write the container if it is already in changed state
     //
-    CheckAndWrite();
-
-    return kTRUE;
+    return CheckAndWrite();
 }
 
@@ -90,6 +88,5 @@
 Bool_t MWriteFile::ReInit(MParList *pList)
 {
-    CheckAndWrite();
-    return kTRUE;
+    return CheckAndWrite();
 }
 
@@ -101,6 +98,5 @@
 Int_t MWriteFile::Process()
 {
-    CheckAndWrite();
-    return kTRUE;
+    return CheckAndWrite();
 }
 
@@ -115,5 +111,4 @@
     // check if the container changed state is set
     //
-    CheckAndWrite();
-    return kTRUE;
+    return CheckAndWrite();
 }
Index: trunk/MagicSoft/Mars/mfileio/MWriteFile.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteFile.h	(revision 3335)
+++ trunk/MagicSoft/Mars/mfileio/MWriteFile.h	(revision 3336)
@@ -15,5 +15,5 @@
 
     virtual Bool_t      IsFileOpen() const = 0;
-    virtual void        CheckAndWrite() const = 0;
+    virtual Bool_t      CheckAndWrite() const = 0;
     virtual Bool_t      GetContainer(MParList *pList) = 0;
     virtual const char *GetFileName() const = 0;
Index: trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 3335)
+++ trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 3336)
@@ -338,40 +338,43 @@
         entry->SetTree(tree);
 
+        TString branchname(cname);
+        branchname.Append(".");
+
         //
         // Try to get the branch from the file. 
         // If the branch already exists the user specified one branch twice.
         //
-        TBranch *branch = tree->GetBranch(cname);
+        TBranch *branch = tree->GetBranch(branchname);
         if (branch)
         {
-            *fLog << err << "Branch '" << cname << "' already existing." << endl;
-            return kFALSE;
-        }
-
-        //
-        // Create a new branch in the actual tree. The branch has the name
-        // container name. The type of the container is given by the
-        // ClassName entry in the container. The Address is the address of a
-        // pointer to the container (gotten from the branch entry). As
-        // Basket size we specify a (more or less) common default value.
-        // The containers should be written in Splitlevel=1
-        //
-        *fLog << inf << "Creating Branch " << cname << " of " << cont->ClassName() << "... " << flush;
-
-        TString branchname(cname);
-        branchname.Append(".");
-        branch = tree->Branch(branchname, cont->ClassName(), entry->GetAddress());
-
-        //
-        // If the branch couldn't be created we have a problem.
-        //
-        if (!branch)
-        {
-            *fLog << endl;
-            *fLog << err << "Unable to create branch '" << cname << "'." << endl;
-            return kFALSE;
-        }
-
-        *fLog << "done." << endl;
+            *fLog << inf << "Branch '" << cname << "' already existing... updating." << endl;
+            branch->SetAddress(entry->GetAddress());
+        }
+        else
+        {
+            //
+            // Create a new branch in the actual tree. The branch has the name
+            // container name. The type of the container is given by the
+            // ClassName entry in the container. The Address is the address of a
+            // pointer to the container (gotten from the branch entry). As
+            // Basket size we specify a (more or less) common default value.
+            // The containers should be written in Splitlevel=1
+            //
+            *fLog << inf << "Creating Branch " << cname << " of " << cont->ClassName();
+            *fLog << " in tree " << tree->GetName() << "... " << flush;
+
+            branch = tree->Branch(branchname, cont->ClassName(), entry->GetAddress());
+            //
+            // If the branch couldn't be created we have a problem.
+            //
+            if (!branch)
+            {
+                *fLog << endl;
+                *fLog << err << "Unable to create branch '" << cname << "'." << endl;
+                return kFALSE;
+            }
+
+            *fLog << "done." << endl;
+        }
 
         //
@@ -398,5 +401,5 @@
 // has the write flag, all containers in this tree are filled!
 //
-void MWriteRootFile::CheckAndWrite() const
+Bool_t MWriteRootFile::CheckAndWrite() const
 {
     TObject *obj;
@@ -423,5 +426,11 @@
             b->GetTree()->SetBit(kFillTree);
         else
-            b->GetBranch()->Fill();
+        {
+            if (!b->GetBranch()->Fill())
+            {
+                *fLog << err << "ERROR - Zero bytes written to branch '" << b->GetBranch()->GetName() << "'... abort." << endl;
+                return kFALSE;
+            }
+        }
     }
 
@@ -445,7 +454,12 @@
         // of written/filled entries.
         //
-        t->Fill();
         t->ResetBit(kFillTree);
-    }
+        if (!t->Fill())
+        {
+            *fLog << err << "ERROR - Zero bytes written to tree '" << t->GetName() << "'... abort." << endl;
+            return kFALSE;
+        }
+    }
+    return kTRUE;
 }
 
Index: trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h	(revision 3335)
+++ trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h	(revision 3336)
@@ -75,5 +75,5 @@
     //UInt_t fNumEvents; //! Number of events written in a run
 
-    void        CheckAndWrite() const;
+    Bool_t      CheckAndWrite() const;
     Bool_t      IsFileOpen() const;
     Bool_t      GetContainer(MParList *pList);
