diff --git a/cmd/lhef2hepmc/main.go b/cmd/lhef2hepmc/main.go index 0a1f0e78c..8f38422d4 100644 --- a/cmd/lhef2hepmc/main.go +++ b/cmd/lhef2hepmc/main.go @@ -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. @@ -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 @@ -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 { diff --git a/hepmc/decoder.go b/hepmc/decoder.go index 679e30540..2d049c5dc 100644 --- a/hepmc/decoder.go +++ b/hepmc/decoder.go @@ -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 } diff --git a/hepmc/go-hepmc-dump/main.go b/hepmc/go-hepmc-dump/main.go index d0471665a..72df34089 100644 --- a/hepmc/go-hepmc-dump/main.go +++ b/hepmc/go-hepmc-dump/main.go @@ -35,6 +35,7 @@ package main import ( + "errors" "fmt" "io" "log" @@ -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 {