Skip to content

egede/calorimeter

Repository files navigation

GPLv3 License Tests codecov Binder

Calorimeter

A Python package for visualization and analysis of calorimeter data.

Shower visualization

Features

  • Create a 1D calorimenter with active and passive layers
  • Visualise shower development
  • Monte Carlo generation to explore resolution

Installation

From Source

Clone the repository and install in development mode:

git clone https://github.com/yourusername/calorimeter.git
cd calorimeter
pip install -e .

With Development Dependencies

pip install -e ".[dev]"

Run in Binder

If you are staff or student at an Australian or New Zealand University, you can use binder on ARDC resources.

Quick Start

from calorimeter import Calorimeter, Simulation, Layer, Electron
import matplotlib.pyplot as plt

mycal = Calorimeter()
lead = Layer('lead', 2.0, 0.5, 0.0)
scintillator = Layer('Scin', 0.01, 0.5, 1.0)
for i in range(40):
    mycal.add_layers([lead, scintillator])

sim = Simulation(mycal)
ionisations, cal_with_traces = sim.simulate_with_tracing(Electron(0.0, 100.0), deadcellfraction=0.0)

fig, ax = plt.subplots(figsize=(14, 6))
ax = cal_with_traces.draw(ax=ax, show_traces=True)
plt.tight_layout()
plt.show()

Running Tests

Run the test suite using pytest:

pytest

With coverage report:

pytest --cov=calorimeter tests/

Development

Code Quality

The project uses several tools for code quality:

  • pytest: Testing framework
  • pytest-cov: Code coverage measurement
  • black: Code formatting
  • flake8: Linting
  • mypy: Static type checking

Running Quality Checks

# Format code
black calorimeter tests

# Run linting
flake8 calorimeter tests

# Type checking
mypy calorimeter

# Tests with coverage
pytest --cov=calorimeter tests/

License

This project is licensed under the GPLv3 License - see the LICENSE file for details.

Contributing

Contributions are welcome! Before submitting a PR:

  • Install dev dependencies: pip install -e ".[dev]"
  • Run the test suite: pytest -q
  • Check linting and types: flake8 calorimeter tests and mypy calorimeter

Running Tests Locally

In a fresh clone, run:

pip install -e ".[dev]"
pytest -q

Pre-commit Hooks

This repository includes a shared pre-commit configuration at .pre-commit-config.yaml.

It will:

  • Strip outputs from *.ipynb notebooks (via nbstripout).
  • Apply basic hygiene checks (trailing whitespace, EOF fixer, YAML checks).

Set up locally:

pip install -e ".[dev]"
pre-commit install
pre-commit run --all-files

Note: pre-commit runs automatically on git commit after installation.

Support

  • For issues, or bug reports, please open an issue on GitHub.
  • For questions and discussions, use the discussion forum.

About

A simple model of a sampling calorimeter for education purposes

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors