Skip to content

HcalBarrel: replace tessellated tiles and end ring with primitive solids - #1108

Open
wdconinc wants to merge 3 commits into
mainfrom
hcal-primitive-solids
Open

HcalBarrel: replace tessellated tiles and end ring with primitive solids#1108
wdconinc wants to merge 3 commits into
mainfrom
hcal-primitive-solids

Conversation

@wdconinc

@wdconinc wdconinc commented May 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Replace 16 scintillator-tile tessellations and the barrel end-ring tessellation in the HCal Barrel geometry plugin with equivalent Geant4 primitive solids, and use daughter-volume placements for the end-ring bolt holes so that Geant4's smart voxelisation applies.

All geometry dimensions are now specified in the compact XML file (compact/hcal/barrel_gdml.xml) rather than hardcoded in the plugin. No hardcoded data tables remain in the C++ source.

Motivation

Tessellated solids force the Geant4 navigator to test every triangle facet at each boundary crossing. The tiles contain several hundred to ~1000 triangles each and are placed ≥192 times per event (12 η layers × 16 φ sectors); the end ring had 9844 vertices and 19816 triangles. Replacing them with primitives removes the facet-loop overhead entirely. For the bolt holes an additional optimisation is possible: using daughter-volume placements instead of a Boolean-subtraction chain lets Geant4's SmartVoxelHeader voxelise the 32 holes, giving O(log 32) boundary lookup instead of traversing a depth-32 CSG tree.

Changes

Scintillator tiles → ExtrudedPolygon (G4ExtrudedSolid)

All 16 tile shapes (Tile01–Tile12, CTile09–CTile12) are flat 7 mm slabs with an 8–9 vertex boundary polygon. Each tile element in the compact XML now carries a <shape type="Xtru"> child with <twoDimVertex> and <section> sub-elements (following GDML conventions). The plugin reads and constructs an ExtrudedPolygon directly from those elements — no GDML file download is required at runtime.

Tile01 retains the non-zero z offset (z: 1.9212–8.9212 mm) that was baked into the original tessellation.

End ring → Tube mother + 32 air Tube daughters

The end ring element in the compact XML now carries a <dimensions> child with attributes rinner, router, zhalf, zcenter, nholes, rhole, and rhole_ctr (all in mm). The plugin reads these and constructs a steel annulus (Tube) with 32 evenly-spaced air-filled bolt-hole daughters.

Rather than building a depth-32 Boolean subtraction chain — which Geant4 cannot voxelise — the holes are represented as air-filled daughter Tube volumes placed inside the steel annulus mother. A track inside a daughter sees air, which is geometrically equivalent to a hole. Geant4's SmartVoxelHeader then voxelises the 32 daughters, reducing per-boundary work from O(32) (CSG tree) to O(log 32).

The two ring copies are placed at z = ±zcenter with a simple translation (previously RotationY(180°) was used on a shape with z baked in from the tessellation).

Compact XML

file/url/cache attributes removed from tile and end-ring elements. Each tile now has a <shape type="Xtru"> child; the end ring has a <dimensions> child. material attributes are retained. The sector and chimney-sector GDML files are unchanged.

Not changed

The steel barrel sector and chimney-sector tessellations (18–21 distinct Z levels, varying XY cross-sections) are left as tessellations pending benchmarking to confirm they are worth the additional implementation effort.

Copilot AI review requested due to automatic review settings May 23, 2026 16:08
@github-actions github-actions Bot added topic: barrel Mid-rapidity detectors topic: calorimetry labels May 23, 2026

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 improves HCal Barrel Geant4 navigation performance by replacing several tessellated GDML-based solids (scintillator tiles and the steel end ring) with analytically navigable primitive solids built directly in the geometry plugin.

Changes:

  • Replace 16 scintillator tile tessellations with ExtrudedPolygon solids using hardcoded boundary vertices and z extents.
  • Replace the end-ring tessellation with a Tube annulus minus 32 cylindrical bolt-hole subtractions, and place the two rings via explicit ±z translations.
  • Remove file/url/cache attributes for tile and end-ring elements from the compact XML (material remains).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/BarrelHCalCalorimeter_geo.cpp Builds tile and end-ring geometry from primitive solids instead of loading tessellated GDML.
compact/hcal/barrel_gdml.xml Removes now-unused GDML download attributes for tiles/end ring while keeping materials.

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

Comment thread src/BarrelHCalCalorimeter_geo.cpp
Comment thread src/BarrelHCalCalorimeter_geo.cpp Outdated
Comment thread src/BarrelHCalCalorimeter_geo.cpp Outdated
@wdconinc
wdconinc force-pushed the hcal-primitive-solids branch 2 times, most recently from 54829eb to 8d18916 Compare May 23, 2026 16:38
@wdconinc
wdconinc force-pushed the hcal-primitive-solids branch from 2c00a8e to 371cc8b Compare May 26, 2026 08:46
@wdconinc
wdconinc force-pushed the hcal-primitive-solids branch from 371cc8b to 1fca8cc Compare May 26, 2026 17:23
wdconinc and others added 3 commits June 6, 2026 16:15
Replace 16 scintillator tile tessellations (Tile01-12, CTile09-12) with
G4ExtrudedSolid (ExtrudedPolygon) shapes and the barrel end ring tessellation
with a G4Tubs annulus minus 32 bolt-hole G4Tubs subtractions.

Tessellated solids require the generic navigator to test every facet during
boundary crossing, while primitive solids use analytical intersection formulae.
Replacing ~1000-vertex tiles (placed >=192 times) and the ~10000-vertex end ring
with primitives is expected to give a measurable improvement in navigation speed.

Tile shapes (ExtrudedPolygon):
- Each tile is a flat 7 mm slab with an 8- or 9-vertex boundary polygon.
- Polygon vertex coordinates were extracted from the original tessellation
  GDML files (stored in eic/epic-data) by tracing boundary edges on the
  top face. Tile01 retains its non-zero z offset (z: 1.921-8.921 mm)
  that was baked into the tessellation; all other tiles span +/-3.5 mm.

End ring (Tube - 32 x Tube):
- Annulus: inner radius 1980.15 mm, outer radius 2619.85 mm,
  half-length 19.304 mm.
- 32 bolt holes: radius 152.4 mm, centres at R = 2293.86069 mm,
  evenly spaced in phi (11.25 deg pitch).
- Previously placed with RotationY(180 deg) to produce the negative-z copy
  from a shape with z baked in; now placed at +/-3178.406 mm with no
  rotation (the centred Tube is already reflection-symmetric in z).

The GDML file/url/cache attributes for the tiles and end ring are removed
from compact/hcal/barrel_gdml.xml; material attributes are retained.
The steel sector and chimney-sector tessellations are unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
er_gdmlfile -> end_ring
tile{N}_gdmlfile -> tile{N}
ctile{N}_gdmlfile -> ctile{N}

These elements no longer reference GDML files; their geometry
is defined inline via <shape> and <dimensions> children.
sec_gdmlfile and csec_gdmlfile are unchanged as they still load
tessellated steel sector shapes from GDML.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
DD4hep's Tube has no (name, rmin, rmax, dz) constructor.
The 4-argument template is (rmin, rmax, dz, endPhi).
Passing a char const* as the first argument caused the
string to be evaluated as rmin, and an empty string ""
triggered dd4hep::Evaluator 'blank string detected'.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@wdconinc
wdconinc force-pushed the hcal-primitive-solids branch from 1fca8cc to da39251 Compare June 6, 2026 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants