import (
"os"
"path/filepath"
"go-hep.org/x/hep/hbook/rootcnv"
"go-hep.org/x/hep/rootio"
)
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()
printf("keys: %v\n", f.Keys())
h1, err := f.Get("h1f")
if err != nil {
panic(err)
}
h1f, err := rootcnv.H1D(h1.(rootio.H1))
if err != nil {
panic(err)
}
import (
"image/color"
"go-hep.org/x/hep/hplot"
)
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())
hplot.Show(p, 640, -1, "png")
f.Close()
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()
printf("keys: %v\n", f.Keys())
h2, err := f.Get("h2f")
if err != nil {
panic(err)
}
h2f, err := rootcnv.H2D(h2.(rootio.H2))
if err != nil {
panic(err)
}
p = hplot.New()
p.Title.Text = "Histogram 2D"
p.Add(hplot.NewH2D(h2f, nil))
p.Add(hplot.NewGrid())
hplot.Show(p, 640, -1, "png")