Skip to main content

lheutils v0.0.8

A collection of utilities for working with LHE files.

Installation

pip install lheutils

CLI Programs

Program Description
lhe2lhe Convert LHE files with different compression and weight format options.
lhecheck Validate LHE files and check momentum conservation.
lhediff Compare two LHE files and report differences.
lhefilter Filter LHE files based on process ID, particle PDG IDs, and event numbers.
lhefix Fix common issues in LHE files.
lheinfo Display information about LHE files.
lhemerge Merge LHE files with identical initialization sections (inverse of lhesplit).
lheshow Display specific events or init block from LHE files.
lhesplit Split LHE events from input file into multiple output files.
lhestack Stack multiple LHE files into a single file.
lheunstack Split a single LHE file by process ID into separate files (inverse of lhestack).
lhevalidate Validate LHE files against the LHE XML schema.

Examples

More details can be found by running each program with the --help option.

Filtering

Get the first event with two gluons in the initial state:

$ lhefilter  pwgevents-0001.lhe --incoming-a 21 --incoming-b 21 --max-events 1
<LesHouchesEvents version="3.0">
<init>
   2212   2212  4.0000000e+03  4.0000000e+03    -1    -1    -1    -1    -4     1
 1.3255800e+01  5.9743900e-01  1.0000000e+00  10001
<initrwgt /></init>
<event>
  5  10001 -1.9892700000e+01  3.8913200000e+00 -1.0000000000e+00  2.5869900000e-01
   21  -1   0   0 503 501  0.00000000e+00  0.00000000e+00  2.20685469e+02  2.20685469e+02  0.00000000e+00  0.0000e+00  9.0000e+00
   21  -1   0   0 502 512  0.00000000e+00  0.00000000e+00 -4.74395615e+02  4.74395615e+02  0.00000000e+00  0.0000e+00  9.0000e+00
   25   1   1   2   0   0  8.07980331e-01  3.58616348e+00  2.02904340e+02  2.38346235e+02  1.25000972e+02  0.0000e+00  9.0000e+00
   21   1   1   2 502 501 -4.44099588e+00 -2.19203006e+00 -1.25758039e+02  1.25855520e+02  2.33601546e-06  0.0000e+00  9.0000e+00
   21   1   1   2 503 512  3.63301555e+00 -1.39413342e+00 -3.30856446e+02  3.30879329e+02  3.81469727e-06  0.0000e+00  9.0000e+00
</event>
</LesHouchesEvents>

Information

Display general information about an LHE file:

$ lheinfo pwgevents-0500.lhe
------------------------------------------------------------
File: pwgevents-0500.lhe
Beam A: 2212 (PDF: -1) @ 4000.0 GeV
Beam B: 2212 (PDF: -1) @ 4000.0 GeV
Number of events: 100000 (negative: 16.72%)
Process 10001 cross-section: (1.326e+01 +- 5.974e-01) pb
  [21, 21] -> [21, 21, 25]: 65,542 events (65.5%, negative: 18.83%)
  [2, 21] -> [2, 21, 25]: 13,076 events (13.1%, negative: 14.51%)
  [1, 21] -> [1, 21, 25]: 6,934 events (6.9%, negative: 13.37%)
  [-1, 21] -> [-1, 21, 25]: 2,232 events (2.2%, negative: 14.83%)
  [-2, 21] -> [-2, 21, 25]: 1,944 events (1.9%, negative: 13.01%)
  [3, 21] -> [3, 21, 25]: 1,286 events (1.3%, negative: 12.44%)
  [-3, 21] -> [-3, 21, 25]: 1,265 events (1.3%, negative: 11.15%)
  [-4, 21] -> [-4, 21, 25]: 807 events (0.8%, negative: 12.27%)
  [4, 21] -> [4, 21, 25]: 796 events (0.8%, negative: 12.19%)
...

Remove negative weight events from an LHE file and display summary information:

