Hi, I’ve got a seemingly simple goal, but it’s proving difficult.
I would like to write a PyROOT function that takes as an argument a TTree or TChain and a string with a branch name. In the function, I’d like to set all the branch statuses to 0 except for the named branch. Then I’d loop over all the entries in the TTree or TChain to do something (e.g. fill a set or numpy array), restore all the branch statuses to what they were BEFORE the function was called, then return.
My complication is that some of the branches in the TTree may be nontrivial & split. E.g. when I do mytree.Show(0), I get a largeish list of branches, but in mytree.GetListOfBranches() I only get a few, because many of those “Shown” branches are actually just members of a single branch in the List. I’d like my function to work for those member branches and for simple branches.
My real code where the branch is created in the TTree can be seen here: http://bazaar.launchpad.net/~jfcaron/+junk/Proto2BeamTest2/view/head:/MydaqT.C#L174 and the composite struct which has the sub-branches is here: http://bazaar.launchpad.net/~jfcaron/+junk/Proto2BeamTest2/view/head:/Utility.C#L197
I also tried using TTree::GetBranch to access only a single branch, but again I have trouble with the fact that the branch name is actually for a split member of the struct.