Hi Volker, Volker Hejny wrote: > > Hi, > > I'm currently working with data sets in a TTree, which have to > be processed by an analysis/simulation/etc. The output of these > programs has to be written to a TTree together with the input > data. At the moment this means to copy the existing tree to a > new file and adding new branches to the tree. This works, but > it also means copying large amounts of data from one file > to another. > > So my first question is: is it in some way possible to add new > branches to an existing tree on a file without changing the > old branches? > Yes, this is possible. However, you must be very careful when doing it. You should fill only the new branches and with teh same number of entries as the existing branches. See a small example below that adds two branches to the Tree generated in $ROOTSYS/test/Event > Another solution (which I'm actually using now) is to write > only the new information to the new file, in a tree which could > have the same name as the old one. In a later analysis one has > to open both files and go through both trees in parallel. > This works. You can read both Trees in parallel. There are no performance penalty for having more than one Tree in parallel. The only problem is that with TTree::Draw one cannot make correlations between branches of different Trees. I am planning to add this functionality. > I would suggest to add a class similar to TChain, but not working > with file chains, but parallel. Then it would be possible to > process on input file by several independant analysis programs > with individual output files. Later on, one could define such > a file collection, which should than act as one file (e.g. > when having trees with the same name in more than one file, > the objects in these trees could be accessed by only one > tree pointer). > This is another possible solution (say a TConcatTree), but then TChain must be able to support this new class. Rene Brun void add() { gSystem->Load("libEvent"); TFile f("Event.root","update"); TTree *T = (TTree*)f.Get("T"); Float_t x,y; TBranch *bx = T->Branch("x",&x,"x/F"); TBranch *by = T->Branch("y",&y,"y/F"); Int_t nentries = T->GetEntries(); for (Int_t i=0;i<nentries;i++) { x = i; y = nentries-i; bx->Fill(); by->Fill(); } T->Write(); f.Close(); }
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:35 MET