New features for CAD-based simulations#15628
Open
sawenzel wants to merge 2 commits into
Open
Conversation
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR makes the CAD→TGeo integration path for
o2-simmore configurable and adds support for sensitive external detectors.Highlights
--extGeomFileoption, activated through the normal detector/module list. No more hardcoding passive modules inbuild_geometry.C.MaterialManager.o2::ext::ExternalDetectormarks configured volumes/media sensitive and ties them to a freeDetID. A sharedo2::ext::Hitpayload 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 inO2HitMergerfor parallel-mode persistence.--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
scripts/geometry/README.mdcovering the JSON setup, sensitive detectors, and clipping / name-selection options.run/SimExamples/External_Sensitive_Detectorsexample with two artificial sensitive detectors (built-in and custom JITted actions, parallel-mode persistence).