Skip to content

Issue 129#132

Merged
augustocattafesta merged 31 commits into
mainfrom
issue_129
May 12, 2026
Merged

Issue 129#132
augustocattafesta merged 31 commits into
mainfrom
issue_129

Conversation

@augustocattafesta

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new pixel equalization calibration workflow (and supporting CLI/pipeline wiring) and adds a spectrum-PDF facility used by the equalization likelihood fit, while refactoring gain calibration to be derived from the equalization result.

Changes:

  • Added SpectrumPDF (save/load + KDE-based interpolation) and a calibspec task/CLI command to generate PDFs from reconstructed spectra.
  • Added CalibrationType.EQUALIZATION plus a new CalibrateEqualization likelihood-based calibration, and refactored gain calibration to use equalization + sensor material properties.
  • Updated reconstruction/display/eta calibration to use an equalization matrix and expanded recon output to include an adc column.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 18 comments.

Show a summary per file
File Description
tests/test_pdf.py New tests for SpectrumPDF (currently has pytest-signature and assertion issues).
src/hexsample/pdf.py New SpectrumPDF implementation (KDE + spline, serialization, derivative, plotting).
src/hexsample/calibration.py Adds equalization calibration type/metadata and implements likelihood-based equalization + refactored gain calibration.
src/hexsample/tasks.py Wires equalization into reconstruct/display/eta, adds calibspec, refactors calibration tasks and filenames.
src/hexsample/pipeline.py Pipeline entrypoints updated for equalization + new calibspec and split equalization vs gain calibration.
src/hexsample/cli.py CLI updated: adds calibspec, adds calibgen equalization, refactors calibgen gain options.
src/hexsample/clustering.py Adds adc_to_ev handling in Cluster and propagates conversion factor from calibration metadata.
src/hexsample/recon.py Refactors ReconEvent to expose adc() and uses Cluster.energy() for energy calculation.
src/hexsample/fileio.py Recon table schema updated to include adc column and writes event.adc() into output.
src/hexsample/caldb.py Adds CalDB accessor for equalization calibration files.
pyproject.toml Adds new dependencies (iminuit, joblib).
docs/release_notes.rst Documents the new equalization/PDF workflow and CLI changes (contains a few typos).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_pdf.py
Comment thread tests/test_pdf.py
Comment thread tests/test_pdf.py Outdated
Comment thread src/hexsample/clustering.py
Comment thread src/hexsample/clustering.py
Comment thread docs/release_notes.rst Outdated
Comment thread src/hexsample/tasks.py
Comment thread src/hexsample/tasks.py
Comment thread src/hexsample/recon.py
Comment on lines +54 to +62
def adc(self) -> int:
"""Return the total ADC count for the event.
"""
return self.cluster.pulse_height()

.. warning::
This is currently using the ionization energy of Silicon to do the
conversion, assuming a detector gain of 1. We will need to do some
bookkeeping, here, to make this work reliably.
def energy(self) -> float:
"""Return the energy of the event in eV.
"""
return ionization_potential * self.cluster.pulse_height()
return self.cluster.energy()
Comment thread src/hexsample/fileio.py
energy = tables.Float32Col(pos=5)
posx = tables.Float32Col(pos=6)
posy = tables.Float32Col(pos=7)
adc = tables.Int32Col(pos=5)
@augustocattafesta augustocattafesta marked this pull request as ready for review May 12, 2026 09:45
@augustocattafesta augustocattafesta merged commit 866e2a1 into main May 12, 2026
2 checks passed
@augustocattafesta augustocattafesta deleted the issue_129 branch May 12, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change the role of the gain calibration matrix

2 participants