Skip to content
This repository was archived by the owner on Oct 30, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions cmd/lhef2hepmc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ var (
ifname = flag.String("i", "", "path to LHEF input file (default: STDIN)")
ofname = flag.String("o", "", "path to HEPMC output file (default: STDOUT)")

// see https://arxiv.org/pdf/hep-ph/0109068.pdf, page 7:
// integer ISTUP(I) : status code
// –1 Incoming particle
// +1 Outgoing final state particle
// –2 Intermediate space-like propagator defining an x and Q2 which should be preserved
// +2 Intermediate resonance, Mass should be preserved
// +3 Intermediate resonance, for documentation only
// –9 Incoming beam particles at time t = −∞
keep = flag.Bool("keep-all", false, "keep internediaries (with |ISTUP| != 1)")

// in case IDWTUP == +/-4, one has to keep track of the accumulated
// weights and event numbers to evaluate the cross section on-the-fly.
// The last evaluation is the one used.
Expand Down Expand Up @@ -168,7 +178,7 @@ func main() {
nmax := 2
imax := int(lhevt.NUP)
for i := 0; i < imax; i++ {
if lhevt.ISTUP[i] != 1 {
if !*keep && lhevt.ISTUP[i] != 1 {
continue
}
nmax += 1
Expand All @@ -181,7 +191,7 @@ func main() {
),
GeneratedMass: lhevt.PUP[i][4],
PdgID: lhevt.IDUP[i],
Status: 1,
Status: int(lhevt.ISTUP[i]),
Barcode: 3 + i,
})
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions hepmc/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,14 @@ loop:
_ = tokens.next() // header 'N'
nWeights, err := tokens.int()
if err != nil {
return err
return fmt.Errorf("hepmc: could not decode N token: %w", err)
}
names := make(map[string]int, nWeights)
for i := 0; i < nWeights; i++ {
nn, err := strconv.Unquote(tokens.next())
tok := tokens.next()
nn, err := strconv.Unquote(tok)
if err != nil {
return err
return fmt.Errorf("hepmc: could not unquote weight %q: %w", tok, err)
}
names[nn] = i
}
Expand Down
10 changes: 6 additions & 4 deletions hepmc/go-hepmc-dump/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
package main

import (
"errors"
"fmt"
"io"
"log"
Expand Down Expand Up @@ -72,12 +73,13 @@ func main() {
}

func dump(w io.Writer, r io.Reader) error {
var err error
dec := hepmc.NewDecoder(r)
for {
var evt hepmc.Event
err = dec.Decode(&evt)
if err == io.EOF {
var (
evt hepmc.Event
err = dec.Decode(&evt)
)
if errors.Is(err, io.EOF) {
return nil
}
if err != nil {
Expand Down