RooFit: RooTreeData.plotOn with PlotOpt

Hi,

I am using RooFit to plot some generated data and I am having trouble setting the plot options when using RooTreeData.plotOn.

As you can see here:
root.cern.ch/phpBB2/viewtopic.ph … ght=ploton
or here
root.cern.ch/phpBB2/viewtopic.ph … ght=ploton
the C++ examples don’t work, e.g. (stolen from the link above):

mass = RooRealVar("mass","Reconstructed Candidate Mass",0.0,8.0,"GeV")
mean =  RooRealVar("mean","Peak Mass",4.0,2.0,6.0,"GeV")
sigma = RooRealVar("sigma","Peak Width",1.0,0.1,2.0,"GeV")
gauss = RooGaussian("gauss","Gaussian Peak Model",mass,mean,sigma)
data=gauss.generate(RooArgSet(mass),1000)
frame = mass.frame()
data.plotOn(frame)

The last line gives the error

Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: RooPlot* RooDataHist(RooPlot* frame, RooTreeData::PlotOpt o) =>
    takes at least 2 arguments (1 given)

I figured out, that one must to use the RooTreeData::PlotOpt class as an argument, whereas for plotting the “gauss” you don’t need to give the second argument:

data.plotOn(frame,RooTreeData.PlotOpt())
gauss.plotOn(frame)

This works fine, but I haven’t figured out how to use this PlotOpt class to set for example the number of bins. Again the C++ example does not work, which is obvious looking at the type of “RooFit.Binning”:

In [15]: RooFit.Binning(8)
Out[15]: <ROOT.RooCmdArg object ("BinningSpec") at 0x945ec98>

In [16]: data.plotOn(frame, RooFit.Binning(8))
TypeError: none of the 2 overloaded methods succeeded. Full details:
  RooPlot* RooTreeData(RooPlot* frame, const RooLinkedList& cmdList) =>
    could not convert argument 2
  RooPlot* RooTreeData(RooPlot* frame, RooTreeData::PlotOpt o) =>
    could not convert argument 2

I can see that the PlotOpt class has a variable “bins” which is of type “RooAbsBinning”, but every time I use this class I get errors like:

In [2]: test=RooAbsBinning()
In [3]: test

 *** Break *** segmentation violation
(no debugging symbols found)
Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
Attaching to program: /proc/10861/exe, process 10861
[Thread debugging using libthread_db enabled]
[New Thread -1210472768 (LWP 10861)]
[New Thread -1256252496 (LWP 10881)]
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
Failed to read a valid object file image from memory.
0xb7f33410 in ?? ()
Thread 2 (Thread -1256252496 (LWP 10881)):
#0  0xb7f33410 in ?? ()
#1  0xb51f0a98 in ?? ()
#2  0x00000000 in ?? ()

I would be glad if someone has an working example or tells me that I am going in the wrong direction when I continue to dig on this RooTreeData.PlotOpt class. I am using Root 5.14 with included RooFit 2.10.

Thanks
Duc

Duc,

the differences in default arguments are b/c PyROOT is still not handling “using” properly (or at least not getting the info properly from CINT).

As for RooAbsBinning, according to TClass, it has no constructors (even as looking at the .h, there seem to be 2). Note that you can’t instantiate a RooAbsBinning from CINT either b/c of the missing ctor in the dictionary. I don’t understand what the issue is here.

As for passing the RooFit.Binning(8) argument, you can add it to the RooLinkedList and pass that:l = RooLinkedList() l.Add( RooFit.Binning(8) ) data.plotOn(frame, l)
which runs w/o complaints at least (sorry, I still haven’t had the time to familiarize myself with RooFit, so I don’t know whether passing the arg actually results in the desired effect).

HTH,
Wim