Skip to content

refactor: build TimingDetector geometry in C++ instead of GeoModelXML#62

Merged
olantwin merged 1 commit into
mainfrom
timedet-cxx
Jul 15, 2026
Merged

refactor: build TimingDetector geometry in C++ instead of GeoModelXML#62
olantwin merged 1 commit into
mainfrom
timedet-cxx

Conversation

@olantwin

@olantwin olantwin commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

The TimingDetector was the only subsystem still built from a GeoModelXML (.gmx) file loaded at runtime via Gmx2Geo. Its geometry is a regular grid of identical bars whose positions are fully analytic, so the GMX indirection only added a GeoModelXml link dependency, DTD-copying CMake plumbing and a runtime path-resolution step — with no benefit over a plain C++ factory like every other subsystem. This ports it to native C++.

Changes

  • TimingDetectorFactory::build() places the 330 bars (3 columns × 110 rows) directly in two nested loops with analytic positions, reproducing the previous placement exactly:
    • x = (col-1)·1300 mm
    • y = -3220 + row·6440/109 mm
    • z = (row%2)·12 + (col%2)·90 mm (stagger levels 0/12/90/102)
  • Bars share one GeoLogVol and are placed as GeoPhysVol with hierarchical /SHiP/timing_detector/bar_<col>_<row> names; sensitivity is assigned downstream by name pattern, matching the UpstreamTagger convention.
  • Added a dedicated TimDetScint material (C8H8, ρ = 1.023 g/cm³) to SHiPMaterials.
  • Removed SHiPTimingDetInterface, the timing_detector.gmx data file, and all GMX-related CMake plumbing (GeoModelXml link, DTD discovery/copy, compile definitions, install rules).

The public API (TimingDetectorFactory(SHiPMaterials&), build(), barCount()) and the world placement in SHiPGeometry.cpp are unchanged.

Verification

  • pixi run build — clean; no GeoModelXml reference in TimingDetector.
  • pixi run test — 33/33 pass, including TimingDetectorBarCount, the builder, consistency Z-overlap checks, and the full OverlapCheck (bar positions are identical to the GMX, so overlap results are unchanged).
  • pixi run gdml — exports cleanly; the GDML contains the TimDetScint material, one shared bar logvol, and 330 bar placements at the correct staggered positions.

Notes

Two pre-existing conditions are preserved faithfully (not introduced here): the outermost bars reach y = ±3250 mm (exactly the container half-Y), and the bars span z ∈ [−5, +107] mm within the ±250 mm container. Neither trips the overlap check.

Summary by CodeRabbit

  • New Features
    • Timing detector geometry is now built directly in C++, with an analytic 3×110 (330) bar arrangement and standardized /SHiP/timing_detector/bar_<col>_<row> naming, including the z-stagger placement rule.
    • Added the TimDetScint scintillator material for timing detector bars.
  • Bug Fixes
    • Confirmed the constructed timing detector contains exactly 330 timing bars.
  • Documentation
    • Updated the TimingDetector README to reflect the C++ implementation, placement rules (including z-stagger), and name-pattern sensitive-volume identification.
  • Tests
    • Expanded the bar-count test to also validate the expected number of geometry child volumes.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 320589d2-ecbe-417e-bf68-1167a5eeee93

📥 Commits

Reviewing files that changed from the base of the PR and between 1933f7e and e77df25.

📒 Files selected for processing (8)
  • src/SHiPMaterials.cpp
  • subsystems/TimingDetector/CMakeLists.txt
  • subsystems/TimingDetector/README.md
  • subsystems/TimingDetector/data/timing_detector.gmx
  • subsystems/TimingDetector/include/TimingDetector/SHiPTimingDetInterface.h
  • subsystems/TimingDetector/include/TimingDetector/TimingDetectorFactory.h
  • subsystems/TimingDetector/src/TimingDetectorFactory.cpp
  • subsystems/TimingDetector/test_timingdetector.cpp
💤 Files with no reviewable changes (3)
  • subsystems/TimingDetector/include/TimingDetector/SHiPTimingDetInterface.h
  • subsystems/TimingDetector/data/timing_detector.gmx
  • subsystems/TimingDetector/CMakeLists.txt
🚧 Files skipped from review as they are similar to previous changes (4)
  • subsystems/TimingDetector/include/TimingDetector/TimingDetectorFactory.h
  • subsystems/TimingDetector/src/TimingDetectorFactory.cpp
  • subsystems/TimingDetector/test_timingdetector.cpp
  • src/SHiPMaterials.cpp

📝 Walkthrough

Walkthrough

This PR replaces GeoModelXML-based TimingDetector construction with direct C++ placement of 330 analytically positioned bars, adds the TimDetScint material, removes GMX build wiring, and updates tests and documentation.

Changes

TimingDetector C++ Construction Migration

