Is there a streamlined way to combine categorized RooDataSets in pyROOT? There is a partial answer from years ago in the forum, but this necessitates the extremely awkward
import ROOT as r
# create workspace
ws = r.RooWorkspace("ws")
# create variable
x = ws.factory("x[0, 100]")
# get datasets and declare categories
dsdict = {category: dataset, ...}
cat = ws.factory(f"infile[{' ,'.join(dsdict.keys())}]")
# a lot of ROOT magic to convert from a dictionary to a map
r.gInterpreter.GenerateDictionary("std::pair<std::string, RooDataSet*>", "map;string;RooDataSet.h")
r.gInterpreter.GenerateDictionary("std::map<std::string, RooDataSet*>", "map;string;RooDataSet.h")
r.gInterpreter.GenerateDictionary("std::pair<std::map<string,RooDataSet*>::iterator, bool>", "map;string;RooDataSet.h")
dsmap = r.std.map('string, RooDataSet*')()
dsmap.keepalive = list()
for c, d in dsdict.items():
dsmap.keepalive.append(d)
dsmap.insert(dsmap.begin(), r.std.pair("const string,RooDataSet*")(c, d))
# combine
ds = r.RooDataSet(
"data",
"data",
r.RooArgSet(x),
r.RooFit.Index(cat),
r.RooFit.Import(dsmap),
)
Are there any pythonizations or easier workarounds I have missed?