Hi,
I have a TTree, and a TTreeFormula (unknown until runtime). I would like to turn off all branches except for those used by the TTreeFormula, so that iteration over the tree reads less data and goes faster. Is there a way to ask the TTreeFormula which branches it needs? I’ve looked through the docs, and can’t find anything, except that TTreeFormula has a protected data member “fBranches”, but no public method for accessing it. Am I missing something?
Regards,
Jon
[quote]I have a TTree, and a TTreeFormula (unknown until runtime). I would like to turn off all branches except for those used by the TTreeFormula, so that iteration over the tree reads less data and goes faster[/quote]Yes you can interrogate which branches the TTreeFormula need … (TTreeFormula::GetLeaf from 0 to GetNcodes).
However there is usually no need / no reason to manually load those branches. TTreeFormula::EvalInstance will load the data for only the branches it needs. Remember that to move the ‘cursor’ to the right entry, all you need to do is call TTree::LoadTree(entry_number) which moves the cursor (and possibly open a new TFile if the tree is a chain) but does not load any data.
Cheers,
Philippe.
Hi Phillipe,
Thanks for the help. I am currently using the basic PyRoot TTree iterator, which calls GetEntry instead of LoadTree. So I guess I’ll either switch to using LoadTree or else use GetLeaf and SetBranchStatus.
Thanks,
Jon