Go-HEP v0.16.0: rootio is dead, long live groot

hi there,

I realized I’ve talked a bit about the new groot package on the ROOT-forum, but didn’t properly introduce it.
It’s part of the new Go-HEP v0.16.0 release.

see the full announcement here:

TL;DR: it’s a new package, still in Go, that presents a somewhat better API to interact with ROOT files and ROOT types from Go (and Go-HEP.)


DOI

Release v0.16.0 is fresh from the oven.

This new release introduces a new package, groot, that replaces rootio.

groot & rootio

groot is a new package that is meant to replace rootio.
For backward compatibility, rootio will remain in the repository for a couple of releases (presumably until v1.0.0.)

groot is the result of refactoring rootio in a couple of more focused packages with clear API boundaries:

  • groot/rbase: definitions of basic ROOT classes (Object, Named, ObjString, …)
  • groot/rbytes: definitions of types useful for serializing and deserializing ROOT data buffers, interfaces to interact with ROOT’s metadata classes such as StreamerInfo and StreamerElements.
  • groot/rcont: definitions of ROOT container types (TList, THashList, TObjArray, TArrayX)
  • groot/rdict: definitions of ROOT streamers (TStreamerArtificial, TStreamerLoop, …)
  • groot/rhist: definitions of ROOT types related to histograms and graphs (TH1x, TH2x, TGraph, TGraphErrors, TGraphAsymmErrors)
  • groot/riofs: low-level types and functions to deal with opening and creating ROOT files; users should prefer using the groot package to open and create ROOT files
  • groot/root: ROOT core interfaces (Object, Named, ObjArray, …)
  • groot/rsrv: exposes HTTP end-point to manipulate ROOT files, plot and create histograms and graphs from files or trees
  • groot/rtree: interface to decode, read, concatenate and iterate over ROOT Trees
  • groot/rtypes: rtypes contains the means to register types (ROOT ones and user defined ones) with the ROOT type factory system
  • groot/rvers: rvers contains the ROOT version and the classes’ versions groot is supporting and currently reading.

Interacting with ROOT files should be performed with the groot package:

import "go-hep.org/x/hep/groot"

func F() {
	f1, err := groot.Open("some/file.root")
	f2, err := groot.Create("some/other.root")
}

groot has the needed bootstrap code that allows to automatically import the registration code for all the ROOT types groot knows how to handle.

Here is a quick and dirty Rosetta code for migrating to groot:

  • rootio.H1groot/rhist.H1
  • rootio.H2groot/rhist.H2
  • rootio.Graphgroot/rhist.Graph
  • rootio.Treegroot/rtree.Tree
  • rootio.ChainOfgroot/rtree.ChainOf
  • rootio.Scannergroot/rtree.Scanner
  • rootio.Filegroot/riofs.File
  • rootio.Directorygroot/riofs.Directory
  • rootio.Opengroot.Open
  • rootio.Creategroot.Create

groot/rsrv & root-srv

root-srv has been refactored to extract the pure plot/file interaction machinery from the GUI part.
The plot creation and the ROOT file interaction parts have been refactored into a new package go-hep.org/x/hep/groot/rsrv that contains a couple of HTTP end-points that can be reused in third-party packages or applications.

rsrv exposes a REST API that expects JSON requests (OpenFileRequest, PlotH1Request, PlotTreeRequest, …) and returns JSON responses.
The HTTP end-points are attached to the rsrv.Server type.

root-srv can now open ROOT files served over xrootd.