For a long time, maybe improperly, I was using TTrees with variables refering to the branches names, not leafs names (usually I have one leaf per variable). This is working with TTree::Draw() and Scan() in ROOT and PyROOT. It was also working directly in PyROOT referring to tree.branchname. However, it seems it stopped, or stops in some cases in ROOT >5.34.15. I use .15 on my computer and the info that it does not work comes from other people with higher versions.
Now, when referring to a branch name one gets:
Is it how it is supposed to be, Scan() and Draw() just still supporting a wrong approach? Or was there a bug introduced in more recent ROOTs?
a workaround would be to create the object of the right type, use SetBranchAddress, then assign it to the tree. Quick ‘pseudo-code’:t = f.tevent
cpu_packet_time = CpuPacketTime()
t.cpu_packet_time = cpu_packet_time
Since the TypeError is a python exception, you can also do the above in a custom getattr for TTree, if you do not know a priori the types.
okay, got it: there’s no named leaf, but then there is only one leaf, so the code may assume that that’s got to be the one. Will apply. But it also suggests another workaround: simply name the leaf:t.GetBranch("cpu_packet_time").GetListOfLeaves().At(0).SetName("cpu_packet_time")
Actually, putting that wrong: there’s no leaf named “cpu_packet_time”. The leaf does have a name, of course, but it is “time” (per the “time/I” part when creating the branch). And yes, t.time does give the proper result.