Index: trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 9230)
+++ trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 9292)
@@ -106,5 +106,6 @@
 // --------------------------------------------------------------------------
 //
-// Try to get the file from gROOT->GetListOfFiles.
+// Try to get the file from gROOT->GetListOfFiles. (In case the file name
+// is /dev/null we look for a file with name /dev/null and the given title)
 // If it is found fOut is set to it and returned.
 // Otherwise a new file is opened and returned.
@@ -112,15 +113,32 @@
 TFile *MWriteRootFile::OpenFile(const char *name, Option_t *option, const char *title, Int_t comp)
 {
-    TFile *file = dynamic_cast<TFile*>(gROOT->GetListOfFiles()->FindObject(name));
-
-    // If the file was not found with its name try its expanded name
+    TFile *file = 0;
+
+    if (TString(name)=="/dev/null")
+    {
+        TIter Next(gROOT->GetListOfFiles());
+        TObject *obj = 0;
+        while ((obj=Next()))
+            if (TString(obj->GetName())=="/dev/null" && TString(obj->GetTitle())==title)
+            {
+                *fLog << inf3 << "Found file '/dev/null' <Title=" << title << ">" << endl;
+                file = dynamic_cast<TFile*>(obj);
+                break;
+            }
+    }
+    else
+    {
+        file = dynamic_cast<TFile*>(gROOT->GetListOfFiles()->FindObject(name));
+
+        // If the file was not found with its name try its expanded name
+        if (!file)
+        {
+            TString fqp(name);
+            gSystem->ExpandPathName(fqp);
+            file = dynamic_cast<TFile*>(gROOT->GetListOfFiles()->FindObject(fqp));
+        }
+    }
+
     if (!file)
-    {
-        TString fqp(name);
-        gSystem->ExpandPathName(fqp);
-        file = dynamic_cast<TFile*>(gROOT->GetListOfFiles()->FindObject(fqp));
-    }
-
-    if (!file || TString(name)=="/dev/null")
     {
         file = new TFile(name, option, title, comp);
@@ -130,4 +148,6 @@
             return NULL;
         }
+
+        *fLog << inf3 << "New file '" << name << "' <Title=" << title << "> created." << endl;
 
         file->SetOption(option); // IMPORTANT!
@@ -143,4 +163,5 @@
     *fLog << inf;
     *fLog << "File '" << name << "' already open... using." << endl;
+    *fLog << inf3;
     *fLog << "Make sure that you do NOT write to trees which are" << endl;
     *fLog << "scheduled already by a different MWriteRootFile..." << endl;
@@ -170,4 +191,8 @@
 // ftitle:      File title stored in the file (see TFile)
 // name, title: Name and title of this object
+//
+// Until the first file is opened a dummy file with name /dev/null is
+// opened to allow creation of trees and branches in the file.
+// To distinguish between different /dev/null-files the given title is used.
 //
 MWriteRootFile::MWriteRootFile(const Int_t comp,
