slha

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2018 License: BSD-3-Clause, BSD-3-Clause Imports: 10 Imported by: 0

README

slha

GoDoc

Package slha implements encoding and decoding of SUSY Les Houches Accords (SLHA) data format.

Installation

$ go get go-hep.org/x/hep/slha

Example

package main

import (
	"fmt"
	"os"

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

func handle(err error) {
	if err != nil {
		panic(err)
	}
}

func main() {
	fname := "testdata/sps1a.spc"
	if len(os.Args) > 1 {
		fname = os.Args[1]
	}
	f, err := os.Open(fname)
	handle(err)

	defer f.Close()

	data, err := slha.Decode(f)
	handle(err)

	spinfo := data.Blocks.Get("SPINFO")
	value, err := spinfo.Get(1)
	handle(err)
	fmt.Printf("spinfo: %s -- %q\n", value.Interface(), value.Comment())

	modsel := data.Blocks.Get("MODSEL")
	value, err = modsel.Get(1)
	handle(err)
	fmt.Printf("modsel: %d -- %q\n", value.Interface(), value.Comment())

	mass := data.Blocks.Get("MASS")
	value, err = mass.Get(5)
	handle(err)
	fmt.Printf("mass[pdgid=5]: %v -- %q\n", value.Interface(), value.Comment())

	nmix := data.Blocks.Get("NMIX")
	value, err = nmix.Get(1, 2)
	handle(err)
	fmt.Printf("nmix[1,2] = %v -- %q\n", value.Interface(), value.Comment())
}


// Output:
// spinfo: SOFTSUSY -- "spectrum calculator"
// modsel: 1 -- "sugra"
// mass[pdgid=5]: 4.88991651 -- "b-quark pole mass calculated from mb(mb)_Msbar"
// nmix[1,2] = -0.0531103553 -- "N_12"

Documentation

Documentation is available on godoc:

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

Documentation

Overview

Package slha implements encoding and decoding of SUSY Les Houches Accords (SLHA) data format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(w io.Writer, data *SLHA) error

Encode writes the SLHA informations to w.

Types

type Block

type Block struct {
	Name    string
	Comment string
	Q       float64
	Data    DataArray
}

Block represents a block in a SLHA file.

func (*Block) Get

func (b *Block) Get(args ...int) (Value, error)

Get returns the Value at index args. Note that args are 1-based indices.

func (*Block) Set

func (b *Block) Set(v interface{}, args ...int) error

Set sets the Value at index args with v. Set creates a new empty Value if none exists at args. Note that args are 1-based indices.

type Blocks

type Blocks []Block

Blocks is a list of Blocks.

func (Blocks) Get

func (b Blocks) Get(name string) *Block

Get returns the block named name or nil.

func (Blocks) Keys

func (b Blocks) Keys() []string

Keys returns the names of the contained blocks.

type DataArray

type DataArray []DataItem

DataArray is an ordered list of DataItems.

func (DataArray) Get

func (d DataArray) Get(idx Index) (Value, bool)

Get returns the value at the n-dim index idx.

type DataItem

type DataItem struct {
	Index Index
	Value Value
}

DataItem is a pair of (Index,Value). Index is a n-dim index (1-based indices)

type Decay

type Decay struct {
	Br      float64 // Branching Ratio
	IDs     []int   // list of PDG IDs to which the decay occur
	Comment string  // comment attached to this decay line - if any
}

Decay is a decay line in an SLHA file.

type Decays

type Decays []Decay

Decays is a list of decays in a Decay block.

type Index

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

Index is an n-dimensional index. Note that the indices are 1-based.

func NewIndex

func NewIndex(args ...int) Index

NewIndex creates a new n-dim index from args. Note that args are 1-based indices.

func (Index) Index

func (idx Index) Index() []int

Index returns the n-dim indices. Note that the indices are 1-based.

type Particle

type Particle struct {
	PdgID   int     // PDG-ID code
	Width   float64 // total width of that particle
	Mass    float64 // mass of that particle
	Comment string
	Decays  Decays
}

Particle is the representation of a single, specific particle, decay block from a SLHA file.

type Particles

type Particles []Particle

Particles is a block of particle's decays in an SLHA file.

func (Particles) Get

func (p Particles) Get(pdgid int) *Particle

Get returns the Particle with matching pdgid or nil.

func (Particles) Len

func (p Particles) Len() int

func (Particles) Less

func (p Particles) Less(i, j int) bool

func (Particles) Swap

func (p Particles) Swap(i, j int)

type SLHA

type SLHA struct {
	Blocks    Blocks
	Particles Particles
}

SLHA holds informations about a SUSY Les Houches Accords file.

func Decode

func Decode(r io.Reader) (*SLHA, error)

Decode reads SLHA informations from r and returns them as a *slha.SLHA.

type Value

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

Value represents a value (string,int,float64) + comment in a SLHA line.

func (*Value) Comment

func (v *Value) Comment() string

Comment returns the comment string attached to this value

func (*Value) Float

func (v *Value) Float() float64

Float returns the value as a float64. Float panics if the underlying value isn't a float64.

func (*Value) Int

func (v *Value) Int() int64

Int returns the value as an int64. Int panics if the underlying value isn't an int64.

func (*Value) Interface

func (v *Value) Interface() interface{}

Interface returns the value as an interface{}.

func (*Value) Kind

func (v *Value) Kind() reflect.Kind

Kind returns the kind of the value (reflect.String, reflect.Float64, reflect.Int)

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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