go-hep.org/x/hep@v0.38.1/hbook/hbook.go (about)

     1  // Copyright ©2016 The go-hep Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package hbook // import "go-hep.org/x/hep/hbook"
     6  
     7  import (
     8  	"math"
     9  )
    10  
    11  //go:generate go tool github.com/campoy/embedmd -w README.md
    12  
    13  //go:generate go tool go-hep.org/x/hep/brio/cmd/brio-gen -p go-hep.org/x/hep/hbook -t Dist0D,Dist1D,Dist2D -o dist_brio.go
    14  //go:generate go tool go-hep.org/x/hep/brio/cmd/brio-gen -p go-hep.org/x/hep/hbook -t Range,Binning1D,binningP1D,Bin1D,BinP1D,Binning2D,Bin2D -o binning_brio.go
    15  //go:generate go tool go-hep.org/x/hep/brio/cmd/brio-gen -p go-hep.org/x/hep/hbook -t Point2D -o points_brio.go
    16  //go:generate go tool go-hep.org/x/hep/brio/cmd/brio-gen -p go-hep.org/x/hep/hbook -t H1D,H2D,P1D,S2D -o hbook_brio.go
    17  
    18  // Bin models 1D, 2D, ... bins.
    19  type Bin interface {
    20  	Rank() int           // Number of dimensions of the bin
    21  	Entries() int64      // Number of entries in the bin
    22  	EffEntries() float64 // Effective number of entries in the bin
    23  	SumW() float64       // sum of weights
    24  	SumW2() float64      // sum of squared weights
    25  }
    26  
    27  // Range is a 1-dim interval [Min, Max].
    28  type Range struct {
    29  	Min float64
    30  	Max float64
    31  }
    32  
    33  func (r Range) clone() Range {
    34  	return r
    35  }
    36  
    37  // Width returns the size of the range.
    38  func (r Range) Width() float64 {
    39  	return math.Abs(r.Max - r.Min)
    40  }
    41  
    42  // Count is a 1-dim binned information, made of
    43  // a X range, a value and its uncertainties.
    44  type Count struct {
    45  	XRange Range
    46  	Val    float64
    47  	Err    struct {
    48  		Low  float64
    49  		High float64
    50  	}
    51  }
    52  
    53  // Histogram is an n-dim histogram (with weighted entries)
    54  type Histogram interface {
    55  	// Annotation returns the annotations attached to the
    56  	// histogram. (e.g. name, title, ...)
    57  	Annotation() Annotation
    58  
    59  	// Name returns the name of this histogram
    60  	Name() string
    61  
    62  	// Rank returns the number of dimensions of this histogram.
    63  	Rank() int
    64  
    65  	// Entries returns the number of entries of this histogram.
    66  	Entries() int64
    67  }