lcio

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2019 License: BSD-3-Clause Imports: 11 Imported by: 1

README

lcio

GoDoc

lcio is a pure Go implementation of LCIO.

Installation

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

Documentation

The documentation is browsable at godoc.org:

Example

Reading a LCIO event file
func ExampleReader() {
	r, err := lcio.Open("testdata/event_golden.slcio")
	if err != nil {
		log.Fatal(err)
	}
	defer r.Close()

	for r.Next() {
		evt := r.Event()
		fmt.Printf("event number = %d (weight=%+e)\n", evt.EventNumber, evt.Weight())
		fmt.Printf("run   number = %d\n", evt.RunNumber)
		fmt.Printf("detector     = %q\n", evt.Detector)
		fmt.Printf("collections  = %v\n", evt.Names())
		calohits := evt.Get("CaloHits").(*lcio.CalorimeterHitContainer)
		fmt.Printf("calohits: %d\n", len(calohits.Hits))
		for i, hit := range calohits.Hits {
			fmt.Printf(" calohit[%d]: cell-id0=%d cell-id1=%d ene=%+e ene-err=%+e\n",
				i, hit.CellID0, hit.CellID1, hit.Energy, hit.EnergyErr,
			)
		}
	}

	err = r.Err()
	if err == io.EOF {
		err = nil
	}

	if err != nil {
		log.Fatal(err)
	}

	// Output:
	// event number = 52 (weight=+4.200000e+01)
	// run   number = 42
	// detector     = "my detector"
	// collections  = [McParticles SimCaloHits CaloHits]
	// calohits: 1
	//  calohit[0]: cell-id0=1024 cell-id1=2048 ene=+1.000000e+03 ene-err=+1.000000e-01
}
Writing a LCIO event file
func ExampleWriter() {
	w, err := lcio.Create("out.slcio")
	if err != nil {
		log.Fatal(err)
	}
	defer w.Close()

	run := lcio.RunHeader{
		RunNumber:    42,
		Descr:        "a simple run header",
		Detector:     "my detector",
		SubDetectors: []string{"det-1", "det-2"},
		Params: lcio.Params{
			Floats: map[string][]float32{
				"floats-1": {1, 2, 3},
				"floats-2": {4, 5, 6},
			},
		},
	}

	err = w.WriteRunHeader(&run)
	if err != nil {
		log.Fatal(err)
	}

	const NEVENTS = 1
	for ievt := 0; ievt < NEVENTS; ievt++ {
		evt := lcio.Event{
			RunNumber:   run.RunNumber,
			Detector:    run.Detector,
			EventNumber: 52 + int32(ievt),
			TimeStamp:   1234567890 + int64(ievt),
			Params: lcio.Params{
				Floats: map[string][]float32{
					"_weight": {42},
				},
				Strings: map[string][]string{
					"Descr": {"a description"},
				},
			},
		}

		calhits := lcio.CalorimeterHitContainer{
			Flags: lcio.BitsRChLong | lcio.BitsRChID1 | lcio.BitsRChTime | lcio.BitsRChNoPtr | lcio.BitsRChEnergyError,
			Params: lcio.Params{
				Floats:  map[string][]float32{"f32": {1, 2, 3}},
				Ints:    map[string][]int32{"i32": {1, 2, 3}},
				Strings: map[string][]string{"str": {"1", "2", "3"}},
			},
			Hits: []lcio.CalorimeterHit{
				{
					CellID0:   1024,
					CellID1:   2048,
					Energy:    1000,
					EnergyErr: 0.1,
					Time:      1234,
					Pos:       [3]float32{11, 22, 33},
					Type:      42,
				},
			},
		}

		evt.Add("CaloHits", &calhits)

		fmt.Printf("evt has key %q: %v\n", "CaloHits", evt.Has("CaloHits"))

		err = w.WriteEvent(&evt)
		if err != nil {
			log.Fatal(err)
		}
	}

	err = w.Close()
	if err != nil {
		log.Fatal(err)
	}

	// Output:
	// evt has key "CaloHits": true
}
Reading and plotting McParticles' energy
$> lcio-ex-read-event ./DST01-06_ppr004_bbcsdu.slcio
lcio-ex-read-event: read 50 events from file "./DST01-06_ppr004_bbcsdu.slcio"

$> open out.png

hist-example

func main() {
	log.SetPrefix("lcio-ex-read-event: ")
	log.SetFlags(0)

	var (
		fname  = ""
		h      = hbook.NewH1D(100, 0., 100.)
		nevts  = 0
		mcname = flag.String("mc", "MCParticlesSkimmed", "name of the MCParticle collection to read")
	)

	flag.Parse()

	if flag.NArg() > 0 {
		fname = flag.Arg(0)
	}

	if fname == "" {
		flag.Usage()
		os.Exit(1)
	}

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

	for f.Next() {
		evt := f.Event()
		mcs := evt.Get(*mcname).(*lcio.McParticleContainer)
		for _, mc := range mcs.Particles {
			h.Fill(mc.Energy(), 1)
		}
		nevts++
	}

	err = f.Err()
	if err == io.EOF {
		err = nil
	}

	if err != nil {
		log.Fatal(err)
	}
	log.Printf("read %d events from file %q", nevts, fname)

	p := hplot.New()
	p.Title.Text = "LCIO -- McParticles"
	p.X.Label.Text = "E (GeV)"

	hh := hplot.NewH1D(h)
	hh.Color = color.RGBA{R: 255, A: 255}
	hh.Infos.Style = hplot.HInfoSummary

	p.Add(hh)
	p.Add(hplot.NewGrid())

	err = p.Save(20*vg.Centimeter, -1, "out.png")
	if err != nil {
		log.Fatal(err)
	}
}

