Dear Rene and Philippe, Thanks for the informative explanation. Zaldy > Hi Zaldy, > > A short answer to your question(s) > > TTree has a pointer to the file where the Tree must be written. > When calling TTree::Fill, the function will automatically write > the buffers to the file where the tree was created. > At the end of your job, if you call tree->AutoSave, the Tree header > will also be written to the right file. You do not need to do, > file->cd(); > tree->Write(); > although you may want to do it if you want to write the tree header > to another file. > > Rene Brun > > On Sun, > 20 > Jul 2003, zaldy wrote: > > > > > Dear ROOT Users, > > > > > > In using the methods tree_ptr->Write() and file_ptr->Write(), how does the > > TTree object communicates with the TFile object? > > > > For instance in writing a root file, I noticed the ff. steps from the > > tutorial(filename: tree*.C) or manual (Users Man. 3.05, pp.212-214): > > > > 1. a declaration of the form > > TFile * firstFILEinput = new TFile("INPUT.root",MODE); > > TTree * myTree= new TTree("T","Oak Tree"); > > > > 2. Creating branches; > > myTree->Branch(.......arguments.......); > > ....... > > > > 3. Filling the branches with data; > > branchName = data_one; > > ............. > > myTree->Fill(); > > > > 4. actual writing; > > myTree->Write(); > > (sometimes: fileOUT->Write(); ) > > > > Now what about if one has to create another TFile object > > > > TFile * anotherFileOUTPUT = new TFile("OUTPUT.root",MODE), > > > > how will the TTree select which TFile's to direct? > > (Or, how intelligent this tree is to choose w/c from the two files to > > write?) > > > > I did not see an explicit > > declaration on the part of TTree that it has to write to a specific file. > > So far in the manual, we are told that it is for writing or reading > > through its MODE. > > > > In otherwords, is it INPUT.root or UTPUT.root ? > > Are we assured that it will not overwrite, for instance, the file > > "INPUT.root" with mode=>READ? > > > > My apology for the many questions. > > > > Thanks. > > > > > -- -------------------------------------------------------- Zaldy A. Nawang PS Users Room 2 Yon Gokan, E362, Neutrino Group, IPNS, KEK, Japan e-mail: zaldy@neutrino.kek.jp Tel. No. : (81) 029864 - 5387 --------------------------------------------------------
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:13 MET