This works !! I did as you said, i.e I create my *file, THEN I create my *tree, and just before writing this tree, I come back to the directory of the file with file.cd(). This (basic!!) step was missing ! Indeed, between creating the tree and writing it, I did open (then close) an other file, so there was a problem. Thank you very much for all. Matthieu. On Mon, 29 Sep 2003, Rene Brun wrote: > I can only repeat my original request. Send the piece of code where > you create/open/close ALL your Root files, fill the Tree, etc. > I remind you that filling a Tree may imply writing to a file! > In general a tree does not fit in memory. > > Rene Brun > > Matthieu Lechowski wrote: > > > > On Mon, 29 Sep 2003, Rene Brun wrote: > > > > > You should not do: > > > > > > TTree *TREE = new TTree(...) > > > TFile *myfile=new TFile(name_ntuple, "RECREATE"); > > > ... > > > TREE->Write(); > > > > > > but > > > > > > TFile *myfile=new TFile(name_ntuple, "RECREATE"); > > > TTree *TREE = new TTree(...) > > > ... > > > > Yes but here I open a file of data, fill my Tree, and close the file, > > and after that TREE->Write(); doesn't work. > > > > > TREE->Write(); > > > > > > Rene Brun > > > > > > Matthieu Lechowski wrote: > > > > > > > > Hello, > > > > > > > > It's not easy to have a simplified version of my code, but if it's > > > > necessary I will provide you. > > > > > > > > I understand why the 2nd solution did not work: actually, I have to > > > > open a second file where I get data to fill my Tree. > > > > > > > > So I have this order of instructions: > > > > > > > > TTree *TREE = new TTree(...) > > > > TFile *data_file = new TFile(name_data_file); > > > > //..fill tree > > > > data_file->Close(); > > > > > > > > TFile *myfile=new TFile(name_ntuple, "RECREATE"); > > > > TREE->Write(); > > > > myfile->Close(); //"delete myfile;" doesn't work > > > > > > > > I just have changed the place of data_file->Close(). Indeed it was at > > > > the end, so when I tried to put "TFile *myfile=new ..." at the top as you > > > > said, of course the TREE->Write() wanted write in "data_file" instead of > > > > "myfile" (that's why I had the message "... not writable", I did not see > > > > that the message concerned "data_file" and not "myfile", sorry). > > > > > > > > But even placing data_file->Close() before writing the tree, it does not > > > > work when I put "TFile *myfile=new ..." at the top. > > > > > > > > ---- > > > > In conclusion, I have to manage 2 files, and I want write a Tree in one > > > > of them. The instructions above work for small files, but not for big > > > > ones. > > > > Do you see where could be the problem ? > > > > > > > > Matthieu. > > > > > > > > On Mon, 29 Sep 2003, Rene Brun wrote: > > > > > > > > > I am afraid that we will not make any progress without looking at a simplified > > > > > version of your code reproducing this problem. > > > > > > > > > > Rene Brun > > > > > > > > > > Matthieu Lechowski wrote: > > > > > > > > > > > > Hello, > > > > > > Thanks, but unfortunately it doesn't work. > > > > > > The first solution doesn't change anything, and with the second ROOT > > > > > > tells me my file is not writable (Error in <TTree::Write>: File ... is > > > > > > not writable). > > > > > > Have you others ideas ? > > > > > > Thank you. > > > > > > > > > > > > Matthieu. > > > > > > > > > > > > On Fri, 26 Sep 2003, Rene Brun wrote: > > > > > > > > > > > > > Matthieu, > > > > > > > > > > > > > > This seems to be a problem with the destructor of your TTree when > > > > > > > you close the file. > > > > > > > You can try two solutions: > > > > > > > 1- after TREE.Write(); add the statement > > > > > > > TREE.SetFile(0); > > > > > > > > > > > > > > 2- Do not create your Tree in the stack, but in the heap with > > > > > > > TFile *myfile=new TFile(name_ntuple, "RECREATE"); > > > > > > > TTree *TREE = new TTRee(... > > > > > > > //..fill tree > > > > > > > TREE->Write(); > > > > > > > delete myfile; //do not delete TREE > > > > > > > > > > > > > > Rene Brun > > > > > > > > > > > > > > Matthieu Lechowski wrote: > > > > > > > > > > > > > > > > Hello, > > > > > > > > > > > > > > > > ROOT leaves without saying anything when I try to write a TTree in a > > > > > > > > TFile, and the file has only few bytes (and can not be opened of > > > > > > > > course). > > > > > > > > > > > > > > > > I have a global tree: TTree TREE("T","TREE"); > > > > > > > > In a function, I fill it, then: > > > > > > > > TFile *myfile=new TFile(name_ntuple, "RECREATE"); > > > > > > > > TREE.Write(); > > > > > > > > myfile->Close(); > > > > > > > > > > > > > > > > This is the way I always used, and it always worked, but this time I > > > > > > > > have a big Tree and this doesn't work, I don't know why. > > > > > > > > Its size is less than the limit 2Gb, I think it should be around 80Mb > > > > > > > > with 100.000 entries (I have already a similar file of 8Mb with 10.000 > > > > > > > > entries that I succeeded to write). > > > > > > > > > > > > > > > > Have you an idea of what goes wrong ? > > > > > > > > Thank you. > > > > > > > > > > > > > > > > Matthieu Lechowski > > > > > > > > LAL Orsay > > > > > > > > > > > > > > > > lxplus > > > > > > > > ROOTSYS=/afs/cern.ch/sw/root/v3.05.05/rh73_gcc2952/root > > > > > > > > > > > > > > > >
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:15 MET