Skip to content

Add RecParticle - #2

Merged
olantwin merged 14 commits into
ShipSoft:mainfrom
mesmith75:rec_particle
Jun 11, 2026
Merged

olantwin merged 14 commits into
ShipSoft:mainfrom
mesmith75:rec_particle

Conversation

@mesmith75

@mesmith75 mesmith75 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Adds a RecParticle class.

This is to store more information from a reconstructed particle. For now the IP wrt some notional vertex.

Summary by CodeRabbit

  • New Features
    • Added reconstructed particle data type with framework serialization support, enabling proper handling of particle reconstruction data.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new plain data struct SHiP::RecParticle with default-initialized public members and a fromSimParticle helper; exposes its header in the SHiPDataModel public headers and registers the type (and std::vector of it) for ROOT/Cling dictionary generation.

Changes

RecParticle data class integration

Layer / File(s) Summary
RecParticle struct and converter
include/SHiP/RecParticle.hpp
Introduces SHiP::RecParticle as a plain struct with default-initialized members (trackId, parentId, pdgCode, vertex, endpoint, momentum, energy, time, creatorProcess, ipPV) and an inline fromSimParticle(const SimParticle&) helper that populates those fields.
ROOT dictionary registration and CMake export
include/SHiP/LinkDef.h, CMakeLists.txt
Adds #pragma link directives for SHiP::RecParticle and std::vector<SHiP::RecParticle> under __CLING__, exposes include/SHiP/RecParticle.hpp in the SHiPDataModel public header FILE_SET, and includes the header in root_generate_dictionary inputs.

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.
Title check ✅ Passed The title clearly and directly summarizes the main change: introducing a new RecParticle struct to store reconstructed particle information.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

@mesmith75 mesmith75 changed the title WIP: Add rec particle WIP: Add RecParticle Jun 9, 2026

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

🤖 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/RecParticle.hpp`:
- Line 34: Fix the typo in the trailing comment for the member variable ipPV in
RecParticle (double ipPV{0};) by removing the extraneous '>' so the unit
annotation reads "[mm]" instead of "[mm]>" and ensure the comment remains "///<
IP wrt to the PV (at 0,0,0) [mm]".
- Around line 10-35: RecParticle currently hides all data members making it
unusable; update the declaration so external code can read reconstruction
results by either converting class RecParticle to a struct or making its member
variables public (trackId, parentId, pdgCode, vertex, endpoint, momentum,
energy, time, creatorProcess, ipPV), or alternatively add const accessors for
each field (e.g., trackId(), parentId(), pdgCode(), vertex(), endpoint(),
momentum(), energy(), time(), creatorProcess(), ipPV()) and keep the existing
constructor RecParticle(const SimParticle&). Ensure the chosen change is applied
consistently to the existing constructor and any users of RecParticle.
- Line 3: Replace the incorrect include in RecParticle.hpp from
<SimParticle.hpp> to the project SHiP path (e.g., "SHiP/SimParticle.hpp" or
<SHiP/SimParticle.hpp>) so the header is found via BASE_DIRS; remove the stray
extra '>' in the comment near the parameter units (the comment around line 34
that currently reads "... [mm]>"); and make the reconstructed-data members of
class RecParticle accessible by adding appropriate public getters (or making
them public) so external C++ code can read the reconstructed values rather than
relying solely on ROOT I/O or reflection.
🪄 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: 376e78e2-392a-4254-a3e2-994e352fe2d2

📥 Commits

Reviewing files that changed from the base of the PR and between e709b82 and a2ca5b2.

📒 Files selected for processing (3)
  • CMakeLists.txt
  • include/SHiP/LinkDef.h
  • include/SHiP/RecParticle.hpp

Comment thread include/SHiP/RecParticle.hpp Outdated
Comment thread include/SHiP/RecParticle.hpp Outdated
Comment thread include/SHiP/RecParticle.hpp Outdated
@mesmith75

Copy link
Copy Markdown
Contributor Author

There is a clash in the pre-commit ci. Something is putting the #include "SHiP/SimParticle.hpp" first, but the check wants it last

@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

🧹 Nitpick comments (1)
include/SHiP/RecParticle.hpp (1)

23-36: ⚡ Quick win

Add documentation and consider noexcept for the converter function.

The fromSimParticle function lacks documentation explaining its purpose, what happens to ipPV, and why it's a free function rather than a constructor. Additionally, since the function only copies POD-like data without allocations or throwing operations, marking it noexcept would help compilers optimize and clarify the exception guarantee.

📚 Suggested documentation and noexcept addition
+/// Converts a SimParticle to RecParticle
+/// \param sp Source simulation particle
+/// \return RecParticle with copied fields and ipPV initialized to 0.0
-inline RecParticle fromSimParticle(SimParticle const& sp) {
+inline RecParticle fromSimParticle(SimParticle const& sp) noexcept {
   return {
       .trackId = sp.trackId,
🤖 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/RecParticle.hpp` around lines 23 - 36, Add a brief doc comment
above the free function fromSimParticle explaining its purpose (convert a
SimParticle to a RecParticle), what ipPV is initialized to (explicitly set to
0.0 here) and why this conversion is provided as a free function rather than a
RecParticle constructor (e.g., non-owning conversion helper, keeps RecParticle
lightweight, or to avoid dependency on SimParticle in RecParticle header). Also
mark the function noexcept since it only performs trivial member copies of
POD-like fields (update the signature inline RecParticle
fromSimParticle(SimParticle const& sp) noexcept) to document the non-throwing
guarantee and enable compiler optimizations.
🤖 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/RecParticle.hpp`:
- Around line 3-5: The include order in RecParticle.hpp is wrong: move the
standard library headers <array> and <cstdint> so they come before the project
header <SHiP/SimParticle.hpp> to match the convention used across other SHiP
headers; update the top-of-file include sequence so that <array> and <cstdint>
appear first, followed by <SHiP/SimParticle.hpp> (the file referencing
RecParticle/SimParticle symbols) to satisfy the include-order lint.

---

Nitpick comments:
In `@include/SHiP/RecParticle.hpp`:
- Around line 23-36: Add a brief doc comment above the free function
fromSimParticle explaining its purpose (convert a SimParticle to a RecParticle),
what ipPV is initialized to (explicitly set to 0.0 here) and why this conversion
is provided as a free function rather than a RecParticle constructor (e.g.,
non-owning conversion helper, keeps RecParticle lightweight, or to avoid
dependency on SimParticle in RecParticle header). Also mark the function
noexcept since it only performs trivial member copies of POD-like fields (update
the signature inline RecParticle fromSimParticle(SimParticle const& sp)
noexcept) to document the non-throwing guarantee and enable compiler
optimizations.
🪄 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: 776c2c23-1c5b-4826-ace6-e7ee46f53fcb

📥 Commits

Reviewing files that changed from the base of the PR and between a2ca5b2 and 9286927.

📒 Files selected for processing (2)
  • include/SHiP/LinkDef.h
  • include/SHiP/RecParticle.hpp
💤 Files with no reviewable changes (1)
  • include/SHiP/LinkDef.h

Comment on lines +3 to +5
#include <SHiP/SimParticle.hpp>
#include <array>
#include <cstdint>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check include order patterns in existing SHiP headers

echo "== Include order in other SHiP headers =="
for f in include/SHiP/*.hpp; do
  if [[ "$f" == *"RecParticle.hpp"* ]]; then continue; fi
  echo "--- $f ---"
  rg -n '^`#include`' "$f" | head -n 10