Documentation

Overview

Package lcio provides read/write access to the LCIO data model.

Index

Examples

Constants

View Source
const (
	MajorVersion uint32 = 2
	MinorVersion uint32 = 8
	Version      uint32 = (MajorVersion << 16) + MinorVersion
)

Variables

View Source
var Blocks = struct {
	Index        string
	RandomAccess string
	RunHeader    string
	EventHeader  string
}{
	Index:        "LCIOndex",
	RandomAccess: "LCIORandomAccess",
	RunHeader:    "RunHeader",
	EventHeader:  "EventHeader",
}
View Source
var Records = struct {
	Index        string
	RandomAccess string
	RunHeader    string
	EventHeader  string
	Event        string
}{
	Index:        "LCIOIndex",
	RandomAccess: "LCIORandomAccess",
	RunHeader:    "LCRunHeader",
	EventHeader:  "LCEventHeader",
	Event:        "LCEvent",
}

Functions

func ID

func ID(ptr interface{}) uint32

ID returns a unique identifier for ptr.

Types

type BlockDescr

type BlockDescr struct {
	Name string
	Type string
}

BlockDescr describes a SIO block. BlockDescr provides the name of the SIO block and the type name of the data stored in that block.

type CalorimeterHit

type CalorimeterHit struct {
	CellID0   int32
	CellID1   int32
	Energy    float32
	EnergyErr float32
	Time      float32
	Pos       [3]float32
	Type      int32
	Raw       Hit
}

func (*CalorimeterHit) GetCellID0

func (hit *CalorimeterHit) GetCellID0() int32

func (*CalorimeterHit) GetCellID1

func (hit *CalorimeterHit) GetCellID1() int32

type CalorimeterHitContainer

type CalorimeterHitContainer struct {
	Flags  Flags
	Params Params
	Hits   []CalorimeterHit
}

CalorimeterHitContainer is a collection of calorimeter hits.

func (*CalorimeterHitContainer) MarshalSio

func (hits *CalorimeterHitContainer) MarshalSio(w sio.Writer) error

func (CalorimeterHitContainer) String

func (hits CalorimeterHitContainer) String() string

func (*CalorimeterHitContainer) UnmarshalSio

func (hits *CalorimeterHitContainer) UnmarshalSio(r sio.Reader) error

func (*CalorimeterHitContainer) VersionSio

func (*CalorimeterHitContainer) VersionSio() uint32

type CellIDDecoder

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

CellIDDecoder decodes cell IDs from a Hit cell-ID

func NewCellIDDecoder

func NewCellIDDecoder(codec string) *CellIDDecoder

func NewCellIDDecoderFrom

func NewCellIDDecoderFrom(params Params) *CellIDDecoder

func (*CellIDDecoder) Get

func (dec *CellIDDecoder) Get(hit Hit, name string) int64

func (*CellIDDecoder) Value

func (dec *CellIDDecoder) Value(hit Hit) int64

func (*CellIDDecoder) ValueString

func (dec *CellIDDecoder) ValueString(hit Hit) string

type Cluster

type Cluster struct {
	// Type of cluster:
	//  - bits 31-16: ECAL, HCAL, COMBINED, LAT, LCAL
	//  - bits 15-00: NEUTRAL, CHARGED, UNDEFINED
	Type       int32
	Energy     float32    // energy of the cluster
	EnergyErr  float32    // energy error of the cluster
	Pos        [3]float32 // center of cluster (x,y,z)
	PosErr     [6]float32 // covariance matrix of position
	Theta      float32    // intrinsic direction: theta at position
	Phi        float32    // intrinsic direction: phi at position
	DirErr     [3]float32 // covariance matrix of direct
	Shape      []float32  // shape parameters, defined in collection parameter 'ShapeParameterNames'
	PIDs       []ParticleID
	Clusters   []*Cluster        // clusters combined into this cluster
	Hits       []*CalorimeterHit // hits that made this cluster
	Weights    []float32         // energy fraction of the hit that contributed to this cluster
	SubDetEnes []float32         // energy observed in a particular subdetector
}

type ClusterContainer

type ClusterContainer struct {
	Flags    Flags
	Params   Params
	Clusters []Cluster
}

ClusterContainer is a collection of clusters.

func (*ClusterContainer) MarshalSio

func (clus *ClusterContainer) MarshalSio(w sio.Writer) error

func (ClusterContainer) String

func (clus ClusterContainer) String() string

func (*ClusterContainer) UnmarshalSio

func (clus *ClusterContainer) UnmarshalSio(r sio.Reader) error

func (*ClusterContainer) VersionSio

func (*ClusterContainer) VersionSio() uint32

type Contrib

type Contrib struct {
	Mc      *McParticle
	Energy  float32
	Time    float32
	PDG     int32
	StepPos [3]float32
}

type Event

type Event struct {
	RunNumber   int32
	EventNumber int32
	TimeStamp   int64
	Detector    string
	Params      Params
	// contains filtered or unexported fields
}

Event holds informations about an LCIO event. Event also holds collection data for that event.

func (*Event) Add

func (evt *Event) Add(name string, ptr interface{})

Add attaches the (pointer to the) data ptr to this event, with the given name. Add panics if there is already some data labelled with the same name. Add panics if ptr is not a pointer to some data.

func (*Event) Get

func (evt *Event) Get(name string) interface{}

Get returns the event data labelled name.

func (*Event) Has

func (evt *Event) Has(name string) bool

Has returns whether this event has data named name.

