jpata / API

Description and discussion of the HEP API
2 stars 1 forks source link

TFile, TDirectory model #4

Open jpata opened 8 years ago

jpata commented 8 years ago

How to best write objects to TFile or TDirectory? ROOT has the concept of a current working directory, creating tons of confusion. I would propose not to deal with that part of the API at all (i.e. TObject::SetDirectory, TDirectory::Add), but rather make a sane version of it.

HDF5.jl might be an inspiration: https://github.com/JuliaIO/HDF5.jl#quickstart

h5write("/tmp/test2.h5", "mygroup2/A", A)

#or
h5open("mydata.h5", "w") do file
    write(file, "A", A)  # alternatively, say "@write file A"
end

#or
using HDF5

h5open("test.h5", "w") do file
    g = g_create(file, "mygroup") # create a group
    g["dset1"] = 3.2              # create a scalar dataset inside the group
    attrs(g)["Description"] = "This group contains only a single dataset" # an attribute
end