Home | News | Documentation | Download

Setting the Name/Title of a tree from GetClonedTree()?

Hi all,

I’m trying to move some of my C++ code to python, but I’ve found something I don’t understand during the porting.

As a MWE I have…

import ROOT

##---

Observable = ROOT.RooRealVar("Observable", "Observable", 0.1, 1.0)

c   = ROOT.RooRealVar("c", "c", -2.0)
PDF = ROOT.RooExponential("PDF", "PDF", Observable, c)

##---

DataSet = PDF.generate(ROOT.RooArgSet(Observable), 10000)
Tree = DataSet.GetClonedTree()

##---

## Tree.SetNameTitle("Name", "Name")

Adding back in the line that calls .SetNameTitle() causes a crash during the shutdown of pyROOT/python/ROOT. Have I missed something somewhere?

Thanks,
Andy.

Weird. Maybe @etejedor has an idea

Hello,

Could you paste here the error you get at teardown?

I don’t know what SetNameTitile does that could cause this, but it looks like it modifies some internal memory management of the cloned tree. Perhaps @moneta can comment.

Log.txt (4.1 KB)

@bellenot @etejedor

Enjoy!

It happens during teardown in TROOT::CloseFiles(), and it must be related to the internal memory management of the cloned tree.

This is ok:

import ROOT

Tree = ROOT.TTree()
Tree.SetNameTitle("Name", "Name")

A workaround to prevent this is to add ROOT.SetOwnership(Tree, False) to prevent the deletion of the cloned tree from Python, since it seems there might be some double deletion going on.

@moneta or @pcanal can perhaps further comment.

1 Like