hep: go-hep.org/x/hep/hbook/ntup/ntroot Index | Examples | Files

package ntroot

import "go-hep.org/x/hep/hbook/ntup/ntroot"

Package ntroot provides convenience functions to access ROOT trees as n-tuple data.

Example:

nt, err := ntroot.Open("testdata/simple.root", "mytree")
if err != nil {
    log.Fatalf("%+v", err)
}
defer nt.DB().Close()

Index

Examples

Package Files

ntroot.go

func Open Uses

func Open(name, tree string) (*ntup.Ntuple, error)

Open opens the named ROOT file in read-only mode and returns an n-tuple connected to the named tree.

Code:

nt, err := ntroot.Open("../../../groot/testdata/simple.root", "tree")
if err != nil {
    log.Fatalf("could not open n-tuple: %+v", err)
}
defer nt.DB().Close()

err = nt.Scan(
    "(one, two, three)",
    func(i int32, f float32, s string) error {
        fmt.Printf("row=(%v, %v, %q)\n", i, f, s)
        return nil
    },
)

if err != nil {
    log.Fatalf("could not scan n-tuple: %+v", err)
}

Output:

row=(1, 1.1, "uno")
row=(2, 2.2, "dos")
row=(3, 3.3, "tres")
row=(4, 4.4, "quatro")

Package ntroot imports 6 packages (graph). Updated 2020-05-20. Refresh now. Tools for package owners.