PyROOT: branch dereferenced after TChain::Draw()

Dear All,

I’ve just encountered what is possibly a PyROOT bug. An instance obtained from a TChain with GetBranch() is no longer the same branch (get dereferenced?) after TChain::Draw(). I did not encounter this behaviour with a single TTree or in C++.

Here is the PyROOT code that shows the bug:

#!/usr/bin/python

import ROOT

c = ROOT.TChain("tefield", "tefield")
c.Add("efield_1683733523-869645459_L0_0000.root")
c.Add("efield_3950562315-861740959_L0_0000.root")
c.Add("efield_3952437815-3952437815_L0_0000.root")
c.Add("efield_861745459-3951652315_L0_0000.root")

br = c.GetBranch("du_id")
print(br)
count = c.Draw("du_id", "", "goff")
print(br)

The first and last print usually shows a different branch, and the first shows the correct one.

Here are the tree files that I’ve used:

I also attach the C++ code that prints the same branch address before and after a Draw.
test_draw_getbranch.C (378 Bytes)


ROOT Version: 6.30.06
Platform: Fedora 40
Compiler: Not Provided


Hi,

Thanks for the report. Let me add @jonas in the loop.
In the meantime, at the cost of mentioning something you are already aware of, I would suggest, if possible for the use case, to try out RDataFrame ROOT: ROOT::RDataFrame Class Reference for this kind of operations.

Cheers,
Danilo

Thanks. I am expanding my quite big Python interface to TTrees, that allows I/O of trees in our experiment in a pythonic way, without any knowledge of ROOT and/or C++. I end up with classes with specific attributes to be I/O by the user. So not really a task for RDataFrame in my feeling :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.