Hello, I’m struggling with saving a tree into a file.
What I’m trying to do is :
Read a tree file and get values from leaves, then calculate a physical quantity from those values, and fill it in another(new) tree, for each entry. And save the new tree into a file.
Please find the attached file.
When the first tree file is not too large (number of entries < 106), my program work. But when the
number of enties exceeds ~5x106, my program abort when writing the file.
I tried to use TTree::AutoSave(), but this function only save the the tree header, and I cannot read the content later.[/list] mkEnergyTree.C (2.33 KB)
Nice to meet you, Brun. And A Happy New Year.
Thank you very much for your help. Now, my program works as I want.
By the way, I have one more question related to the program and the tree.
The original tree contains 5 branches, whose types are Int_t, Int_t, array of Short_t (64), array of Double_t (64), array of Double_t (2), respectively. The file size is 618588698. (See below.)
On the other hands, the new tree contains only 1 branch, whose type is array of Float_t (64). The file size is 1238224876, which is twice as large as the original one. (See below.)
I would like to know about the file size. Why the file size of new tree get so large? Are there any way to control the compression factor when making this tree?
Thank you.
titoh
— “original” tree —
root [1] TFile *f = new TFile(“041231_na_m20_4us_clon_tree.root”)
root [2] TTree tr = (TTree)f->Get(“tree”)
root [3] tr->Print()
*Tree :tree : tree for data *
*Entries : 5174246 : Total = 3445009597 bytes File Size = 618588698 *