TFile: .Open() vs constructor

From: Giovanni Franzoni <franzoni_at_mail.cern.ch>
Date: Wed, 1 Jun 2005 19:19:37 +0200 (CEST)

Dear colleagues,

needing to open a file from two different points of my code, I get problems (reported at the bottom) if I make two TFile instantiations which point to the same file on disk, and Open()-Close() them. [i.e. TFile b; b.Open("File__.root","RECREATE","piffero",1);]

If instead I just instantiate the TFile objects with the path-name of the file in the constrictor, the problem does not appear. [i.e.: TFile b("File__.root","RECREATE","piffero",1);]

Using:
ROOTSYS=/afs/cern.ch/sw/root/v4.02.00/rh73_slc3/root/

                Best regards, Giovanni

_________ complaint ______________________________________
Warning in <TFile::Init>: file File__.root probably not closed, cannot read free segments
Warning in <TFile::Init>: file File__.root probably not closed, trying to recover
Info in <TFile::Recover>: File__.root, recovered key TH1F:ciao at address 232 Warning in <TFile::Init>: successfully recovered 1 keys
_________ code ___________________________________________
//c++ `root-config --libs --cflags` file.cpp -o file_haha2

#include <iostream>
#include "TFile.h"
#include "TH1F.h"

int main(int argc, char * argv[]){   

  std::cout << "hello world" << std::endl;   

  TFile b;
  b.Open("File__.root","RECREATE","piffero",1);   // TFile b("File__.root","RECREATE","piffero",1);   TH1F a("ciao","ciao1",0,0,1);
  a.Write();
  b.Close();

  // TFile c("File__.root","UPDATE","piffero",1);   TFile c;
  c.Open("File__.root","UPDATE","piffero",1);   TH1F d("ciao2","ciao3",0,0,1);
  d.Write();
  c.Close();  

}

-- 
Received on Wed Jun 01 2005 - 19:20:16 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:09 MET