Skip to content

Add RecHit#5

Open
mesmith75 wants to merge 36 commits into
ShipSoft:mainfrom
mesmith75:rec_particle
Open

Add RecHit#5
mesmith75 wants to merge 36 commits into
ShipSoft:mainfrom
mesmith75:rec_particle

Conversation

@mesmith75

@mesmith75 mesmith75 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Added a new RecHit reconstructed hit type, including a helper to convert from simulation hits.
    • Introduced detector-specific hit types (UBT, SBT, TimeDet, StrawTubes, Calo) built on RecHit.
    • Added TrackFitResult with a helper to translate track-fit outputs.
    • Extended RecParticle to store associated reconstructed hits.
  • Refactor
    • Updated the build setup and ROOT dictionary integration so the new and extended types are fully supported.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds new reconstruction data types, ACTS fit conversion, detector hit specializations, and build/ROOT wiring for the new headers.

Changes

Reconstruction data and conversion

Layer / File(s) Summary
New reconstruction types
include/SHiP/RecHit.hpp, include/SHiP/TrackFitResult.hpp
Defines SHiP::RecHit, its fromSimHit helper, and the SHiP::TrackFitResult struct with fit, location, and measurement-vector fields.
Track-fit conversion and particle hits
include/SHiP/Utilities.hpp, include/SHiP/RecParticle.hpp
Adds fromACTSFitResult to convert ACTS track data into TrackFitResult, and adds RecParticle::hits as a default-initialized std::vector<RecHit>.
Detector hits and exports
include/SHiP/detectors/*.hpp, CMakeLists.txt, include/SHiP/LinkDef.h
Defines empty detector-specific hit structs, registers the new headers in the build, and adds ROOT dictionary directives for the new hit and track-fit types.

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

Possibly related PRs

  • ShipSoft/data-model#2: Introduces RecParticle with the same RecHit-backed storage and export pattern that this PR extends.
🚥 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 is concise and correctly reflects the main addition of the RecHit data model.
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 unit tests (beta)
  • Create PR with unit tests

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.

@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: 2

🧹 Nitpick comments (2)
include/SHiP/RecHit.hpp (1)

10-10: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Doc comment mismatch.

Comment says "Reconstructed particle" but this is RecHit.

🤖 Prompt for 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.

In `@include/SHiP/RecHit.hpp` at line 10, The doc comment on RecHit is incorrect
and refers to a reconstructed particle instead of a rec hit. Update the comment
in RecHit.hpp so it accurately describes the RecHit type, keeping the wording
aligned with the RecHit declaration and related class naming.
include/SHiP/TrackFitResult.hpp (1)

8-9: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove commented-out includes; fix doc comment.

Lines 8-9 are dead code (the same includes are added live in Utilities.hpp). Line 13's comment "Reconstructed particle" is a copy-paste leftover — should describe a track-fit result.

Proposed cleanup
-
-//#include <Acts/EventData/VectorMultiTrajectory.hpp>
-//#include <Acts/EventData/VectorTrackContainer.hpp>

 namespace SHiP {

-/// Reconstructed particle
+/// Reconstructed track fit result
 struct TrackFitResult {

Also applies to: 13-13

🤖 Prompt for 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.

In `@include/SHiP/TrackFitResult.hpp` around lines 8 - 9, Remove the commented-out
include lines from TrackFitResult.hpp since those headers are already brought in
through Utilities.hpp, and update the doc comment on the TrackFitResult
type/member so it describes a track-fit result rather than the copied
“Reconstructed particle” text. Use the TrackFitResult declaration and its nearby
comment as the anchor when cleaning up the header.
🤖 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 `@include/SHiP/RecHit.hpp`:
- Around line 22-30: The fromSimHit helper currently omits SimHit::pathLength,
leaving RecHit::pathLength at its default value. Update the mapping in
fromSimHit in RecHit to copy sp.pathLength alongside the other fields so
reconstructed hits preserve the simulated path length.

In `@include/SHiP/Utilities.hpp`:
- Around line 32-36: The TrackFitResult::refLoc assignment in the utility
conversion is misleading because it stores Acts::eBoundLoc0/1 local surface
coordinates with a dummy zero z-value, which makes the field look like a global
position. Update the semantics in this conversion path by either
renaming/commenting the TrackFitResult::refLoc field to clearly indicate it is
local bound coordinates, or change the logic to transform the values into a true
global position before storing them. Use the existing parameter extraction in
the conversion helper to keep the chosen representation consistent throughout
the code.

---

Nitpick comments:
In `@include/SHiP/RecHit.hpp`:
- Line 10: The doc comment on RecHit is incorrect and refers to a reconstructed
particle instead of a rec hit. Update the comment in RecHit.hpp so it accurately
describes the RecHit type, keeping the wording aligned with the RecHit
declaration and related class naming.

In `@include/SHiP/TrackFitResult.hpp`:
- Around line 8-9: Remove the commented-out include lines from
TrackFitResult.hpp since those headers are already brought in through
Utilities.hpp, and update the doc comment on the TrackFitResult type/member so
it describes a track-fit result rather than the copied “Reconstructed particle”
text. Use the TrackFitResult declaration and its nearby comment as the anchor
when cleaning up the header.
🪄 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: 48333f5c-0a5b-4f51-923c-2e80bf069f69

📥 Commits

Reviewing files that changed from the base of the PR and between ddac47a and b84aa05.

📒 Files selected for processing (6)
  • CMakeLists.txt
  • include/SHiP/LinkDef.h
  • include/SHiP/RecHit.hpp
  • include/SHiP/RecParticle.hpp
  • include/SHiP/TrackFitResult.hpp
  • include/SHiP/Utilities.hpp
✅ Files skipped from review due to trivial changes (1)
  • include/SHiP/LinkDef.h
🚧 Files skipped from review as they are similar to previous changes (1)
  • include/SHiP/RecParticle.hpp

Comment thread include/SHiP/RecHit.hpp
Comment thread include/SHiP/Utilities.hpp Outdated
Comment on lines +32 to +36
result.qoverp = params[Acts::eBoundQOverP];
result.phi = params[Acts::eBoundPhi];
result.theta = params[Acts::eBoundTheta];
result.time = params[Acts::eBoundTime];
result.refLoc = {params[Acts::eBoundLoc0], params[Acts::eBoundLoc1], 0.0};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n## Utilities.hpp context\n'
sed -n '1,120p' include/SHiP/Utilities.hpp

printf '\n## refLoc usages/declarations\n'
rg -n --hidden --no-ignore-vcs '\brefLoc\b' include src . || true

printf '\n## nearby type definitions for the result struct/class\n'
rg -n --hidden --no-ignore-vcs 'struct|class.*refLoc|std::array<double, 3>|std::array<.*3>' include src || true

Repository: ShipSoft/data-model

Length of output: 4724


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n## TrackFitResult.hpp\n'
sed -n '1,120p' include/SHiP/TrackFitResult.hpp

printf '\n## TrackFitResult usages\n'
rg -n --hidden --no-ignore-vcs '\bTrackFitResult\b' include . || true

Repository: ShipSoft/data-model

Length of output: 1902


Clarify TrackFitResult::refLoc semantics Acts::eBoundLoc0/1 are local surface coordinates, so this field reads like a global point while storing local bound values plus a dummy z=0. Rename/comment it, or store a transformed global position instead.

🤖 Prompt for 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.

In `@include/SHiP/Utilities.hpp` around lines 32 - 36, The TrackFitResult::refLoc
assignment in the utility conversion is misleading because it stores
Acts::eBoundLoc0/1 local surface coordinates with a dummy zero z-value, which
makes the field look like a global position. Update the semantics in this
conversion path by either renaming/commenting the TrackFitResult::refLoc field
to clearly indicate it is local bound coordinates, or change the logic to
transform the values into a true global position before storing them. Use the
existing parameter extraction in the conversion helper to keep the chosen
representation consistent throughout the code.

@mesmith75 mesmith75 changed the title WIP: Add RecHit Add RecHit Jul 9, 2026
@olantwin

olantwin commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 9, 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 9, 2026

Copy link
Copy Markdown
Contributor

I think we need to be careful here. The ROOT dep here is only for the dictionary generation, none of the structs depend on ROOT. Adding ACTS here would pull it in as a dep basically everywhere. Maybe we can move the conversion utility to the reco project?

@mesmith75

Copy link
Copy Markdown
Contributor Author

Yes, that makes sense. I'll move the conversion

@olantwin olantwin 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.

Some nitpicks and one general question:
Would it be better to introduce the currently identical hit structs now or better to introduce them once they diverge from the standard RecHit?

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.

This is currently unused. Was the intention to use this as the type of detectorId in RecHit? (also, could we make it detector_id?)
In that case, we might have to add a dict, not sure.

@mesmith75 mesmith75 Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is used in the digitisation and will be in the reconstruction. I guess we could use it in Aegir too. The point is to make sure that each detector always uses something consistent.

Comment thread include/SHiP/detectors/DetectorID.hpp
Comment thread include/SHiP/detectors/DetectorID.hpp
Comment thread include/SHiP/RecHit.hpp
Comment thread include/SHiP/TrackFitResult.hpp
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.

2 participants