ntroot

package
v0.34.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

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.

Example
package main

import (
	"fmt"
	"log"

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

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

	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")

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL