def load_data(file_name, dir_name):
ROOTfile = ROOT.TFile(file_name)
dir = ROOTfile.Get("PAUReco")
tree = dir.Get("PAUReco")
print tree
return tree
def main():
t = load_data("../MC.root","PAUReco")
print t
Most likely the problem is that the TFile object got deleted/garbage collected at the end of the routine (the deletion of the TFile deletes the TTree object).
Most likely the problem is that the TFile object got deleted/garbage collected at the end of the routine (the deletion of the TFile deletes the TTree object).
Cheers,
Philippe.[/quote]
Why the deletion of TFile deletes TTree? At the end of the function there is a name associated to the TTree so the garbage collector doesn’t delete it. It’s not a python garbage collector problem, it is a problem of the ROOT implementation.