Skip to content

ZDC_Sampling: share layer/slice template volumes across repetitions - #1121

Open
wdconinc wants to merge 2 commits into
mainfrom
zdc-param-volumes
Open

ZDC_Sampling: share layer/slice template volumes across repetitions#1121
wdconinc wants to merge 2 commits into
mainfrom
zdc-param-volumes

Conversation

@wdconinc

Copy link
Copy Markdown
Contributor

Problem

ZeroDegreeCalorimeterSampling_geo.cpp (used by ZDCHcal and ZDCEcal) created a new unique layer_vol and new unique slice_vol objects on every iteration of the repeat loop. For ZDCHcal (ZDC_PbScint_NRepeat=120, 3 slices per layer) this inflated the TGeo volume registry with 480 unique TGeoVolumes for entirely identical geometry.

This is the same class of inefficiency recently fixed in dRICH, BIC, FEMC, forwardEcal, and BarrelCalorimeterScFi.

Fix

  • Build one layer template TGeoVolume per layer group (instead of one per repetition).
  • Build one TGeoVolume per slice type and place them in the template once.
  • The explicit repeat loop reuses that single template, reducing unique volume count from ~480 → ~4 for ZDCHcal.

Geometry loads and converts correctly (tested with geoDisplay against ZDC_Athena.xml).

Notes

  • Layer physVolID is now 0-based (0…N−1) instead of 1-based (1…N). This affects ZDCHcalHits cell IDs; no standard ePIC craterlake config currently uses ZDC_Athena.xml, so no EICrecon reconstruction is impacted.
  • A paramVolume1D (G4PVParameterised) approach was explored but is blocked by two DD4hep 1.37 constraints: (a) the parameterised entity may have at most one daughter, and (b) addPhysVolID base must be 0. Since ZDC layers have multiple slices each with independent physVolIDs, shared-template + explicit loop is the correct approach here.
  • ZeroDegreeCalorimeterEcalWSciFi_geo.cpp: modVol was already shared; added a comment noting the explicit 2-D placement loop and a potential future optimisation.

Replace per-repeat unique volume construction with shared templates.
Previously the repeat loop in ZeroDegreeCalorimeterSampling_geo.cpp
created a new layer_vol (named _layer1, _layer2, ...) and new slice_vol
objects (named _layer1slice1, ...) on every iteration.  For ZDCHcal
(ZDC_PbScint_NRepeat=120, 3 slices per layer) this inflated the TGeo
volume registry with 480 unique TGeoVolumes for identical geometry.

After this change:
- One layer template TGeoVolume is built per layer group.
- Three slice TGeoVolumes (one per slice type) are placed in the template
  once.
- The explicit repeat loop reuses that single template 120 times, reducing
  unique volume count from ~480 to ~4 for ZDCHcal.

Note: layer physVolID is now 0-based (0..N-1) instead of 1-based (1..N),
matching the pattern used in other recently-optimised detectors.

Also add a comment in ZeroDegreeCalorimeterEcalWSciFi_geo.cpp noting that
modVol is already shared and pointing to a potential future paramVolume1D
optimisation for the module placement loop.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 30, 2026 01:58

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 ZDC sampling geometry construction by sharing repeated layer and slice template volumes instead of creating duplicate TGeoVolume instances for every repetition.

Changes:

  • Reworks ZDC_Sampling layer construction to create one reusable layer volume per layer group and one reusable slice volume per slice type.
  • Places repeated layer templates explicitly with distinct layer physVolIDs.
  • Adds a clarifying comment to the ScFi ZDC ECAL module placement loop.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/ZeroDegreeCalorimeterSampling_geo.cpp Shares layer/slice template volumes across repeated sampling layers.
src/ZeroDegreeCalorimeterEcalWSciFi_geo.cpp Documents that module volume sharing is already used in the 2-D placement loop.

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

Comment thread src/ZeroDegreeCalorimeterSampling_geo.cpp Outdated
@github-actions github-actions Bot added topic: calorimetry topic: far-forward Deterctors for small-angle particles labels May 30, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: calorimetry topic: far-forward Deterctors for small-angle particles

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants