2

I am trying to store a python class (or just the members) in a ROOT file (CERN, TFile) via rootpy.

I can easily do this using a Tree and a TreeModel but that only works for basic types and does not result in the structure I am looking for. I had also a quick look at rootpy.io.pickler but that does not allow the inspection with a TBrowser (it crashes).

I was wondering if there is a better way. What I would like to have

My file:

  • directory of my choosing
    • directory with the name of my object
    • object basic types (int, float, string)
    • histograms (that one is easy)
    • other complex objects

As you see this cannot be realised with a Tree and I do not know how to add the basic types to a Directory. Any ideas?

I would like to avoid, if possible, the logical work-around of storing the object parameters in a tree and the histograms directly in the same Directory.

Nathanael Farley
  • 400
  • 3
  • 19
DragonTux
  • 732
  • 10
  • 22

1 Answers1

1

The only idea I have is to create the TDirectory you want in your TFile and add the contents to this directory. Histograms are easy. The basic types could be stored in a tree. For other complex objects you could have a look at pickle. The serialized object (i.e. pickle_string = pickle.dumps(Foo)) can then be stored in a tree as a string without breaking inspection via TBrowser. This works without rootpy, just using PyROOT. I hope this might help.

Sascha
  • 86
  • 1
  • 4