Hi Ole, Sorry for this late reply. See below Rene Brun On Thu, 8 Aug 2002, Ole Streicher wrote: > Hello! > > I am just starting in using ROOT, and I have some questions in how to > organize a TTree. I want to have there a structure like > > event -+- branch1 -+- subbranch1 -+- var1 > | | +- var2 > | | : > | | > | +- subbranch2 -+- var3 > | | +- var4 > | | : > | : > | > +- branch2 -+- subbranch3 -+- var5 > | | | > : : : > > But all tutorials describe only how to get *one* level into (first > argument of ttree->Branch()), and not how tu build a second one. > If you look carefully at the examples, in particular $ROOTSYS/test/Event, you will see a way to build a Tree with two levels. You can try the Event example with the following configurations and see the meaning of the split mode: Event 200 0 0 1 Event 200 0 1 1 Event 200 0 2 1 Event 200 0 9 1 In general, it does not make sense to go below two levels of containers in the data base. The organisation in memory is a different question. You organize yourself the hierarchy level using class composition. > Also I am curious in how it would be possible to add another leaf to > an existing branch. Using > > int i, j; > TTree tree("mytree", "Example tree"); > tree.Branch("branch", &i, "i/I"); > tree.Branch("branch", &j, "j/I"); This redefines the same branch. It does not add a new leaf to a branch. You better define a new branch in this case. > > seems to add *two* branches with the same name to the tree - at least > if I execute "tree.StartViewer()" afterwards. > > Is it possible to put a complete "C" structure into a TTree without > the need to specify every of its elements? (would rootcint help here?) We try to discourage the use of C structs. Use a class instead. When using a class, the Branch function will automatically build the leaves for each data member of the class. > > The last question I have for Trees is in how can I view a tree > together with all its friends in a viewer. If I just execute > tree.StartViewer(), I can see the tree itself but not its friends. Is > there a possibility to combine them? > The TreeViewer does not show the branches/leaves of friend Trees in the same pane as the main Tree. This option could be implemented. > And one more (very last ;-) ) question: How can I link a TTree to a > certain TFile? I have the feeling that TTree uses the last TFile that > was created before the TTree was created - is that right? Can one > change this? You can use TTree::SetFile. However, you should not call SetFile once you have started filling the tree. > > Thank you! > > Tschuessi > > Ole >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:04 MET