fTree->Fill();
fTree->Write();
}
The entry number of each branch is 1 and I don’t understand why is this. I was expecting 10 entry for the first branch and 20 entry for the second one. Am I dong something wrong?
[quote]The entry number of each branch is 1 and I don’t understand why is this.[/quote]Because you only call Fill once.
[quote] I was expecting 10 entry for the first branch and 20 entry for the second one.[/quote]Even-though this is ‘possible’ to do, we strongly advise against it.
To fill a TTree, you should o:[code]void testtree() {
TFile* tfile = new TFile(“treetest.root”, “RECREATE”);
Double_t test1, test2;
fTree = new TTree(“Treetest”,“Treetest”);
fTree->Branch(“test1”,&test1,“test1/D”);
fTree->Branch(“test2”,&test2,“test2/D”);
Now I can fill the tree correctly. Actually I have about 100 different loop like this and I don’t want to create a new tree for each loop. I just wanted to put the result of each loop in a different branch. So, if you don’t recommend to use this structure, what should I use to collect the results?
[quote] So, if you don’t recommend to use this structure, what should I use to collect the results? [/quote]What is the higher level description of what you need to achieve?
[quote] Actually I have about 100 different loop like this and I don’t want to create a new tree for each loop.[/quote]I would create the TTree outside of the function and pass it around to the other filler.
[quote]I just wanted to put the result of each loop in a different branch.[/quote]Usually, this is done is 3 steps:
create all the branches and associate place holder