Pyroot and roofit PlotOn problem

Is RooFit ready for python (pyROOT)? I’m trying to plot data from histogram using RooDataHist::PlotOn as data.plotOn(frame), and I got

TypeError: RooPlot* RooDataHist::plotOn(RooPlot* frame, RooAbsData::PlotOpt o) =>
takes at least 2 arguments (1 given)

if I try with:

data.plotOn(frame, ROOT.RooArgList())

I got

TClass::TClass:0: RuntimeWarning: no dictionary for class RooAbsData::PlotOpt is available

Hi,

which release is this? I recently made some fixes to workaround the “using” statements of plotOn (CINT does not propagate “using” in the dictionary, so it had to be manually fixed). For older releases, the base class plotOn needs to be called directly.

That said, I don’t quite see how a RooArgList() could possibly pass through a RooAbsData::PlotOpt?

Cheers,
Wim

[quote=“wlav”]Hi,

which release is this? I recently made some fixes to workaround the “using” statements of plotOn (CINT does not propagate “using” in the dictionary, so it had to be manually fixed). For older releases, the base class plotOn needs to be called directly.

That said, I don’t quite see how a RooArgList() could possibly pass through a RooAbsData::PlotOpt?

Cheers,
Wim[/quote]

I’m using

ROOT 5.26/00 (trunk@31882, Dec 14 2009, 20:18:36 on linuxx8664gcc)

I tried to add a RooArgList() argument because the first error says that RooDataHist::plotOn wants 2 arguments

Hi,

but why a RooArgList(), and not a RooAbsData.PlotOpt()?

Cheers,
Wim

[quote=“wlav”]Hi,

but why a RooArgList(), and not a RooAbsData.PlotOpt()?

Cheers,
Wim[/quote]

It was a random choice, tomorrow I’ll try with your solution, thanks.

[quote=“wiso”][quote=“wlav”]Hi,

but why a RooArgList(), and not a RooAbsData.PlotOpt()?

Cheers,
Wim[/quote]

It was a random choice, tomorrow I’ll try with your solution, thanks.[/quote]

data.plotOn(frame, ROOT.RooAbsData.PlotOpt())

TClass::TClass:0: RuntimeWarning: no dictionary for class RooAbsData::PlotOpt is available

Hi,

yes, I’ve seen the warning, but when a construction fails from the dictionary, it’s handed to CINT to give it a try, and that succeeds, AFAICS? (Not sure why it succeeds, but that’s a different matter, and for CINT experts to answer; but CINT interpreted constructors are okay for simple structs in my experience.)

And again, you can also call the base class plotOn directly, and in trunk the “using” has been worked around, making it no longer an issue.

Cheers,
Wim

[quote=“wlav”]Hi,

yes, I’ve seen the warning, but when a construction fails from the dictionary, it’s handed to CINT to give it a try, and that succeeds, AFAICS? (Not sure why it succeeds, but that’s a different matter, and for CINT experts to answer; but CINT interpreted constructors are okay for simple structs in my experience.)

And again, you can also call the base class plotOn directly, and in trunk the “using” has been worked around, making it no longer an issue.

Cheers,
Wim[/quote]

Sorry, but I’m not so expert. Can you explaint better how can I draw this histogram (RooFit histogram, not ROOT histogram) in PyROOT? Actually I can draw the fitted function, but I want to superimpose the data histogram.

Hi,

no expert on RooFit here either, so w/o sample code I can’t be sure that I even understand what you’re asking for …

For plotOn, the following is “my” preferred way, i.e. call the base class plotOn directly:RooAbsData.plotOn( myDataHist, myFrame )with myDataHist being a RooDataHist, and myFrame being a RooPlot. I prefer this way b/c it will work for all releases, and it is most closely to what is done in the RooFit tutorial examples (which is all the RooFit code I’ve ever run), where the existence of a “using” declaration will make the base class plotOn be called in C++.

A fully functional code snippet (again, I have no idea whether this is proper RooFit code, or whether this is what you’re doing; I just took it from another thread on this forum):from ROOT import * hh=TH1F("hh", "test histo", 100, -5, 5) hh.FillRandom("gaus", 10000) x=RooRealVar("x", "x", -5, 5) data=RooDataHist("data", "dataset with x", RooArgList(x), hh) frame=x.frame() RooAbsData.plotOn( data, frame ) frame.Draw()
Now, if you have a trunk build, then data.plotOn( frame ) would do as well (the using is manually worked around in there, since this has become such a FAQ).

If this still is not what you are looking for, then please provide your own code snippet so that we have something concrete to work with. I’ve run out of ideas on how to explain this …

HTH,
Wim

thank you very much, now it works