ROOT Version: 5.34.36
Platform: CentOS 7
Compiler: gcc4.9.3
This question might be related to my previous post titled “Naive question about TFile::GetSize()” of April 26.
I am running a data acquisition program that works like this:
- open file n.0
- write 10000 events to it
- close file n.0
- open file n.1
- write 10000 events to it
- close file n.1
.etc.etc.etc.
Besides the problem of getting the file size after closing each file, reported in my previous post, I found that if I try to read with an external program one of the closed files while the acquisition program is still running, I get a Warning message:
Warning in TFile::Init: file run_22_001.root probably not closed, trying to recover
If I wait till the acquisition program has exited, then the Warning from the external program disappears.
The actual code used to open and close the file is the following:
fTFileHandle = new TFile();
// First file
fTFileHandle->Open("run_22_000","NEW","PADME Merged Raw Events");
fTTreeMain = new TTree("RawEvents","PADME Raw Events Tree");
fTTreeMain->Branch("RawEvent",&fTRawEvent);
...write events...
fTTreeMain->Write();
fTFileHandle->Close();
delete fTTreeMain;
// Second file
fTFileHandle->Open("run_22_001","NEW","PADME Merged Raw Events");
fTTreeMain = new TTree("RawEvents","PADME Raw Events Tree");
...etc...etc...and finally...
fTTreeMain->Write();
fTFileHandle->Close();
delete fTTreeMain;
// When acquisition program exits
delete fTFileHandle;
Are there obvious errors in the procedure I am using?
In particular, is it correct to create the TFile at the beginning (fTFileHandle) and to reuse it for all the files created during the run?
Thank you
Emanuele Leonardi