func (*Event) Names

func (evt *Event) Names() []string

Names returns the event data labels that define this event.

func (*Event) String

func (evt *Event) String() string

func (*Event) Weight

func (evt *Event) Weight() float64

type EventHeader

type EventHeader struct {
	RunNumber   int32
	EventNumber int32
	TimeStamp   int64
	Detector    string
	Blocks      []BlockDescr
	Params      Params
}

EventHeader provides metadata about an Event.

func (*EventHeader) MarshalSio

func (hdr *EventHeader) MarshalSio(w sio.Writer) error

func (*EventHeader) String

func (hdr *EventHeader) String() string

func (*EventHeader) UnmarshalSio

func (hdr *EventHeader) UnmarshalSio(r sio.Reader) error

func (*EventHeader) VersionSio

func (*EventHeader) VersionSio() uint32

func (*EventHeader) Weight

func (hdr *EventHeader) Weight() float64

type Flags

type Flags uint32

Flags are bit patterns describing detector and simulation states.

const (
	BitsChLong   Flags = 1 << 31 // long(1) - short(0), (position)
	BitsChBarrel Flags = 1 << 30 // barrel(1) - endcap(0)
	BitsChID1    Flags = 1 << 29 // cellid1 stored
	BitsChPDG    Flags = 1 << 28 // PDG(1) - no PDG(0) (detailed shower contributions) // DEPRECATED: use ChBitStep
	BitsChStep   Flags = 1 << 28 // detailed shower contributions
)

Flags for SimCalorimeterHit (CH)

const (
	BitsRChLong        Flags = 1 << 31 // long(1) - short(0), incl./excl. position
	BitsRChBarrel      Flags = 1 << 30 // barrel(1) - endcap(0)
	BitsRChID1         Flags = 1 << 29 // cellid1 stored
	BitsRChNoPtr       Flags = 1 << 28 // 1: pointer tag not added
	BitsRChTime        Flags = 1 << 27 // 1: time information stored
	BitsRChEnergyError Flags = 1 << 26 // 1: store energy error
)

Flags for the (raw) Calorimeter hits

const (
	BitsTRawID1 Flags = 1 << 31 // cellid1 stored
	BitsTRawCM  Flags = 1 << 30 // covariant matrix stored(1) - not stored(0)
)

Flags for the (raw) tracker data (pulses)

const (
	BitsThBarrel   Flags = 1 << 31 // barrel(1) - endcap(0)
	BitsThMomentum Flags = 1 << 30 // momentum of particle stored(1) - not stored(0)
	BitsThID1      Flags = 1 << 29 // cellid1 stored
)

Flags for the SimTrackerHit

const (
	BitsTPCRaw   Flags = 1 << 31 // raw data stored(1) - not stored(0)
	BitsTPCNoPtr Flags = 1 << 30 // 1: pointer tag not added (needed for TrackerHit)
)

Flags for the TPCHit

const (
	BitsClHits Flags = 1 << 31 // hits stored(1) - not stored(0)
)

Flags for the Cluster

const (
	BitsGOFixed Flags = 1 << 31 // is fixed size
)

Flags for GenericObject

const (
	BitsRThID1 Flags = 1 << 31 // cellid1 stored
)

Flags for the raw tracker hit

const (
	BitsRelWeighted Flags = 1 << 31 // relation has weights
)

Flags for Relation

const (
	BitsThPID1 Flags = 1 << 31 // cellid1 stored
)

Flags for the tracker hit plane

const (
	BitsThZID1 Flags = 1 << 31 // cellid1 stored
)

Flags for the tracker hit z-cylinder

const (
	BitsTrHits Flags = 1 << 31 // hits stored(1) - not stored(0)
)

Flags for the Tracks

func (Flags) Test

func (flags Flags) Test(bit Flags) bool

Test returns whether the given bit is != 0

type FloatVec

type FloatVec struct {
	Flags    Flags
	Params   Params
	Elements [][]float32
}

func (*FloatVec) MarshalSio

func (vec *FloatVec) MarshalSio(w sio.Writer) error

func (FloatVec) String

func (vec FloatVec) String() string

func (*FloatVec) UnmarshalSio

func (vec *FloatVec) UnmarshalSio(r sio.Reader) error

func (*FloatVec) VersionSio

func (*FloatVec) VersionSio() uint32

type GenericObject

type GenericObject struct {
	Flag   Flags
	Params Params
	Data   []GenericObjectData
}

func (*GenericObject) MarshalSio

func (obj *GenericObject) MarshalSio(w sio.Writer) error

func (GenericObject) String

func (obj GenericObject) String() string

func (*GenericObject) UnmarshalSio

func (obj *GenericObject) UnmarshalSio(r sio.Reader) error

func (*GenericObject) VersionSio

func (*GenericObject) VersionSio() uint32

type GenericObjectData

type GenericObjectData struct {
	I32s []int32
	F32s []float32
	F64s []float64
}

func (*GenericObjectData) String

func (obj *GenericObjectData) String() string

type Hit

type Hit interface {
	GetCellID0() int32
	GetCellID1() int32
}

Hit is an abstract Hit in the LCIO event data model.

type Index

type Index struct {
	// Bit 0 = single run.
	// Bit 1 = int64 offset required
	// Bit 2 = Params included (not yet implemented)
	ControlWord uint32
	RunMin      int32
	BaseOffset  int64
	Offsets     []Offset
}

func (*Index) MarshalSio

func (idx *Index) MarshalSio(w sio.Writer) error

func (*Index) UnmarshalSio

func (idx *Index) UnmarshalSio(r sio.Reader) error

