Skip to content

feat(data-model): add EventHeader for per-event weight and provenance#17

Open
matclim wants to merge 1 commit into
ShipSoft:mainfrom
matclim:header
Open

feat(data-model): add EventHeader for per-event weight and provenance#17
matclim wants to merge 1 commit into
ShipSoft:mainfrom
matclim:header

Conversation

@matclim

@matclim matclim commented Jul 17, 2026

Copy link
Copy Markdown

Add SHiP::EventHeader, a per-event metadata record carrying an event weight and the id of the originating event.

The weight (default 1.0) supports weighted generation such as forced or oversampled muon DIS, where each replica of a source muon is written as its own event and down-weighted accordingly. parentEventId (default -1) records which source event a replica came from — event-level provenance, distinct from MCParticle::motherId, which links particles within an event.

The struct is a single per-event record like SimResult, so it is registered in the ROOT dictionary without a std::vector counterpart, and added to both the installed header set and the dictionary inputs. RNTuple and TTree round-trip tests cover it, and the TTree dictionary-presence check now includes SHiP::EventHeader. Purely additive: existing classes and files are unchanged, so old files simply lack the new field.

Summary by CodeRabbit

  • New Features

    • Added SHiP::EventHeader for storing event weight and parent-event provenance metadata.
    • Made event metadata available through the public library interface and ROOT dictionary support.
    • Documented the new event metadata class.
  • Tests

    • Added ROOT TTree and RNTuple round-trip coverage to verify event metadata is stored and restored correctly.

Add SHiP::EventHeader, a per-event metadata record carrying an event
weight and the id of the originating event.

The weight (default 1.0) supports weighted generation such as forced or
oversampled muon DIS, where each replica of a source muon is written as
its own event and down-weighted accordingly. parentEventId (default -1)
records which source event a replica came from — event-level provenance,
distinct from MCParticle::motherId, which links particles within an
event.

The struct is a single per-event record like SimResult, so it is
registered in the ROOT dictionary without a std::vector counterpart, and
added to both the installed header set and the dictionary inputs. RNTuple
and TTree round-trip tests cover it, and the TTree dictionary-presence
check now includes SHiP::EventHeader. Purely additive: existing classes
and files are unchanged, so old files simply lack the new field.
@coderabbitai

coderabbitai Bot commented Jul 17, 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: e82b7471-fd16-46e8-bded-b650bef4df23

📥 Commits

Reviewing files that changed from the base of the PR and between c1f918f and bf06169.

📒 Files selected for processing (7)
  • CMakeLists.txt
  • README.md
  • include/SHiP/EventHeader.hpp
  • include/SHiP/LinkDef.h
  • tests/test_rntuple_io.cpp
  • tests/test_ttree_io.cpp
  • tests/test_utils.hpp

📝 Walkthrough

Walkthrough

Adds SHiP::EventHeader with event weight and parent-event provenance fields, exposes it through CMake and ROOT dictionaries, documents it, and validates TTree and RNTuple persistence with round-trip tests.

Changes

EventHeader integration

Layer / File(s) Summary
EventHeader contract and ROOT registration
include/SHiP/EventHeader.hpp, include/SHiP/LinkDef.h, CMakeLists.txt, README.md
Defines EventHeader, registers it for ROOT dictionary generation, exposes it as a public header, and adds it to the data-class documentation.
EventHeader test helpers
tests/test_utils.hpp
Adds deterministic EventHeader fixtures and equality comparison support.
ROOT round-trip coverage
tests/test_rntuple_io.cpp, tests/test_ttree_io.cpp
Writes, reads, and compares EventHeader values in RNTuple and TTree tests, including dictionary presence and cleanup handling.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Test as Round-trip tests
  participant Utils as test::makeEventHeader
  participant Writer as TTree/RNTuple writer
  participant Storage as ROOT storage
  participant Reader as TTree/RNTuple reader
  participant Compare as test::equal

  Test->>Utils: Create deterministic EventHeader
  Utils-->>Writer: Provide eventHeader values
  Writer->>Storage: Write eventHeader
  Storage-->>Reader: Read eventHeader
  Reader->>Compare: Compare with expected EventHeader
  Compare-->>Test: Return round-trip result
Loading

Suggested reviewers: olantwin

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.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.
Title check ✅ Passed The title clearly and concisely describes the main change: adding EventHeader for per-event metadata.
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.

@matclim
matclim requested a review from olantwin July 17, 2026 21:47
@matclim matclim self-assigned this Jul 17, 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.

1 participant