8000 Calorimetry evaluators: per-layer energies and energy resolution; geometry check by jbeirer · Pull Request #2 · key4hep/k4OptHub · GitHub
[go: up one dir, main page]

Skip to content

Calorimetry evaluators: per-layer energies and energy resolution; geometry check - #2

Open
jbeirer wants to merge 1 commit into
repository-setupfrom
calorimetry-evaluators
Open

jbeirer wants to merge 1 commit into
repository-setupfrom
calorimetry-evaluators

Conversation

@jbeirer
@jbeirer jbeirer commented Dec 5, 2026
Copy link
Copy Markdown
Member

Stacked on #1.

Three evaluators for the first study, each stating in its docstring what it assumes of the detector.

calo.layer_energies (evaluators/calorimetry/layer_energies.py): per event, the energy in the active and in the passive material of each longitudinal layer, and the true energy and direction of the generated particle (.npz artifact). Reads the EDM4hep file with uproot; the collection, cell ID encoding, layer field and active selection are settings.
Applies to layered sampling calorimeters that record their passive deposits in the same collection, identified in the cell ID (in Key4hep today: ALLEGRO's noble-liquid calorimeters with sensitive absorbers), for single-particle samples. Not to CLD's SiW ECAL, IDEA's dual-readout calorimeter or crystals as they are. An event without deposits is kept with zero energy; a missing collection, a layer out of range or an event count that does not match the stage fails.

calo.energy_resolution (evaluators/calorimetry/energy_resolution.py, with sampling_calibration.py and resolution_fit.py), combining the energies of one particle:

  1. per-layer sampling fractions from the even-numbered events (active / active + passive);
  2. E_rec = Σ E_active,l / SF_l of the odd-numbered events (calibration and measurement never share an event);
  3. at each energy, the Gaussian core of E_rec/E (iterated ±2σ window, truncation-corrected), response and resolution, with the plain mean and RMS beside them;
  4. fit σ/E = √(a²/E + c²);
  5. uncertainties from bootstrap resamplings of the whole procedure, calibration included, so the correlation the common calibration induces between energies is in them.

Reports a, c, their correlation, χ²/ndf, the mean sampling fraction, σ/E at reference energies, and the measured resolution and response at each energy; a summary JSON and a figure. A term fitted at 0 is a valid result, with its 95% upper limit. Simulation-level: no noise, no clustering, no upstream-material correction.

geometry.check (evaluators/geometry/dd4hep_check.py, with dd4hep_geometry.py): builds the candidate's geometry with DD4hep in a separate process, reports DD4hep expressions as metrics (what the values a problem writes made of it), and checks a subdetector for overlaps with TGeo (meshes and random points). Any DD4hep geometry. Overlaps make the candidate invalid; a geometry that does not build fails.

Tests (tests/unit/calorimetry): toy calorimeters with known sampling fractions and resolution: the terms are recovered; over 40 toy experiments the bootstrap uncertainties of a and c have pull widths close to 1 (slow, run nightly); the core estimator ignores tails; the failure cases. Separately checked on ALLEGRO simulations: calo.layer_energies agrees exactly with an independent podio-based extraction of the same files, and geometry.check reports 1536 planes at 50.18° and 1200 at 60°, without overlaps.

CI runs the tests in the Key4hep container with the pinned release.

@jbeirer
jbeirer force-pushed the calorimetry-evaluators branch from ed9ca21 to 23413a4 Compare December 5, 2026 18:43
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.

1 participant

0