$ lhefilter --negative-weights pwgevents-0500.lhe | lheinfo
------------------------------------------------------------
File: <stdin>
Beam A: 2212 (PDF: -1) @ 4000.0 GeV
Beam B: 2212 (PDF: -1) @ 4000.0 GeV
Number of events: 83276 (negative: 0.00%)
Process 10001 cross-section: (1.326e+01 +- 5.974e-01) pb
  [21, 21] -> [21, 21, 25]: 53,203 events (63.9%, negative: 0.00%)
  [2, 21] -> [2, 21, 25]: 11,179 events (13.4%, negative: 0.00%)
  [1, 21] -> [1, 21, 25]: 6,007 events (7.2%, negative: 0.00%)
  [-1, 21] -> [-1, 21, 25]: 1,901 events (2.3%, negative: 0.00%)
  [-2, 21] -> [-2, 21, 25]: 1,691 events (2.0%, negative: 0.00%)
  [3, 21] -> [3, 21, 25]: 1,126 events (1.4%, negative: 0.00%)
  [-3, 21] -> [-3, 21, 25]: 1,124 events (1.3%, negative: 0.00%)
...

Formatting

Switching formats via lhe2lhe, starting from the first event in pwgevents-0001.lhe:

$ lhefilter --max-events 1  pwgevents-0001.lhe
<LesHouchesEvents version="3.0">
<init>
   2212   2212  4.0000000e+03  4.0000000e+03    -1    -1    -1    -1    -4     1
 1.3255800e+01  5.9743900e-01  1.0000000e+00  10001
<initrwgt /></init>
<event>
  5  10001  1.9892700000e+01  1.9026000000e+01 -1.0000000000e+00  1.6423900000e-01
   21  -1   0   0 501 502  0.00000000e+00  0.00000000e+00  9.59159976e+01  9.59159976e+01  0.00000000e+00  0.0000e+00  9.0000e+00
   -3  -1   0   0   0 511  0.00000000e+00  0.00000000e+00 -2.72494064e+02  2.72494064e+02  0.00000000e+00  0.0000e+00  9.0000e+00
   25   1   1   2   0   0  4.09599828e+01  7.10971103e+00  4.31925771e+01  1.38634178e+02  1.25002274e+02  0.0000e+00  9.0000e+00
   -3   1   1   2   0 502 -3.20825130e+01  1.03220177e+01 -1.96527493e+02  1.99396307e+02  0.00000000e+00  0.0000e+00  9.0000e+00
   21   1   1   2 501 511 -8.87746976e+00 -1.74317287e+01 -2.32431503e+01  3.03795766e+01  4.76837158e-07  0.0000e+00  9.0000e+00
</event>
</LesHouchesEvents>

appending the LHE event weight to the rwgt section:

$ lhefilter --max-events 1  pwgevents-0001.lhe  | lhe2lhe --weight-format "rwgt" --append-lhe-weight default default default
<LesHouchesEvents version="3.0">
<init>
   2212   2212  4.0000000e+03  4.0000000e+03    -1    -1    -1    -1    -4     1
 1.3255800e+01  5.9743900e-01  1.0000000e+00  10001
<initrwgt>
  <weightgroup name="default">
    <weight id="default">default</weight>
  </weightgroup>
</initrwgt>
</init>
<event>
  5  10001  1.9892700000e+01  1.9026000000e+01 -1.0000000000e+00  1.6423900000e-01
   21  -1   0   0 501 502  0.00000000e+00  0.00000000e+00  9.59159976e+01  9.59159976e+01  0.00000000e+00  0.0000e+00  9.0000e+00
   -3  -1   0   0   0 511  0.00000000e+00  0.00000000e+00 -2.72494064e+02  2.72494064e+02  0.00000000e+00  0.0000e+00  9.0000e+00
   25   1   1   2   0   0  4.09599828e+01  7.10971103e+00  4.31925771e+01  1.38634178e+02  1.25002274e+02  0.0000e+00  9.0000e+00
   -3   1   1   2   0 502 -3.20825130e+01  1.03220177e+01 -1.96527493e+02  1.99396307e+02  0.00000000e+00  0.0000e+00  9.0000e+00
   21   1   1   2 501 511 -8.87746976e+00 -1.74317287e+01 -2.32431503e+01  3.03795766e+01  4.76837158e-07  0.0000e+00  9.0000e+00
