rootio

package
Version: v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2020 License: BSD-3-Clause Imports: 27 Imported by: 0

README

rootio

GoDoc

Experimental, pure-Go package to read ROOT files (and perhaps write them out too), without having ROOT installed.

Installation

go get go-hep.org/x/hep/rootio

Documentation

rootio documentation can be found over there:

https://godoc.org/go-hep.org/x/hep/rootio

Documentation

Overview

Package rootio provides a pure-go read-access to ROOT files. rootio might, with time, provide write-access too.

A typical usage is as follows:

f, err := rootio.Open("ntup.root")
if err != nil {
    log.Fatal(err)
}
defer f.Close()

obj, err := f.Get("tree")
if err != nil {
    log.Fatal(err)
}
tree := obj.(rootio.Tree)
fmt.Printf("entries= %v\n", tree.Entries())

More complete examples on how to iterate over the content of a Tree can be found in the examples attached to rootio.TreeScanner and rootio.Scanner: https://godoc.org/go-hep.org/x/hep/rootio#pkg-examples

Another possibility is to look at: https://godoc.org/go-hep.org/x/hep/rootio/cmd/root-ls, a command that inspects the content of ROOT files.

File layout

ROOT files are a suite of consecutive data records. Each data record consists of a header part, called a TKey, and a payload whose content, length and meaning are described by the header. The current ROOT file format encodes all data in big endian.

ROOT files initially only supported 32b addressing. Large files support (>4Gb) was added later on by migrating to a 64b addressing.

The on-disk binary layout of a ROOT file header looks like this:

     Type        | Record Name | Description
=================+=============+===========================================
   [4]byte       | "root"      | Root file identifier
   int32         | fVersion    | File format version
   int32         | fBEGIN      | Pointer to first data record
   int32 [int64] | fEND        | Pointer to first free word at the EOF
   int32 [int64] | fSeekFree   | Pointer to FREE data record
   int32         | fNbytesFree | Number of bytes in FREE data record
   int32         | nfree       | Number of free data records
   int32         | fNbytesName | Number of bytes in TNamed at creation time
   byte          | fUnits      | Number of bytes for file pointers
   int32         | fCompress   | Compression level and algorithm
   int32 [int64] | fSeekInfo   | Pointer to TStreamerInfo record
   int32         | fNbytesInfo | Number of bytes in TStreamerInfo record
   [18]byte      | fUUID       | Universal Unique ID
=================+=============+===========================================

This is followed by a sequence of data records, starting at the fBEGIN offset from the beginning of the file.

The on-disk binary layout of a data record is:

      Type     | Member Name | Description
===============+=============+===========================================
 int32         | Nbytes      | Length of compressed object (in bytes)
 int16         | Version     | TKey version identifier
 int32         | ObjLen      | Length of uncompressed object
 int32         | Datime      | Date and time when object was written to file
 int16         | KeyLen      | Length of the key structure (in bytes)
 int16         | Cycle       | Cycle of key
 int32 [int64] | SeekKey     | Pointer to record itself (consistency check)
 int32 [int64] | SeekPdir    | Pointer to directory header
 byte          | lname       | Number of bytes in the class name
 []byte        | ClassName   | Object Class Name
 byte          | lname       | Number of bytes in the object name
 []byte        | Name        | Name of the object
 byte          | lTitle      | Number of bytes in the object title
 []byte        | Title       | Title of the object
 []byte        | DATA        | Data bytes associated to the object
===============+=============+===========================================

The high-level on-disk representation of a ROOT file is thus:

+===============+ -- 0
|               |
|  File Header  |
|               |
+===============+ -- fBEGIN offset
|               |
| Record Header | -->-+
|               |     |
+---------------+     |
|               |     |
|  Record Data  |     | Reference to next Record
|    Payload    |     |
|               |     |
+===============+ <---+
|               |
| Record Header | -->-+
|               |     |
+---------------+     |
|               |     |
|  Record Data  |     | Reference to next Record
|    Payload    |     |
|               |     |
+===============+ <---+
|               |
       ...

|               |
+===============+ -- fSeekInfo
|               |
| Record Header | -->-+
|               |     |
+---------------+     |
|               |     |
|  Record Data  |     | Reference to next Record
|    Payload    |     |
|               |     |
+===============+ <---+ -- fEND offset

Data records payloads and how to deserialize them are described by a TStreamerInfo. The list of all TStreamerInfos that are used to interpret the content of a ROOT file is stored at the end of that ROOT file, at offset fSeekInfo.

Data records

Data records' payloads may be compressed. Detecting whether a payload is compressed is usually done by comparing the object length (ObjLen) field of the record header with the length of the compressed object (Nbytes) field. If they differ after having subtracted the record header length, then the payload has been compressed.

A record data payload is itself split into multiple chunks of maximum size 16*1024*1024 bytes. Each chunk consists of:

  • the chunk header,
  • the chunk compressed payload.

The chunk header:

  • 3 bytes to identify the compression algorithm and version,
  • 3 bytes to identify the deflated buffer size,
  • 3 bytes to identify the inflated buffer size.

Streamer informations

Streamers describe how a given type, for a given version of that type, is written on disk. In C++/ROOT, a streamer is represented as a TStreamerInfo class that can give metadata about the type it's describing (version, name). When reading a file, all the streamer infos are read back in memory, from disk, by reading the data record at offset fSeekInfo. A streamer info is actually a list of streamer elements, one for each field and, in C++, base class (in Go, this is emulated as an embedded field.)

Index

Examples

Constants

This section is empty.

Variables

View Source
var Factory = factory{
	// contains filtered or unexported fields
}

Functions

func NewObjString

func NewObjString(s string) *tobjstring

NewObjString creates a new ObjString.

Types

type Array

type Array interface {
	Len() int // number of array elements
	Get(i int) interface{}
	Set(i int, v interface{})
}

Array describes ROOT abstract array type.

type ArrayD

type ArrayD struct {
	Data []float64
}

ArrayD implements ROOT TArrayD

func (*ArrayD) At

func (arr *ArrayD) At(i int) float64

func (*ArrayD) Class

func (*ArrayD) Class() string

Class returns the ROOT class name.

func (*ArrayD) Get

func (arr *ArrayD) Get(i int) interface{}

func (*ArrayD) Len

func (arr *ArrayD) Len() int

func (*ArrayD) MarshalROOT

func (arr *ArrayD) MarshalROOT(w *WBuffer) (int, error)

func (*ArrayD) Set

func (arr *ArrayD) Set(i int, v interface{})

func (*ArrayD) UnmarshalROOT

func (arr *ArrayD) UnmarshalROOT(r *RBuffer) error

type ArrayF

type ArrayF struct {
	Data []float32
}

ArrayF implements ROOT TArrayF

func (*ArrayF) At

func (arr *ArrayF) At(i int) float32

func (*ArrayF) Class

func (*ArrayF) Class() string

Class returns the ROOT class name.

func (*ArrayF) Get

func (arr *ArrayF) Get(i int) interface{}

func (*ArrayF) Len

func (arr *ArrayF) Len() int

func (*ArrayF) MarshalROOT

func (arr *ArrayF) MarshalROOT(w *WBuffer) (int, error)

func (*ArrayF) Set

func (arr *ArrayF) Set(i int, v interface{})

func (*ArrayF) UnmarshalROOT

func (arr *ArrayF) UnmarshalROOT(r *RBuffer) error

type ArrayI

type ArrayI struct {
	Data []int32
}

ArrayI implements ROOT TArrayI

func (*ArrayI) At

func (arr *ArrayI) At(i int) int32

func (*ArrayI) Class

func (*ArrayI) Class() string

Class returns the ROOT class name.

func (*ArrayI) Get

func (arr *ArrayI) Get(i int) interface{}

func (*ArrayI) Len

func (arr *ArrayI) Len() int

func (*ArrayI) MarshalROOT

func (arr *ArrayI) MarshalROOT(w *WBuffer) (int, error)

func (*ArrayI) Set

func (arr *ArrayI) Set(i int, v interface{})

func (*ArrayI) UnmarshalROOT

func (arr *ArrayI) UnmarshalROOT(r *RBuffer) error

type ArrayL64

type ArrayL64 struct {
	Data []int64
}

ArrayL64 implements ROOT TArrayL64

func (*ArrayL64) At

func (arr *ArrayL64) At(i int) int64

func (*ArrayL64) Class

func (*ArrayL64) Class() string

Class returns the ROOT class name.

func (*ArrayL64) Get

func (arr *ArrayL64) Get(i int) interface{}

func (*ArrayL64) Len

func (arr *ArrayL64) Len() int

func (*ArrayL64) MarshalROOT

func (arr *ArrayL64) MarshalROOT(w *WBuffer) (int, error)

func (*ArrayL64) Set

func (arr *ArrayL64) Set(i int, v interface{})

func (*ArrayL64) UnmarshalROOT

func (arr *ArrayL64) UnmarshalROOT(r *RBuffer) error

type Axis

type Axis interface {
	Named
	XMin() float64
	XMax() float64
	NBins() int
	XBins() []float64
	BinCenter(int) float64
	BinLowEdge(int) float64
	BinWidth(int) float64
}

Axis describes a ROOT TAxis.

type Basket

type Basket struct {
	// contains filtered or unexported fields
}

func (*Basket) Class

func (b *Basket) Class() string

func (*Basket) Name

func (b *Basket) Name() string

func (*Basket) Title

func (b *Basket) Title() string

func (*Basket) UnmarshalROOT

func (b *Basket) UnmarshalROOT(r *RBuffer) error

type Branch

type Branch interface {
	Named
	Branches() []Branch
	Leaves() []Leaf
	Branch(name string) Branch
	Leaf(name string) Leaf

	GoType() reflect.Type
	// contains filtered or unexported methods
}

Branch describes a branch of a ROOT Tree.

type Class

type Class interface {
	// GetCheckSum gets the check sum for this ROOT class
	CheckSum() int

	// Members returns the list of members for this ROOT class
	Members() []Member

	// Version returns the version number for this ROOT class
	Version() int

	// ClassName returns the ROOT class name for this ROOT class
	ClassName() string
}

Class represents a ROOT class. Class instances are created by a ClassFactory.

type ClassFactory

type ClassFactory interface {
	Create(name string) Class
}

ClassFactory creates ROOT classes

type Collection

type Collection interface {
	Object

	// Name returns the name of the collection.
	Name() string

	// Last returns the last element index
	Last() int

	// At returns the element at index i
	At(i int) Object

	// Len returns the number of elements in the collection
	Len() int
}

Collection is a collection of ROOT Objects.

type Directory

type Directory interface {
	// Get returns the object identified by namecycle
	//   namecycle has the format name;cycle
	//   name  = * is illegal, cycle = * is illegal
	//   cycle = "" or cycle = 9999 ==> apply to a memory object
	//
	//   examples:
	//     foo   : get object named foo in memory
	//             if object is not in memory, try with highest cycle from file
	//     foo;1 : get cycle 1 of foo on file
	Get(namecycle string) (Object, error)

	// Put puts the object v under the key with the given name.
	Put(name string, v Object) error

	// Keys returns the list of keys being held by this directory.
	Keys() []Key
}

Directory describes a ROOT directory structure in memory.

type Double32

type Double32 float64

Double32 is a float64 in memory, written as a float32 to disk.

type FactoryFct

type FactoryFct func() reflect.Value

FactoryFct creates new values of a given type.

type File

type File struct {
	// contains filtered or unexported fields
}

