go-hep.org/x/hep@v0.38.1/hepmc/README.md (about) 1 hepmc 2 ===== 3 4 [](https://godoc.org/go-hep.org/x/hep/hepmc) 5 6 ``hepmc`` is a pure ``Go`` implementation of the ``C++`` ``HepMC`` 7 library. 8 9 ## Installation 10 11 ```sh 12 $ go get go-hep.org/x/hep/hepmc 13 ``` 14 15 ## Documentation 16 17 Doc is on [godoc](https://godoc.org/go-hep.org/x/hep/hepmc) 18 19 ## Example 20 21 ```go 22 package main 23 24 import ( 25 "fmt" 26 "io" 27 "os" 28 29 "go-hep.org/x/hep/hepmc" 30 ) 31 32 func main() { 33 f, err := os.Open("test.hepmc") 34 if err != nil { panic(err) } 35 defer f.Close() 36 37 dec := hepmc.NewDecoder(f) 38 if dec == nil { panic("nil decoder")} 39 40 for { 41 var evt hepmc.Event 42 err = dec.Decode(&evt) 43 if err == io.EOF { 44 break 45 } 46 if err != nil { 47 panic(err) 48 } 49 50 fmt.Printf("==evt: %d\n", evt.EventNumber) 51 fmt.Printf(" #parts: %d\n", len(evt.Particles)) 52 fmt.Printf(" #verts: %d\n", len(evt.Vertices)) 53 54 err = hepmc.Delete(&evt) 55 if err != nil { 56 panic(err) 57 } 58 } 59 } 60 ``` 61 62 ## go-hepmc-dump command 63 64 ``go-hepmc-dump`` is a simple command to dump in an almost 65 human-friendly format the content of a hepmc file. 66 67 ```sh 68 $ go-hepmc-dump foo.hepmc | head -n20 69 ________________________________________________________________________________ 70 GenEvent: #0000 ID= 111 SignalProcessGenVertex Barcode: 0 71 Momentum units: GEV Position units: MM 72 Cross Section: 2.666668e+12 +/- 2.666668e+12 73 Entries this event: 129 vertices, 241 particles. 74 Beam Particle barcodes: 1 2 75 RndmState(0)= 76 Wgts(1)=(0,1.000000) 77 EventScale 1.438780e+00 [energy] alphaQCD=4.519907e-01 alphaQED=7.472465e-03 78 GenParticle Legend 79 Barcode PDG ID ( Px, Py, Pz, E ) Stat DecayVtx 80 ________________________________________________________________________________ 81 GenVertex: -1 ID: 0 (X,cT):0 82 I: 1 7 21 -5.87e-14, 9.60e-15, 3.41e+01, 3.41e+01 42 -1 83 O: 1 3 21 0.00e+00, 0.00e+00, 3.41e+01, 3.41e+01 21 -3 84 GenVertex: -2 ID: 0 (X,cT):0 85 I: 1 8 21 3.20e-14, 0.00e+00,-7.23e+01, 7.23e+01 41 -2 86 O: 2 4 21 0.00e+00, 0.00e+00,-1.19e+00, 1.19e+00 21 -3 87 11 21 9.42e-01,-1.56e-01,-7.11e+01, 7.11e+01 43 -12 88 [...] 89 ``` 90 91