Skip to main content

A local visualizer for HEP data

Project description

hep-viz

A local visualizer for High Energy Physics (HEP) data.

hep-viz is a lightweight, high-performance tool designed to visualize high-dimensional particle tracking and calorimeter data directly from your local machine or Python environment. It bridges the gap between massive local datasets and fluid web-based visualization.

Features

  • 🚀 Local & Fast: Runs a local web server to stream data on demand—no cloud upload required.
  • 🐍 Python API: Seamlessly integrates with Jupyter Notebooks and Python scripts.
  • 💻 CLI Support: Quickly visualize datasets from your terminal.
  • ✨ 3D Visualization: Interactive 3D view of particles, tracks, and calorimeter hits.
  • 📂 Parquet Support: Optimized for reading large datasets stored in Parquet format.

Installation

Requires Python 3.8+.

Option 1: Install from PyPI

pip install hep-viz

Option 2: Install from Conda

conda install finnbarwilson::hep-viz

Option 3: Install from Source

git clone https://github.com/FinnbarWilson/hep-viz.git
cd hep-viz
pip install .

Usage

1. Command Line Interface (CLI)

Visualize a directory containing your Parquet data files:

hep-viz view /path/to/data/directory

Options:

  • --port <int>: Specify the port to run the server on (default: 8000).
  • --no-browser: Prevent the browser from opening automatically.

2. Python API

Use hep-viz directly within your Python scripts or Jupyter Notebooks. This is perfect for visualizing in-memory data (e.g., from Hugging Face Datasets).

Example with Hugging Face Datasets:

import hep_viz
from datasets import load_dataset

# Load a compatible dataset (e.g., OpenDataDetector)
dataset = load_dataset("OpenDataDetector/ColliderML_higgs_pu0")

# Launches the server and opens the visualization
hep_viz.view(dataset)

Example with Custom Dictionary:

import hep_viz

# Data should be a dictionary of lists
data = {
    "particles": [...],
    "tracks": [...],
    "tracker_hits": [...],
    "calo_hits": [...]
}

hep_viz.view(data)

3. The Application

hep-viz_event

Once the server starts, hep-viz opens an interactive 3D visualization in your browser. The interface displays:

  • Particle Tracks: Trajectories of particles with a pt cut filter
  • Calorimeter Hits: Energy deposits shown as cubes, sized by energy contribution.
  • Tracker Hits: Individual detector measurements forming the reconstructed tracks.
  • Interactive Controls: Rotate, zoom, and pan to explore the event from any angle.
  • Event Navigation: Browse through multiple events in your dataset using the event selector.
  • Track Selection: Click on any track in the 3D view to see detailed information:
    • Particle Info: PDG ID, Truth pT.
    • Reconstruction Info: d0, z0, phi, theta, qop (if available).
    • Calorimeter Deposits: Total energy and a collapsible list of individual cell contributions.

Data Format

hep-viz expects data to be organized into four main categories. If using the CLI, these should be Parquet files in your target directory. If using the Python API, these should be keys in your dictionary.

Required Categories

  1. particles: Truth-level particle information.
    • Columns: event_id, particle_id, pdg_id, px, py, vx, vy
  2. tracks: Reconstructed track information (optional, or derived from hits).
    • Columns: event_id, hit_ids, majority_particle_id, track_id
  3. tracker_hits: Individual hits in the tracker layers.
    • Columns: event_id, particle_id, x, y, z, volume_id
  4. calo_hits: Energy deposits in the calorimeter.
    • Columns: event_id, x, y, z, contrib_particle_ids (list), contrib_energies (list)

File Naming (CLI)

For the CLI to automatically detect files, they should contain the category name (e.g., my_particles.parquet). You can split data across multiple files using the pattern events<start>-<end> (e.g., particles.events0-999.parquet).

Development

To contribute or modify hep-viz:

  1. Clone the repository:

    git clone https://github.com/yourusername/hep-viz.git
    cd hep-viz
    
  2. Install in editable mode:

    pip install -e .
    
  3. Run Tests:

    # Install test dependencies
    pip install pytest httpx
    
    # Run the test suite
    pytest
    

License

This project is licensed under the MIT License.

Copyright (c) 2025 Finnbar Wilson

Project details


Download files

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

Source Distribution

hep_viz-0.1.3.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

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

hep_viz-0.1.3-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

Details for the file hep_viz-0.1.3.tar.gz.

File metadata

  • Download URL: hep_viz-0.1.3.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for hep_viz-0.1.3.tar.gz
Algorithm Hash digest
SHA256 845561366100d3f4e8a91045045dc9aa75a4a9e63d17b9a7e6d3660e81a96d41
MD5 38178660a1324d8de8f7eb7d5b9fa87e
BLAKE2b-256 37d40df1cebd2fcf602a86050d7ae1b912695f9af523fd095cc418c43cb5e779

See more details on using hashes here.

File details

Details for the file hep_viz-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: hep_viz-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 25.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for hep_viz-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4f22f37d1580cec25a1bb8a1ca493ec258b4fc45e72ea6b9af32a2a2ef880a4b
MD5 44a38b89925061f5fe5a9e70b953f5a5
BLAKE2b-256 a904649532b2274ff6a4d418e4640b1601c1c5c61fe7ac864cc4720719765187

See more details on using hashes here.

Supported by

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