Layer / File(s) Summary
Material and factory layout contract
src/SHiPMaterials.cpp, subsystems/TimingDetector/include/TimingDetector/TimingDetectorFactory.h
Adds TimDetScint and defines the dimensions, grid parameters, and z-stagger constants used by the factory.
Analytic bar placement and validation
subsystems/TimingDetector/src/TimingDetectorFactory.cpp, subsystems/TimingDetector/CMakeLists.txt, subsystems/TimingDetector/test_timingdetector.cpp
Builds 330 named bar volumes from computed coordinates, removes GMX linkage and setup, and verifies bar and child-volume counts.
TimingDetector documentation alignment
subsystems/TimingDetector/README.md
Documents the C++ construction, bar naming and z-staggering, TimDetScint, and updated implementation status.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant TimingDetectorFactory
  participant GeoModelKernel
  participant TimingDetectorTest
  TimingDetectorFactory->>GeoModelKernel: create container and reusable bar logical volume
  loop 3 columns x 110 rows
    TimingDetectorFactory->>GeoModelKernel: place named bar with computed transform
  end
  TimingDetectorFactory->>TimingDetectorTest: return built detector volume
  TimingDetectorTest->>TimingDetectorTest: assert 330 bars and 330 child volumes
Loading

Possibly related PRs

Suggested reviewers: matclim

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: TimingDetector geometry moved from GeoModelXML to C++ construction.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch timedet-cxx

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@olantwin
olantwin requested a review from matclim July 4, 2026 00:18
@olantwin

olantwin commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/SHiPMaterials.cpp`:
- Around line 203-211: The TimDetScint material definition is internally
inconsistent because its name/comment indicate PVT scintillator while the
Carbon/Hydrogen fractions match Polystyrene. Update the material in
SHiPMaterials::SHiPMaterials so it is either renamed/commented to reflect the
polystyrene composition or changed to the intended PVT C9H10 fractions, and make
sure the density and element fractions agree with the chosen material
definition.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fd3a8034-3eda-49ed-bafa-eb1eeea66544

📥 Commits

Reviewing files that changed from the base of the PR and between 787e426 and caca019.

📒 Files selected for processing (8)
  • src/SHiPMaterials.cpp
  • subsystems/TimingDetector/CMakeLists.txt
  • subsystems/TimingDetector/README.md
  • subsystems/TimingDetector/data/timing_detector.gmx
  • subsystems/TimingDetector/include/TimingDetector/SHiPTimingDetInterface.h
  • subsystems/TimingDetector/include/TimingDetector/TimingDetectorFactory.h
  • subsystems/TimingDetector/src/TimingDetectorFactory.cpp
  • subsystems/TimingDetector/test_timingdetector.cpp
💤 Files with no reviewable changes (2)
  • subsystems/TimingDetector/include/TimingDetector/SHiPTimingDetInterface.h
  • subsystems/TimingDetector/data/timing_detector.gmx

Comment thread src/SHiPMaterials.cpp
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

✅ prek hooks passed

@olantwin

olantwin commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@olantwin

olantwin commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@olantwin

olantwin commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@olantwin

olantwin commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@subsystems/TimingDetector/README.md`:
- Around line 11-15: The fenced geometry example in the README needs a language
hint to satisfy markdownlint. Update the code block around the Timing_Detector
layout example to use an explicit fence tag such as text, keeping the content
unchanged; this is the only change needed in the README example block.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 943c8c32-2226-43f8-b0c0-ec4fc36e513f

📥 Commits

Reviewing files that changed from the base of the PR and between caca019 and f5ebd3a.

📒 Files selected for processing (8)
  • src/SHiPMaterials.cpp
  • subsystems/TimingDetector/CMakeLists.txt
  • subsystems/TimingDetector/README.md
  • subsystems/TimingDetector/data/timing_detector.gmx
  • subsystems/TimingDetector/include/TimingDetector/SHiPTimingDetInterface.h
  • subsystems/TimingDetector/include/TimingDetector/TimingDetectorFactory.h
  • subsystems/TimingDetector/src/TimingDetectorFactory.cpp
  • subsystems/TimingDetector/test_timingdetector.cpp
💤 Files with no reviewable changes (2)
  • subsystems/TimingDetector/data/timing_detector.gmx
  • subsystems/TimingDetector/include/TimingDetector/SHiPTimingDetInterface.h
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/SHiPMaterials.cpp
  • subsystems/TimingDetector/test_timingdetector.cpp
  • subsystems/TimingDetector/include/TimingDetector/TimingDetectorFactory.h
  • subsystems/TimingDetector/src/TimingDetectorFactory.cpp

Comment thread subsystems/TimingDetector/README.md
@olantwin

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

The TimingDetector was the only subsystem still built from a GeoModelXML
(.gmx) file loaded at runtime via Gmx2Geo. Its geometry is a regular grid
of identical bars whose positions are fully analytic, so the GMX indirection
added a GeoModelXml link dependency, DTD-copying CMake plumbing and a runtime
path-resolution step without any benefit over a plain C++ factory like every
other subsystem.

TimingDetectorFactory::build() now places the 330 bars (3 columns x 110 rows)
directly in two nested loops with analytic positions
(x = (col-1)*1300, y = -3220 + row*6440/109, z = (row%2)*12 + (col%2)*90),
reproducing the previous placement exactly. Bars share one GeoLogVol and are
placed as GeoPhysVol with hierarchical /SHiP/timing_detector/bar_<col>_<row>
names; sensitivity is assigned downstream by name pattern, matching the
UpstreamTagger convention.

A dedicated TimDetScint material (C8H8, 1.023 g/cm3) is added to SHiPMaterials.
The SHiPTimingDetInterface, the .gmx data file and all GMX-related CMake plumbing
are removed. The public API and the world placement are unchanged.
@olantwin

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@olantwin
olantwin merged commit 386f421 into main Jul 15, 2026
4 checks passed
@olantwin
olantwin deleted the timedet-cxx branch July 15, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant