SPlots can only work with unbinned data, because they have to reweight each entry in the dataset. It is therefore correct that the constructor only takes a RooDataSet, and no RooDataHist.
This should not have anything to do with python. If you had unbinned data on the python side, I would expect that you could call the constructor.
(And if you cannot, let us know please )
Hi Stephan,
thank you for your answer.
Yes, you are right, this has actually nothing to do with python The thing is, with python3 I could not build a RooDataSet from TTree using the constructor… I don’t know why but it kept failing
Anyway, I was just complaining because I am experiencing a lot of problems with PyRoot. Sorry if I bothered you!
Oh yes. It’s a lifetime problem that’s notoriously difficult to solve between those two languages, but there’s an easy workaround:
x = RooRealVar(...)
xSet = ROOT.RooArgSet(x)
data = RooDataSet("data","data",tree,xSet)
What happens:
Python creates a temporary RooArgSet, and calls the function. RooDataSet uses the (C++) RooArgSet to define which variables should be in use. Python thinks that nobody uses the ArgSet, and deletes it --> the C++ object vanishes --> dangling pointer --> Crash.
Give it a name, and python lets it survive.
We are thinking about how to solve it, but this requires to smartly find out when python should release ownership of an object. Alternatively, we need to teach python’s garbage collector that C++ still needs the thing.
It’s a work in progress …