Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ target_sources(
include/SHiP/SimHit.hpp
include/SHiP/SimParticle.hpp
include/SHiP/SimResult.hpp
include/SHiP/RecParticle.hpp
)
target_link_libraries(SHiPDataModel PUBLIC ROOT::Core)
set_target_properties(SHiPDataModel PROPERTIES LINKER_LANGUAGE CXX)
Expand All @@ -29,6 +30,7 @@ root_generate_dictionary(
SHiP/SimHit.hpp
SHiP/SimParticle.hpp
SHiP/SimResult.hpp
SHiP/RecParticle.hpp
MODULE
SHiPDataModel
LINKDEF
Expand Down
4 changes: 4 additions & 0 deletions include/SHiP/LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@
#pragma link C++ class SHiP::SimResult+;
#pragma link C++ class std::vector<SHiP::SimHit>+;
#pragma link C++ class std::vector<SHiP::SimParticle>+;

// Reconstruction
#pragma link C++ class SHiP::RecParticle+;
#pragma link C++ class std::vector<SHiP::RecParticle>+;
#endif
38 changes: 38 additions & 0 deletions include/SHiP/RecParticle.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#pragma once

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

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.


namespace SHiP {

/// Reconstructed particle
struct RecParticle {
std::int32_t trackId{0};
std::int32_t parentId{0};
std::int32_t pdgCode{0};
std::array<double, 3> vertex{0, 0, 0}; ///< Production vertex [mm]
std::array<double, 3> endpoint{0, 0, 0}; ///< End point [mm]
std::array<double, 3> momentum{0, 0, 0}; ///< Initial momentum [GeV/c]
double energy{0}; ///< Initial kinetic energy [GeV]
double time{0}; ///< Production time [ns]
std::int32_t creatorProcess{0};
double ipPV{0}; ///< IP wrt to the PV (at 0,0,0) [mm]
};

inline RecParticle fromSimParticle(SimParticle const& sp) {
return {
.trackId = sp.trackId,
.parentId = sp.parentId,
.pdgCode = sp.pdgCode,
.vertex = sp.vertex,
.endpoint = sp.endpoint,
.momentum = sp.momentum,
.energy = sp.energy,
.time = sp.time,
.creatorProcess = sp.creatorProcess,
.ipPV = 0.0,
};
}

} // namespace SHiP