Hi James,
I can replicate this (the fact that the histogram is not saved to the file) on Debian "sid" with Python 2.5.2 and ROOT 5.18.00. A couple minor differences are: 1) I don't get the segfault upon exiting Python, and 2) I also don't get any warnings like "class TFile already in TClassTable".
I can also replicate the fact that the TH1F is not saved using the equivalent statements in ROOT 5.18's Cint interface. So if this is a bug, it isn't Python-specific.
However it seems that in either Python or Cint, what you can do is make a call to g.Write() before f.Close(). At least in my tests, this *will* save the histogram into the test file. As to whether the call to g.Write() is supposed to be unnecessary, I will let more knowledgeable people answer.
What the call to g.Write() appears to do is add a key to the file:
>>> f.ls()
TFile** test.root TFile* test.root OBJ: TH1F testhist testhist : 0 at: 0x885fe68>>> g.Write()
TFile** test.root TFile* test.root OBJ: TH1F testhist testhist : 0 at: 0x885fe68 KEY: TH1F testhist;1 testhist
and then upon closing and re-opening the file,
>>> f.ls()
TFile** test.root TFile* test.root KEY: TH1F testhist;1 testhist>>> g = TH1F(f.Get("testhist"))
best regards,
James Jackson wrote:
> Hi,
>
> I am having serious problems with PyRoot on a new SLC4 machine (it's a
> VM but that shouldn't make any difference), with ROOT built from the
> latest production source:
>
> ----------------------------------
> [james_at_slc4vm PdfErrors]$ python
> Python 2.3.4 (#1, Dec 11 2007, 21:18:01)
> [GCC 3.4.6 20060404 (Red Hat 3.4.6-9)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from ROOT import TFile, TH1F
>>>> f = TFile("test.root", "recreate") >>>> g = TH1F("testhist", "testhist", 10, 0, 10) >>>> g.Fill(5)
>>>> f.ls()> OBJ: TH1F testhist testhist : 0 at: 0x9a9e280
> TFile** test.root
> TFile* test.root
>>>> f.Close() >>>> <here do Ctrl+D>
>>>> from ROOT import TFile
>>>> f = TFile("test.root") >>>> f.ls()>
> TFile** test.root
> TFile* test.root
> ----------------------------------
-- Kevin B. McCarty <kmccarty_at_gmail.com> WWW: http://www.starplot.org/ WWW: http://people.debian.org/~kmccarty/ GPG: public key ID 4F83C751Received on Fri Jun 13 2008 - 18:50:48 CEST
This archive was generated by hypermail 2.2.0 : Fri Jun 13 2008 - 23:50:01 CEST