Home | News | Documentation | Download

RooDataSet Import


I’m trying to set up a very simple simultaneous fit, and need a combined RooDataSet with categories. I tried:

from ROOT import RooRealVar, RooPolynomial, RooCategory, RooFit, RooDataSet, RooArgSet

# Declare observable
x = RooRealVar("x","x",2.,-10,10) 

# Construction a uniform pdf
p0 = RooPolynomial("px","px",x) 

# Sample 1000 events from pdf
data1 = p0.generate(RooArgSet(x),1000)
data2 = p0.generate(RooArgSet(x),1000)

# Define categories
myCats = RooCategory("categories","categories")

# Make a combined dataset
combData = RooDataSet("combData","combined data" , RooArgSet(x) ,
                      RooFit.Import("Cat1",data1) ,
                      RooFit.Import("Cat2",data2) ,
                      RooFit.Index(myCats) )# , RooFit::WeightVar(weighting) ) ;

But this fails with:

[#0] ERROR:InputArguments – RooDataSet::ctor(combData) ERROR: missing arguments: IndexCat

What am I doing wrongly?


Kudos to @chrisburr who solved this for me.

Turns out not all RooCmdArgs are created equal, and the RooFit::Index() command has to come before any RooFit::Import() commands. Actually, it can also come after the first one. From Chris:

combData = RooDataSet("combData","combined data" , RooArgSet(x), RooFit.Index(myCats), RooFit.Import("Cat1",data1), RooFit.Import("Cat2",data2))

Interestingly putting Index in between of the Import arguments also works so there must be a quirk in how the arguments are processed:

combData = RooDataSet("combData","combined data" , RooArgSet(x), RooFit.Import("Cat1",data1), RooFit.Index(myCats), RooFit.Import("Cat2",data2))

ROOT devs, this isn’t obvious from the documentation… can you fix it?


I guess this is a PyROOT only issue. Have you tried in C++ ?




No, this is a problem with both PyROOT and regular C++ (which is where I first encountered it)




Thank you. Could you please then open a JIRA bug for this ?
It is then a bug in the parsing and it should be possible to fix



Done: https://sft.its.cern.ch/jira/browse/ROOT-9665


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.


This problem is fixed in the soon-to-be-released ROOT v6.16.