as alluded to during the ROOT Users’ workshop:
GoHEP v0.15.0
has now support for (also) writing ROOT files:
-
TObjString
,TObject
,TNamed
, -
TH1x
,TH2x
,TGraph
,TGraph{,Asymm}Errors
it also ships with a new root-cp
command that can extract objects from a ROOT file and save them into a new one.
go-hep/rootio
also supports writing compressed ROOT files (zlib
, LZ4
, LZMA
).
Here is the full announcement: https://go-hep.org/news/release-0.15.0/
and here is a simple example:
func main() {
w, err := rootio.Create("out.root", rootio.WithLZ4(flate.BestCompression))
if err != nil {
log.Fatal(err)
}
defer w.Close()
v := rootio.NewObjString("Hello World from Go-HEP!")
err = w.Put("my-obj-string", v)
if err != nil {
log.Fatal(err)
}
fmt.Printf("keys: %d\n", len(w.Keys()))
err = w.Close()
if err != nil {
log.Fatalf("could not close file: %v", err)
}
}
(Go-HEP tests make sure that the file is also correctly read-back from ROOT/C++)
also:
$> root-cp -h
Usage: root-cp [options] file1.root [file2.root [...]] out.root
ex:
$> root-cp f.root out.root
$> root-cp f1.root f2.root f3.root out.root
$> root-cp f1.root:hist.* f2.root:h2 out.root
options:
$> root-cp ./testdata/graphs.root:g.* out.root
$> root-cp root://xrootd.example.org/file.root:hist.* out.root
Next steps are:
-
TTree
,TBranch{,Element}
,TLeaf{,Element}
andTBasket
- interoperability of
TTree
with Apache Arrow (both read & write to leverage the whole Apache Arrow ecosystem) - profiling (CPU/Memory)
Enjoy
(and happy to get any kind of feedback)