Unclosed ROOT file

Hello,
I am running a MC program and the results are written out in a Root file.
When the size of ouput Root file reaches about 1.9GB, a new Root file,
like “XXX_1.root”, will be created automatically. However, when I tried to
open 2nd Root file “XXX_1.root”, I got a message that

“file XXX_1.root probably not closed, trying to recover”

I did call “Close()” at end of my program. Please help me !!!

Thanks very much !!!

ROOT Version 4.00.03. RedHat 9.0, gcc 3.2.2

See the IMPORTANT NOTE at
root.cern.ch/root/htmldoc/TTree. … ChangeFile

Rene

Thanks very much!!!

Hello,
I have the same problem as linch:
Warning in : file castor:///castor/cern.ch/user/b/bifani/pigg/scmp/SS0-22/8_1.root probably not closed, trying to recover

but adding the line:
file = T->GetCurrentFile(); //to get the pointer to the current file

I didn’t fix the error.

That’s my situation:

int user_init() {

file = new TFile(“compact.root”, “recreate”, “root”, 0);
root.tree = new TTree(“Tree”, “Tree”);

}

int user_ana() {

root.tree->Fill()

}

int user_exit() {

file->Write();
file->Close();

}

Where do I have to put the file = root.tree->GetCurrentFile(); line? In user_ana or in user_exit?

ROOT Version: /afs/cern.ch/sw/lcg/external/root/5.13.06/slc3_ia32_gcc323/root/

Must be in your user_exit function.
In case ROOT has automatically switched to a new file, your pointer "file"
is not valid anymore. The first file open has been closed by the system.

Rene

I put it in the user_exit but i get the same error:

int user_exit() {

file = root.tree->GetCurrentFile();
file->Write();
file->Close();

}

Info in : fDiskServer: lxfs5574, r: rootug://lxfs5574//shift/lxfs5574/data0 … oot.100230
Warning in : file castor:///castor/cern.ch/user/b/bifani/pigg/scmp/SS0-23/2_1.root probably not closed, trying to recover
Info in : castor:///castor/cern.ch/user/b/bifani/pigg/scmp/SS0-23/2_1.root, recovered key TTree:Tree at address 1716909133
Info in : castor:///castor/cern.ch/user/b/bifani/pigg/scmp/SS0-23/2_1.root, recovered key TTree:Tree at address 1786343196
Warning in : successfully recovered 2 keys