type IntVec

type IntVec struct {
	Flags    Flags
	Params   Params
	Elements [][]int32
}

func (*IntVec) MarshalSio

func (vec *IntVec) MarshalSio(w sio.Writer) error

func (IntVec) String

func (vec IntVec) String() string

func (*IntVec) UnmarshalSio

func (vec *IntVec) UnmarshalSio(r sio.Reader) error

func (*IntVec) VersionSio

func (*IntVec) VersionSio() uint32

type McParticle

type McParticle struct {
	Parents   []*McParticle
	Children  []*McParticle
	PDG       int32
	GenStatus int32
	SimStatus uint32
	Vertex    [3]float64
	Time      float32    // creation time of the particle in ns
	P         [3]float64 // Momentum at production vertex
	Mass      float64
	Charge    float32

	PEndPoint [3]float64 // momentum at end-point
	Spin      [3]float32
	ColorFlow [2]int32
	// contains filtered or unexported fields
}

func (*McParticle) EndPoint

func (mc *McParticle) EndPoint() [3]float64

func (*McParticle) Energy

func (mc *McParticle) Energy() float64

func (*McParticle) HasLeftDetector

func (mc *McParticle) HasLeftDetector() bool

func (*McParticle) IsBackScatter

func (mc *McParticle) IsBackScatter() bool

func (*McParticle) IsCreatedInSimulation

func (mc *McParticle) IsCreatedInSimulation() bool

func (*McParticle) IsDecayedInCalorimeter

func (mc *McParticle) IsDecayedInCalorimeter() bool

func (*McParticle) IsDecayedInTracker

func (mc *McParticle) IsDecayedInTracker() bool

func (*McParticle) IsOverlay

func (mc *McParticle) IsOverlay() bool

func (*McParticle) IsStopped

func (mc *McParticle) IsStopped() bool

func (*McParticle) MarshalSio

func (mc *McParticle) MarshalSio(w sio.Writer) error

func (*McParticle) SimStatusString

func (mc *McParticle) SimStatusString() string

func (*McParticle) UnmarshalSio

func (mc *McParticle) UnmarshalSio(r sio.Reader) error

func (*McParticle) VersionSio

func (mc *McParticle) VersionSio() uint32

func (*McParticle) VertexIsNotEnpointOfParent

func (mc *McParticle) VertexIsNotEnpointOfParent() bool

type McParticleContainer

type McParticleContainer struct {
	Flags     Flags
	Params    Params
	Particles []McParticle
}

McParticleContainer is a collection of monte-carlo particles.

func (*McParticleContainer) LinkSio

func (mc *McParticleContainer) LinkSio(vers uint32) error

func (*McParticleContainer) MarshalSio

func (mc *McParticleContainer) MarshalSio(w sio.Writer) error

func (McParticleContainer) String

func (mcs McParticleContainer) String() string

func (*McParticleContainer) UnmarshalSio

func (mc *McParticleContainer) UnmarshalSio(r sio.Reader) error

func (*McParticleContainer) VersionSio

func (*McParticleContainer) VersionSio() uint32

type Offset

type Offset struct {
	RunOffset   int32 // run offset relative to Index.RunMin
	EventNumber int32 // event number or -1 for run header records
	Location    int64 // location offset relative to Index.BaseOffset
	Ints        []int32
	Floats      []float32
	Strings     []string
}

type Params

type Params struct {
	Ints    map[string][]int32
	Floats  map[string][]float32
	Strings map[string][]string
}

func (*Params) MarshalSio

func (p *Params) MarshalSio(w sio.Writer) error

func (Params) String

func (p Params) String() string

func (*Params) UnmarshalSio

func (p *Params) UnmarshalSio(r sio.Reader) error

func (*Params) VersionSio

func (*Params) VersionSio() uint32

type ParticleID

type ParticleID struct {
	Likelihood float32
	Type       int32
	PDG        int32
	AlgType    int32
	Params     []float32
}

type RandomAccess

type RandomAccess struct {
	RunMin         int32
	EventMin       int32
	RunMax         int32
	EventMax       int32
	RunHeaders     int32
	Events         int32
	RecordsInOrder int32
	IndexLoc       int64
	PrevLoc        int64
	NextLoc        int64
	FirstRecordLoc int64
	RecordSize     int32
}

type RawCalorimeterHit

type RawCalorimeterHit struct {
	CellID0   int32
	CellID1   int32
	Amplitude int32
	TimeStamp int32
}

func (*RawCalorimeterHit) GetCellID0

func (hit *RawCalorimeterHit) GetCellID0() int32

func (*RawCalorimeterHit) GetCellID1

func (hit *RawCalorimeterHit) GetCellID1() int32

type RawCalorimeterHitContainer

type RawCalorimeterHitContainer struct {
	Flags  Flags
	Params Params
	Hits   []RawCalorimeterHit
}

RawCalorimeterHitContainer is a collection of raw calorimeter hits.

func (*RawCalorimeterHitContainer) MarshalSio

func (hits *RawCalorimeterHitContainer) MarshalSio(w sio.Writer) error

func (RawCalorimeterHitContainer) String

func (hits RawCalorimeterHitContainer) String() string

func (*RawCalorimeterHitContainer) UnmarshalSio

func (hits *RawCalorimeterHitContainer) UnmarshalSio(r sio.Reader) error

func (*RawCalorimeterHitContainer) VersionSio

func (*RawCalorimeterHitContainer) VersionSio() uint32

type Reader

type Reader struct {
	// contains filtered or unexported fields
}
Example
package main

