Extracting the name of the branches used in a TCut

Dear all,
if I have a TCut cut = “x>10 && y==3 || z” is there a ROOT method that gives me the list of branches used in the TCut (in this case “x”, “y”, “z”)? I would like to use it to turn off all branches of a TTree except those used by the TCut (+ the ones I am interested in) before doing a TTree::CopyTree(cut) to speed up the process and disabled unused branches.
Thanks,
Giovanni

Hi Giovanni,

You can use:

TTreeFormula f("cutparser", cut, tree); for(int i = 0; i < f.GetNcodes(); ++i) { TLeaf* leaf = f.GetLeaf(i); if (leaf) { TBranch* branch = leaf->GetBranch(); printf("branch name: %s\n", branch->GetName()); } }
Cheers,
Philippe.