Added file as a data member; close the file before opening a new one
authorschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 26 Apr 2002 15:59:45 +0000 (15:59 +0000)
committerschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 26 Apr 2002 15:59:45 +0000 (15:59 +0000)
EMCAL/AliEMCALGetter.cxx
EMCAL/AliEMCALGetter.h

index 75fc6365e34957d175be1fa6104b4f69d0ab6261..de848e0eb2d1f5454147e8d8f9ab03419144fd21 100644 (file)
@@ -104,24 +104,31 @@ AliEMCALGetter::AliEMCALGetter(const char* headerFile, const char* branchTitle,
   fTasksFolder   = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Tasks")) ; 
 
   fFailed = kFALSE ; 
+  if (!fFile) 
+    fFile = new TFile() ; 
+
+  if (fFile->IsOpen() )
+    fFile->Close() ; 
+                  
   if ( fHeaderFile != "aliroot"  ) { // to call the getter without a file
 
     //open headers file
-    TFile * file = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
+    fFile = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
     
-    if(file == 0){    //if file was not opened yet, read gAlice
-      if(fHeaderFile.Contains("rfio")) // if we read file using HPSS
-       file =  TFile::Open(fHeaderFile.Data(),rw) ;
-      else
-       file = new TFile(fHeaderFile.Data(),rw) ;
+    if(fFile == 0){    //if file was not opened yet, read gAlice
+      //      if(fHeaderFile.Contains("rfio")) // if we read file using HPSS
+       fFile = TFile::Open(fHeaderFile.Data(),rw) ;
+       //else
+       //fFile = new TFile(fHeaderFile.Data(),rw) ;
       
-      if (!file->IsOpen()) {
+      if (!fFile->IsOpen()) {
        cerr << "ERROR : AliEMCALGetter::AliEMCALGetter -> Cannot open " << fHeaderFile.Data() << endl ; 
                fFailed = kTRUE ;
         return ;  
       }
       
-      gAlice = static_cast<AliRun *>(file->Get("gAlice")) ;
+      gAlice = static_cast<AliRun *>(fFile->Get("gAlice")) ;
     }
   }
 
@@ -148,6 +155,7 @@ AliEMCALGetter::~AliEMCALGetter(){
     delete fPrimaries ; 
   }
 
+  delete fFile ; 
 }
 
 //____________________________________________________________________________ 
index 06acc925d0e6fc7c11f679ec29ea0d629dd6efda..f8ca9d41150ffb085aedbda3b991fa9f20c386cc 100644 (file)
@@ -200,6 +200,7 @@ class AliEMCALGetter : public TObject {
 
  private:
 
+  TFile *        fFile ;              //!
   TString        fHeaderFile ;        //! File in which gAlice lives
   TString        fBranchTitle ;       //!
   //TString        fTrackSegmentsTitle ;//!