done

echo ""
echo "== Check if pre-commit config specifies include order =="
fd -t f -e yaml -e yml -e toml -e cfg 'pre-commit|clang-format|cpplint' . | head -n 5 | while read cfg; do
  echo "--- $cfg ---"
  cat "$cfg" | head -n 100
done

Repository: ShipSoft/data-model

Length of output: 659


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== pre-commit config files =="
fd -t f -e yml -e yaml '.pre-commit-config*' . || true
fd -t f -e cfg -e toml '.clang-format|CPPLINT|cpplint' . || true

echo
echo "== CPPLINT config =="
ls -1 CPPLINT.cfg 2>/dev/null || true
[ -f CPPLINT.cfg ] && cat CPPLINT.cfg

echo
echo "== Include-order scan (first few includes per header) =="
for f in include/SHiP/*.hpp; do
  echo "--- $f ---"
  # show first non-empty include lines
  awk '{
    if ($0 ~ /^`#include/`){ print NR ":" $0; n++ }
    else if(n>=1 && $0 ~ /^[[:space:]]*$/){ next }
    else if(n>=1 && $0 !~ /^[[:space:]]*$/){ exit }
  }' "$f"
done

Repository: ShipSoft/data-model

Length of output: 784


Fix include order in include/SHiP/RecParticle.hpp
include/SHiP/RecParticle.hpp (line 3) includes <SHiP/SimParticle.hpp> before <array>/<cstdint>, while other include/SHiP/*.hpp headers place standard library includes first (and include/SHiP/SimResult.hpp places "SHiP/..." after <vector>). Reorder to match the established convention to align with the include-order CI/lint expectations.

🤖 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/RecParticle.hpp` around lines 3 - 5, The include order in
RecParticle.hpp is wrong: move the standard library headers <array> and
<cstdint> so they come before the project header <SHiP/SimParticle.hpp> to match
the convention used across other SHiP headers; update the top-of-file include
sequence so that <array> and <cstdint> appear first, followed by
<SHiP/SimParticle.hpp> (the file referencing RecParticle/SimParticle symbols) to
satisfy the include-order lint.

@mesmith75 mesmith75 changed the title WIP: Add RecParticle Add RecParticle Jun 11, 2026
@mesmith75

Copy link
Copy Markdown
Contributor Author

@olantwin Can we merge this. It is a bit of a placeholder for now but we can extend it later.

@olantwin

Copy link
Copy Markdown
Contributor

Apologies, I didn't notice that I wasn't (yet) subscribed to notifications for this repo.

@olantwin
olantwin merged commit 8402f57 into ShipSoft:main Jun 11, 2026
1 of 2 checks passed
@mesmith75
mesmith75 deleted the rec_particle branch June 11, 2026 12:17
@coderabbitai coderabbitai Bot mentioned this pull request Jun 19, 2026
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