<rwgt>
 <wgt id='default'> 1.9893e+01</wgt>
</rwgt>
</event>
</LesHouchesEvents>

and finally moving the weight to the init-rwgt section:

$ lhefilter --max-events 1  pwgevents-0001.lhe  | lhe2lhe --weight-format "rwgt" --append-lhe-weight default default default | lhe2lhe --weight-format "init-rwgt"
<LesHouchesEvents version="3.0">
<init>
   2212   2212  4.0000000e+03  4.0000000e+03    -1    -1    -1    -1    -4     1
 1.3255800e+01  5.9743900e-01  1.0000000e+00  10001
<initrwgt>
  <weightgroup name="default">
    <weight id="default">default</weight>
  </weightgroup>
</initrwgt>
</init>
<event>
  5  10001  1.9892700000e+01  1.9026000000e+01 -1.0000000000e+00  1.6423900000e-01
   21  -1   0   0 501 502  0.00000000e+00  0.00000000e+00  9.59159976e+01  9.59159976e+01  0.00000000e+00  0.0000e+00  9.0000e+00
   -3  -1   0   0   0 511  0.00000000e+00  0.00000000e+00 -2.72494064e+02  2.72494064e+02  0.00000000e+00  0.0000e+00  9.0000e+00
   25   1   1   2   0   0  4.09599828e+01  7.10971103e+00  4.31925771e+01  1.38634178e+02  1.25002274e+02  0.0000e+00  9.0000e+00
   -3   1   1   2   0 502 -3.20825130e+01  1.03220177e+01 -1.96527493e+02  1.99396307e+02  0.00000000e+00  0.0000e+00  9.0000e+00
   21   1   1   2 501 511 -8.87746976e+00 -1.74317287e+01 -2.32431503e+01  3.03795766e+01  4.76837158e-07  0.0000e+00  9.0000e+00
<weights>
 1.9893e+01
</weights>
</event>
</LesHouchesEvents>

Parallelization

Python is slow, but when using all available CPU core the IO speed can become the bottleneck too. To parallelize use GNU parallel:

$ parallel -j 8 lhefix ::: *.lhe

To pick a specific weight ID

$ parallel 'lhe2lhe --only-weight-id aMiNLO -i {} -o {}.aminlo.lhe.gz' ::: fixed_*-rwgt.lhe

Rivet

Rivet can read LHE files via HepMC3 to pipe a subset of a LHEFile to Rivet we can use /dev/stdin as source of a piped stream:

lhefilter --events 1,100 filtered2.lhe |  /usr/bin/rivet -a MC_FSPARTICLES /dev/stdin  --verbose

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lheutils-0.0.8.tar.gz (46.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lheutils-0.0.8-py3-none-any.whl (52.3 kB view details)

Uploaded Python 3

File details

Details for the file lheutils-0.0.8.tar.gz.

File metadata

  • Download URL: lheutils-0.0.8.tar.gz
  • Upload date:
  • Size: 46.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.2

File hashes

Hashes for lheutils-0.0.8.tar.gz
Algorithm Hash digest
SHA256 4fd62b5248e5d3f3b7d42950c0a46568ebc7d621074b4c6e40f03145aed45ca6
MD5 e78f623554359c33380bb384e5e48642
BLAKE2b-256 95718e4738ec2ac3295684d0576790444b4d29bc6a44db1a2caf7ae438a11316

See more details on using hashes here.

File details

Details for the file lheutils-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: lheutils-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 52.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.2

File hashes

Hashes for lheutils-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 dacc3b70ce292463cac498a6ea34a6510688e87d0a69e31b2aedb550e2b82a1f
MD5 109970855d2b8f39dad9b3e2b55c7c35
BLAKE2b-256 35b836a43ae30a58a5a18c36cd6694f5986594665ff47cadc6ab24f2ceaf795f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.8 This release

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page