{ "cells": [ { "cell_type": "markdown", "id": "9b1401a1-37ea-4058-a2a4-482a39106fce", "metadata": {}, "source": [ "# LHEH5/HDF5 example" ] }, { "cell_type": "code", "execution_count": 12, "id": "37b55429-a72e-47b2-8bf1-240abd77f259", "metadata": {}, "outputs": [], "source": [ "import shutil\n", "from tempfile import NamedTemporaryFile\n", "from urllib.request import urlopen\n", "\n", "import hist\n", "\n", "import pylhe" ] }, { "cell_type": "code", "execution_count": 29, "id": "6785dc2c-a9a1-448e-a42d-33f750118873", "metadata": {}, "outputs": [], "source": [ "url = \"https://zenodo.org/records/7751000/files/l2_1.hdf5?download=1\"\n", "with urlopen(url) as response, NamedTemporaryFile(suffix=\".hdf5\") as tmp:\n", " shutil.copyfileobj(response, tmp)\n", " tmp.flush()\n", "\n", " lhe = pylhe.LHEFile.fromfile(tmp.name)" ] }, { "cell_type": "code", "execution_count": 30, "id": "4bf821bf-e0c1-49cb-a9c0-c7949151da61", "metadata": {}, "outputs": [], "source": [ "arr = pylhe.to_awkward(lhe)" ] }, { "cell_type": "code", "execution_count": 31, "id": "b696fe38-4983-427c-b09f-289e7df8895c", "metadata": {}, "outputs": [], "source": [ "higgs = arr.particles[(abs(arr.particles.id) == 25) & (arr.particles.status == 1)]" ] }, { "cell_type": "code", "execution_count": 32, "id": "b9f55fb0-84f7-4124-98ce-5d8db074a10c", "metadata": {}, "outputs": [], "source": [ "mass_hist = hist.Hist.new.Reg(30, 0, 50).Int64()" ] }, { "cell_type": "code", "execution_count": 33, "id": "09760f25-8893-41f1-9540-47452042ab19", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "