In [ ]:
import (
    "os"
    "path/filepath"
    
    "go-hep.org/x/hep/hbook/rootcnv"
    "go-hep.org/x/hep/rootio"
)
In [ ]:
fname := filepath.Join(os.Getenv("GOPATH"), "src", "go-hep.org/x/hep/hbook/rootcnv/testdata/gauss-h1.root")
f, err := rootio.Open(fname)
if err != nil {
    panic(err)
}
defer f.Close()
In [ ]:
printf("keys: %v\n", f.Keys())
In [ ]:
h1, err := f.Get("h1f")
if err != nil {
    panic(err)
}
In [ ]:
h1f, err := rootcnv.H1D(h1.(rootio.H1))
if err != nil {
    panic(err)
}
In [ ]:
import (
    "image/color"
    "go-hep.org/x/hep/hplot"
)
In [ ]:
p := hplot.New()
p.Title.Text = "Histogram 1D"
hh := hplot.NewH1D(h1f)
hh.Color = color.RGBA{R: 0xff, A: 255}
hh.Infos.Style = hplot.HInfoSummary
p.Add(hh)
p.Add(hplot.NewGrid())
In [ ]:
hplot.Show(p, 640, -1, "png")
In [ ]:
f.Close()
In [ ]:
fname = filepath.Join(os.Getenv("GOPATH"), "src", "go-hep.org/x/hep/hbook/rootcnv/testdata/gauss-h2.root")
f, err = rootio.Open(fname)
if err != nil {
    panic(err)
}
defer f.Close()
In [ ]:
printf("keys: %v\n", f.Keys())
In [ ]:
h2, err := f.Get("h2f")
if err != nil {
    panic(err)
}
In [ ]:
h2f, err := rootcnv.H2D(h2.(rootio.H2))
if err != nil {
    panic(err)
}
In [ ]:
p = hplot.New()
p.Title.Text = "Histogram 2D"
p.Add(hplot.NewH2D(h2f, nil))
p.Add(hplot.NewGrid())
In [ ]:
hplot.Show(p, 640, -1, "png")