A Geant4-based Simulator for LumaCam Event Camera
G4LumaCam is a Geant4-based simulation package for the LumaCam event camera that enables reconstruction of neutron events using the same analysis workflow as experimental data. The simulator generates standard Timepix-3 (TPX3) files that can be processed with various reconstruction tools, including the official EMPIR workflow. This flexibility allows researchers to simulate, validate, and optimize neutron detection setups before conducting physical experiments, reducing development time and costs.
- High-Fidelity Physics: Neutron interaction simulation based on Geant4 10.6 physics models
- Realistic Optics: Accurate optical ray tracing through the LumaCam lens system
- Advanced Detector Models: 8 physics-based detector models including MCP+intensifier, Timepix3, and customizable phosphor screens (P20/P43/P46/P47)
- Standard Output Format: Generates TPX3 files compatible with multiple reconstruction tools
- Flexible Reconstruction: Use EMPIR for official workflow - just like in a real experiment!
- Configurable Sources: Customizable neutron source properties (energy, spatial distribution, flux, etc.)
- Efficient Processing: Multi-process support for large-scale simulations
- End-to-End Workflow: From particle generation to reconstructed images
Check out our new detailed tutorial for a comprehensive guide covering simulation setup, ray tracing, and data analysis.
import lumacam
# 1. Run neutron source simulation
sim = lumacam.Simulate("openbeam")
config = lumacam.Config.neutrons_uniform_energy()
df = sim.run(config)
# 2. Trace rays through the optical system with physics-based detector model
lens = lumacam.Lens(archive="openbeam")
lens.trace_rays(
detector_model="image_intensifier_gain", # Recommended: Gain-dependent MCP model
gain=5000, # MCP gain (typical at 1000V)
decay_time=100, # P47 phosphor decay (~100ns)
deadtime=475 # Timepix3 deadtime (475ns)
)
# This generates TPX3 files compatible with various reconstruction tools
# 3. Reconstruct using EMPIR (requires EMPIR license)
analysis = lumacam.Analysis(archive="archive/test/openbeam")
analysis.process(params="hitmap", event2image=True)Geant4 via Docker (recommended):
docker pull jeffersonlab/geant4:g4v10.6.2-ubuntu24Python Dependencies:
- Python 3.7+
- ray-optics - Optical ray tracing (instsalled automatically)
- NumPy, Pandas, Matplotlib (installed automatically)
EMPIR (optional - for official analysis workflow):
EMPIR is a proprietary reconstruction code for Timepix-3 detector data, available from LoskoVision Ltd.. Note: EMPIR is only required if you want to use the lumacam.Analysis workflow. The simulation generates standard TPX3 files that can be processed with alternative, open-source Timepix-3 reconstruction tools
-
Clone the repository:
git clone https://github.com/TsvikiHirsh/G4LumaCam.git cd G4LumaCam -
(Optional) Configure EMPIR path before installation:
export EMPIR_PATH=/path/to/empir/executables -
Install G4LumaCam:
pip install .
G4LumaCam generates standard TPX3 files from the simulation, which are compatible with various Timepix-3 reconstruction tools.
The lumacam.Analysis class provides seamless integration with EMPIR for the complete LumaCam reconstruction pipeline. This requires EMPIR licensing (see EMPIR Configuration below).
G4LumaCam automatically discovers EMPIR binaries within the specified directory,
searching the root as well as common subdirectories (bin/, empir_export/).
Set EMPIR_PATH once in your shell profile or conda/micromamba environment:
# Shell profile (~/.bashrc, ~/.zshrc)
export EMPIR_PATH=/path/to/empir
# Or persist in a conda/micromamba environment
micromamba env config vars set EMPIR_PATH=/path/to/empir -n baseIn a Jupyter notebook:
%env EMPIR_PATH /path/to/empirPass explicitly when creating an Analysis or Lens object:
analysis = lumacam.Analysis(
archive="your_archive",
empir_dirpath="/path/to/empir"
)If neither is set, G4LumaCam falls back to ./empir relative to the working directory.
- Tutorial Notebook: Step-by-step guide with examples
- Detector Models Guide: Quick reference for 8 available detector models
- Full Detector Documentation: Complete documentation with physics background
- Blob vs Gain Explained: Understanding gain-dependent blob sizing
- Detector Models Demo Notebook: Interactive comparison of all models
For additional support, please open an issue.
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-feature) - Commit your changes (
git commit -m 'Add new feature') - Push to the branch (
git push origin feature/new-feature) - Open a Pull Request
If you use G4LumaCam in your research, please cite:
@software{g4lumacam,
author = {Hirsh, Tsviki Y.},
title = {G4LumaCam: A Geant4-based Simulator for LumaCam Event Camera},
url = {https://github.com/TsvikiHirsh/G4LumaCam},
year = {2025},
}G4LumaCam is released under the MIT License. See LICENSE for details.
- Author: Tsviki Y. Hirsh
- Repository: https://github.com/TsvikiHirsh/G4LumaCam
- Issues: GitHub Issues
