Write a map of objects using HFile
Code: "io_hfile_map.py". Programming language: Python DMelt Version 1. Last modified: 12/11/2015. License: Pro
https://datamelt.org/code/cache/io_hfile_map_3139.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.



from jhplot  import *
from jhplot.io import *
import os.path


# write events to serialized files
file="output.ser"


f=HFile(file,"w")

h1=H1D("Histo",100,0,10)
p0=P0D();
p0.add(1)
p0.add(2)

p1=P1D()
p1.add(1,2)
p1.add(2,4)

f.write("data/h1",h1)
f.write("data/p0",p0)
f.write("data/p1",p1)
# obg =f.getObjectMap()
#print f.getEntries()
#print obg
f.close()


# read all the entries 
f=HFile(file)
obg =f.getObjectMap()
print obg
print f.getEntries()
obg =f.getObjectMap()
print obg
h=f.read("data/h1")
print h.toString()
f.close()

Ads help maintain this website.