Recover RooDataSet from root file in a python script

Hi Folks,
I’m attempting to read back a RooDataSet into a python script after saving it to a root file.

Following the procedure demonstrated in r402_datahandling.py, I save with:
# Save the roodata set
rooName= Outfile+’_roofit.root’
f = ROOT.TFile(rooName, “RECREATE”)
X17_mass_set.Write()
f.ls()
f.Close()

But I can’t work out how to read it back into a python script.
The procedure outlined in rf402 is not valid python and doing:

f= ROOT.TFile(Infile)
X17_mass_set = f.FindObject("X17_mass_set")

Returns a TObject not a RooDataSet.

How should I proceed?

Thanks!

Martin

Python should know that this really is a RooDataSet. You can also just do f.X17_mass_set to access it.

Hi Axel,

Thanks. That worked perfectly and is simpler than what implemented (30 minutes after posting the question!). For completeness this worked too.

f= ROOT.TFile(Infile)
X17_mass_set = f.Get("X17_mass_set")

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