Skip to content

LFHCAL: reuse slice volume templates across readout sections#1112

Open
wdconinc wants to merge 2 commits into
mainfrom
fix/lfhcal-lv-reuse
Open

LFHCAL: reuse slice volume templates across readout sections#1112
wdconinc wants to merge 2 commits into
mainfrom
fix/lfhcal-lv-reuse

Conversation

@wdconinc

Copy link
Copy Markdown
Contributor

Summary

The LFHCAL XML defines 7 readout sections (readoutlayer=0..6), all with identical slice geometry (Polystyrene + Kapton + Steel235 with the same thicknesses). Previously, layer_num was reset to 0 at each readout section boundary inside createDetector, causing createEightMModule/createFourMModule to create separate TGeoVolume objects for every layer index in every section — producing 1704 unique volumes when ~57 suffice.

Fix

Pre-build one template per slice type (absorber, filler, scintillator assembly) from the first occurrence of each slice_partID. For all subsequent layers, place the same template. The per-layer layerz and rlayerz physVolIDs are set on each placement node (consistent with how DD4hep's VolumeManager collects IDs along the full path).

The createScintillatorPlateEightM/createScintillatorPlateFourM helper signatures no longer receive layerID/roLayer; foil volume names are now fixed strings instead of layer-indexed.

Impact

Measured locally using npdet_to_dot and checkGeometry:

Metric Before After
Unique TGeoVolumes (DOT nodes) 1704 57
Reduction 97%
Peak PSS (checkGeometry on epic_lfhcal_only.xml) ~596 MB ~585 MB
Geometry overlaps 0 0

The primary benefit is reduced unique volume count — fewer G4LogicalVolume objects during Geant4 initialization, a smaller VolumeManager tree in EICRecon, and lower memory footprint at startup.

Copilot AI review requested due to automatic review settings May 26, 2026 02:04

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 optimizes the LFHCAL DD4hep geometry construction by reusing slice volume templates across readout sections, reducing the number of unique TGeoVolumes created while preserving per-placement PhysVolID tagging for readout identification.

Changes:

  • Reworked 8M/4M module slice construction to pre-build and reuse absorber/filler/scintillator templates instead of creating per-layer volumes.
  • Updated scintillator plate helpers (8M/4M) to remove layer/readout parameters and to use fixed foil volume names.
  • Moved layerz/rlayerz ID assignment for scintillator to the placed-instance level (module slice placement) rather than per-tower placement.

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

Comment thread src/LFHCAL_geo.cpp
Comment thread src/LFHCAL_geo.cpp
All 7 readout sections share identical slice geometry (Polystyrene +
Kapton + Steel235 with the same thicknesses). Previously, layer_num
was reset to 0 at each readout section boundary, causing createEightM/
FourMModule to create separate TGeoVolume objects for every layer
index in every section (1704 unique volumes total).

Pre-build one template per slice type (absorber, filler, scintillator)
and place it for every layer, setting layerz and rlayerz physVolIDs on
each placement. This reduces the unique TGeoVolume count by ~97%
(1704 → 57), lowering memory footprint and geometry lookup cost in
reconstruction.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@wdconinc wdconinc force-pushed the fix/lfhcal-lv-reuse branch from caf3d86 to 7145a01 Compare May 26, 2026 17:22
Add runtime consistency checks in createEightMModule and
createFourMModule: store the first-occurrence slice parameters
(thickness, material, region, limits, vis) for each template type
and throw std::runtime_error if a later slice of the same partID
differs. This ensures future XML changes that introduce non-uniform
slice geometry fail loudly rather than silently using wrong geometry.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@wdconinc

wdconinc commented May 26, 2026

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants