RooHistPdf Objet can't live outside a class member function

Dear expert

I am using pyROOT to create RooHistPdf and use it.

The problem lies with the RooHistPdf object. It seems that even when I define it as self.pdf = RooHistPdf(), the content of RooHistPdf gets deleted once the member function completes, although the type of the instance is retained.

For example, when I define sigpdf in one function (HZZAnalysis/SignalModel/ConstructSiganl2l2q.py at cbf0b63514ad533371ce5ae470d9df8672f9d11f · jialin-guo1/HZZAnalysis · GitHub), I am unable to use it in another function (HZZAnalysis/SignalModel/ConstructSiganl2l2q.py at cbf0b63514ad533371ce5ae470d9df8672f9d11f · jialin-guo1/HZZAnalysis · GitHub). when I check the type of sigpdf outside the function. it is still a RooHistPdf but no content in it.

Best
Jialin

Dear Jialin,

as far as I can tell from the RooHistPdf documentation, it does not take ownership of the passed RooDataHist. Could you try storing it in self as well and see if that works?

Jonas

Indeed that should work!

There was recently another post with the same problem:
https://root-forum.cern.ch/t/problems-in-fitting-with-root-6-32