]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
https://savannah.cern.ch/bugs/?101683
authormorsch <andreas.morsch@cern.ch>
Fri, 21 Feb 2014 17:29:49 +0000 (18:29 +0100)
committermorsch <andreas.morsch@cern.ch>
Fri, 21 Feb 2014 17:29:49 +0000 (18:29 +0100)
Hans Beck

STEER/STEERBase/AliOADBContainer.cxx

index 02e379fd7faeeaa877e6b2dafc2c58532e2fa421..dc4efd4ee9da3df4c999db0bba656b95ee1bce15 100644 (file)
@@ -29,6 +29,7 @@
 #include <TBrowser.h>
 #include <TSystem.h>
 #include <TError.h>
+#include <TROOT.h>
 
 ClassImp(AliOADBContainer);
 
@@ -263,9 +264,38 @@ void AliOADBContainer::WriteToFile(const char* fname) const
 
 Int_t AliOADBContainer::InitFromFile(const char* fname, const char* key)
 {
+  //
+  // Hans: See whether the file is already open
+  //
+  // For now print info
+  printf("-----------------------------------------------\n");
+  printf("D-InitFromFile for file: %s and key %s\n",fname,key);
+  printf("D-List of already open files:\n");
+  TIter nextFile(gROOT->GetListOfFiles());
+  while (1) {
+    TObject *obj = nextFile();
+    if(!obj)break;
+    printf("%s\n",obj->GetName());
+  }
+  printf("-----------------------------------------------\n");
+
+  // Declare the file
+  TFile* file(0);
+  // Try to get the file from the list of already open files
+  const TSeqCollection *listOfFiles(gROOT->GetListOfFiles());
+  if(listOfFiles){
+    file =dynamic_cast<TFile*> (listOfFiles->FindObject(fname));
+  }
+  if(file){
+    printf("Success! File was already open!\n");
+  }
+  else{
+    printf("Couldn't find file, opening it\n");
+    file = TFile::Open(fname);
+  }
+
     // 
     // Initialize object from file
-    TFile* file = TFile::Open(fname);
     if (!file) return (1);
     AliOADBContainer* cont  = 0;
     file->GetObject(key, cont);