]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/TTreeStream.cxx
High_gain/Low_gain ratio calculated in the ProcessLEDRun()
[u/mrichter/AliRoot.git] / STEER / TTreeStream.cxx
index 487e535c126e2520fe7a29183200b2b0ab853324..2287454cc2d547bb73d2acd071c97f16970298bd 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <TClass.h>
 #include <TFile.h>
+#include <TDirectory.h>
 #include <TObjArray.h>
 #include <TTree.h>
 #include <TTreeStream.h>
@@ -163,7 +164,7 @@ void TTreeSRedirector::StoreObject(TObject* object){
   //
   //
   //
-  TFile * backup = gFile;
+  TDirectory * backup = gDirectory;
   fFile->cd();
   object->Write();
   if (backup) backup->cd();
@@ -188,12 +189,14 @@ TTreeStream  & TTreeSRedirector::operator<<(Int_t id)
     }
   }
   if (!clayout){
+    TDirectory * backup = gDirectory;
     fFile->cd();
     char chname[100];
     sprintf(chname,"Tree%d",id);
     clayout = new TTreeStream(chname);
     clayout->fId=id;
     fDataLayouts->AddAt(clayout,entries);
+    if (backup) backup->cd();
   }
   return *clayout;
 }
@@ -209,11 +212,13 @@ TTreeStream  & TTreeSRedirector::operator<<(const char* name)
   Int_t entries = fDataLayouts->GetEntriesFast();
 
   if (!clayout){
+    TDirectory * backup = gDirectory;
     fFile->cd();
     clayout = new TTreeStream(name);
     clayout->fId=-1;
     clayout->SetName(name);
     fDataLayouts->AddAt(clayout,entries);    
+    if (backup) backup->cd();
   }
   return *clayout;
 }
@@ -224,7 +229,7 @@ TTreeStream  & TTreeSRedirector::operator<<(const char* name)
 void TTreeSRedirector::Close(){
   //
   //
-  TFile * backup = gFile;
+  TDirectory * backup = gDirectory;
   fFile->cd();
   if (fDataLayouts){
     Int_t entries = fDataLayouts->GetEntriesFast();
@@ -395,8 +400,8 @@ void TTreeStream::BuildTree(){
   //
   // Build the Tree
   //
-  if (fTree->GetEntries()>0) return;
-  fTree = new TTree(GetName(),GetName());
+  if (fTree && fTree->GetEntries()>0) return;
+  if (!fTree)  fTree = new TTree(GetName(),GetName());
   Int_t entries = fElements->GetEntriesFast();  
   fBranches = new TObjArray(entries);