Add the remaining 139 files
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- README.mdAdded+45
- labeled/test/noise_tags.npzAdded+3
- labeled/test/pid_labels.npzAdded+3
- labeled/test/spacepoints.npzAdded+3
- labeled/test/track_ids.npzAdded+3
- labeled/train/noise_tags_000.npzAdded+3
- labeled/train/noise_tags_001.npzAdded+3
- labeled/train/noise_tags_002.npzAdded+3
- labeled/train/noise_tags_003.npzAdded+3
- labeled/train/noise_tags_004.npzAdded+3
- labeled/train/noise_tags_005.npzAdded+3
- labeled/train/noise_tags_006.npzAdded+3
- labeled/train/pid_labels_000.npzAdded+3
- labeled/train/pid_labels_001.npzAdded+3
- labeled/train/pid_labels_002.npzAdded+3
- labeled/train/pid_labels_003.npzAdded+3
- labeled/train/pid_labels_004.npzAdded+3
- labeled/train/pid_labels_005.npzAdded+3
- labeled/train/pid_labels_006.npzAdded+3
- labeled/train/spacepoints_000.npzAdded+3
- labeled/train/spacepoints_001.npzAdded+3
- labeled/train/spacepoints_002.npzAdded+3
- labeled/train/spacepoints_003.npzAdded+3
- labeled/train/spacepoints_004.npzAdded+3
- labeled/train/spacepoints_005.npzAdded+3
- labeled/train/spacepoints_006.npzAdded+3
- labeled/train/track_ids_000.npzAdded+3
- labeled/train/track_ids_001.npzAdded+3
- labeled/train/track_ids_002.npzAdded+3
- labeled/train/track_ids_003.npzAdded+3
- labeled/train/track_ids_004.npzAdded+3
- labeled/train/track_ids_005.npzAdded+3
- labeled/train/track_ids_006.npzAdded+3
- labeled/validation/noise_tags.npzAdded+3
- labeled/validation/pid_labels.npzAdded+3
- labeled/validation/spacepoints.npzAdded+3
- labeled/validation/track_ids.npzAdded+3
- scripts/demo.ipynbAdded+477
- scripts/plot.pyAdded+188
- unlabeled/spacepoints_000.npzAdded+3
- unlabeled/spacepoints_001.npzAdded+3
- unlabeled/spacepoints_002.npzAdded+3
- unlabeled/spacepoints_003.npzAdded+3
- unlabeled/spacepoints_004.npzAdded+3
- unlabeled/spacepoints_005.npzAdded+3
- unlabeled/spacepoints_006.npzAdded+3
- unlabeled/spacepoints_007.npzAdded+3
- unlabeled/spacepoints_008.npzAdded+3
- unlabeled/spacepoints_009.npzAdded+3
- unlabeled/spacepoints_010.npzAdded+3
123456789101112131415161718192021222324252627282930313233343536373839404142434445---license: cc-by-4.0pretty_name: TPCpp-10Mtags:- particle-physics- time-projection-chamber- sphenix- point-cloud---
# TPCpp-10M
This repository mirrors TPCpp-10M, the dataset of simulated proton-proton collisions in an sPHENIX-like Time Projection Chamber that Li et al. released with the FM4NPP foundation model ([Zenodo 10.5281/zenodo.16970029](https://doi.org/10.5281/zenodo.16970029), CC BY 4.0). Zenodo distributes it as one 118.5 GB archive, which is larger than a single file on the Hugging Face Hub may be, so we mirror the archive's files instead: every file of `TPCpp-10M.zip`, unchanged and in the archive's folders. The release's `TPCpp-10M_scripts.zip` and `TPCpp-10M_labeled_test.zip` hold copies of `scripts/` and `labeled/test/` and are not repeated here.
Each event is a set of TPC space points from one collision at √s = 200 GeV. `labeled/train/` (sharded `_000` to `_006`), `labeled/validation/` and `labeled/test/` hold 70,000, 13,000 and 7,000 labeled events, and `unlabeled/spacepoints_000.npz` to `_099.npz` hold 100,000 unlabeled events each for pretraining. In every `.npz` file, `data` is a flat array over the points of all its events and `size` (in the `spacepoints` files) gives the points per event. The `spacepoints` columns are the deposited energy and the position x, y, z; `track_ids`, `pid_labels` (0 other, 1 pion, 2 kaon, 3 proton, 4 electron) and `noise_tags` label each point of the labeled events.
## Use
```pythonimport panda
dataset = panda.v2.TPCpp10MDataset(split="test", transform=panda.v2.transform("sphenix"))```
The dataset reads these files directly, without a conversion step, and returns each event exactly as the [Panda V2](https://github.com/DeepLearnPhysics/Panda) models were trained and scored on it. As in the Panda V2 paper, `validation` and `test` keep the events with at most 3,200 points by default.
## Citation
Please cite the dataset and the FM4NPP paper:
```bibtex@article{tpcpp10m2025, title = {TPCpp-10M: Simulated proton-proton collisions in a Time Projection Chamber for AI Foundation Models}, author = {Li, Shuhang and Huang, Yi and Park, David and Luo, Xihaier and Yu, Haiwang and Go, Yeonju and Pinkenburg, Christopher and Lin, Yuewei and Yoo, Shinjae and Osborn, Joseph and Roland, Christof and Huang, Jin and Ren, Yihui}, journal = {arXiv preprint arXiv:2509.05792}, year = {2025}}
@article{park2025fm4npp, title = {FM4NPP: A Scaling Foundation Model for Nuclear and Particle Physics}, author = {Park, David and Li, Shuhang and Huang, Yi and Luo, Xihaier and Yu, Haiwang and Go, Yeonju and Pinkenburg, Christopher and Lin, Yuewei and Yoo, Shinjae and Osborn, Joseph and others}, journal = {arXiv preprint arXiv:2508.14087}, year = {2025}}```123version https://git-lfs.github.com/spec/v1oid sha256:a7c67208c883553bc091fd046ae3e647cd80cc409f5a7a2792c4918792ead388size 41200123version https://git-lfs.github.com/spec/v1oid sha256:bc09332dc4a542b07f04722a3a9322b6e4850b5aa5a8ed4ba1d1300352eb8b95size 129697123version https://git-lfs.github.com/spec/v1oid sha256:71094f7658aeb94da6fd15dbafcc95cdfead04e71e1d76853cc29981d2b9fe8dsize 81356628123version https://git-lfs.github.com/spec/v1oid sha256:19c02c6e0f45ffa379200f553634bdee972bd4ce4c86d8277511f679c678f621size 242053123version https://git-lfs.github.com/spec/v1oid sha256:a02f794144ed49c599ed349410328de4f65fc2b5e79c1a0927251365d5600b81size 58854123version https://git-lfs.github.com/spec/v1oid sha256:6832209966aa5d33c066fba35dac1b755b6f217f2de886acbde0ad65ce9783c4size 58706123version https://git-lfs.github.com/spec/v1oid sha256:391e8aa5401b384d5d1547a85d8ed1a2c60d7ca12bbfb1c9b810b7d43817ffdbsize 58912123version https://git-lfs.github.com/spec/v1oid sha256:40516929e2e6f585adc2bacc04344b8d092a28e54230dd130981bca146fe7c8esize 58449123version https://git-lfs.github.com/spec/v1oid sha256:afa1582471fcb7cd8701a706b7bfbdbd8ffa4617e021f38293532902b5d367ebsize 58939123version https://git-lfs.github.com/spec/v1oid sha256:d1277fc2351e6da167c0538e1a1539278d896751781d96ff800f948fd4e26d89size 58670123version https://git-lfs.github.com/spec/v1oid sha256:f6c24f40b2c1bc8666cd2df050c1c0c0f87b91c97f708bf986795c46dc6f1e03size 58598123version https://git-lfs.github.com/spec/v1oid sha256:3e4aa01001bd16c40ec6855f884b484e73e366be58885cee1d03f8f545e22fbfsize 187741123version https://git-lfs.github.com/spec/v1oid sha256:899c8336b5862e95fbaee4b2ccd645c955dfe857d76b3a98f5a4c89a02da85d9size 185595123version https://git-lfs.github.com/spec/v1oid sha256:efe9e976637b077424104d175b504d0e319fa4d826c4c279a73edf314630d9fesize 185703123version https://git-lfs.github.com/spec/v1oid sha256:bbb642193a450fce351ea456947c2cb67a0113d74fc8f42e1c6537af74fba5c6size 185011123version https://git-lfs.github.com/spec/v1oid sha256:51163f326f60c6e4e111e60b9acb0579e7dcce40f9cd9c123d037da72a3aa32asize 185860123version https://git-lfs.github.com/spec/v1oid sha256:d357ef53498fe9bf5605f2ab19bfbc86af695ecc1a62486604a22dce752c53e8size 185938123version https://git-lfs.github.com/spec/v1oid sha256:6e88e19b0fe12d4e07387cfbaffb4d3c13c5f94b8997a011977dc6c41a4f62c9size 185728123version https://git-lfs.github.com/spec/v1oid sha256:8bf6417bcbb491286dffbc145ace6dbec0a6ed2f26bfbebf9034325a73d7d2bfsize 117601899123version https://git-lfs.github.com/spec/v1oid sha256:e4c3fcaf805f4bc9ebb4705e96a0fa4fa678375e3d8200189b61919d8c7e046fsize 116437544123version https://git-lfs.github.com/spec/v1oid sha256:314f971354ae275518769fc6c60a358c295723e7ff1b578e6ec461c7205f7a36size 116504710123version https://git-lfs.github.com/spec/v1oid sha256:5b48d9e4b2f23d4365ca5fe44af8a69c9ea0d900ffa3f3d42724dc629d2c96a3size 115874758123version https://git-lfs.github.com/spec/v1oid sha256:65a9df77703a5ff1c1593880de635aa22c89f85701e0881387e5aef1142eb05asize 116946862123version https://git-lfs.github.com/spec/v1oid sha256:17c1fe7b224e4e5359a6d82fb19237fab281ab5984cdfcaf10ff1305b9e92257size 116376887123version https://git-lfs.github.com/spec/v1oid sha256:86445720b5d13b678f2460862e67cf64b77ac431c2c31554c63dd23f1ca1c1adsize 116225763123version https://git-lfs.github.com/spec/v1oid sha256:5db12f3d917135ff7a25768c1c0679348e509bfb5c5c5ec5ceb60bf838771fb3size 348633123version https://git-lfs.github.com/spec/v1oid sha256:9ba4ce74df8f3ceaa50dc6f9f3c39f88c5d5859a2a745ad420d579bc9e34fa46size 346649123version https://git-lfs.github.com/spec/v1oid sha256:be5f722ad41fb34f90c06172afa995a0e75a08e223c73eaead8590a65b0782bdsize 346601123version https://git-lfs.github.com/spec/v1oid sha256:057dea0ce7d198da64b4620255b26b631be0c9fe980e458ad78f99319302a776size 344934123version https://git-lfs.github.com/spec/v1oid sha256:494d78aae3e65bb9a3ac871d3c43c7d758f54b29efe5f84d1e1613b42a7f752fsize 346891123version https://git-lfs.github.com/spec/v1oid sha256:357bf05895b061255c8295fe7ba32707442aba01fa275c570210ce8faf0daa19size 345794123version https://git-lfs.github.com/spec/v1oid sha256:ac1e5abe7e538e4ba5326d6da834686c83de916f4406badc247d490caeeae454size 344714123version https://git-lfs.github.com/spec/v1oid sha256:2717eaa45de9cf88392958578cce6505424af63cc7699ad45adebbba2c9a10ccsize 76308123version https://git-lfs.github.com/spec/v1oid sha256:697745036e4adc9bdafa8eba989d03401edc48ee0dc0b15e8f316ec158a99713size 242172123version https://git-lfs.github.com/spec/v1oid sha256:309ca42dc067b19f963518db67fc47ac56db2818aee33ff4bb04c6ded24b0126size 151305488123version https://git-lfs.github.com/spec/v1oid sha256:3b16adcd63b98aff575ccb169cc299e7f68e7c471bdfd756e5c3f898b7dc7cabsize 450401123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477{ "cells": [ { "cell_type": "markdown", "id": "37b4fe8e-f16b-4d86-b06c-2d6782b50de0", "metadata": {}, "source": [ "# TPCpp-10M Dataset\n", "\n", "This notebook provides an example for dataloading and simple visualization of the **TPCpp-10M dataset**, a large-scale particle physics dataset designed for machine learning applications in high-energy physics research. The definitions of the plotting functions are defined in `plot.py`.\n", "\n", "## Dataset Overview\n", "\n", "The TPCpp-10M dataset contains simulated particle collision events from a Time Projection Chamber (TPC) detector, commonly used in particle physics experiments. This dataset is specifically designed for:\n", "\n", "- **Foundation model training** for particle and nuclear physics applications\n", "- **Particle track reconstruction**\n", "- **Particle identification** \n", "- **Signal vs. noise discrimination**\n", "\n", "## Dataset Characteristics\n", "\n", "- **Total Events**: over 10 million simulated proton-proton collision events at 200GeV \n", "- **Input Data Format**: Structured spacepoint data with 4D coordinates (energy + $x,y,z$-coordiantes)\n", "- **Labels**: including track IDs, particle types, and noise classification\n", "- **Split**: 10M unlabeled events, 70k/13k/7k labeled events for training/validation/testing\n", "\n", "## Data Components\n", "\n", "1. **Spacepoints**: 4D spacepoints with energy and spatial coordinates\n", "2. **Track IDs**: Unique identifiers for particle trajectories \n", "3. **Particle ID Labels**: Classification labels for different particle types\n", "4. **Noise Tags**: Binary labels distinguishing signal from detector noise\n", "\n", "## Notebook Contents\n", "\n", "This demonstration notebook includes:\n", "- Data loading.\n", "- Distribution of numbers of spacepoints, number of tracks, and class ratios.\n", "- Interactive 3D scatter plots color-coded by track, particle type, and signal/noise classification." ] }, { "cell_type": "markdown", "id": "45bcca32-9eaa-4bdb-a979-eac5dc5178e3", "metadata": {}, "source": [ "## Install and run `Plotly`\n", "The notebook uses the library `Plotly` for plotting. If it is not installed, please use the following command to install it:\n", "- **Conda**:\n", " ```\n", " conda install -c conda-forge plotly\n", " ```\n", "- **Pip**:\n", " ```\n", " pip install plotly\n", " ```\n", "\n", "For running `Plotly` in Jupyter Notebook or Jupyter Lab and saving the plots, please check out this webpage: [https://plotly.com/python/getting-started/](https://plotly.com/python/getting-started/)." ] }, { "cell_type": "code", "execution_count": null, "id": "2244df27-c924-4369-9c05-4a2eba8c6c04", "metadata": {}, "outputs": [], "source": [ "from pathlib import Path\n", "import numpy as np\n", "\n", "# custom plotting functions\n", "from plot import (plot_histogram, \n", " plot_pie, \n", " plot_scatter)" ] }, { "cell_type": "code", "execution_count": null, "id": "cff4a872-84c1-4a40-acb8-5970c3c24f91", "metadata": {}, "outputs": [], "source": [ "# if you want to save the plots\n", "plot_folder = Path('./plots')\n", "plot_folder.mkdir(exist_ok=True)" ] }, { "cell_type": "markdown", "id": "a90837ff-4828-4853-8c68-3b23bc31f064", "metadata": {}, "source": [ "## Load all events saved in one `.npz` file \n", "together with labels for downstream tasks" ] }, { "cell_type": "code", "execution_count": null, "id": "da3b9642-de59-4906-ac8c-5a6cde7864e2", "metadata": {}, "outputs": [], "source": [ "folder = Path('labeled/test/')\n", "\n", "with np.load(folder/'spacepoints.npz') as handle:\n", " spacepoints = handle['data']\n", " event_sizes = handle['size']\n", "\n", "# although track_ids, pid_labels, and noise_tags\n", "# all have 'size' containing the sizes of each \n", "# individual events, they are the same as that\n", "# from the spacepoints, so we don't have to\n", "# load them.\n", "with np.load(folder/'track_ids.npz') as handle:\n", " # track_ids are of type np.uint32\n", " track_ids = handle['data']\n", "\n", "with np.load(folder/'pid_labels.npz') as handle:\n", " # pid_labels are of type np.uint8\n", " pid_labels = handle['data']\n", "\n", "with np.load(folder/'noise_tags.npz') as handle:\n", " # noise_tags are boolean\n", " noise_tags = handle['data']\n", "\n", "num_events = len(event_sizes)\n", "print(f'Loaded {num_events} events.')" ] }, { "cell_type": "markdown", "id": "9f0cf560-7999-4b37-9608-ebb584ac496a", "metadata": {}, "source": [ "## Load one event" ] }, { "cell_type": "code", "execution_count": null, "id": "dd7dffb7-50ee-433a-9824-0a4574d31259", "metadata": {}, "outputs": [], "source": [ "# we can use event sizes to determine the start\n", "# and end indices of each event.\n", "indices = np.cumsum(event_sizes)" ] }, { "cell_type": "code", "execution_count": null, "id": "b6084963-43ae-4120-bb52-16bdec74aff6", "metadata": {}, "outputs": [], "source": [ "# specify an event id\n", "event_id = 20\n", "\n", "# get the start and end indices from the event sizes\n", "start_id = 0 if event_id == 0 else indices[event_id - 1]\n", "end_id = indices[event_id]\n", "\n", "# get a single event\n", "event_spacepoints = spacepoints[start_id: end_id]\n", "event_track_ids = track_ids[start_id: end_id]\n", "event_pid_labels = pid_labels[start_id: end_id]\n", "event_noise_tags = noise_tags[start_id: end_id]\n", "\n", "print(f'event {event_id}:')\n", "print(f'\\tspacepoints shape = {event_spacepoints.shape}')\n", "print(f'\\ttrack_ids[:50] = {event_track_ids[:50]}')\n", "print(f'\\tpid_labels[:50] = {pid_labels[:50]}')\n", "print(f'\\tnoise_tags[:50] = {noise_tags[:50]}')" ] }, { "cell_type": "markdown", "id": "03ba25bd-1d06-40ef-a6b5-288c140d9763", "metadata": {}, "source": [ "## Statistics" ] }, { "cell_type": "markdown", "id": "04c53af3-c80d-4804-8c60-20d4e2eb1ce6", "metadata": {}, "source": [ "### Distribution of number of spacepoints" ] }, { "cell_type": "code", "execution_count": null, "id": "e377d98d-3d70-4103-be0b-8156be12db36", "metadata": {}, "outputs": [], "source": [ "start_id = 0\n", "num_sp = [] # \n", "for end_id in indices:\n", " event_spacepoints = spacepoints[start_id: end_id]\n", " num_sp.append(len(event_spacepoints))\n", " start_id = end_id\n", "\n", "fig = plot_histogram(num_sp, xaxis_title='Number of Spacepoints')\n", "fig.show()\n", "fig.write_image(plot_folder/'distribution_spacepoints.png', scale=2)\n", "fig.write_html(plot_folder/'distribution_spacepoints.html')" ] }, { "cell_type": "markdown", "id": "e922c119-2325-473c-a120-7a6446fa374e", "metadata": {}, "source": [ "### Distribution of number of tracks" ] }, { "cell_type": "code", "execution_count": null, "id": "9eb713e2-8432-43b5-bf6e-6ebd0ea2d362", "metadata": {}, "outputs": [], "source": [ "start_id = 0\n", "num_tracks = []\n", "for end_id in indices:\n", " event_track_ids = track_ids[start_id: end_id]\n", " event_num_tracks = len(np.unique(event_track_ids))\n", " num_tracks.append(event_num_tracks)\n", " start_id = end_id\n", "\n", "fig = plot_histogram(num_tracks, xaxis_title='Number of Tracks')\n", "fig.show()\n", "fig.write_image(plot_folder/'distribution_tracks.png', scale=2)\n", "fig.write_html(plot_folder/'distribution_tracks.html')" ] }, { "cell_type": "markdown", "id": "8d08a18c-40c6-47b7-8fec-0bc7218e6341", "metadata": {}, "source": [ "### Distribution of noise fraction" ] }, { "cell_type": "code", "execution_count": null, "id": "9bb092f2-0ed4-4034-880f-f948b9144692", "metadata": {}, "outputs": [], "source": [ "start_id = 0\n", "noise_fraction = []\n", "for end_id in indices:\n", " event_noise_tags = noise_tags[start_id: end_id]\n", " \n", " total = len(event_noise_tags)\n", " noise = event_noise_tags.sum()\n", " \n", " noise_fraction.append(noise / total)\n", " start_id = end_id\n", "\n", "fig = plot_histogram(noise_fraction, xaxis_title='Fraction of Noise')\n", "fig.show()\n", "fig.write_image(plot_folder/'distribution_noise.png', scale=2)\n", "fig.write_html(plot_folder/'distribution_noise.html')" ] }, { "cell_type": "markdown", "id": "24436b6a-018f-4478-8472-40ce36863263", "metadata": {}, "source": [ "### Distribution of particle ids" ] }, { "cell_type": "code", "execution_count": null, "id": "6b688bab-eb73-4517-a44e-6292edcf6d8d", "metadata": {}, "outputs": [], "source": [ "_, counts = np.unique(pid_labels, return_counts=True)\n", "total = sum(counts)\n", "fractions = [count / total for count in counts]\n", "names = ['others', 'pion', 'kaon', 'proton', 'electron']\n", "\n", "fig = plot_pie(names, \n", " fractions, \n", " title=\"Particle IDs\", \n", " width=450, \n", " height=450)\n", "fig.show()\n", "fig.write_image(plot_folder/'distribution_particle_ids.png', scale=2)\n", "fig.write_html(plot_folder/'distribution_particle_ids.html')" ] }, { "cell_type": "markdown", "id": "5642fa73-3202-4904-8a5a-0421a7a2d52e", "metadata": {}, "source": [ "## Visualization" ] }, { "cell_type": "markdown", "id": "124df5df-36e0-41e9-8816-dda272091cfd", "metadata": {}, "source": [ "### Load one event" ] }, { "cell_type": "code", "execution_count": null, "id": "61c58913-2fdc-467e-82f5-67765a9fb16a", "metadata": {}, "outputs": [], "source": [ "# specify an event id\n", "event_id = 20\n", "\n", "# get the start and end indices from the event sizes\n", "start_id = 0 if event_id == 0 else indices[event_id - 1]\n", "end_id = indices[event_id]\n", "\n", "# get a single event\n", "event_spacepoints = spacepoints[start_id: end_id]\n", "event_track_ids = track_ids[start_id: end_id]\n", "event_pid_labels = pid_labels[start_id: end_id]\n", "event_noise_tags = noise_tags[start_id: end_id]" ] }, { "cell_type": "code", "execution_count": null, "id": "436a9cfb-86c3-444d-b512-f900c5f21451", "metadata": {}, "outputs": [], "source": [ "# spacepoints contains 4 columns: energy, x, y, z.\n", "# x, y, z are the coordinates (cm) in the Euclidean space.\n", "energy, x, y, z = event_spacepoints.T" ] }, { "cell_type": "markdown", "id": "dec8a4d8-ad87-4a68-b429-b0c1c9caffa1", "metadata": {}, "source": [ "### Spacepoints" ] }, { "cell_type": "code", "execution_count": null, "id": "aef788d5-07b3-42aa-9301-08ec4d998726", "metadata": {}, "outputs": [], "source": [ "fig = plot_scatter(x, y, z)\n", "fig.show()\n", "fig.write_image(plot_folder/'scatter_spacepoints.png', scale=2)\n", "fig.write_html(plot_folder/'scatter_spacepoints.html')" ] }, { "cell_type": "markdown", "id": "03c33b61-91b1-4e0d-9530-a66e60600e8f", "metadata": {}, "source": [ "### Tracks" ] }, { "cell_type": "code", "execution_count": null, "id": "4256ffdf-3dd6-41df-96cd-a50b9d0abaf8", "metadata": {}, "outputs": [], "source": [ "fig = plot_scatter(x, y, z, labels=event_track_ids)\n", "fig.show()\n", "fig.write_image(plot_folder/'scatter_tracks.png', scale=2)\n", "fig.write_html(plot_folder/'scatter_tracks.html')" ] }, { "cell_type": "markdown", "id": "ef38d5a9-87d0-4430-9bf5-d3f3377fc209", "metadata": {}, "source": [ "### Signal vs. Noise" ] }, { "cell_type": "code", "execution_count": null, "id": "901c521e-9cbe-47c7-beab-f566d8b74322", "metadata": {}, "outputs": [], "source": [ "# Let us give all possible labels since an event may \n", "# not contain noise/signal spacepoints.\n", "fig = plot_scatter(x, y, z, \n", " labels = event_noise_tags, \n", " color_cycle = ['skyblue', 'orange'],\n", " unique_labels = [0, 1],\n", " names = ['signal', 'noise'])\n", "fig.show()\n", "fig.write_image(plot_folder/'scatter_signal-vs-noise.png', scale=2)\n", "fig.write_html(plot_folder/'scatter_signal-vs-noise.html')" ] }, { "cell_type": "markdown", "id": "058e79cc-c122-4110-ad74-cc5d8c8d079e", "metadata": {}, "source": [ "### Particle IDs" ] }, { "cell_type": "code", "execution_count": null, "id": "e186396a-12da-494f-82e4-2d4f377fcc3a", "metadata": {}, "outputs": [], "source": [ "# Let us give all possible labels since an event may \n", "# not contain all types of particles\n", "fig = plot_scatter(x, y, z, \n", " labels = event_pid_labels, \n", " unique_labels = [1, 2, 3, 4, 0],\n", " names = ['charged pion', # instead of π±\n", " 'charged kaon', # instead of K±\n", " 'proton/antiproton',\n", " 'electron/positron',\n", " 'others'])\n", "fig.show()\n", "fig.write_image(plot_folder/'scatter_particle-ids.png', scale=2)\n", "fig.write_html(plot_folder/'scatter_particle-ids.html')" ] } ], "metadata": { "kernelspec": { "display_name": "pyg", "language": "python", "name": "pyg" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.6" } }, "nbformat": 4, "nbformat_minor": 5}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188import numpy as npimport plotly.express as pximport plotly.graph_objects as go
def plot_histogram(data, nbins=100, mean_color='coral', bar_color='skyblue', xaxis_title=None, log_y=False): # add bar plot fig = px.histogram(data, nbins=100, title=None, color_discrete_sequence=[bar_color]) # whether to use a log scale for the y-axis if log_y: fig.update_yaxes(type="log", title="Count") fig.update_layout(bargap=0.2) # gaps between bar fig.update_traces(showlegend=False) # remove legend for bars
# add a line for mean mean = np.mean(data) fig.add_vline(x=mean, line_width=3, line_dash="dot", line_color=mean_color) # add a dummy trace so we can have a legend for the mean value fig.add_trace(go.Scatter(x=[mean], y=[0], mode="lines", line=dict(color=mean_color, width=3, dash="dot"), name=f"Mean={mean:.2f}", showlegend=True))
if xaxis_title is None: xaxis_title = 'Number' fig.update_layout( width=450, height=350, xaxis_title=xaxis_title, yaxis_title="Count", legend=dict( x=0.95, # horizontal position (0 = left, 1 = right) y=0.95, # vertical position (0 = bottom, 1 = top) xanchor="right", yanchor="top", bgcolor="rgba(255,255,255,0.3)", # optional: semi-transparent background title=None, ), margin=dict( l=50, # left margin r=50, # right margin t=50, # top margin b=50 # bottom margin ) ) return fig
def plot_pie(names, fractions, title = None, width = 450, height = 450): fig = px.pie( names = names, values = fractions, title = title, category_orders={"names": names}, color_discrete_sequence=px.colors.qualitative.Pastel ) fig.update_layout( width = width, height = height, margin = dict(l=20, r=10, t=50, b=10)) return fig
def plot_scatter(x, y, z, labels = None, color_cycle = None, *, marker_size = 2, opacity = 1, width = 600, height = 480, shuffle = False, names = None, axis_title_font_size = 16, axis_tick_font_size = 12, legend_config = None, showticklabels = True, unique_labels = None, distance = 1):
# set up parameters if labels is None: labels = [1] * len(x) if color_cycle is None: color_cycle = color_discrete_sequence=px.colors.qualitative.Set3 if unique_labels is None: unique_labels = np.unique(labels)
if shuffle: np.random.shuffle(unique_labels)
if names is not None: assert len(unique_labels) <= len(names) else: names = [None] * len(unique_labels)
# == create one trace for a unique label value ============ traces = [] for i, (label, name) in enumerate(zip(unique_labels, names)): color = color_cycle[i % len(color_cycle)] trace = go.Scatter3d( x=x[labels == label], y=y[labels == label], z=z[labels == label], mode = 'markers', marker = dict(size = marker_size, color = color, opacity = opacity), name = name, showlegend = False ) traces.append(trace)
# Dummy trace for larger legend marker if name is not None: trace = go.Scatter3d( x=[None], y=[None], z=[None], # Invisible point mode = 'markers', name = name, marker = dict(size = 12, color = color), # Larger size for legend showlegend = True ) traces.append(trace) # == figure layout ======================================== def config_axis(title): return dict(title = dict(text = title, font = dict(size=axis_title_font_size)), tickfont = dict(size = axis_tick_font_size), showticklabels = showticklabels)#, # backgroundcolor='lightgray')
layout = go.Layout( width=width, height=height, scene=dict( xaxis = config_axis('x (cm)' if showticklabels else ''), yaxis = config_axis('y (cm)' if showticklabels else ''), zaxis = config_axis('z (cm)' if showticklabels else ''), camera = dict( # zoom (default is (1.25, 1.25, 1.25)) eye=dict(x=1.8 * distance, y=1.2 * distance, z=1.6 * distance), # y axis is pointing up, so the z axis can lie down up=dict(x=0, y=1, z=0) ) ), # paper_bgcolor='rgba(0,0,0,0)', # plot_bgcolor='rgba(0,0,0,0)', margin = dict(l=0, r=0, t=0, b=20), legend=dict( x=0.80, # horizontal position (0 = left, 1 = right) y=0.80, # vertical position (0 = bottom, 1 = top) xanchor="left", yanchor="top", bgcolor="rgba(200,200,200,0.3)", # optional: semi-transparent background title=None, ), ) figure = go.Figure(data=traces, layout=layout)
if legend_config is not None: figure.update_layout(legend=legend_config) return figure123version https://git-lfs.github.com/spec/v1oid sha256:ad72994db44e0143def058e1cd1ef1b01b4b5877e012ebb0866757a5ab63b9casize 1176875238123version https://git-lfs.github.com/spec/v1oid sha256:f0287db34cd294e90f90e30a57455f6512a3368a879ccb53d6f7d90fc9fa60c0size 1178328291123version https://git-lfs.github.com/spec/v1oid sha256:b75f0b4b2eeb14fb058b8a2ba820f44b9cc4cb21a68c2d0078f9fddc1cf5bfcbsize 1171916499123version https://git-lfs.github.com/spec/v1oid sha256:7f61f516fd87908f628c0971d11c9d854f0decfb78901acd97fe5cb51281a62asize 1175086277123version https://git-lfs.github.com/spec/v1oid sha256:48cbfbf7b8fd57e02605b24fb0e19ea547f6a7487f6d140060f16c4d67587f47size 1170835321123version https://git-lfs.github.com/spec/v1oid sha256:a6e91181720492fa169a1294ace278e035132109859ed48e0f0573287d2aa1basize 1175301499123version https://git-lfs.github.com/spec/v1oid sha256:c6b2dde7d5fcd651e76442a24c7107d9613a76d675403af63665fe8704ee04c7size 1177957025123version https://git-lfs.github.com/spec/v1oid sha256:a8d640579f038a0638cca3ef7df4330f979db66636edfe85830f2b4acf489851size 1177875383123version https://git-lfs.github.com/spec/v1oid sha256:40096a52c34bc69173f9220bd336c125dbf7425f674c29f800e1ff4cd19c30cesize 1175363705123version https://git-lfs.github.com/spec/v1oid sha256:3289fe24a9f030608256f6f74641dec54f45b8c95ef44017b0fd2c13ea3a73d1size 1170801682123version https://git-lfs.github.com/spec/v1oid sha256:51b6f06bf876924e4a8657c62643db725810ba010bdc0eb6d52dc3d9a18aa99dsize 1173860720README.mdAdded+45
labeled/test/noise_tags.npzAdded+3
labeled/test/pid_labels.npzAdded+3
labeled/test/spacepoints.npzAdded+3
labeled/test/track_ids.npzAdded+3
labeled/train/noise_tags_000.npzAdded+3
labeled/train/noise_tags_001.npzAdded+3
labeled/train/noise_tags_002.npzAdded+3
labeled/train/noise_tags_003.npzAdded+3
labeled/train/noise_tags_004.npzAdded+3
labeled/train/noise_tags_005.npzAdded+3
labeled/train/noise_tags_006.npzAdded+3
labeled/train/pid_labels_000.npzAdded+3
labeled/train/pid_labels_001.npzAdded+3
labeled/train/pid_labels_002.npzAdded+3
labeled/train/pid_labels_003.npzAdded+3
labeled/train/pid_labels_004.npzAdded+3
labeled/train/pid_labels_005.npzAdded+3
labeled/train/pid_labels_006.npzAdded+3
labeled/train/spacepoints_000.npzAdded+3
labeled/train/spacepoints_001.npzAdded+3
labeled/train/spacepoints_002.npzAdded+3
labeled/train/spacepoints_003.npzAdded+3
labeled/train/spacepoints_004.npzAdded+3
labeled/train/spacepoints_005.npzAdded+3
labeled/train/spacepoints_006.npzAdded+3
labeled/train/track_ids_000.npzAdded+3
labeled/train/track_ids_001.npzAdded+3
labeled/train/track_ids_002.npzAdded+3
labeled/train/track_ids_003.npzAdded+3
labeled/train/track_ids_004.npzAdded+3
labeled/train/track_ids_005.npzAdded+3
labeled/train/track_ids_006.npzAdded+3
labeled/validation/noise_tags.npzAdded+3
labeled/validation/pid_labels.npzAdded+3
labeled/validation/spacepoints.npzAdded+3
labeled/validation/track_ids.npzAdded+3
scripts/demo.ipynbAdded+477
scripts/plot.pyAdded+188
unlabeled/spacepoints_000.npzAdded+3
unlabeled/spacepoints_001.npzAdded+3
unlabeled/spacepoints_002.npzAdded+3
unlabeled/spacepoints_003.npzAdded+3
unlabeled/spacepoints_004.npzAdded+3
unlabeled/spacepoints_005.npzAdded+3
unlabeled/spacepoints_006.npzAdded+3
unlabeled/spacepoints_007.npzAdded+3
unlabeled/spacepoints_008.npzAdded+3
unlabeled/spacepoints_009.npzAdded+3
unlabeled/spacepoints_010.npzAdded+3