import (
	"fmt"
	"io"
	"log"

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

func main() {
	r, err := lcio.Open("testdata/event_golden.slcio")
	if err != nil {
		log.Fatal(err)
	}
	defer r.Close()

	for r.Next() {
		evt := r.Event()
		fmt.Printf("event number = %d (weight=%+e)\n", evt.EventNumber, evt.Weight())
		fmt.Printf("run   number = %d\n", evt.RunNumber)
		fmt.Printf("detector     = %q\n", evt.Detector)
		fmt.Printf("collections  = %v\n", evt.Names())
		calohits := evt.Get("CaloHits").(*lcio.CalorimeterHitContainer)
		fmt.Printf("calohits: %d\n", len(calohits.Hits))
		for i, hit := range calohits.Hits {
			fmt.Printf(" calohit[%d]: cell-id0=%d cell-id1=%d ene=%+e ene-err=%+e\n",
				i, hit.CellID0, hit.CellID1, hit.Energy, hit.EnergyErr,
			)
		}
	}

	err = r.Err()
	if err == io.EOF {
		err = nil
	}

	if err != nil {
		log.Fatal(err)
	}

}
Output:

event number = 52 (weight=+4.200000e+01)
run   number = 42
detector     = "my detector"
collections  = [McParticles SimCaloHits CaloHits]
calohits: 1
 calohit[0]: cell-id0=1024 cell-id1=2048 ene=+1.000000e+03 ene-err=+1.000000e-01

func Open

func Open(fname string) (*Reader, error)

func (*Reader) Close

func (r *Reader) Close() error

func (*Reader) Err

func (r *Reader) Err() error

func (*Reader) Event

func (r *Reader) Event() Event

func (*Reader) EventHeader

func (r *Reader) EventHeader() EventHeader

func (*Reader) Next

func (r *Reader) Next() bool

func (*Reader) RunHeader

func (r *Reader) RunHeader() RunHeader

type RecParticle

type RecParticle struct {
	Type          int32
	P             [3]float32  // momentum (Px,PyPz)
	Energy        float32     // energy of particle
	Cov           [10]float32 // covariance matrix for 4-vector (Px,Py,Pz,E)
	Mass          float32     // mass of object used for 4-vector
	Charge        float32     // charge of particle
	Ref           [3]float32  // reference point of 4-vector
	PIDs          []ParticleID
	PIDUsed       *ParticleID
	GoodnessOfPID float32 // overall quality of the particle identification
	Recs          []*RecParticle
	Tracks        []*Track
	Clusters      []*Cluster
	StartVtx      *Vertex // start vertex associated to the particle
}

type RecParticleContainer

type RecParticleContainer struct {
	Flags  Flags
	Params Params
	Parts  []RecParticle
}

RecParticleContainer is a collection of RecParticles.

func (*RecParticleContainer) MarshalSio

func (recs *RecParticleContainer) MarshalSio(w sio.Writer) error

func (*RecParticleContainer) String

func (recs *RecParticleContainer) String() string

func (*RecParticleContainer) UnmarshalSio

func (recs *RecParticleContainer) UnmarshalSio(r sio.Reader) error

func (*RecParticleContainer) VersionSio

func (*RecParticleContainer) VersionSio() uint32

type References

type References struct {
	Flags  Flags
	Params Params
	Refs   []interface{}
}

func (*References) MarshalSio

func (refs *References) MarshalSio(w sio.Writer) error

func (*References) UnmarshalSio

func (refs *References) UnmarshalSio(r sio.Reader) error

func (*References) VersionSio

func (*References) VersionSio() uint32

type Relation

type Relation struct {
	From   interface{}
	To     interface{}
	Weight float32
}

type RelationContainer

type RelationContainer struct {
	Flags  Flags
	Params Params
	Rels   []Relation
}

func (*RelationContainer) MarshalSio

func (rc *RelationContainer) MarshalSio(w sio.Writer) error

func (RelationContainer) String

func (rc RelationContainer) String() string

func (*RelationContainer) UnmarshalSio

func (rc *RelationContainer) UnmarshalSio(r sio.Reader) error

func (*RelationContainer) VersionSio

func (*RelationContainer) VersionSio() uint32

type RunHeader

type RunHeader struct {
	RunNumber    int32
	Detector     string
	Descr        string
	SubDetectors []string
	Params       Params
}

RunHeader provides metadata about a Run.

func (*RunHeader) MarshalSio

func (hdr *RunHeader) MarshalSio(w sio.Writer) error

func (*RunHeader) String

func (hdr *RunHeader) String() string

func (*RunHeader) UnmarshalSio

func (hdr *RunHeader) UnmarshalSio(r sio.Reader) error

func (*RunHeader) VersionSio

func (*RunHeader) VersionSio() uint32

type SimCalorimeterHit

type SimCalorimeterHit struct {
	Params        Params
	CellID0       int32
	CellID1       int32
	Energy        float32
	Pos           [3]float32
	Contributions []Contrib
}

func (*SimCalorimeterHit) GetCellID0

func (hit *SimCalorimeterHit) GetCellID0() int32

func (*SimCalorimeterHit) GetCellID1

func (hit *SimCalorimeterHit) GetCellID1() int32

type SimCalorimeterHitContainer

type SimCalorimeterHitContainer struct {
	Flags  Flags
	Params Params
	Hits   []SimCalorimeterHit
}

SimCalorimeterHitContainer is a collection of simulation calorimter hits.

func (*SimCalorimeterHitContainer) MarshalSio

func (hits *SimCalorimeterHitContainer) MarshalSio(w sio.Writer) error

func (SimCalorimeterHitContainer) String

func (hits SimCalorimeterHitContainer) String() string

func (*SimCalorimeterHitContainer) UnmarshalSio

func (hits *SimCalorimeterHitContainer) UnmarshalSio(r sio.Reader) error

func (*SimCalorimeterHitContainer) VersionSio

func (*SimCalorimeterHitContainer) VersionSio() uint32

type SimTrackerHit

type SimTrackerHit struct {
	CellID0    int32
	CellID1    int32 // second word for cell ID
	Pos        [3]float64
	EDep       float32 // energy deposited on the hit
	Time       float32
	Mc         *McParticle
	Momentum   [3]float32
	PathLength float32
	Quality    int32
}

func (*SimTrackerHit) GetCellID0

func (hit *SimTrackerHit) GetCellID0() int32

func (*SimTrackerHit) GetCellID1

func (hit *SimTrackerHit) GetCellID1() int32

type SimTrackerHitContainer

type SimTrackerHitContainer struct {
	Flags  Flags
	Params Params
	Hits   []SimTrackerHit
}

SimTrackerHitContainer is a collection of simulated tracker hits.

func (*SimTrackerHitContainer) MarshalSio

func (hits *SimTrackerHitContainer) MarshalSio(w sio.Writer) error

func (SimTrackerHitContainer) String

func (hits SimTrackerHitContainer) String() string

func (*SimTrackerHitContainer) UnmarshalSio

func (hits *SimTrackerHitContainer) UnmarshalSio(r sio.Reader) error

func (*SimTrackerHitContainer) VersionSio

func (*SimTrackerHitContainer) VersionSio() uint32

type StrVec

type StrVec struct {
	Flags    Flags
	Params   Params
	Elements [][]string
}

func (*StrVec) MarshalSio

func (vec *StrVec) MarshalSio(w sio.Writer) error

func (StrVec) String

func (vec StrVec) String() string

func (*StrVec) UnmarshalSio

func (vec *StrVec) UnmarshalSio(r sio.Reader) error

func (*StrVec) VersionSio

func (*StrVec) VersionSio() uint32

type Track

type Track struct {
	Type       int32 // type of track (e.g TPC, VTX, SIT)
	States     []TrackState
	Chi2       float32  // chi^2 of fit
	NdF        int32    // ndf of fit
	DEdx       float32  // dEdx
	DEdxErr    float32  // error of dEdx
	Radius     float32  // radius of innermost hit used in track fit
	SubDetHits []int32  // number of hits in particular sub-detectors
	Tracks     []*Track // tracks that have been combined into this track
	Hits       []*TrackerHit
}

func (*Track) D0

func (trk *Track) D0() float64

func (*Track) Omega

func (trk *Track) Omega() float64

func (*Track) Phi

func (trk *Track) Phi() float64

func (*Track) TanL

func (trk *Track) TanL() float64

func (*Track) Z0

func (trk *Track) Z0() float64

type TrackContainer

type TrackContainer struct {
	Flags  Flags
	Params Params
	Tracks []Track
}

TrackContainer is a collection of tracks.

func (*TrackContainer) MarshalSio

func (trks *TrackContainer) MarshalSio(w sio.Writer) error

func (*TrackContainer) String

func (trks *TrackContainer) String() string

func (*TrackContainer) UnmarshalSio

func (trks *TrackContainer) UnmarshalSio(r sio.Reader) error

func (*TrackContainer) VersionSio

func (*TrackContainer) VersionSio() uint32

type TrackState

type TrackState struct {
	Loc   int32       // location of the track state
	D0    float32     // impact parameter in r-phi
	Phi   float32     // phi of track in r-phi
	Omega float32     // curvature signed with charge
	Z0    float32     // impact parameter in r-z
	TanL  float32     // tangent of dip angle in r-z
	Cov   [15]float32 // covariance matrix
	Ref   [3]float32  // reference point (x,y,z)
}

type TrackerData

type TrackerData struct {
	CellID0 int32
	CellID1 int32
	Time    float32
	Charges []float32
}

func (*TrackerData) GetCellID0

func (data *TrackerData) GetCellID0() int32

func (*TrackerData) GetCellID1

func (data *TrackerData) GetCellID1() int32

type TrackerDataContainer

type TrackerDataContainer struct {
	Flags  Flags // bits 0-15 are user/detector specific
	Params Params
	Data   []TrackerData
}

func (*TrackerDataContainer) MarshalSio

func (tds *TrackerDataContainer) MarshalSio(w sio.Writer) error

func (*TrackerDataContainer) String

func (tds *TrackerDataContainer) String() string

func (*TrackerDataContainer) UnmarshalSio

func (tds *TrackerDataContainer) UnmarshalSio(r sio.Reader) error

func (*TrackerDataContainer) VersionSio

func (*TrackerDataContainer) VersionSio() uint32

type TrackerHit

type TrackerHit struct {
	CellID0 int32
	CellID1 int32
	Type    int32 // type of Track; encoded in parameters TrackerHitTypeName+TrackerHit TypeValue
	Pos     [3]float64
	Cov     [6]float64 // covariance matrix of position (x,y,z)
	EDep    float32    // energy deposit on the hit
	EDepErr float32    // error measured on EDep
	Time    float32
	Quality int32 // quality flag word
	RawHits []Hit
}

func (*TrackerHit) GetCellID0

func (hit *TrackerHit) GetCellID0() int32

func (*TrackerHit) GetCellID1

func (hit *TrackerHit) GetCellID1() int32

type TrackerHitContainer

type TrackerHitContainer struct {
	Flags  Flags
	Params Params
	Hits   []TrackerHit
}

TrackerHitContainer is a collection of tracker hits.

func (*TrackerHitContainer) MarshalSio

func (hits *TrackerHitContainer) MarshalSio(w sio.Writer) error

func (TrackerHitContainer) String

func (hits TrackerHitContainer) String() string

func (*TrackerHitContainer) UnmarshalSio

func (hits *TrackerHitContainer) UnmarshalSio(r sio.Reader) error

func (*TrackerHitContainer) VersionSio

func (*TrackerHitContainer) VersionSio() uint32

type TrackerHitPlane

type TrackerHitPlane struct {
	CellID0 int32
	CellID1 int32
	Type    int32 // type of Track; encoded in parameters TrackerHitTypeName+TrackerHit TypeValue
	Pos     [3]float64
	U       [2]float32
	V       [2]float32
	DU      float32 // measurement error along u
	DV      float32 // measurement error along v
	EDep    float32 // energy deposit on the hit
	EDepErr float32 // error measured on EDep
	Time    float32
	Quality int32 // quality flag word
	RawHits []*RawCalorimeterHit
}

func (*TrackerHitPlane) GetCellID0

func (hit *TrackerHitPlane) GetCellID0() int32

func (*TrackerHitPlane) GetCellID1

func (hit *TrackerHitPlane) GetCellID1() int32

type TrackerHitPlaneContainer

type TrackerHitPlaneContainer struct {
	Flags  Flags
	Params Params
	Hits   []TrackerHitPlane
}

TrackerHitPlaneContainer is a collection of tracker hit planes.

func (*TrackerHitPlaneContainer) MarshalSio

func (hits *TrackerHitPlaneContainer) MarshalSio(w sio.Writer) error

func (TrackerHitPlaneContainer) String

func (hits TrackerHitPlaneContainer) String() string

func (*TrackerHitPlaneContainer) UnmarshalSio

func (hits *TrackerHitPlaneContainer) UnmarshalSio(r sio.Reader) error

func (*TrackerHitPlaneContainer) VersionSio

func (*TrackerHitPlaneContainer) VersionSio() uint32

type TrackerHitZCylinder

type TrackerHitZCylinder struct {
	CellID0 int32
	CellID1 int32
	Type    int32 // type of Track; encoded in parameters TrackerHitTypeName+TrackerHit TypeValue
	Pos     [3]float64
	Center  [2]float32
	DRPhi   float32 // measurement error along RPhi
	DZ      float32 // measurement error along z
	EDep    float32 // energy deposit on the hit
	EDepErr float32 // error measured on EDep
	Time    float32
	Quality int32 // quality flag word
	RawHits []Hit
}

func (*TrackerHitZCylinder) GetCellID0

func (hit *TrackerHitZCylinder) GetCellID0() int32

func (*TrackerHitZCylinder) GetCellID1

func (hit *TrackerHitZCylinder) GetCellID1() int32

type TrackerHitZCylinderContainer

type TrackerHitZCylinderContainer struct {
	Flags  Flags
	Params Params
	Hits   []TrackerHitZCylinder
}

TrackerHitZCylinderContainer is a collection of tracker hit z-cylinders.

func (*TrackerHitZCylinderContainer) MarshalSio

func (hits *TrackerHitZCylinderContainer) MarshalSio(w sio.Writer) error

func (TrackerHitZCylinderContainer) String

func (hits TrackerHitZCylinderContainer) String() string

func (*TrackerHitZCylinderContainer) UnmarshalSio

func (hits *TrackerHitZCylinderContainer) UnmarshalSio(r sio.Reader) error

func (*TrackerHitZCylinderContainer) VersionSio

func (*TrackerHitZCylinderContainer) VersionSio() uint32

type TrackerPulse

type TrackerPulse struct {
	CellID0 int32
	CellID1 int32
	Time    float32      // time of pulse
	Charge  float32      // charge of pulse
	Cov     [3]float32   // covariance matrix of charge (c) and time (t) measurements
	Quality int32        // quality flag word
	TPC     *TrackerData // TPC corrected data: spectrum used to create this pulse
}

func (*TrackerPulse) GetCellID0

func (hit *TrackerPulse) GetCellID0() int32

func (*TrackerPulse) GetCellID1

func (hit *TrackerPulse) GetCellID1() int32

type TrackerPulseContainer

type TrackerPulseContainer struct {
	Flags  Flags
	Params Params
	Pulses []TrackerPulse
}

func (*TrackerPulseContainer) MarshalSio

func (ps *TrackerPulseContainer) MarshalSio(w sio.Writer) error

func (*TrackerPulseContainer) String

func (ps *TrackerPulseContainer) String() string

func (*TrackerPulseContainer) UnmarshalSio

func (ps *TrackerPulseContainer) UnmarshalSio(r sio.Reader) error

func (*TrackerPulseContainer) VersionSio

func (*TrackerPulseContainer) VersionSio() uint32

type TrackerRawData

type TrackerRawData struct {
	CellID0 int32
	CellID1 int32
	Time    int32
	ADCs    []uint16
}

func (*TrackerRawData) GetCellID0

func (data *TrackerRawData) GetCellID0() int32

func (*TrackerRawData) GetCellID1

func (data *TrackerRawData) GetCellID1() int32

type TrackerRawDataContainer

type TrackerRawDataContainer struct {
	Flags  Flags // bits 0-15 are user/detector specific
	Params Params
	Data   []TrackerRawData
}

func (*TrackerRawDataContainer) MarshalSio

func (trs *TrackerRawDataContainer) MarshalSio(w sio.Writer) error

func (*TrackerRawDataContainer) String

func (tds *TrackerRawDataContainer) String() string

func (*TrackerRawDataContainer) UnmarshalSio

func (trs *TrackerRawDataContainer) UnmarshalSio(r sio.Reader) error

func (*TrackerRawDataContainer) VersionSio

func (*TrackerRawDataContainer) VersionSio() uint32

type Vertex

type Vertex struct {
	Primary int32      // primary vertex of the event
	AlgType int32      // algorithm type
	Chi2    float32    // Chi^2 of vertex
	Prob    float32    // probability of the fit
	Pos     [3]float32 // position of the vertex (Px,Py,Pz)
	Cov     [6]float32 // covariance matrix
	Params  []float32
	RecPart *RecParticle // reconstructed particle associated to the vertex
}

func (*Vertex) AlgName

func (vtx *Vertex) AlgName() string

type VertexContainer

type VertexContainer struct {
	Flags  Flags
	Params Params
	Vtxs   []Vertex
}

VertexContainer is a collection of vertices

func (*VertexContainer) MarshalSio

func (vtxs *VertexContainer) MarshalSio(w sio.Writer) error

func (VertexContainer) String

func (vtxs VertexContainer) String() string

func (*VertexContainer) UnmarshalSio

func (vtxs *VertexContainer) UnmarshalSio(r sio.Reader) error

func (*VertexContainer) VersionSio

func (*VertexContainer) VersionSio() uint32

type Writer

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

Writer provides a way to write LCIO RunHeaders and Events to an output SIO stream.

Example
package main

import (
	"fmt"
	"log"

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

func main() {
	w, err := lcio.Create("out.slcio")
	if err != nil {
		log.Fatal(err)
	}
	defer w.Close()

	run := lcio.RunHeader{
		RunNumber:    42,
		Descr:        "a simple run header",
		Detector:     "my detector",
		SubDetectors: []string{"det-1", "det-2"},
		Params: lcio.Params{
			Floats: map[string][]float32{
				"floats-1": {1, 2, 3},
				"floats-2": {4, 5, 6},
			},
		},
	}

	err = w.WriteRunHeader(&run)
	if err != nil {
		log.Fatal(err)
	}

	const NEVENTS = 1
	for ievt := 0; ievt < NEVENTS; ievt++ {
		evt := lcio.Event{
			RunNumber:   run.RunNumber,
			Detector:    run.Detector,
			EventNumber: 52 + int32(ievt),
			TimeStamp:   1234567890 + int64(ievt),
			Params: lcio.Params{
				Floats: map[string][]float32{
					"_weight": {42},
				},
				Strings: map[string][]string{
					"Descr": {"a description"},
				},
			},
		}

		calhits := lcio.CalorimeterHitContainer{
			Flags: lcio.BitsRChLong | lcio.BitsRChID1 | lcio.BitsRChTime | lcio.BitsRChNoPtr | lcio.BitsRChEnergyError,
			Params: lcio.Params{
				Floats:  map[string][]float32{"f32": {1, 2, 3}},
				Ints:    map[string][]int32{"i32": {1, 2, 3}},
				Strings: map[string][]string{"str": {"1", "2", "3"}},
			},
			Hits: []lcio.CalorimeterHit{
				{
					CellID0:   1024,
					CellID1:   2048,
					Energy:    1000,
					EnergyErr: 0.1,
					Time:      1234,
					Pos:       [3]float32{11, 22, 33},
					Type:      42,
				},
			},
		}

		evt.Add("CaloHits", &calhits)

		fmt.Printf("evt has key %q: %v\n", "CaloHits", evt.Has("CaloHits"))

		err = w.WriteEvent(&evt)
		if err != nil {
			log.Fatal(err)
		}
	}

	err = w.Close()
	if err != nil {
		log.Fatal(err)
	}

}
Output:

evt has key "CaloHits": true

func Create

func Create(fname string) (*Writer, error)

Create creates a new LCIO writer, saving data in file fname.

func (*Writer) Close

func (w *Writer) Close() error

Close closes the underlying output stream and makes it unavailable for further I/O operations. Close will synchronize and commit to disk any lingering data before closing the output stream.

func (*Writer) SetCompressionLevel

func (w *Writer) SetCompressionLevel(lvl int)

SetCompressionLevel sets the compression level to lvl. lvl must be a compress/flate compression value. SetCompressionLevel must be called before WriteRunHeader or WriteEvent.

func (*Writer) WriteEvent

func (w *Writer) WriteEvent(evt *Event) error

func (*Writer) WriteRunHeader

func (w *Writer) WriteRunHeader(run *RunHeader) error

Directories

Path Synopsis
cmd
lcio-ls
lcio-ls displays the content of a LCIO file.
lcio-ls displays the content of a LCIO file.
example
lcio-ex-read-event
lcio-ex-read-event is the hep/x/lcio example equivalent to: https://github.com/iLCSoft/LCIO/blob/master/examples/cpp/rootDict/readEventTree.C example: $> lcio-ex-read-event ./DST01-06_ppr004_bbcsdu.slcio lcio-ex-read-event: read 50 events from file "./DST01-06_ppr004_bbcsdu.slcio" $> open out.png
lcio-ex-read-event is the hep/x/lcio example equivalent to: https://github.com/iLCSoft/LCIO/blob/master/examples/cpp/rootDict/readEventTree.C example: $> lcio-ex-read-event ./DST01-06_ppr004_bbcsdu.slcio lcio-ex-read-event: read 50 events from file "./DST01-06_ppr004_bbcsdu.slcio" $> open out.png

Jump to

Keyboard shortcuts

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