How to register ROOT object read from python pickle

From: Benjamin Bannier <bbannier_at_gmail.com>
Date: Tue, 11 Jan 2011 16:33:31 -0500


Dear ROOT experts,

I am trying to get a ROOT object loaded from a python pickle via name from some global registry like gDirectory or gROOT, but somehow cannot make it work.

If I write an object like

----(out.py)
import ROOT as r
import pickle

h = r.TH1D('h_test','', 100, -10, 10)

pickle.dump(h, file('h.pkl', 'w'))


and try to get it from gDirectory or gROOT like

----(in.py)
import ROOT as r
import pickle

h = pickle.load(file('h.pkl'))

for t in (r.gDirectory, r.gROOT):
  print t.FindObjectAny('h_test')
  print t.Get('h_test')


I get nothing:



$ python in.py
<ROOT.TObject object at 0x(nil)>
<ROOT.TObject object at 0x(nil)>
<ROOT.TObject object at 0x(nil)>
<ROOT.TObject object at 0x(nil)>

How would I make these objects known to the usual suspects or if they are already know how do I get them?

Thanks,

Benjamin

Received on Tue Jan 11 2011 - 22:33:42 CET

This archive was generated by hypermail 2.2.0 : Wed Jan 12 2011 - 05:50:01 CET