A ROOT file is a suite of consecutive data records (TKey's) with the following format (see also the TKey class). If the key is located past the 32 bit file limit (> 2 GB) then some fields will be 8 instead of 4 bytes:

1->4            Nbytes    = Length of compressed object (in bytes)
5->6            Version   = TKey version identifier
7->10           ObjLen    = Length of uncompressed object
11->14          Datime    = Date and time when object was written to file
15->16          KeyLen    = Length of the key structure (in bytes)
17->18          Cycle     = Cycle of key
19->22 [19->26] SeekKey   = Pointer to record itself (consistency check)
23->26 [27->34] SeekPdir  = Pointer to directory header
27->27 [35->35] lname     = Number of bytes in the class name
28->.. [36->..] ClassName = Object Class Name
..->..          lname     = Number of bytes in the object name
..->..          Name      = lName bytes with the name of the object
..->..          lTitle    = Number of bytes in the object title
..->..          Title     = Title of the object
----->          DATA      = Data bytes associated to the object

The first data record starts at byte fBEGIN (currently set to kBEGIN). Bytes 1->kBEGIN contain the file description, when fVersion >= 1000000 it is a large file (> 2 GB) and the offsets will be 8 bytes long and fUnits will be set to 8:

1->4            "root"      = Root file identifier
5->8            fVersion    = File format version
9->12           fBEGIN      = Pointer to first data record
13->16 [13->20] fEND        = Pointer to first free word at the EOF
17->20 [21->28] fSeekFree   = Pointer to FREE data record
21->24 [29->32] fNbytesFree = Number of bytes in FREE data record
25->28 [33->36] nfree       = Number of free data records
29->32 [37->40] fNbytesName = Number of bytes in TNamed at creation time
33->33 [41->41] fUnits      = Number of bytes for file pointers
34->37 [42->45] fCompress   = Compression level and algorithm
38->41 [46->53] fSeekInfo   = Pointer to TStreamerInfo record
42->45 [54->57] fNbytesInfo = Number of bytes in TStreamerInfo record
46->63 [58->75] fUUID       = Universal Unique ID

func Create

func Create(name string, opts ...FileOption) (*File, error)

Create creates the named ROOT file for writing.

Example
package main

import (
	"fmt"
	"log"
	"os"

	"go-hep.org/x/hep/rootio"
)

func main() {
	const fname = "objstring.root"
	defer os.Remove(fname)

	w, err := rootio.Create(fname)
	if err != nil {
		log.Fatal(err)
	}
	defer w.Close()

	var (
		k = "my-objstring"
		v = rootio.NewObjString("Hello World from Go-HEP!")
	)

	err = w.Put(k, v)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("wkeys: %d\n", len(w.Keys()))

	err = w.Close()
	if err != nil {
		log.Fatalf("could not close file: %v", err)
	}

	r, err := rootio.Open(fname)
	if err != nil {
		log.Fatalf("could not open file: %v", err)
	}
	defer r.Close()

	fmt.Printf("rkeys: %d\n", len(r.Keys()))

	for _, k := range r.Keys() {
		fmt.Printf("key: name=%q, type=%q\n", k.Name(), k.ClassName())
	}

	obj, err := r.Get(k)
	if err != nil {
		log.Fatal(err)
	}
	rv := obj.(rootio.ObjString)
	fmt.Printf("objstring=%q\n", rv)

}
Output:

wkeys: 1
rkeys: 1
key: name="my-objstring", type="TObjString"
objstring="Hello World from Go-HEP!"
Example (Empty)
package main

import (
	"fmt"
	"log"
	"os"

	"go-hep.org/x/hep/rootio"
)

func main() {
	const fname = "empty.root"
	defer os.Remove(fname)

	w, err := rootio.Create(fname)
	if err != nil {
		log.Fatal(err)
	}
	defer w.Close()

	// empty file. close it.
	err = w.Close()
	if err != nil {
		log.Fatalf("could not close empty file: %v", err)
	}

	// read back.
	r, err := rootio.Open(fname)
	if err != nil {
		log.Fatalf("could not open empty file: %v", err)
	}
	defer r.Close()

	fmt.Printf("file: %q\n", r.Name())

}
Output:

file: "empty.root"
Example (Graph)
package main

import (
	"fmt"
	"log"
	"os"

	"go-hep.org/x/hep/hbook"
	"go-hep.org/x/hep/hbook/rootcnv"
	"go-hep.org/x/hep/rootio"
)

func main() {
	const fname = "graph_example.root"
	defer os.Remove(fname)

	f, err := rootio.Create(fname)
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	hg := hbook.NewS2D(hbook.Point2D{X: 1, Y: 1}, hbook.Point2D{X: 2, Y: 1.5}, hbook.Point2D{X: -1, Y: +2})

	fmt.Printf("original graph:\n")
	for i, pt := range hg.Points() {
		fmt.Printf("pt[%d]=%+v\n", i, pt)
	}

	rg := rootio.NewGraphFrom(hg)

	err = f.Put("gr", rg)
	if err != nil {
		log.Fatal(err)
	}

	err = f.Close()
	if err != nil {
		log.Fatalf("error closing ROOT file: %v", err)
	}

	r, err := rootio.Open(fname)
	if err != nil {
		log.Fatal(err)
	}
	defer r.Close()

	robj, err := r.Get("gr")
	if err != nil {
		log.Fatal(err)
	}

	hr, err := rootcnv.S2D(robj.(rootio.Graph))
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("\ngraph read back:\n")
	for i, pt := range hr.Points() {
		fmt.Printf("pt[%d]=%+v\n", i, pt)
	}

}
Output:

original graph:
pt[0]={X:1 Y:1 ErrX:{Min:0 Max:0} ErrY:{Min:0 Max:0}}
pt[1]={X:2 Y:1.5 ErrX:{Min:0 Max:0} ErrY:{Min:0 Max:0}}
pt[2]={X:-1 Y:2 ErrX:{Min:0 Max:0} ErrY:{Min:0 Max:0}}

graph read back:
pt[0]={X:1 Y:1 ErrX:{Min:0 Max:0} ErrY:{Min:0 Max:0}}
pt[1]={X:2 Y:1.5 ErrX:{Min:0 Max:0} ErrY:{Min:0 Max:0}}
pt[2]={X:-1 Y:2 ErrX:{Min:0 Max:0} ErrY:{Min:0 Max:0}}
Example (GraphAsymmErrors)
package main

import (
	"fmt"
	"log"
	"os"

	"go-hep.org/x/hep/hbook"
	"go-hep.org/x/hep/hbook/rootcnv"
	"go-hep.org/x/hep/rootio"
)

func main() {
	const fname = "graphasymmerr_example.root"
	defer os.Remove(fname)

	f, err := rootio.Create(fname)
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	hg := hbook.NewS2D(
		hbook.Point2D{X: 1, Y: 1, ErrX: hbook.Range{Min: 1, Max: 2}, ErrY: hbook.Range{Min: 3, Max: 4}},
		hbook.Point2D{X: 2, Y: 1.5, ErrX: hbook.Range{Min: 1, Max: 2}, ErrY: hbook.Range{Min: 3, Max: 4}},
		hbook.Point2D{X: -1, Y: +2, ErrX: hbook.Range{Min: 1, Max: 2}, ErrY: hbook.Range{Min: 3, Max: 4}},
	)

	fmt.Printf("original graph:\n")
	for i, pt := range hg.Points() {
		fmt.Printf("pt[%d]=%+v\n", i, pt)
	}

	rg := rootio.NewGraphAsymmErrorsFrom(hg)

	err = f.Put("gr", rg)
	if err != nil {
		log.Fatal(err)
	}

	err = f.Close()
	if err != nil {
		log.Fatalf("error closing ROOT file: %v", err)
	}

	r, err := rootio.Open(fname)
	if err != nil {
		log.Fatal(err)
	}
	defer r.Close()

	robj, err := r.Get("gr")
	if err != nil {
		log.Fatal(err)
	}

	hr, err := rootcnv.S2D(robj.(rootio.GraphErrors))
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("\ngraph read back:\n")
	for i, pt := range hr.Points() {
		fmt.Printf("pt[%d]=%+v\n", i, pt)
	}

}
Output:

original graph:
pt[0]={X:1 Y:1 ErrX:{Min:1 Max:2} ErrY:{Min:3 Max:4}}
pt[1]={X:2 Y:1.5 ErrX:{Min:1 Max:2} ErrY:{Min:3 Max:4}}
pt[2]={X:-1 Y:2 ErrX:{Min:1 Max:2} ErrY:{Min:3 Max:4}}

graph read back:
pt[0]={X:1 Y:1 ErrX:{Min:1 Max:2} ErrY:{Min:3 Max:4}}
pt[1]={X:2 Y:1.5 ErrX:{Min:1 Max:2} ErrY:{Min:3 Max:4}}
pt[2]={X:-1 Y:2 ErrX:{Min:1 Max:2} ErrY:{Min:3 Max:4}}
Example (GraphErrors)
package main

import (
	"fmt"
	"log"
	"os"

	"go-hep.org/x/hep/hbook"
	"go-hep.org/x/hep/hbook/rootcnv"
	"go-hep.org/x/hep/rootio"
)

func main() {
	const fname = "grapherr_example.root"
	defer os.Remove(fname)

	f, err := rootio.Create(fname)
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	hg := hbook.NewS2D(
		hbook.Point2D{X: 1, Y: 1, ErrX: hbook.Range{Min: 2, Max: 2}, ErrY: hbook.Range{Min: 3, Max: 3}},
		hbook.Point2D{X: 2, Y: 1.5, ErrX: hbook.Range{Min: 2, Max: 2}, ErrY: hbook.Range{Min: 3, Max: 3}},
		hbook.Point2D{X: -1, Y: +2, ErrX: hbook.Range{Min: 2, Max: 2}, ErrY: hbook.Range{Min: 3, Max: 3}},
	)

	fmt.Printf("original graph:\n")
	for i, pt := range hg.Points() {
		fmt.Printf("pt[%d]=%+v\n", i, pt)
	}

	rg := rootio.NewGraphErrorsFrom(hg)

	err = f.Put("gr", rg)
	if err != nil {
		log.Fatal(err)
	}

	err = f.Close()
	if err != nil {
		log.Fatalf("error closing ROOT file: %v", err)
	}

	r, err := rootio.Open(fname)
	if err != nil {
		log.Fatal(err)
	}
	defer r.Close()

	robj, err := r.Get("gr")
	if err != nil {
		log.Fatal(err)
	}

	hr, err := rootcnv.S2D(robj.(rootio.GraphErrors))
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("\ngraph read back:\n")
	for i, pt := range hr.Points() {
		fmt.Printf("pt[%d]=%+v\n", i, pt)
	}

}
Output:

original graph:
pt[0]={X:1 Y:1 ErrX:{Min:2 Max:2} ErrY:{Min:3 Max:3}}
pt[1]={X:2 Y:1.5 ErrX:{Min:2 Max:2} ErrY:{Min:3 Max:3}}
pt[2]={X:-1 Y:2 ErrX:{Min:2 Max:2} ErrY:{Min:3 Max:3}}

graph read back:
pt[0]={X:1 Y:1 ErrX:{Min:2 Max:2} ErrY:{Min:3 Max:3}}
pt[1]={X:2 Y:1.5 ErrX:{Min:2 Max:2} ErrY:{Min:3 Max:3}}
pt[2]={X:-1 Y:2 ErrX:{Min:2 Max:2} ErrY:{Min:3 Max:3}}
Example (Histo1D)
package main

import (
	"fmt"
	"log"
	"os"

	"go-hep.org/x/hep/hbook"
	"go-hep.org/x/hep/hbook/rootcnv"
	"go-hep.org/x/hep/rootio"
	"golang.org/x/exp/rand"
	"gonum.org/v1/gonum/stat/distuv"
)

func main() {
	const fname = "h1d_example.root"
	defer os.Remove(fname)

	f, err := rootio.Create(fname)
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	const npoints = 10000

	// Create a normal distribution.
	dist := distuv.Normal{
		Mu:    0,
		Sigma: 1,
		Src:   rand.New(rand.NewSource(0)),
	}

	// Draw some random values from the standard
	// normal distribution.
	h := hbook.NewH1D(20, -4, +4)
	for i := 0; i < npoints; i++ {
		v := dist.Rand()
		h.Fill(v, 1)
	}
	h.Fill(-10, 1) // fill underflow
	h.Fill(-20, 2)
	h.Fill(+10, 3) // fill overflow

	fmt.Printf("original histo:\n")
	fmt.Printf("w-mean:    %.7f\n", h.XMean())
	fmt.Printf("w-rms:     %.7f\n", h.XRMS())

	hroot := rootio.NewH1DFrom(h)

	err = f.Put("h1", hroot)
	if err != nil {
		log.Fatal(err)
	}

	err = f.Close()
	if err != nil {
		log.Fatalf("error closing ROOT file: %v", err)
	}

	r, err := rootio.Open(fname)
	if err != nil {
		log.Fatal(err)
	}
	defer r.Close()

	robj, err := r.Get("h1")
	if err != nil {
		log.Fatal(err)
	}

	hr, err := rootcnv.H1D(robj.(rootio.H1))
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("\nhisto read back:\n")
	fmt.Printf("r-mean:    %.7f\n", hr.XMean())
	fmt.Printf("r-rms:     %.7f\n", hr.XRMS())

}
Output:

original histo:
w-mean:    0.0023919
w-rms:     1.0628679

histo read back:
r-mean:    0.0023919
r-rms:     1.0628679
Example (Histo2D)
package main

import (
	"fmt"
	"log"
	"os"

	"go-hep.org/x/hep/hbook"
	"go-hep.org/x/hep/hbook/rootcnv"
	"go-hep.org/x/hep/rootio"
	"golang.org/x/exp/rand"
	"gonum.org/v1/gonum/stat/distuv"
)

func main() {
	const fname = "h2d_example.root"
	defer os.Remove(fname)

	f, err := rootio.Create(fname)
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	const npoints = 1000

	// Create a normal distribution.
	dist := distuv.Normal{
		Mu:    0,
		Sigma: 1,
		Src:   rand.New(rand.NewSource(0)),
	}

	// Draw some random values from the standard
	// normal distribution.
	h := hbook.NewH2D(5, -4, +4, 6, -4, +4)
	for i := 0; i < npoints; i++ {
		x := dist.Rand()
		y := dist.Rand()
		h.Fill(x, y, 1)
	}
	h.Fill(-10, -10, 1) // fill underflow
	h.Fill(-10, +10, 1)
	h.Fill(+10, -10, 1)
	h.Fill(+10, +10, 3) // fill overflow

	fmt.Printf("original histo:\n")
	fmt.Printf("w-mean-x:    %+.6f\n", h.XMean())
	fmt.Printf("w-rms-x:     %+.6f\n", h.XRMS())
	fmt.Printf("w-mean-y:    %+.6f\n", h.YMean())
	fmt.Printf("w-rms-y:     %+.6f\n", h.YRMS())

	hroot := rootio.NewH2DFrom(h)

	err = f.Put("h2", hroot)
	if err != nil {
		log.Fatal(err)
	}

	err = f.Close()
	if err != nil {
		log.Fatalf("error closing ROOT file: %v", err)
	}

	r, err := rootio.Open(fname)
	if err != nil {
		log.Fatal(err)
	}
	defer r.Close()

	robj, err := r.Get("h2")
	if err != nil {
		log.Fatal(err)
	}

	hr, err := rootcnv.H2D(robj.(rootio.H2))
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("\nhisto read back:\n")
	fmt.Printf("w-mean-x:    %+.6f\n", hr.XMean())
	fmt.Printf("w-rms-x:     %+.6f\n", hr.XRMS())
	fmt.Printf("w-mean-y:    %+.6f\n", hr.YMean())
	fmt.Printf("w-rms-y:     %+.6f\n", hr.YRMS())

}
Output:

original histo:
w-mean-x:    +0.046442
w-rms-x:     +1.231044
w-mean-y:    -0.018977
w-rms-y:     +1.253143

histo read back:
w-mean-x:    +0.046442
w-rms-x:     +1.231044
w-mean-y:    -0.018977
w-rms-y:     +1.253143
Example (WithZlib)
package main

import (
	"compress/flate"
	"fmt"
	"log"
	"os"

	"go-hep.org/x/hep/rootio"
)

func main() {
	const fname = "objstring-zlib.root"
	defer os.Remove(fname)

	w, err := rootio.Create(fname, rootio.WithZlib(flate.BestCompression))
	if err != nil {
		log.Fatal(err)
	}
	defer w.Close()

	var (
		k = "my-objstring"
		v = rootio.NewObjString("Hello World from Go-HEP!")
	)

	err = w.Put(k, v)
	if err != nil {
		log.Fatal(err)
	}

	err = w.Close()
	if err != nil {
		log.Fatalf("could not close writable file: %v", err)
	}

	r, err := rootio.Open(fname)
	if err != nil {
		log.Fatalf("could not open file: %v", err)
	}
	defer r.Close()

	for _, k := range r.Keys() {
		fmt.Printf("key: name=%q, type=%q\n", k.Name(), k.ClassName())
	}

	obj, err := r.Get(k)
	if err != nil {
		log.Fatalf("could not get key %q: %v", k, err)
	}
	rv := obj.(rootio.ObjString)
	fmt.Printf("objstring=%q\n", rv)

}
Output:

key: name="my-objstring", type="TObjString"
objstring="Hello World from Go-HEP!"

func NewReader

func NewReader(r Reader) (*File, error)

NewReader creates a new ROOT file reader.

func Open

func Open(path string) (*File, error)

Open opens the named ROOT file for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode os.O_RDONLY.

func (*File) Class

func (f *File) Class() string

func (*File) Close

func (f *File) Close() error

Close closes the File, rendering it unusable for I/O. It returns an error, if any.

func (*File) Get

func (f *File) Get(namecycle string) (Object, error)

Get returns the object identified by namecycle

namecycle has the format name;cycle
name  = * is illegal, cycle = * is illegal
cycle = "" or cycle = 9999 ==> apply to a memory object

examples:
  foo   : get object named foo in memory
          if object is not in memory, try with highest cycle from file
  foo;1 : get cycle 1 of foo on file

func (*File) Keys

func (f *File) Keys() []Key

Keys returns the list of keys this File contains

func (*File) Name

func (f *File) Name() string

func (*File) Put

func (f *File) Put(name string, v Object) error

Put puts the object v under the key with the given name.

func (*File) Read

func (f *File) Read(p []byte) (int, error)

Read implements io.Reader

func (*File) ReadAt

func (f *File) ReadAt(p []byte, off int64) (int, error)

ReadAt implements io.ReaderAt

func (*File) Seek

func (f *File) Seek(offset int64, whence int) (int64, error)

Seek implements io.Seeker

func (*File) Stat

func (f *File) Stat() (os.FileInfo, error)

Stat returns the os.FileInfo structure describing this file.

func (*File) StreamerInfo

func (f *File) StreamerInfo(name string) (StreamerInfo, error)

StreamerInfo returns the StreamerInfo with name of this file and an error if any.

func (*File) StreamerInfos

func (f *File) StreamerInfos() []StreamerInfo

StreamerInfos returns the list of StreamerInfos of this file.

func (*File) Tell

func (f *File) Tell() int64

func (*File) Title

func (f *File) Title() string

func (*File) Version

func (f *File) Version() int

Version returns the ROOT version this file was created with.

type FileOption added in v0.15.0

type FileOption func(f *File) error

FileOption configures internal states of a ROOT file.

func WithLZ4 added in v0.15.0

func WithLZ4(level int) FileOption

WithLZ4 configures a ROOT file to use LZ4 as a compression mechanism.

func WithLZMA added in v0.15.0

func WithLZMA(level int) FileOption

WithLZMA configures a ROOT file to use LZMA as a compression mechanism.

func WithZlib added in v0.15.0

func WithZlib(level int) FileOption

WithZlib configures a ROOT file to use zlib as a compression mechanism.

func WithoutCompression added in v0.15.0

func WithoutCompression() FileOption

WithoutCompression configures a ROOT file to not use any compression mechanism.

type Float16

type Float16 float32

Float16 is a float32 in memory, written with a truncated mantissa.

type Graph

type Graph interface {
	Named
	Len() int
	XY(i int) (float64, float64)
}

Graph describes a ROOT TGraph

Example
package main

import (
	"fmt"
	"log"

	"go-hep.org/x/hep/rootio"
)

func main() {
	f, err := rootio.Open("testdata/graphs.root")
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	obj, err := f.Get("tg")
	if err != nil {
		log.Fatal(err)
	}

	g := obj.(rootio.Graph)
	fmt.Printf("name:  %q\n", g.Name())
	fmt.Printf("title: %q\n", g.Title())
	fmt.Printf("#pts:  %d\n", g.Len())
	for i := 0; i < g.Len(); i++ {
		x, y := g.XY(i)
		fmt.Printf("(x,y)[%d] = (%+e, %+e)\n", i, x, y)
	}

}
Output:

name:  "tg"
title: "graph without errors"
#pts:  4
(x,y)[0] = (+1.000000e+00, +2.000000e+00)
(x,y)[1] = (+2.000000e+00, +4.000000e+00)
(x,y)[2] = (+3.000000e+00, +6.000000e+00)
(x,y)[3] = (+4.000000e+00, +8.000000e+00)

func NewGraphFrom added in v0.15.0

func NewGraphFrom(s2 *hbook.S2D) Graph

NewGraphFrom creates a new Graph from 2-dim hbook data points.

type GraphErrors

type GraphErrors interface {
	Graph
	// XError returns two error values for X data.
	XError(i int) (float64, float64)
	// YError returns two error values for Y data.
	YError(i int) (float64, float64)
}

GraphErrors describes a ROOT TGraphErrors

Example
package main

import (
	"fmt"
	"log"

	"go-hep.org/x/hep/rootio"
)

func main() {
	f, err := rootio.Open("testdata/graphs.root")
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	obj, err := f.Get("tge")
	if err != nil {
		log.Fatal(err)
	}

	g := obj.(rootio.GraphErrors)
	fmt.Printf("name:  %q\n", g.Name())
	fmt.Printf("title: %q\n", g.Title())
	fmt.Printf("#pts:  %d\n", g.Len())
	for i := 0; i < g.Len(); i++ {
		x, y := g.XY(i)
		xlo, xhi := g.XError(i)
		ylo, yhi := g.YError(i)
		fmt.Printf("(x,y)[%d] = (%+e +/- [%+e, %+e], %+e +/- [%+e, %+e])\n", i, x, xlo, xhi, y, ylo, yhi)
	}

}
Output:

name:  "tge"
title: "graph with errors"
#pts:  4
(x,y)[0] = (+1.000000e+00 +/- [+1.000000e-01, +1.000000e-01], +2.000000e+00 +/- [+2.000000e-01, +2.000000e-01])
(x,y)[1] = (+2.000000e+00 +/- [+2.000000e-01, +2.000000e-01], +4.000000e+00 +/- [+4.000000e-01, +4.000000e-01])
(x,y)[2] = (+3.000000e+00 +/- [+3.000000e-01, +3.000000e-01], +6.000000e+00 +/- [+6.000000e-01, +6.000000e-01])
(x,y)[3] = (+4.000000e+00 +/- [+4.000000e-01, +4.000000e-01], +8.000000e+00 +/- [+8.000000e-01, +8.000000e-01])
Example (AsymmErrors)
package main

import (
	"fmt"
	"log"

	"go-hep.org/x/hep/rootio"
)

func main() {
	f, err := rootio.Open("testdata/graphs.root")
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	obj, err := f.Get("tgae")
	if err != nil {
		log.Fatal(err)
	}

	g := obj.(rootio.GraphErrors)
	fmt.Printf("name:  %q\n", g.Name())
	fmt.Printf("title: %q\n", g.Title())
	fmt.Printf("#pts:  %d\n", g.Len())
	for i := 0; i < g.Len(); i++ {
		x, y := g.XY(i)
		xlo, xhi := g.XError(i)
		ylo, yhi := g.YError(i)
		fmt.Printf("(x,y)[%d] = (%+e +/- [%+e, %+e], %+e +/- [%+e, %+e])\n", i, x, xlo, xhi, y, ylo, yhi)
	}

}
Output:

name:  "tgae"
title: "graph with asymmetric errors"
#pts:  4
(x,y)[0] = (+1.000000e+00 +/- [+1.000000e-01, +2.000000e-01], +2.000000e+00 +/- [+3.000000e-01, +4.000000e-01])
(x,y)[1] = (+2.000000e+00 +/- [+2.000000e-01, +4.000000e-01], +4.000000e+00 +/- [+6.000000e-01, +8.000000e-01])
(x,y)[2] = (+3.000000e+00 +/- [+3.000000e-01, +6.000000e-01], +6.000000e+00 +/- [+9.000000e-01, +1.200000e+00])
(x,y)[3] = (+4.000000e+00 +/- [+4.000000e-01, +8.000000e-01], +8.000000e+00 +/- [+1.200000e+00, +1.600000e+00])

func NewGraphAsymmErrorsFrom added in v0.15.0

func NewGraphAsymmErrorsFrom(s2 *hbook.S2D) GraphErrors

NewGraphAsymmErrorsFrom creates a new GraphAsymErrors from 2-dim hbook data points.

func NewGraphErrorsFrom added in v0.15.0

func NewGraphErrorsFrom(s2 *hbook.S2D) GraphErrors

NewGraphErrorsFrom creates a new GraphErrors from 2-dim hbook data points.

type H1

type H1 interface {
	Named

	// Entries returns the number of entries for this histogram.
	Entries() float64
	// SumW returns the total sum of weights
	SumW() float64
	// SumW2 returns the total sum of squares of weights
	SumW2() float64
	// SumWX returns the total sum of weights*x
	SumWX() float64
	// SumWX2 returns the total sum of weights*x*x
	SumWX2() float64
	// SumW2s returns the array of sum of squares of weights
	SumW2s() []float64
	// contains filtered or unexported methods
}

H1 is a 1-dim ROOT histogram

type H1D

type H1D struct {
	// contains filtered or unexported fields
}

H1D implements ROOT TH1D

func NewH1DFrom added in v0.15.0

func NewH1DFrom(h *hbook.H1D) *H1D

NewH1DFrom creates a new 1-dim histogram from hbook.

func (*H1D) Array

func (h *H1D) Array() ArrayD

func (*H1D) Class

func (*H1D) Class() string

Class returns the ROOT class name.

func (*H1D) Entries

func (h *H1D) Entries() float64

Entries returns the number of entries for this histogram.

func (*H1D) MarshalROOT

func (h *H1D) MarshalROOT(w *WBuffer) (int, error)

func (*H1D) MarshalYODA

func (h *H1D) MarshalYODA() ([]byte, error)

MarshalYODA implements the YODAMarshaler interface.

func (*H1D) NbinsX

func (h *H1D) NbinsX() int

NbinsX returns the number of bins in X.

func (*H1D) Rank

func (h *H1D) Rank() int

Rank returns the number of dimensions of this histogram.

func (*H1D) SumW

func (h *H1D) SumW() float64

SumW returns the total sum of weights

func (*H1D) SumW2

func (h *H1D) SumW2() float64

SumW2 returns the total sum of squares of weights

func (*H1D) SumW2s

func (h *H1D) SumW2s() []float64

SumW2s returns the array of sum of squares of weights

func (*H1D) SumWX

func (h *H1D) SumWX() float64

SumWX returns the total sum of weights*x

func (*H1D) SumWX2

func (h *H1D) SumWX2() float64

SumWX2 returns the total sum of weights*x*x

func (*H1D) UnmarshalROOT

func (h *H1D) UnmarshalROOT(r *RBuffer) error

func (*H1D) UnmarshalYODA added in v0.15.0

func (h *H1D) UnmarshalYODA(raw []byte) error

UnmarshalYODA implements the YODAUnmarshaler interface.

func (*H1D) XAxis

func (h *H1D) XAxis() Axis

XAxis returns the axis along X.

func (*H1D) XBinCenter

func (h *H1D) XBinCenter(i int) float64

XBinCenter returns the bin center value in X.

func (*H1D) XBinContent

func (h *H1D) XBinContent(i int) float64

XBinContent returns the bin content value in X.

func (*H1D) XBinError

func (h *H1D) XBinError(i int) float64

XBinError returns the bin error in X.

func (*H1D) XBinLowEdge

func (h *H1D) XBinLowEdge(i int) float64

XBinLowEdge returns the bin lower edge value in X.

func (*H1D) XBinWidth

func (h *H1D) XBinWidth(i int) float64

XBinWidth returns the bin width in X.

type H1F

type H1F struct {
	// contains filtered or unexported fields
}

H1F implements ROOT TH1F

func NewH1FFrom added in v0.15.0

func NewH1FFrom(h *hbook.H1D) *H1F

NewH1FFrom creates a new 1-dim histogram from hbook.

func (*H1F) Array

func (h *H1F) Array() ArrayF

func (*H1F) Class

func (*H1F) Class() string

Class returns the ROOT class name.

func (*H1F) Entries

func (h *H1F) Entries() float64

Entries returns the number of entries for this histogram.

func (*H1F) MarshalROOT

func (h *H1F) MarshalROOT(w *WBuffer) (int, error)

func (*H1F) MarshalYODA

func (h *H1F) MarshalYODA() ([]byte, error)

MarshalYODA implements the YODAMarshaler interface.

func (*H1F) NbinsX

func (h *H1F) NbinsX() int

NbinsX returns the number of bins in X.

func (*H1F) Rank

func (h *H1F) Rank() int

Rank returns the number of dimensions of this histogram.

func (*H1F) SumW

func (h *H1F) SumW() float64

SumW returns the total sum of weights

func (*H1F) SumW2

func (h *H1F) SumW2() float64

SumW2 returns the total sum of squares of weights

func (*H1F) SumW2s

func (h *H1F) SumW2s() []float64

SumW2s returns the array of sum of squares of weights

func (*H1F) SumWX

func (h *H1F) SumWX() float64

SumWX returns the total sum of weights*x

func (*H1F) SumWX2

func (h *H1F) SumWX2() float64

SumWX2 returns the total sum of weights*x*x

func (*H1F) UnmarshalROOT

func (h *H1F) UnmarshalROOT(r *RBuffer) error

func (*H1F) UnmarshalYODA added in v0.15.0

func (h *H1F) UnmarshalYODA(raw []byte) error

UnmarshalYODA implements the YODAUnmarshaler interface.

func (*H1F) XAxis

func (h *H1F) XAxis() Axis

XAxis returns the axis along X.

func (*H1F) XBinCenter

func (h *H1F) XBinCenter(i int) float64

XBinCenter returns the bin center value in X.

func (*H1F) XBinContent

func (h *H1F) XBinContent(i int) float64

XBinContent returns the bin content value in X.

func (*H1F) XBinError

func (h *H1F) XBinError(i int) float64

XBinError returns the bin error in X.

func (*H1F) XBinLowEdge

func (h *H1F) XBinLowEdge(i int) float64

XBinLowEdge returns the bin lower edge value in X.

func (*H1F) XBinWidth

func (h *H1F) XBinWidth(i int) float64

XBinWidth returns the bin width in X.

type H1I

type H1I struct {
	// contains filtered or unexported fields
}

H1I implements ROOT TH1I

func NewH1IFrom added in v0.15.0

func NewH1IFrom(h *hbook.H1D) *H1I

NewH1IFrom creates a new 1-dim histogram from hbook.

func (*H1I) Array

func (h *H1I) Array() ArrayI

func (*H1I) Class

func (*H1I) Class() string

Class returns the ROOT class name.

func (*H1I) Entries

func (h *H1I) Entries() float64

Entries returns the number of entries for this histogram.

func (*H1I) MarshalROOT

func (h *H1I) MarshalROOT(w *WBuffer) (int, error)

func (*H1I) MarshalYODA

func (h *H1I) MarshalYODA() ([]byte, error)

MarshalYODA implements the YODAMarshaler interface.

func (*H1I) NbinsX

func (h *H1I) NbinsX() int

NbinsX returns the number of bins in X.

func (*H1I) Rank

func (h *H1I) Rank() int

Rank returns the number of dimensions of this histogram.

func (*H1I) SumW

func (h *H1I) SumW() float64

SumW returns the total sum of weights

func (*H1I) SumW2

func (h *H1I) SumW2() float64

SumW2 returns the total sum of squares of weights

func (*H1I) SumW2s

func (h *H1I) SumW2s() []float64

SumW2s returns the array of sum of squares of weights

func (*H1I) SumWX

func (h *H1I) SumWX() float64

SumWX returns the total sum of weights*x

func (*H1I) SumWX2

func (h *H1I) SumWX2() float64

SumWX2 returns the total sum of weights*x*x

func (*H1I) UnmarshalROOT

func (h *H1I) UnmarshalROOT(r *RBuffer) error

func (*H1I) UnmarshalYODA added in v0.15.0

func (h *H1I) UnmarshalYODA(raw []byte) error

UnmarshalYODA implements the YODAUnmarshaler interface.

func (*H1I) XAxis

func (h *H1I) XAxis() Axis

XAxis returns the axis along X.

func (*H1I) XBinCenter

func (h *H1I) XBinCenter(i int) float64

XBinCenter returns the bin center value in X.

func (*H1I) XBinContent

func (h *H1I) XBinContent(i int) float64

XBinContent returns the bin content value in X.

func (*H1I) XBinError

func (h *H1I) XBinError(i int) float64

XBinError returns the bin error in X.

func (*H1I) XBinLowEdge

func (h *H1I) XBinLowEdge(i int) float64

XBinLowEdge returns the bin lower edge value in X.

func (*H1I) XBinWidth

func (h *H1I) XBinWidth(i int) float64

XBinWidth returns the bin width in X.

type H2

type H2 interface {
	Named

	// Entries returns the number of entries for this histogram.
	Entries() float64
	// SumW returns the total sum of weights
	SumW() float64
	// SumW2 returns the total sum of squares of weights
	SumW2() float64
	// SumWX returns the total sum of weights*x
	SumWX() float64
	// SumWX2 returns the total sum of weights*x*x
	SumWX2() float64
	// SumW2s returns the array of sum of squares of weights
	SumW2s() []float64
	// SumWY returns the total sum of weights*y
	SumWY() float64
	// SumWY2 returns the total sum of weights*y*y
	SumWY2() float64
	// SumWXY returns the total sum of weights*x*y
	SumWXY() float64
	// contains filtered or unexported methods
}

H2 is a 2-dim ROOT histogram

type H2D

type H2D struct {
	// contains filtered or unexported fields
}

H2D implements ROOT TH2D

func NewH2DFrom added in v0.15.0

func NewH2DFrom(h *hbook.H2D) *H2D

NewH2DFrom creates a new H2D from hbook 2-dim histogram.

func (*H2D) Array

func (h *H2D) Array() ArrayD

func (*H2D) Class

func (*H2D) Class() string

Class returns the ROOT class name.

func (*H2D) MarshalROOT

func (h *H2D) MarshalROOT(w *WBuffer) (int, error)

func (*H2D) MarshalYODA

func (h *H2D) MarshalYODA() ([]byte, error)

MarshalYODA implements the YODAMarshaler interface.

func (*H2D) NbinsX

func (h *H2D) NbinsX() int

NbinsX returns the number of bins in X.

func (*H2D) NbinsY

func (h *H2D) NbinsY() int

NbinsY returns the number of bins in Y.

func (*H2D) Rank

func (h *H2D) Rank() int

Rank returns the number of dimensions of this histogram.

func (*H2D) SumWXY

func (h *H2D) SumWXY() float64

SumWXY returns the total sum of weights*x*y

func (*H2D) SumWY

func (h *H2D) SumWY() float64

SumWY returns the total sum of weights*y

func (*H2D) SumWY2

func (h *H2D) SumWY2() float64

SumWY2 returns the total sum of weights*y*y

func (*H2D) UnmarshalROOT

func (h *H2D) UnmarshalROOT(r *RBuffer) error

func (*H2D) UnmarshalYODA added in v0.15.0

func (h *H2D) UnmarshalYODA(raw []byte) error

UnmarshalYODA implements the YODAUnmarshaler interface.

func (*H2D) XAxis

func (h *H2D) XAxis() Axis

XAxis returns the axis along X.

func (*H2D) XBinCenter

func (h *H2D) XBinCenter(i int) float64

XBinCenter returns the bin center value in X.

func (*H2D) XBinContent

func (h *H2D) XBinContent(i int) float64

XBinContent returns the bin content value in X.

func (*H2D) XBinError

func (h *H2D) XBinError(i int) float64

XBinError returns the bin error in X.

func (*H2D) XBinLowEdge

func (h *H2D) XBinLowEdge(i int) float64

XBinLowEdge returns the bin lower edge value in X.

func (*H2D) XBinWidth

func (h *H2D) XBinWidth(i int) float64

XBinWidth returns the bin width in X.

func (*H2D) YAxis

func (h *H2D) YAxis() Axis

YAxis returns the axis along Y.

func (*H2D) YBinCenter

func (h *H2D) YBinCenter(i int) float64

YBinCenter returns the bin center value in Y.

func (*H2D) YBinContent

func (h *H2D) YBinContent(i int) float64

YBinContent returns the bin content value in Y.

func (*H2D) YBinError

func (h *H2D) YBinError(i int) float64

YBinError returns the bin error in Y.

func (*H2D) YBinLowEdge

func (h *H2D) YBinLowEdge(i int) float64

YBinLowEdge returns the bin lower edge value in Y.

func (*H2D) YBinWidth

func (h *H2D) YBinWidth(i int) float64

YBinWidth returns the bin width in Y.

type H2F

type H2F struct {
	// contains filtered or unexported fields
}

H2F implements ROOT TH2F

func NewH2FFrom added in v0.15.0

func NewH2FFrom(h *hbook.H2D) *H2F

NewH2FFrom creates a new H2F from hbook 2-dim histogram.

func (*H2F) Array

func (h *H2F) Array() ArrayF

func (*H2F) Class

func (*H2F) Class() string

Class returns the ROOT class name.

func (*H2F) MarshalROOT

func (h *H2F) MarshalROOT(w *WBuffer) (int, error)

func (*H2F) MarshalYODA

func (h *H2F) MarshalYODA() ([]byte, error)

MarshalYODA implements the YODAMarshaler interface.

func (*H2F) NbinsX

func (h *H2F) NbinsX() int

NbinsX returns the number of bins in X.

func (*H2F) NbinsY

func (h *H2F) NbinsY() int

NbinsY returns the number of bins in Y.

func (*H2F) Rank

func (h *H2F) Rank() int

Rank returns the number of dimensions of this histogram.

func (*H2F) SumWXY

func (h *H2F) SumWXY() float64

SumWXY returns the total sum of weights*x*y

func (*H2F) SumWY

func (h *H2F) SumWY() float64

SumWY returns the total sum of weights*y

func (*H2F) SumWY2

func (h *H2F) SumWY2() float64

SumWY2 returns the total sum of weights*y*y

func (*H2F) UnmarshalROOT

func (h *H2F) UnmarshalROOT(r *RBuffer) error

func (*H2F) UnmarshalYODA added in v0.15.0

func (h *H2F) UnmarshalYODA(raw []byte) error

UnmarshalYODA implements the YODAUnmarshaler interface.

func (*H2F) XAxis

func (h *H2F) XAxis() Axis

XAxis returns the axis along X.

func (*H2F) XBinCenter

func (h *H2F) XBinCenter(i int) float64

XBinCenter returns the bin center value in X.

func (*H2F) XBinContent

func (h *H2F) XBinContent(i int) float64

XBinContent returns the bin content value in X.

func (*H2F) XBinError

func (h *H2F) XBinError(i int) float64

XBinError returns the bin error in X.

func (*H2F) XBinLowEdge

func (h *H2F) XBinLowEdge(i int) float64

XBinLowEdge returns the bin lower edge value in X.

func (*H2F) XBinWidth

func (h *H2F) XBinWidth(i int) float64

XBinWidth returns the bin width in X.

func (*H2F) YAxis

func (h *H2F) YAxis() Axis

YAxis returns the axis along Y.

func (*H2F) YBinCenter

func (h *H2F) YBinCenter(i int) float64

YBinCenter returns the bin center value in Y.

func (*H2F) YBinContent

func (h *H2F) YBinContent(i int) float64

YBinContent returns the bin content value in Y.

func (*H2F) YBinError

func (h *H2F) YBinError(i int) float64

YBinError returns the bin error in Y.

func (*H2F) YBinLowEdge

func (h *H2F) YBinLowEdge(i int) float64

YBinLowEdge returns the bin lower edge value in Y.

func (*H2F) YBinWidth

func (h *H2F) YBinWidth(i int) float64

YBinWidth returns the bin width in Y.

type H2I

type H2I struct {
	// contains filtered or unexported fields
}

H2I implements ROOT TH2I

func NewH2IFrom added in v0.15.0

func NewH2IFrom(h *hbook.H2D) *H2I

NewH2IFrom creates a new H2I from hbook 2-dim histogram.

func (*H2I) Array

func (h *H2I) Array() ArrayI

func (*H2I) Class

func (*H2I) Class() string

Class returns the ROOT class name.

func (*H2I) MarshalROOT

func (h *H2I) MarshalROOT(w *WBuffer) (int, error)

func (*H2I) MarshalYODA

func (h *H2I) MarshalYODA() ([]byte, error)

MarshalYODA implements the YODAMarshaler interface.

func (*H2I) NbinsX

func (h *H2I) NbinsX() int

NbinsX returns the number of bins in X.

func (*H2I) NbinsY

func (h *H2I) NbinsY() int

NbinsY returns the number of bins in Y.

func (*H2I) Rank

func (h *H2I) Rank() int

Rank returns the number of dimensions of this histogram.

func (*H2I) SumWXY

func (h *H2I) SumWXY() float64

SumWXY returns the total sum of weights*x*y

func (*H2I) SumWY

func (h *H2I) SumWY() float64

SumWY returns the total sum of weights*y

func (*H2I) SumWY2

func (h *H2I) SumWY2() float64

SumWY2 returns the total sum of weights*y*y

func (*H2I) UnmarshalROOT

func (h *H2I) UnmarshalROOT(r *RBuffer) error

func (*H2I) UnmarshalYODA added in v0.15.0

func (h *H2I) UnmarshalYODA(raw []byte) error

UnmarshalYODA implements the YODAUnmarshaler interface.

func (*H2I) XAxis

func (h *H2I) XAxis() Axis

XAxis returns the axis along X.

func (*H2I) XBinCenter

func (h *H2I) XBinCenter(i int) float64

XBinCenter returns the bin center value in X.

func (*H2I) XBinContent

func (h *H2I) XBinContent(i int) float64

XBinContent returns the bin content value in X.

func (*H2I) XBinError

func (h *H2I) XBinError(i int) float64

XBinError returns the bin error in X.

func (*H2I) XBinLowEdge

func (h *H2I) XBinLowEdge(i int) float64

XBinLowEdge returns the bin lower edge value in X.

func (*H2I) XBinWidth

func (h *H2I) XBinWidth(i int) float64

XBinWidth returns the bin width in X.

func (*H2I) YAxis

func (h *H2I) YAxis() Axis

YAxis returns the axis along Y.

func (*H2I) YBinCenter

func (h *H2I) YBinCenter(i int) float64

YBinCenter returns the bin center value in Y.

func (*H2I) YBinContent

func (h *H2I) YBinContent(i int) float64

YBinContent returns the bin content value in Y.

func (*H2I) YBinError

func (h *H2I) YBinError(i int) float64

YBinError returns the bin error in Y.

func (*H2I) YBinLowEdge

func (h *H2I) YBinLowEdge(i int) float64

YBinLowEdge returns the bin lower edge value in Y.

func (*H2I) YBinWidth

func (h *H2I) YBinWidth(i int) float64

YBinWidth returns the bin width in Y.

type Key

type Key struct {
	// contains filtered or unexported fields
}

Key is a key (a label) in a ROOT file

The Key class includes functions to book space on a file,
 to create I/O buffers, to fill these buffers
 to compress/uncompress data buffers.

Before saving (making persistent) an object on a file, a key must
be created. The key structure contains all the information to
uniquely identify a persistent object on a file.
The Key class is used by ROOT:
  - to write an object in the Current Directory
  - to write a new ntuple buffer

func (*Key) Bytes

func (k *Key) Bytes() ([]byte, error)

Bytes returns the buffer of bytes corresponding to the Key's value

func (*Key) Class

func (*Key) Class() string

func (*Key) ClassName

func (k *Key) ClassName() string

func (*Key) Cycle

func (k *Key) Cycle() int

func (*Key) MarshalROOT

func (k *Key) MarshalROOT(w *WBuffer) (int, error)

MarshalROOT encodes the key to the provided buffer.

func (*Key) Name

func (k *Key) Name() string

func (*Key) Object

func (k *Key) Object() (Object, error)

Object returns the (ROOT) object corresponding to the Key's value.

func (*Key) ObjectType added in v0.16.0

func (k *Key) ObjectType() reflect.Type

ObjectType returns the Key's payload type.

ObjectType returns nil if the Key's payload type is not known to the registry of rootio.

func (*Key) Title

func (k *Key) Title() string

func (*Key) UnmarshalROOT

func (k *Key) UnmarshalROOT(r *RBuffer) error

UnmarshalROOT decodes the content of data into the Key

func (*Key) Value

func (k *Key) Value() interface{}

Value returns the data corresponding to the Key's value

type Leaf

type Leaf interface {
	Named
	ArrayDim() int
	Branch() Branch
	HasRange() bool
	IsUnsigned() bool
	LeafCount() Leaf // returns the leaf count if is variable length
	Len() int        // Len returns the number of fixed length elements
	LenType() int    // LenType returns the number of bytes for this data type
	MaxIndex() []int
	Offset() int
	Kind() reflect.Kind
	Type() reflect.Type
	Value(int) interface{}
	TypeName() string
	// contains filtered or unexported methods
}

Leaf describes branches data types

type LeafB

type LeafB struct {
	// contains filtered or unexported fields
}

LeafB implements ROOT TLeafB

func (*LeafB) ArrayDim

func (leaf *LeafB) ArrayDim() int

func (*LeafB) Branch

func (leaf *LeafB) Branch() Branch

func (*LeafB) Class

func (leaf *LeafB) Class() string

Class returns the ROOT class name.

func (*LeafB) HasRange

func (leaf *LeafB) HasRange() bool

func (*LeafB) IsUnsigned

func (leaf *LeafB) IsUnsigned() bool

func (*LeafB) Kind

func (*LeafB) Kind() reflect.Kind

Kind returns the leaf's kind.

func (*LeafB) LeafCount

func (leaf *LeafB) LeafCount() Leaf

func (*LeafB) Len

func (leaf *LeafB) Len() int

func (*LeafB) LenType

func (leaf *LeafB) LenType() int

func (*LeafB) MarshalROOT

func (leaf *LeafB) MarshalROOT(w *WBuffer) (int, error)

func (*LeafB) MaxIndex

func (leaf *LeafB) MaxIndex() []int

func (*LeafB) Maximum

func (leaf *LeafB) Maximum() int8

Maximum returns the maximum value of the leaf.

func (*LeafB) Minimum

func (leaf *LeafB) Minimum() int8

Minimum returns the minimum value of the leaf.

func (*LeafB) Name

func (leaf *LeafB) Name() string

Name returns the name of the instance

func (*LeafB) Offset

func (leaf *LeafB) Offset() int

func (*LeafB) Title

func (leaf *LeafB) Title() string

Title returns the title of the instance

func (*LeafB) Type

func (*LeafB) Type() reflect.Type

Type returns the leaf's type.

func (*LeafB) TypeName

func (leaf *LeafB) TypeName() string

func (*LeafB) UnmarshalROOT

func (leaf *LeafB) UnmarshalROOT(r *RBuffer) error

func (*LeafB) Value

func (leaf *LeafB) Value(i int) interface{}

Value returns the leaf value at index i.

type LeafC

type LeafC struct {
	// contains filtered or unexported fields
}

LeafC implements ROOT TLeafC

func (*LeafC) ArrayDim

func (leaf *LeafC) ArrayDim() int

func (*LeafC) Branch

func (leaf *LeafC) Branch() Branch

func (*LeafC) Class

func (leaf *LeafC) Class() string

Class returns the ROOT class name.

func (*LeafC) HasRange

func (leaf *LeafC) HasRange() bool

func (*LeafC) IsUnsigned

func (leaf *LeafC) IsUnsigned() bool

func (*LeafC) Kind

func (*LeafC) Kind() reflect.Kind

Kind returns the leaf's kind.

func (*LeafC) LeafCount

func (leaf *LeafC) LeafCount() Leaf

func (*LeafC) Len

func (leaf *LeafC) Len() int

func (*LeafC) LenType

func (leaf *LeafC) LenType() int

func (*LeafC) MarshalROOT

func (leaf *LeafC) MarshalROOT(w *WBuffer) (int, error)

func (*LeafC) MaxIndex

func (leaf *LeafC) MaxIndex() []int

func (*LeafC) Maximum

func (leaf *LeafC) Maximum() int32

Maximum returns the maximum value of the leaf.

func (*LeafC) Minimum

func (leaf *LeafC) Minimum() int32

Minimum returns the minimum value of the leaf.

func (*LeafC) Name

func (leaf *LeafC) Name() string

Name returns the name of the instance

func (*LeafC) Offset

func (leaf *LeafC) Offset() int

func (*LeafC) Title

func (leaf *LeafC) Title() string

Title returns the title of the instance

func (*LeafC) Type

func (*LeafC) Type() reflect.Type

Type returns the leaf's type.

func (*LeafC) TypeName

func (leaf *LeafC) TypeName() string

func (*LeafC) UnmarshalROOT

func (leaf *LeafC) UnmarshalROOT(r *RBuffer) error

func (*LeafC) Value

func (leaf *LeafC) Value(i int) interface{}

Value returns the leaf value at index i.

type LeafD

type LeafD struct {
	// contains filtered or unexported fields
}

LeafD implements ROOT TLeafD

func (*LeafD) ArrayDim

func (leaf *LeafD) ArrayDim() int

func (*LeafD) Branch

func (leaf *LeafD) Branch() Branch

func (*LeafD) Class

func (leaf *LeafD) Class() string

Class returns the ROOT class name.

func (*LeafD) HasRange

func (leaf *LeafD) HasRange() bool

func (*LeafD) IsUnsigned

func (leaf *LeafD) IsUnsigned() bool

func (*LeafD) Kind

func (*LeafD) Kind() reflect.Kind

Kind returns the leaf's kind.

func (*LeafD) LeafCount

func (leaf *LeafD) LeafCount() Leaf

func (*LeafD) Len

func (leaf *LeafD) Len() int

func (*LeafD) LenType

func (leaf *LeafD) LenType() int

func (*LeafD) MarshalROOT

func (leaf *LeafD) MarshalROOT(w *WBuffer) (int, error)

func (*LeafD) MaxIndex

func (leaf *LeafD) MaxIndex() []int

func (*LeafD) Maximum

func (leaf *LeafD) Maximum() float64

Maximum returns the maximum value of the leaf.

func (*LeafD) Minimum

func (leaf *LeafD) Minimum() float64

Minimum returns the minimum value of the leaf.

func (*LeafD) Name

func (leaf *LeafD) Name() string

Name returns the name of the instance

func (*LeafD) Offset

func (leaf *LeafD) Offset() int

func (*LeafD) Title

func (leaf *LeafD) Title() string

Title returns the title of the instance

func (*LeafD) Type

func (*LeafD) Type() reflect.Type

Type returns the leaf's type.

func (*LeafD) TypeName

func (leaf *LeafD) TypeName() string

func (*LeafD) UnmarshalROOT

func (leaf *LeafD) UnmarshalROOT(r *RBuffer) error

func (*LeafD) Value

func (leaf *LeafD) Value(i int) interface{}

Value returns the leaf value at index i.

type LeafF

type LeafF struct {
	// contains filtered or unexported fields
}

LeafF implements ROOT TLeafF

func (*LeafF) ArrayDim

func (leaf *LeafF) ArrayDim() int

func (*LeafF) Branch

func (leaf *LeafF) Branch() Branch

func (*LeafF) Class

func (leaf *LeafF) Class() string

Class returns the ROOT class name.

func (*LeafF) HasRange

func (leaf *LeafF) HasRange() bool

func (*LeafF) IsUnsigned

func (leaf *LeafF) IsUnsigned() bool

func (*LeafF) Kind

func (*LeafF) Kind() reflect.Kind

Kind returns the leaf's kind.

func (*LeafF) LeafCount

func (leaf *LeafF) LeafCount() Leaf

func (*LeafF) Len

func (leaf *LeafF) Len() int

func (*LeafF) LenType

func (leaf *LeafF) LenType() int

func (*LeafF) MarshalROOT

func (leaf *LeafF) MarshalROOT(w *WBuffer) (int, error)

func (*LeafF) MaxIndex

func (leaf *LeafF) MaxIndex() []int

func (*LeafF) Maximum

func (leaf *LeafF) Maximum() float32

Maximum returns the maximum value of the leaf.

func (*LeafF) Minimum

func (leaf *LeafF) Minimum() float32

Minimum returns the minimum value of the leaf.

func (*LeafF) Name

func (leaf *LeafF) Name() string

Name returns the name of the instance

func (*LeafF) Offset

func (leaf *LeafF) Offset() int

func (*LeafF) Title

func (leaf *LeafF) Title() string

Title returns the title of the instance

func (*LeafF) Type

func (*LeafF) Type() reflect.Type

Type returns the leaf's type.

func (*LeafF) TypeName

func (leaf *LeafF) TypeName() string

func (*LeafF) UnmarshalROOT

func (leaf *LeafF) UnmarshalROOT(r *RBuffer) error

func (*LeafF) Value

func (leaf *LeafF) Value(i int) interface{}

Value returns the leaf value at index i.

type LeafI

type LeafI struct {
	// contains filtered or unexported fields
}

LeafI implements ROOT TLeafI

func (*LeafI) ArrayDim

func (leaf *LeafI) ArrayDim() int

func (*LeafI) Branch

func (leaf *LeafI) Branch() Branch

func (*LeafI) Class

func (leaf *LeafI) Class() string

Class returns the ROOT class name.

func (*LeafI) HasRange

func (leaf *LeafI) HasRange() bool

func (*LeafI) IsUnsigned

func (leaf *LeafI) IsUnsigned() bool

func (*LeafI) Kind

func (*LeafI) Kind() reflect.Kind

Kind returns the leaf's kind.

func (*LeafI) LeafCount

func (leaf *LeafI) LeafCount() Leaf

func (*LeafI) Len

func (leaf *LeafI) Len() int

func (*LeafI) LenType

func (leaf *LeafI) LenType() int

func (*LeafI) MarshalROOT

func (leaf *LeafI) MarshalROOT(w *WBuffer) (int, error)

func (*LeafI) MaxIndex

func (leaf *LeafI) MaxIndex() []int

func (*LeafI) Maximum

func (leaf *LeafI) Maximum() int32

Maximum returns the maximum value of the leaf.

func (*LeafI) Minimum

func (leaf *LeafI) Minimum() int32

Minimum returns the minimum value of the leaf.

func (*LeafI) Name

func (leaf *LeafI) Name() string

Name returns the name of the instance

func (*LeafI) Offset

func (leaf *LeafI) Offset() int

func (*LeafI) Title

func (leaf *LeafI) Title() string

Title returns the title of the instance

func (*LeafI) Type

func (*LeafI) Type() reflect.Type

Type returns the leaf's type.

func (*LeafI) TypeName

func (leaf *LeafI) TypeName() string

func (*LeafI) UnmarshalROOT

func (leaf *LeafI) UnmarshalROOT(r *RBuffer) error

func (*LeafI) Value

func (leaf *LeafI) Value(i int) interface{}

Value returns the leaf value at index i.

type LeafL

type LeafL struct {
	// contains filtered or unexported fields
}

LeafL implements ROOT TLeafL

func (*LeafL) ArrayDim

func (leaf *LeafL) ArrayDim() int

func (*LeafL) Branch

func (leaf *LeafL) Branch() Branch

func (*LeafL) Class

func (leaf *LeafL) Class() string

Class returns the ROOT class name.

func (*LeafL) HasRange

func (leaf *LeafL) HasRange() bool

func (*LeafL) IsUnsigned

func (leaf *LeafL) IsUnsigned() bool

func (*LeafL) Kind

func (*LeafL) Kind() reflect.Kind

Kind returns the leaf's kind.

func (*LeafL) LeafCount

func (leaf *LeafL) LeafCount() Leaf

func (*LeafL) Len

func (leaf *LeafL) Len() int

func (*LeafL) LenType

func (leaf *LeafL) LenType() int

func (*LeafL) MarshalROOT

func (leaf *LeafL) MarshalROOT(w *WBuffer) (int, error)

func (*LeafL) MaxIndex

func (leaf *LeafL) MaxIndex() []int

func (*LeafL) Maximum

func (leaf *LeafL) Maximum() int64

Maximum returns the maximum value of the leaf.

func (*LeafL) Minimum

func (leaf *LeafL) Minimum() int64

Minimum returns the minimum value of the leaf.

func (*LeafL) Name

func (leaf *LeafL) Name() string

Name returns the name of the instance

func (*LeafL) Offset

func (leaf *LeafL) Offset() int

func (*LeafL) Title

func (leaf *LeafL) Title() string

Title returns the title of the instance

func (*LeafL) Type

func (*LeafL) Type() reflect.Type

Type returns the leaf's type.

func (*LeafL) TypeName

func (leaf *LeafL) TypeName() string

func (*LeafL) UnmarshalROOT

func (leaf *LeafL) UnmarshalROOT(r *RBuffer) error

func (*LeafL) Value

func (leaf *LeafL) Value(i int) interface{}

Value returns the leaf value at index i.

type LeafO

type LeafO struct {
	// contains filtered or unexported fields
}

LeafO implements ROOT TLeafO

func (*LeafO) ArrayDim

func (leaf *LeafO) ArrayDim() int

func (*LeafO) Branch

func (leaf *LeafO) Branch() Branch

func (*LeafO) Class

func (leaf *LeafO) Class() string

Class returns the ROOT class name.

func (*LeafO) HasRange

func (leaf *LeafO) HasRange() bool

func (*LeafO) IsUnsigned

func (leaf *LeafO) IsUnsigned() bool

func (*LeafO) Kind

func (*LeafO) Kind() reflect.Kind

Kind returns the leaf's kind.

func (*LeafO) LeafCount

func (leaf *LeafO) LeafCount() Leaf

func (*LeafO) Len

func (leaf *LeafO) Len() int

func (*LeafO) LenType

func (leaf *LeafO) LenType() int

func (*LeafO) MarshalROOT

func (leaf *LeafO) MarshalROOT(w *WBuffer) (int, error)

func (*LeafO) MaxIndex

func (leaf *LeafO) MaxIndex() []int

func (*LeafO) Maximum

func (leaf *LeafO) Maximum() bool

Maximum returns the maximum value of the leaf.

func (*LeafO) Minimum

func (leaf *LeafO) Minimum() bool

Minimum returns the minimum value of the leaf.

func (*LeafO) Name

func (leaf *LeafO) Name() string

Name returns the name of the instance

func (*LeafO) Offset

func (leaf *LeafO) Offset() int

func (*LeafO) Title

func (leaf *LeafO) Title() string

Title returns the title of the instance

func (*LeafO) Type

func (*LeafO) Type() reflect.Type

Type returns the leaf's type.

func (*LeafO) TypeName

func (leaf *LeafO) TypeName() string

func (*LeafO) UnmarshalROOT

func (leaf *LeafO) UnmarshalROOT(r *RBuffer) error

func (*LeafO) Value

func (leaf *LeafO) Value(i int) interface{}

Value returns the leaf value at index i.

type LeafS

type LeafS struct {
	// contains filtered or unexported fields
}

LeafS implements ROOT TLeafS

func (*LeafS) ArrayDim

func (leaf *LeafS) ArrayDim() int

func (*LeafS) Branch

func (leaf *LeafS) Branch() Branch

func (*LeafS) Class

func (leaf *LeafS) Class() string

Class returns the ROOT class name.

func (*LeafS) HasRange

func (leaf *LeafS) HasRange() bool

func (*LeafS) IsUnsigned

func (leaf *LeafS) IsUnsigned() bool

func (*LeafS) Kind

func (*LeafS) Kind() reflect.Kind

Kind returns the leaf's kind.

func (*LeafS) LeafCount

func (leaf *LeafS) LeafCount() Leaf

func (*LeafS) Len

func (leaf *LeafS) Len() int

func (*LeafS) LenType

func (leaf *LeafS) LenType() int

func (*LeafS) MarshalROOT

func (leaf *LeafS) MarshalROOT(w *WBuffer) (int, error)

func (*LeafS) MaxIndex

func (leaf *LeafS) MaxIndex() []int

func (*LeafS) Maximum

func (leaf *LeafS) Maximum() int16

Maximum returns the maximum value of the leaf.

func (*LeafS) Minimum

func (leaf *LeafS) Minimum() int16

Minimum returns the minimum value of the leaf.

func (*LeafS) Name

func (leaf *LeafS) Name() string

Name returns the name of the instance

func (*LeafS) Offset

func (leaf *LeafS) Offset() int

func (*LeafS) Title

func (leaf *LeafS) Title() string

Title returns the title of the instance

func (*LeafS) Type

func (*LeafS) Type() reflect.Type

Type returns the leaf's type.

func (*LeafS) TypeName

func (leaf *LeafS) TypeName() string

func (*LeafS) UnmarshalROOT

func (leaf *LeafS) UnmarshalROOT(r *RBuffer) error

func (*LeafS) Value

func (leaf *LeafS) Value(i int) interface{}

Value returns the leaf value at index i.

type List

type List interface {
	SeqCollection
}

List is a list of ROOT Objects.

type Member

type Member interface {
	// GetArrayDim returns the dimension of the array (if any)
	ArrayDim() int

	// GetComment returns the comment associated with this member
	Comment() string

	// Name returns the name of this member
	Name() string

	// Type returns the class of this member
	Type() Class

	// GetValue returns the value of this member
	Value(o Object) reflect.Value
}

Member represents a single member of a ROOT class

type Named

type Named interface {
	Object

	// Name returns the name of this ROOT object
	Name() string

	// Title returns the title of this ROOT object
	Title() string
}

Named represents a ROOT TNamed object

type ObjArray

type ObjArray interface {
	SeqCollection
	LowerBound() int
}

ObjArray is an array of ROOT Objects.

type ObjString

type ObjString interface {
	Name() string
	String() string
	// contains filtered or unexported methods
}

ObjString is a ROOT string that implements ROOT TObject.

type Object

type Object interface {
	// Class returns the ROOT class of this object
	Class() string
}

Object represents a ROOT object

type RBuffer

type RBuffer struct {
	// contains filtered or unexported fields
}

RBuffer is a read-only ROOT buffer for streaming.

func NewRBuffer

func NewRBuffer(data []byte, refs map[int64]interface{}, offset uint32, ctx StreamerInfoContext) *RBuffer

func (*RBuffer) CheckByteCount

func (r *RBuffer) CheckByteCount(pos, count int32, start int64, class string)

func (*RBuffer) Err

func (r *RBuffer) Err() error

func (*RBuffer) Len

func (r *RBuffer) Len() int64

func (*RBuffer) Pos

func (r *RBuffer) Pos() int64

func (*RBuffer) ReadBool

func (r *RBuffer) ReadBool() bool

func (*RBuffer) ReadCString

func (r *RBuffer) ReadCString(n int) string

func (*RBuffer) ReadF32

func (r *RBuffer) ReadF32() float32

func (*RBuffer) ReadF64

func (r *RBuffer) ReadF64() float64

func (*RBuffer) ReadFastArrayBool

func (r *RBuffer) ReadFastArrayBool(n int) []bool

func (*RBuffer) ReadFastArrayF32

func (r *RBuffer) ReadFastArrayF32(n int) []float32

func (*RBuffer) ReadFastArrayF64

func (r *RBuffer) ReadFastArrayF64(n int) []float64

func (*RBuffer) ReadFastArrayI16

func (r *RBuffer) ReadFastArrayI16(n int) []int16

func (*RBuffer) ReadFastArrayI32

func (r *RBuffer) ReadFastArrayI32(n int) []int32

func (*RBuffer) ReadFastArrayI64

func (r *RBuffer) ReadFastArrayI64(n int) []int64

func (*RBuffer) ReadFastArrayI8

func (r *RBuffer) ReadFastArrayI8(n int) []int8

func (*RBuffer) ReadFastArrayString

func (r *RBuffer) ReadFastArrayString(n int) []string

func (*RBuffer) ReadFastArrayU16

func (r *RBuffer) ReadFastArrayU16(n int) []uint16

func (*RBuffer) ReadFastArrayU32

func (r *RBuffer) ReadFastArrayU32(n int) []uint32

func (*RBuffer) ReadFastArrayU64

func (r *RBuffer) ReadFastArrayU64(n int) []uint64

func (*RBuffer) ReadFastArrayU8

func (r *RBuffer) ReadFastArrayU8(n int) []uint8

func (*RBuffer) ReadI16

func (r *RBuffer) ReadI16() int16

func (*RBuffer) ReadI32

func (r *RBuffer) ReadI32() int32

func (*RBuffer) ReadI64

func (r *RBuffer) ReadI64() int64

func (*RBuffer) ReadI8

func (r *RBuffer) ReadI8() int8

func (*RBuffer) ReadObject

func (r *RBuffer) ReadObject(class string) Object

func (*RBuffer) ReadObjectAny

func (r *RBuffer) ReadObjectAny() (obj Object)

func (*RBuffer) ReadStaticArrayI32

func (r *RBuffer) ReadStaticArrayI32() []int32

func (*RBuffer) ReadString

func (r *RBuffer) ReadString() string

func (*RBuffer) ReadU16

func (r *RBuffer) ReadU16() uint16

func (*RBuffer) ReadU32

func (r *RBuffer) ReadU32() uint32

func (*RBuffer) ReadU64

func (r *RBuffer) ReadU64() uint64

func (*RBuffer) ReadU8

func (r *RBuffer) ReadU8() uint8

func (*RBuffer) ReadVersion

func (r *RBuffer) ReadVersion() (vers int16, pos, n int32)

func (*RBuffer) SkipObject

func (r *RBuffer) SkipObject()

func (*RBuffer) SkipVersion

func (r *RBuffer) SkipVersion(class string)

func (*RBuffer) StreamerInfo

func (r *RBuffer) StreamerInfo(name string) (StreamerInfo, error)

type ROOTMarshaler

type ROOTMarshaler interface {
	MarshalROOT(w *WBuffer) (int, error)
}

ROOTMarshaler is the interface implemented by an object that can marshal itself into a ROOT buffer

type ROOTUnmarshaler

type ROOTUnmarshaler interface {
	UnmarshalROOT(r *RBuffer) error
}

ROOTUnmarshaler is the interface implemented by an object that can unmarshal itself from a ROOT buffer

type RStreamer

type RStreamer interface {
	RStream(r *RBuffer) error
}

type Reader

type Reader interface {
	io.Reader
	io.ReaderAt
	io.Seeker
	io.Closer
}

type ScanVar

type ScanVar struct {
	Name  string      // name of the branch to read
	Leaf  string      // name of the leaf to read
	Value interface{} // pointer to the value to fill
}

ScanVar describes a variable to be read out of a tree during a scan.

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner scans, selects and iterates over Tree entries. Scanner is bound to values the user provides, Scanner will then read data into these values during the tree scan.

Example (WithStruct)
package main

import (
	"fmt"
	"io"
	"log"

	"go-hep.org/x/hep/rootio"
)

func main() {
	log.SetPrefix("rootio: ")
	log.SetFlags(0)

	f, err := rootio.Open("testdata/small-flat-tree.root")
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	obj, err := f.Get("tree")
	if err != nil {
		log.Fatal(err)
	}

	tree := obj.(rootio.Tree)

	type Data struct {
		I64    int64       `rootio:"Int64"`
		F64    float64     `rootio:"Float64"`
		Str    string      `rootio:"Str"`
		ArrF64 [10]float64 `rootio:"ArrayFloat64"`
		N      int32       `rootio:"N"`
		SliF64 []float64   `rootio:"SliceFloat64"`
	}

	var data Data
	sc, err := rootio.NewScanner(tree, &data)
	if err != nil {
		log.Fatal(err)
	}
	defer sc.Close()

	for sc.Next() {
		err := sc.Scan()
		if err != nil {
			log.Fatal(err)
		}

		fmt.Printf("entry[%d]: %+v\n", sc.Entry(), data)
		if sc.Entry() == 9 {
			break
		}
	}

	if err := sc.Err(); err != nil && err != io.EOF {
		log.Fatal(err)
	}

}
Output:

entry[0]: {I64:0 F64:0 Str:evt-000 ArrF64:[0 0 0 0 0 0 0 0 0 0] N:0 SliF64:[]}
entry[1]: {I64:1 F64:1 Str:evt-001 ArrF64:[1 1 1 1 1 1 1 1 1 1] N:1 SliF64:[1]}
entry[2]: {I64:2 F64:2 Str:evt-002 ArrF64:[2 2 2 2 2 2 2 2 2 2] N:2 SliF64:[2 2]}
entry[3]: {I64:3 F64:3 Str:evt-003 ArrF64:[3 3 3 3 3 3 3 3 3 3] N:3 SliF64:[3 3 3]}
entry[4]: {I64:4 F64:4 Str:evt-004 ArrF64:[4 4 4 4 4 4 4 4 4 4] N:4 SliF64:[4 4 4 4]}
entry[5]: {I64:5 F64:5 Str:evt-005 ArrF64:[5 5 5 5 5 5 5 5 5 5] N:5 SliF64:[5 5 5 5 5]}
entry[6]: {I64:6 F64:6 Str:evt-006 ArrF64:[6 6 6 6 6 6 6 6 6 6] N:6 SliF64:[6 6 6 6 6 6]}
entry[7]: {I64:7 F64:7 Str:evt-007 ArrF64:[7 7 7 7 7 7 7 7 7 7] N:7 SliF64:[7 7 7 7 7 7 7]}
entry[8]: {I64:8 F64:8 Str:evt-008 ArrF64:[8 8 8 8 8 8 8 8 8 8] N:8 SliF64:[8 8 8 8 8 8 8 8]}
entry[9]: {I64:9 F64:9 Str:evt-009 ArrF64:[9 9 9 9 9 9 9 9 9 9] N:9 SliF64:[9 9 9 9 9 9 9 9 9]}
Example (WithVars)
package main

import (
	"fmt"
	"io"
	"log"

	"go-hep.org/x/hep/rootio"
)

func main() {
	log.SetPrefix("rootio: ")
	log.SetFlags(0)

	f, err := rootio.Open("testdata/small-flat-tree.root")
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	obj, err := f.Get("tree")
	if err != nil {
		log.Fatal(err)
	}

	tree := obj.(rootio.Tree)

	var (
		i64 int64
		f64 float64
		str string
		arr [10]float64
		n   int32
		sli []float64
	)
	scanVars := []rootio.ScanVar{
		{Name: "Int64", Value: &i64},
		{Name: "Float64", Value: &f64},
		{Name: "Str", Value: &str},
		{Name: "ArrayFloat64", Value: &arr},
		{Name: "N", Value: &n},
		{Name: "SliceFloat64", Value: &sli},
	}
	sc, err := rootio.NewScannerVars(tree, scanVars...)
	if err != nil {
		log.Fatal(err)
	}
	defer sc.Close()

	for sc.Next() {
		err := sc.Scan()
		if err != nil {
			log.Fatal(err)
		}

		fmt.Printf(
			"entry[%d]: i64=%v f64=%v str=%q arr=%v n=%d sli=%v\n",
			sc.Entry(),
			i64, f64, str, arr, n, sli,
		)
		if sc.Entry() == 9 {
			break
		}
	}

	if err := sc.Err(); err != nil && err != io.EOF {
		log.Fatal(err)
	}

}
Output:

entry[0]: i64=0 f64=0 str="evt-000" arr=[0 0 0 0 0 0 0 0 0 0] n=0 sli=[]
entry[1]: i64=1 f64=1 str="evt-001" arr=[1 1 1 1 1 1 1 1 1 1] n=1 sli=[1]
entry[2]: i64=2 f64=2 str="evt-002" arr=[2 2 2 2 2 2 2 2 2 2] n=2 sli=[2 2]
entry[3]: i64=3 f64=3 str="evt-003" arr=[3 3 3 3 3 3 3 3 3 3] n=3 sli=[3 3 3]
entry[4]: i64=4 f64=4 str="evt-004" arr=[4 4 4 4 4 4 4 4 4 4] n=4 sli=[4 4 4 4]
entry[5]: i64=5 f64=5 str="evt-005" arr=[5 5 5 5 5 5 5 5 5 5] n=5 sli=[5 5 5 5 5]
entry[6]: i64=6 f64=6 str="evt-006" arr=[6 6 6 6 6 6 6 6 6 6] n=6 sli=[6 6 6 6 6 6]
entry[7]: i64=7 f64=7 str="evt-007" arr=[7 7 7 7 7 7 7 7 7 7] n=7 sli=[7 7 7 7 7 7 7]
entry[8]: i64=8 f64=8 str="evt-008" arr=[8 8 8 8 8 8 8 8 8 8] n=8 sli=[8 8 8 8 8 8 8 8]
entry[9]: i64=9 f64=9 str="evt-009" arr=[9 9 9 9 9 9 9 9 9 9] n=9 sli=[9 9 9 9 9 9 9 9 9]

func NewScanner

func NewScanner(t Tree, ptr interface{}) (*Scanner, error)

NewScanner creates a new Scanner bound to a (pointer to a) struct value. Scanner will read the branches' data during Scan() and load them into the fields of the struct value.

func NewScannerVars

func NewScannerVars(t Tree, vars ...ScanVar) (*Scanner, error)

NewScannerVars creates a new Scanner from a list of pairs (branch-name, target-address). Scanner will read the branches' data during Scan() and load them into these target-addresses.

func (*Scanner) Close

func (s *Scanner) Close() error

Close closes the Scanner, preventing further iteration. Close is idempotent and does not affect the result of Err.

func (*Scanner) Entry

func (s *Scanner) Entry() int64

Entry returns the entry number of the last read row.

func (*Scanner) Err

func (s *Scanner) Err() error

Err returns the error, if any, that was encountered during iteration.

func (*Scanner) Next

func (s *Scanner) Next() bool

Next prepares the next result row for reading with the Scan method. It returns true on success, false if there is no next result row. Every call to Scan, even the first one, must be preceded by a call to Next.

func (*Scanner) Scan

func (s *Scanner) Scan() error

Scan copies data loaded from the underlying Tree into the values the Scanner is bound to. The values bound to the Scanner are valid until the next call to Scan.

func (*Scanner) SeekEntry

func (s *Scanner) SeekEntry(i int64) error

SeekEntry points the scanner to the i-th entry, ready to call Next.

type SeqCollection

type SeqCollection interface {
	Collection
}

SeqCollection is a sequential collection of ROOT Objects.

type SetFiler

type SetFiler interface {
	SetFile(f *File)
}

SetFiler is a simple interface to establish File ownership.

type StreamerElement

type StreamerElement interface {
	Named
	ArrayDim() int
	ArrayLen() int
	Type() int
	Offset() uintptr
	Size() uintptr
	TypeName() string
}

StreamerElement describes a ROOT StreamerElement

type StreamerInfo

type StreamerInfo interface {
	Named
	CheckSum() int
	ClassVersion() int
	Elements() []StreamerElement
}

StreamerInfo describes a ROOT Streamer.

type StreamerInfoContext

type StreamerInfoContext interface {
	StreamerInfo(name string) (StreamerInfo, error)
}

type Tree

type Tree interface {
	Named
	Entries() int64
	TotBytes() int64
	ZipBytes() int64
	Branch(name string) Branch
	Branches() []Branch
	Leaf(name string) Leaf
	Leaves() []Leaf
	// contains filtered or unexported methods
}

Tree is a collection of branches of data.

func Chain

func Chain(trees ...Tree) Tree

Chain returns a tchain that is the concatenation of all the input Trees.

Example

ExampleChain shows how to create a chain made of 2 trees.

package main

import (
	"fmt"
	"log"

	"go-hep.org/x/hep/rootio"
)

func main() {
	const name = "tree"

	f1, err := rootio.Open("testdata/chain.1.root")
	if err != nil {
		log.Fatal(err)
	}
	defer f1.Close()

	o1, err := f1.Get(name)
	if err != nil {
		log.Fatal(err)
	}
	t1 := o1.(rootio.Tree)

	f2, err := rootio.Open("testdata/chain.2.root")
	if err != nil {
		log.Fatal(err)
	}
	defer f2.Close()

	o2, err := f2.Get(name)
	if err != nil {
		log.Fatal(err)
	}
	t2 := o2.(rootio.Tree)

	chain := rootio.Chain(t1, t2)

	type Data struct {
		Event struct {
			Beg       string      `rootio:"Beg"`
			F64       float64     `rootio:"F64"`
			ArrF64    [10]float64 `rootio:"ArrayF64"`
			N         int32       `rootio:"N"`
			SliF64    []float64   `rootio:"SliceF64"`
			StdStr    string      `rootio:"StdStr"`
			StlVecF64 []float64   `rootio:"StlVecF64"`
			StlVecStr []string    `rootio:"StlVecStr"`
			End       string      `rootio:"End"`
		} `rootio:"evt"`
	}

	sc, err := rootio.NewTreeScanner(chain, &Data{})
	if err != nil {
		log.Fatal(err)
	}
	defer sc.Close()

	for sc.Next() {
		var data Data
		err := sc.Scan(&data)
		if err != nil {
			log.Fatal(err)
		}
		fmt.Printf("entry[%02d]: beg=%q f64=%v\n", sc.Entry(), data.Event.Beg, data.Event.F64)
	}

	if err := sc.Err(); err != nil {
		log.Fatalf("error during scan: %v", err)
	}

}
Output:

entry[00]: beg="beg-000" f64=0
entry[01]: beg="beg-001" f64=1
entry[02]: beg="beg-002" f64=2
entry[03]: beg="beg-003" f64=3
entry[04]: beg="beg-004" f64=4
entry[05]: beg="beg-005" f64=5
entry[06]: beg="beg-006" f64=6
entry[07]: beg="beg-007" f64=7
entry[08]: beg="beg-008" f64=8
entry[09]: beg="beg-009" f64=9
entry[10]: beg="beg-010" f64=10
entry[11]: beg="beg-011" f64=11
entry[12]: beg="beg-012" f64=12
entry[13]: beg="beg-013" f64=13
entry[14]: beg="beg-014" f64=14
entry[15]: beg="beg-015" f64=15
entry[16]: beg="beg-016" f64=16
entry[17]: beg="beg-017" f64=17
entry[18]: beg="beg-018" f64=18
entry[19]: beg="beg-019" f64=19

func ChainOf

func ChainOf(name string, files ...string) (Tree, func() error, error)

ChainOf returns a Tree, a close function and an error if any. The tree is the logical concatenation of all the name trees located in the input named files. The close function allows to close all the open named files.

Example

ExampleChainOf shows how to create a chain made of trees from 2 files.

package main

import (
	"fmt"
	"log"

	"go-hep.org/x/hep/rootio"
)

func main() {
	const name = "tree"

	chain, closer, err := rootio.ChainOf(name, "testdata/chain.1.root", "testdata/chain.2.root")
	if err != nil {
		log.Fatal(err)
	}
	defer closer()

	type Data struct {
		Event struct {
			Beg       string      `rootio:"Beg"`
			F64       float64     `rootio:"F64"`
			ArrF64    [10]float64 `rootio:"ArrayF64"`
			N         int32       `rootio:"N"`
			SliF64    []float64   `rootio:"SliceF64"`
			StdStr    string      `rootio:"StdStr"`
			StlVecF64 []float64   `rootio:"StlVecF64"`
			StlVecStr []string    `rootio:"StlVecStr"`
			End       string      `rootio:"End"`
		} `rootio:"evt"`
	}

	sc, err := rootio.NewTreeScanner(chain, &Data{})
	if err != nil {
		log.Fatal(err)
	}
	defer sc.Close()

	for sc.Next() {
		var data Data
		err := sc.Scan(&data)
		if err != nil {
			log.Fatal(err)
		}
		fmt.Printf("entry[%02d]: beg=%q f64=%v\n", sc.Entry(), data.Event.Beg, data.Event.F64)
	}

	if err := sc.Err(); err != nil {
		log.Fatalf("error during scan: %v", err)
	}

}
Output:

entry[00]: beg="beg-000" f64=0
entry[01]: beg="beg-001" f64=1
entry[02]: beg="beg-002" f64=2
entry[03]: beg="beg-003" f64=3
entry[04]: beg="beg-004" f64=4
entry[05]: beg="beg-005" f64=5
entry[06]: beg="beg-006" f64=6
entry[07]: beg="beg-007" f64=7
entry[08]: beg="beg-008" f64=8
entry[09]: beg="beg-009" f64=9
entry[10]: beg="beg-010" f64=10
entry[11]: beg="beg-011" f64=11
entry[12]: beg="beg-012" f64=12
entry[13]: beg="beg-013" f64=13
entry[14]: beg="beg-014" f64=14
entry[15]: beg="beg-015" f64=15
entry[16]: beg="beg-016" f64=16
entry[17]: beg="beg-017" f64=17
entry[18]: beg="beg-018" f64=18
entry[19]: beg="beg-019" f64=19

type TreeScanner

type TreeScanner struct {
	// contains filtered or unexported fields
}

TreeScanner scans, selects and iterates over Tree entries.

Example
package main

import (
	"fmt"
	"io"
	"log"

	"go-hep.org/x/hep/rootio"
)

func main() {
	log.SetPrefix("rootio: ")
	log.SetFlags(0)

	f, err := rootio.Open("testdata/small-flat-tree.root")
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	obj, err := f.Get("tree")
	if err != nil {
		log.Fatal(err)
	}

	tree := obj.(rootio.Tree)

	type Data struct {
		I64    int64       `rootio:"Int64"`
		F64    float64     `rootio:"Float64"`
		Str    string      `rootio:"Str"`
		ArrF64 [10]float64 `rootio:"ArrayFloat64"`
		N      int32       `rootio:"N"`
		SliF64 []float64   `rootio:"SliceFloat64"`
	}

	sc, err := rootio.NewTreeScanner(tree, &Data{})
	if err != nil {
		log.Fatal(err)
	}
	defer sc.Close()

	for sc.Next() {
		var data Data
		err := sc.Scan(&data)
		if err != nil {
			log.Fatal(err)
		}

		fmt.Printf("entry[%d]: %+v\n", sc.Entry(), data)
		if sc.Entry() == 9 {
			break
		}
	}

	if err := sc.Err(); err != nil && err != io.EOF {
		log.Fatal(err)
	}

}
Output:

entry[0]: {I64:0 F64:0 Str:evt-000 ArrF64:[0 0 0 0 0 0 0 0 0 0] N:0 SliF64:[]}
entry[1]: {I64:1 F64:1 Str:evt-001 ArrF64:[1 1 1 1 1 1 1 1 1 1] N:1 SliF64:[1]}
entry[2]: {I64:2 F64:2 Str:evt-002 ArrF64:[2 2 2 2 2 2 2 2 2 2] N:2 SliF64:[2 2]}
entry[3]: {I64:3 F64:3 Str:evt-003 ArrF64:[3 3 3 3 3 3 3 3 3 3] N:3 SliF64:[3 3 3]}
entry[4]: {I64:4 F64:4 Str:evt-004 ArrF64:[4 4 4 4 4 4 4 4 4 4] N:4 SliF64:[4 4 4 4]}
entry[5]: {I64:5 F64:5 Str:evt-005 ArrF64:[5 5 5 5 5 5 5 5 5 5] N:5 SliF64:[5 5 5 5 5]}
entry[6]: {I64:6 F64:6 Str:evt-006 ArrF64:[6 6 6 6 6 6 6 6 6 6] N:6 SliF64:[6 6 6 6 6 6]}
entry[7]: {I64:7 F64:7 Str:evt-007 ArrF64:[7 7 7 7 7 7 7 7 7 7] N:7 SliF64:[7 7 7 7 7 7 7]}
entry[8]: {I64:8 F64:8 Str:evt-008 ArrF64:[8 8 8 8 8 8 8 8 8 8] N:8 SliF64:[8 8 8 8 8 8 8 8]}
entry[9]: {I64:9 F64:9 Str:evt-009 ArrF64:[9 9 9 9 9 9 9 9 9 9] N:9 SliF64:[9 9 9 9 9 9 9 9 9]}
Example (WithVars)
package main

import (
	"fmt"
	"io"
	"log"

	"go-hep.org/x/hep/rootio"
)

func main() {
	log.SetPrefix("rootio: ")
	log.SetFlags(0)

	f, err := rootio.Open("testdata/small-flat-tree.root")
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	obj, err := f.Get("tree")
	if err != nil {
		log.Fatal(err)
	}

	tree := obj.(rootio.Tree)

	scanVars := []rootio.ScanVar{
		{Name: "Int64"},
		{Name: "Float64"},
		{Name: "Str"},
		{Name: "ArrayFloat64"},
		{Name: "N"},
		{Name: "SliceFloat64"},
	}
	sc, err := rootio.NewTreeScannerVars(tree, scanVars...)
	if err != nil {
		log.Fatal(err)
	}
	defer sc.Close()

	for sc.Next() {
		var (
			i64 int64
			f64 float64
			str string
			arr [10]float64
			n   int32
			sli []float64
		)
		err := sc.Scan(&i64, &f64, &str, &arr, &n, &sli)
		if err != nil {
			log.Fatal(err)
		}

		fmt.Printf(
			"entry[%d]: i64=%v f64=%v str=%q arr=%v n=%d sli=%v\n",
			sc.Entry(),
			i64, f64, str, arr, n, sli,
		)
		if sc.Entry() == 9 {
			break
		}
	}

	if err := sc.Err(); err != nil && err != io.EOF {
		log.Fatal(err)
	}

}
Output:

entry[0]: i64=0 f64=0 str="evt-000" arr=[0 0 0 0 0 0 0 0 0 0] n=0 sli=[]
entry[1]: i64=1 f64=1 str="evt-001" arr=[1 1 1 1 1 1 1 1 1 1] n=1 sli=[1]
entry[2]: i64=2 f64=2 str="evt-002" arr=[2 2 2 2 2 2 2 2 2 2] n=2 sli=[2 2]
entry[3]: i64=3 f64=3 str="evt-003" arr=[3 3 3 3 3 3 3 3 3 3] n=3 sli=[3 3 3]
entry[4]: i64=4 f64=4 str="evt-004" arr=[4 4 4 4 4 4 4 4 4 4] n=4 sli=[4 4 4 4]
entry[5]: i64=5 f64=5 str="evt-005" arr=[5 5 5 5 5 5 5 5 5 5] n=5 sli=[5 5 5 5 5]
entry[6]: i64=6 f64=6 str="evt-006" arr=[6 6 6 6 6 6 6 6 6 6] n=6 sli=[6 6 6 6 6 6]
entry[7]: i64=7 f64=7 str="evt-007" arr=[7 7 7 7 7 7 7 7 7 7] n=7 sli=[7 7 7 7 7 7 7]
entry[8]: i64=8 f64=8 str="evt-008" arr=[8 8 8 8 8 8 8 8 8 8] n=8 sli=[8 8 8 8 8 8 8 8]
entry[9]: i64=9 f64=9 str="evt-009" arr=[9 9 9 9 9 9 9 9 9 9] n=9 sli=[9 9 9 9 9 9 9 9 9]

func NewTreeScanner

func NewTreeScanner(t Tree, ptr interface{}) (*TreeScanner, error)

NewTreeScanner creates a new Scanner connecting the pointer to some user provided type to the given Tree.

func NewTreeScannerVars

func NewTreeScannerVars(t Tree, vars ...ScanVar) (*TreeScanner, error)

NewTreeScannerVars creates a new Scanner from a list of branches. It will return an error if the provided type does not match the type stored in the corresponding branch.

func (*TreeScanner) Close

func (s *TreeScanner) Close() error

Close closes the TreeScanner, preventing further iteration. Close is idempotent and does not affect the result of Err.

func (*TreeScanner) Entry

func (s *TreeScanner) Entry() int64

Entry returns the entry number of the last read row.

func (*TreeScanner) Err

func (s *TreeScanner) Err() error

Err returns the error, if any, that was encountered during iteration.

func (*TreeScanner) Next

func (s *TreeScanner) Next() bool

Next prepares the next result row for reading with the Scan method. It returns true on success, false if there is no next result row. Every call to Scan, even the first one, must be preceded by a call to Next.

func (*TreeScanner) Scan

func (s *TreeScanner) Scan(args ...interface{}) (err error)

Scan copies data loaded from the underlying Tree into the values pointed at by args.

func (*TreeScanner) SeekEntry

func (s *TreeScanner) SeekEntry(i int64) error

SeekEntry points the scanner to the i-th entry, ready to call Next.

type WBuffer

type WBuffer struct {
	// contains filtered or unexported fields
}

WBuffer is a write-only ROOT buffer for streaming.

func NewWBuffer

func NewWBuffer(data []byte, refs map[interface{}]int64, offset uint32, ctx StreamerInfoContext) *WBuffer

func (*WBuffer) Pos

func (w *WBuffer) Pos() int64

func (*WBuffer) SetByteCount

func (w *WBuffer) SetByteCount(beg int64, class string) (int, error)

func (*WBuffer) WriteBool

func (w *WBuffer) WriteBool(v bool)

func (*WBuffer) WriteCString

func (w *WBuffer) WriteCString(v string)

func (*WBuffer) WriteClass

func (w *WBuffer) WriteClass(beg int64, obj Object) (uint32, error)

func (*WBuffer) WriteF32

func (w *WBuffer) WriteF32(v float32)

func (*WBuffer) WriteF64

func (w *WBuffer) WriteF64(v float64)

func (*WBuffer) WriteFastArrayBool

func (w *WBuffer) WriteFastArrayBool(v []bool)

func (*WBuffer) WriteFastArrayF32

func (w *WBuffer) WriteFastArrayF32(v []float32)

func (*WBuffer) WriteFastArrayF64

func (w *WBuffer) WriteFastArrayF64(v []float64)

func (*WBuffer) WriteFastArrayI16

func (w *WBuffer) WriteFastArrayI16(v []int16)

func (*WBuffer) WriteFastArrayI32

func (w *WBuffer) WriteFastArrayI32(v []int32)

func (*WBuffer) WriteFastArrayI64

func (w *WBuffer) WriteFastArrayI64(v []int64)

func (*WBuffer) WriteFastArrayI8

func (w *WBuffer) WriteFastArrayI8(v []int8)

func (*WBuffer) WriteFastArrayU16

func (w *WBuffer) WriteFastArrayU16(v []uint16)

func (*WBuffer) WriteFastArrayU32

func (w *WBuffer) WriteFastArrayU32(v []uint32)

func (*WBuffer) WriteFastArrayU64

func (w *WBuffer) WriteFastArrayU64(v []uint64)

func (*WBuffer) WriteFastArrayU8

func (w *WBuffer) WriteFastArrayU8(v []uint8)

func (*WBuffer) WriteI16

func (w *WBuffer) WriteI16(v int16)

func (*WBuffer) WriteI32

func (w *WBuffer) WriteI32(v int32)

func (*WBuffer) WriteI64

func (w *WBuffer) WriteI64(v int64)

func (*WBuffer) WriteI8

func (w *WBuffer) WriteI8(v int8)

func (*WBuffer) WriteObjectAny

func (w *WBuffer) WriteObjectAny(obj Object) error

func (*WBuffer) WriteStaticArrayI32

func (w *WBuffer) WriteStaticArrayI32(v []int32)

func (*WBuffer) WriteString

func (w *WBuffer) WriteString(v string)

func (*WBuffer) WriteU16

func (w *WBuffer) WriteU16(v uint16)

func (*WBuffer) WriteU32

func (w *WBuffer) WriteU32(v uint32)

func (*WBuffer) WriteU64

func (w *WBuffer) WriteU64(v uint64)

func (*WBuffer) WriteU8

func (w *WBuffer) WriteU8(v uint8)

func (*WBuffer) WriteVersion

func (w *WBuffer) WriteVersion(vers int16)

type Writer

type Writer interface {
	io.Writer
	io.WriterAt
	io.Seeker
	io.Closer
}

Directories

Path Synopsis
internal
rstreamers
Package rstreamers provides the StreamerInfo definitions for a bunch of core ROOT classes, to setup the bootstrap procedure of being able to create streamers from the Go side.
Package rstreamers provides the StreamerInfo definitions for a bunch of core ROOT classes, to setup the bootstrap procedure of being able to create streamers from the Go side.

Jump to

Keyboard shortcuts

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