Skip to content

New features for CAD-based simulations#15628

Open
sawenzel wants to merge 2 commits into
devfrom
swenzel/cad-improvements
Open

New features for CAD-based simulations#15628
sawenzel wants to merge 2 commits into
devfrom
swenzel/cad-improvements

Conversation

@sawenzel

Copy link
Copy Markdown
Collaborator

Summary

This PR makes the CAD→TGeo integration path for o2-sim more configurable and adds support for sensitive external detectors.

Highlights

  • Improved configurability — External CAD geometry is now described through a JSON config passed via a new --extGeomFile option, activated through the normal detector/module list. No more hardcoding passive modules in build_geometry.C.
  • Multiple external geometry modules — Several passive CAD modules can be injected in one simulation. Macros are JIT-loaded into unique namespaces so they coexist despite identical builder symbols, and imported CAD media are remapped into the O2 MaterialManager.
  • Sensitive external detectors (with or without JITted actions) — New generic o2::ext::ExternalDetector marks configured volumes/media sensitive and ties them to a free DetID. A shared o2::ext::Hit payload keeps the merger simple. Per-detector sensitive actions can be loaded from ROOT macros at runtime, falling back to a built-in charged-track entrance/exit action. Active detectors are registered in O2HitMerger for parallel-mode persistence.
  • Clipping CAD geometries before conversion — The converter can restrict output to an axis-aligned --clip-box (with --clip-deduplicate {none,intact}), dropping outside solids, keeping inside ones, and cutting straddling ones. Combines with new name-based selection (--include-name / --exclude-name).

Docs & examples

  • Extended scripts/geometry/README.md covering the JSON setup, sensitive detectors, and clipping / name-selection options.
  • Added a self-contained run/SimExamples/External_Sensitive_Detectors example with two artificial sensitive detectors (built-in and custom JITted actions, parallel-mode persistence).

sawenzel added 2 commits July 22, 2026 15:13
Improve the CAD->TGeo integration path for o2-sim with a
configurable JSON-driven setup for externally provided CAD geometry.
The configuration can describe multiple passive external modules and
sensitive external detectors, both activated through the normal
detector/module list.

Add a --extGeomFile option carrying the external geometry
configuration. Passive CAD modules no longer need to be hardcoded in
build_geometry.C, and several configured CAD modules can be injected
in one simulation.

Introduce shared CAD geometry utilities to JIT-load
O2_CADtoTGeo.py-style ROOT macros into unique namespaces, allowing
several CAD modules to coexist in one Cling session despite identical
exported builder symbols. The utilities also remap imported CAD media
into the O2 MaterialManager.

Add o2::ext::ExternalDetector, a generic sensitive detector
implementation for externally supplied CAD geometry. Configured
volumes or media can be marked sensitive, the detector is tied to a
free DetID slot, and hits flow through the standard o2-sim forwarding
and merging machinery.

Add o2::ext::Hit as a detector-agnostic external hit payload storing
entrance/exit position, momentum, energy, energy loss, time, length,
PDG code and track status flags. All external detector instances share
this wire format, so the hit merger only needs one external hit type.

Support optional per-detector sensitive actions loaded from ROOT
macros at runtime via GetFromMacro. When no custom action is
configured, a built-in charged-track entrance/exit action is used.

Register active external detectors in O2HitMerger so their hits are
persisted in parallel mode, and key DetImpl hit collection buffers by
detector instance to support multiple detectors sharing the same C++
type.

Add a self-contained SimExample with two artificial sensitive external
detectors, demonstrating configurable geometry injection, built-in and
custom sensitive actions, and parallel-mode hit persistence.
Support culling/cutting the CAD model against an axis-aligned --clip-box
(with --clip-deduplicate {none,intact}) and whitelisting/blacklisting
parts via --include-name/--exclude-name regexes before TGeo conversion.

Aided by GPT-5.5 (Copilot CERN pilot licence)
@sawenzel
sawenzel requested review from a team and shahor02 as code owners July 23, 2026 09:18
@sawenzel
sawenzel requested a review from njacazio July 23, 2026 09:19
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.

1 participant