Hello all,
I am using ROOT 5.34/32.
I would like to do the following:
- Chain several trees (each one named ntp) from several root files,
- Select a set of branches of the chained trees and copy them into another three.
I tried to follow the example in the link below,
root.cern.ch/root/html/tutorial … ree.C.html
but with no success.
The structure of the tree is a set of variable size arrays as follows,
- Branch N: actual number of entries of the variable size arrays,
- Branches Var1, Var2, Var3, …: arrays with variable size N => e.g. Var1[N] for each entry in the tree
I tried to do the following,
-
Build a TChain (fChain) and chain the set of root files to it.
TChain* fChain = new TChain(“ntp”,“A chain”);
fChain->Add(“file1.root”);
fChain->Add(“file2.root”);
fChain->Add(“file3.root”);
.
.
. -
Then deactivate all the branches and active only the ones I want,
//Deactivate all the branches
fChain->SetBranchStatus("*",0);//Activate only the ones I want
fChain->SetBranchStatus(“N”,1);
fChain->SetBranchStatus(“Var1”,1);
fChain->SetBranchStatus(“Var2”,1);
fChain->SetBranchStatus(“Var3”,1);
.
.
.Then I tried to create a new tree as follows,
TTree* new_tree = fChain->CloneTree(0);
but I get a segmentation fault.
Any of you guys knows what I am doing wrong?
Many thanks in advance,
Alejandro