Index: fact/tools/rootmacros/PulseTemplates/rootfilehandler.C
===================================================================
--- fact/tools/rootmacros/PulseTemplates/rootfilehandler.C	(revision 13625)
+++ fact/tools/rootmacros/PulseTemplates/rootfilehandler.C	(revision 13626)
@@ -8,10 +8,11 @@
 void
 CreateRootFile(
-        const char*     loc_fname,
+        TString         loc_fname,
         int             verbosityLevel
         )
 {
-    TFile* tf = new TFile(loc_fname,"UPDATE");
-    if (tf->IsZombie())
+    TFile output_rootfile(loc_fname,"UPDATE");
+
+    if (output_rootfile.IsZombie())
     {
         cout << "Error opening file" << endl;
@@ -19,6 +20,7 @@
     }
     else {
-        if (verbosityLevel > 1) cout << "creating root-file successfull" << endl;
-        tf->Close();
+        if (verbosityLevel > 1) cout << "creating root-file...successfull" << endl;
+        output_rootfile.pwd();
+        output_rootfile.Close();
     }
 }
@@ -27,12 +29,11 @@
 
 
-void
+TFile*
 OpenRootFile(
-        TFile*          output_rootfile,
-        const char *    loc_fname,
+        TString    loc_fname,
         int             verbosityLevel
         )
 {
-    output_rootfile = new TFile(loc_fname,"UPDATE");
+    TFile* output_rootfile = new TFile(loc_fname,"UPDATE");
     if (output_rootfile->IsZombie())
     {
@@ -49,5 +50,5 @@
         }
     }
-    return;
+    return output_rootfile;
 }
 //end of OpenRootFile
@@ -57,5 +58,5 @@
 void
 CloseRootFile(
-        TFile* output_rootfile
+        TFile*          output_rootfile
         )
 {
@@ -66,6 +67,6 @@
     } else {
     output_rootfile->Close();
+    }
     delete output_rootfile;
-    }
 }
 //end of CloseRootFile
@@ -75,5 +76,5 @@
 void
 SaveHistograms(
-        const char*     loc_fname,
+        TString         loc_fname,
         TString         subdirectory,
         TObjArray*      histList,
@@ -88,17 +89,13 @@
 
     TFile* output_rootfile = NULL;
-    OpenRootFile(output_rootfile, loc_fname, verbosityLevel);
-    if ( !( subdirectory.CompareTo("root") ) ) //if subdirectory = root
-    {
-        output_rootfile->cd();
-    }
-    else
-    {
-        output_rootfile->cd();
-        output_rootfile->mkdir(subdirectory,subdirectory);
-        output_rootfile->cd(subdirectory);
-    }
-    histList->Write(); // write the major histograms into the top level directory
-    if (verbosityLevel > 3) tf->ls();
+    output_rootfile = OpenRootFile( loc_fname, verbosityLevel);
+
+    if (verbosityLevel > 2) cout << endl
+                                 << "...writing histogram list to root file "
+                                 << endl ;
+    gFile->WriteTObject(histList, subdirectory); // write the histograms into one Key in the top level directory
+
+
+    if (verbosityLevel > 3) output_rootfile->ls();
     CloseRootFile( output_rootfile ); // close the file
     if (verbosityLevel > 2) cout << "...done" << endl;
@@ -124,11 +121,10 @@
 TString
 CreateSubDirName(
-        const char* title
+        TString title
         )
 {
-    TString path = title;
-    path += "_Pixel";
+    title += "_Pixel";
 //    cout << "path " << path << endl ;
-    return path;
+    return title;
 }
 // end of CreateSubDirName
