Skip to content

sEPD Event Plane Calibration - Application (Cleanup)#4200

Merged
pinkenburg merged 11 commits intosPHENIX-Collaboration:masterfrom
Steepspace:sEPD-EventPlaneInfo
Mar 10, 2026
Merged

sEPD Event Plane Calibration - Application (Cleanup)#4200
pinkenburg merged 11 commits intosPHENIX-Collaboration:masterfrom
Steepspace:sEPD-EventPlaneInfo

Conversation

@Steepspace
Copy link
Copy Markdown
Contributor

@Steepspace Steepspace commented Feb 27, 2026

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work for users)
  • Requiring change in macros repository (Please provide links to the macros pull request in the last section)
  • I am a member of GitHub organization of sPHENIX Collaboration, EIC, or ECCE (contact Chris Pinkenburg to join)

What kind of change does this PR introduce? (Bug fix, feature, ...)

  • Adjust the calibration to be applied on 1% centrality basis (previously 10%)
  • Replace the old EventPlaneReco module with the new EventPlaneRecov2 module

Links to other PRs in macros and calibration repositories (if applicable)

sPHENIX-Collaboration/macros#1306

sEPD Event Plane Calibration - Application (Cleanup)

Motivation and Context

This PR refactors the event plane calibration infrastructure for the sPHENIX sEPD (small Electromagnetic Pad Detector) by consolidating and modernizing the calibration and reconstruction modules. The primary motivation is to apply event-plane calibration on significantly finer centrality granularity (80 bins, ~1% per bin, instead of 10% bins) and to replace legacy EventPlaneCalibration and EventPlaneRecov2 modules with a unified, production-ready EventPlaneReco module.

Key Changes

Module Consolidation:

  • Removed EventPlaneCalibration class (840 lines) – legacy calibration wrapper
  • Removed EventPlaneRecov2 class (637 implementation + 134 header lines) – intermediate development version
  • Refactored EventPlaneReco as the unified production module with comprehensive per-harmonic, per-centrality calibration support (net +109 lines with substantial architectural enhancements)

Calibration System Modernization:

  • Introduced per-harmonic (n=2,3,4) and per-centrality (80 bins) calibration pathways via CDBTTree
  • Calibration data loading via LoadCalib() with support for direct URL override or default calibration directory fallback
  • Integrated hard dependency on CentralityInfo node for runtime centrality determination
  • Per-harmonic, per-subdetector (South/North/North-South) Q-vector correction matrices (2×2 flattening)

Data Processing Pipeline:

  • Implemented per-harmonic Q-vector calculations from sEPD TowerInfoContainer data (744 channels)
  • Added per-event recentering and flattening via calculate_flattening_matrix() with per-harmonic/per-centrality correction data
  • Enhanced sEPD channel processing with configurable minimum charge cuts (set_sepd_min_channel_charge()) and hot-channel detection
  • Trigonometric cache pre-computation for efficiency across all 744 SEPD channels
  • Separate track of raw, recentered, and flattened Q-vectors for diagnostics

Data Structure Improvements:

  • Eventplaneinfo base class: parameter signatures changed from by-value to const-reference (avoid unnecessary copies); added protected Rule of Five for safe derived-class copy/move semantics
  • Eventplaneinfov1 and Eventplaneinfov2: now support defaulted copy/move semantics
  • EventplaneinfoMapv1: explicitly prohibits copying/moving to prevent shallow-copy vulnerabilities
  • EventplaneinfoMap: modernized with protected Rule of Five for derived-class safety

API and Lifecycle Changes:

  • Separated Init() and InitRun() for cleaner initialization and geometry setup
  • Replaced legacy End() with per-event ResetEvent() for explicit state cleanup
  • New public configuration setters: set_inputNode(), set_directURL_EventPlaneCalib(), set_doAbortNoEventPlaneCalib(), set_sepd_min_channel_charge(), set_EventPlaneInfoNodeName()
  • Removed legacy setters for old sEPD/MBD configuration flags
  • Deleted copy/move constructors and assignment operators to enforce clear ownership semantics

Build System:

  • Updated Makefile.am to export EventPlaneReco.h instead of EventPlaneCalibration.h and EventPlaneRecov2.h
  • Removed Eventplaneinfov2 from public exports (now internal only)
  • Removed unnecessary <iterator> include from EventplaneinfoMapv1.cc

Potential Risk Areas

Reconstruction Behavior Changes:

  • Event plane angles (psi_n) are now computed from 80-bin, per-harmonic calibrated Q-vectors; physics results will differ noticeably from previous versions
  • Null events or missing CentralityInfo cause early returns or abort (controlled by set_doAbortNoEventPlaneCalib()); event-by-event calibration validity strictly enforced
  • Missing EPD geometry or TowerInfoContainer nodes result in silent returns; error handling should be verified

IO Format and Compatibility:

  • Eventplaneinfo setter signatures changed to const-reference; downstream code passing temporary objects may trigger compiler warnings or require adjustment
  • Calibration data (CDBTTree) naming convention changed; existing calibration files are incompatible with new code – new calibration files must be generated before production use
  • New private CorrectionData and QVec structures maintain calibration state; output node schema may differ

Dependencies and Integration:

  • Hard dependency on CentralityInfo node availability; events without valid centrality determination are skipped/aborted
  • Assumes TowerInfoContainer for sEPD channel data; detector name must match set_inputNode() configuration
  • Matching updates required in macros repository (PR: macros/1306); running old analysis macros with new code will fail due to changed API and calibration requirements
  • No backward compatibility with previous calibration or configuration flags

Data Member Access:

  • Many previously public data members moved to private scope (m_cent, m_globalEvent, correction matrices, Q-vectors); external code relying on direct member access will break
  • Centrality and event state accessible only through internal workflow; no public accessors for intermediate calibration states

Thread Safety:

  • Static and global calibration state (m_cdbttree, m_correction_data, m_trig_cache) shared across events; concurrent multi-threaded event processing is unsafe without external synchronization

Possible Future Improvements

  • Add optional diagnostic output (ROOT TTree, histograms) for per-event Q-vector validation and calibration quality monitoring
  • Provide public accessors for corrected Q-vectors and flattening matrices to enable downstream analysis chains
  • Extend harmonic support framework to easily include higher harmonics (n > 4)
  • Consider lazy-loading or on-demand centrality-bin calibration to reduce memory footprint during initialization
  • Decouple centrality determination from reconstruction for reusability in other event plane algorithms
  • Performance optimization for sEPD channel iteration and trigonometric cache usage in high-multiplicity events
  • Add detailed validation checks and warning messages for edge cases (low-multiplicity, out-of-acceptance channels, boundary centrality bins)

Note: This summary is generated with AI assistance. Human review is strongly recommended to verify all implications, especially regarding: (1) compatibility with existing calibration data and ROOT files, (2) validation of new 80-bin centrality mapping against physics requirements, and (3) integration with downstream analysis code that depends on event plane information.

- Ensure that calibrations are performed on 1% centrality binning (previously 10%)
- Use isHot flag is used over the isGood for the sEPD Bad Channels
  - sEPD Channels don't use the isBadChi2 check that's part of the isGood check (only the isHot which covers the basic dead/hot/cold cases)
- Use consistent naming convention as that for QVecCalib module in the `sepd_eventplanecalib` package
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 27, 2026

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

This PR removes two legacy event plane reconstruction subsystems (EventPlaneCalibration and EventPlaneRecov2), consolidates their functionality into a restructured EventPlaneReco implementation, and updates data container interfaces throughout the eventplaneinfo package to use const references for parameter passing and apply the Rule of Five for copy/move semantics.

Changes

Cohort / File(s) Summary
Removed legacy subsystems
EventPlaneCalibration.cc, EventPlaneCalibration.h, EventPlaneRecov2.cc, EventPlaneRecov2.h
Complete removal of EventPlaneCalibration and EventPlaneRecov2 classes and implementations (1,732 total lines deleted). These subsystems previously handled event plane calculations, histogram management, and calibration workflows.
Restructured core subsystem
EventPlaneReco.cc, EventPlaneReco.h
Major refactoring of EventPlaneReco: introduces CentralityInfo integration, per-harmonic and per-centrality calibration architecture, new lifecycle methods (Init, InitRun, LoadCalib), flattening matrix calculations, improved Q-vector handling with recentering logic, and modularized per-event processing (process_sEPD, process_centrality). Replaces End with ResetEvent. Public interface modernized with new setters and copy/move deletion.
Interface modernization
Eventplaneinfo.h, Eventplaneinfov1.h, Eventplaneinfov2.h
Updated setter parameters to use const references for vector types (qvector, shifted_psi, ring_qvector). Added/defaulted copy/move constructors and assignment operators per Rule of Five.
Container interface updates
EventplaneinfoMap.h, EventplaneinfoMapv1.h
Replaced typedefs with using aliases; defaulted constructors and destructors. EventplaneinfoMapv1 explicitly deletes copy/move operations to prevent unintended copying.
Build configuration update
Makefile.am
Updated pkginclude_HEADERS exports: removed EventPlaneCalibration.h, Eventplaneinfov2.h, EventPlaneRecov2.h; added EventPlaneReco.h. Reflects consolidation of public interfaces.
Minor cleanup
EventplaneinfoMapv1.cc
Removed unused <iterator> include.

Possibly related PRs

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

- Remove EventPlaneCalibration (old approach)
@sphenix-jenkins-ci
Copy link
Copy Markdown

Build & test report

Report for commit f00f62ae243e3e6557479222560893767caf5d9f:
Jenkins on fire


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@sphenix-jenkins-ci
Copy link
Copy Markdown

Build & test report

Report for commit afb23ff00a611f9333353ddf0a0780a25fa994eb:
Jenkins passed


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@sphenix-jenkins-ci
Copy link
Copy Markdown

Build & test report

Report for commit c219232c526ca4d1fc38aaaa335d80d27dbfdbf7:
Jenkins on fire


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@sphenix-jenkins-ci
Copy link
Copy Markdown

Build & test report

Report for commit adbdacfb4cf21c6c3ce81cc154bc827d68466380:
Jenkins on fire


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@sphenix-jenkins-ci
Copy link
Copy Markdown

Build & test report

Report for commit f555f0a4d2fc8d2b93f73e4e8bccb513eb4491c2:
Jenkins on fire


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@Steepspace Steepspace marked this pull request as ready for review March 1, 2026 00:36
Copilot AI review requested due to automatic review settings March 1, 2026 00:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR consolidates the sEPD event plane calibration application from two separate modules (EventPlaneCalibration + EventPlaneRecov2) into a single updated EventPlaneReco module. It adjusts the calibration from a 10% centrality basis to a 1% basis (80 bins covering 0–80%), and removes now-obsolete classes (EventPlaneCalibration, EventPlaneRecov2, Eventplaneinfov2).

Changes:

  • Remove EventPlaneCalibration, EventPlaneRecov2, and Eventplaneinfov2 classes; port their logic into EventPlaneReco, which becomes the single calibration+reconstruction module
  • Upgrade Eventplaneinfov1 to absorb functionality from Eventplaneinfov2 (adding mQvec_raw, mQvec_recentered members, safer bounds-checked accessors, and full Rule-of-Five declarations); add a trig cache in EventPlaneReco for performance
  • Modernize base class housekeeping (Eventplaneinfo, EventplaneinfoMap, EventplaneinfoMapv1): use = default destructors, using aliases, and explicit Rule-of-Five

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
offline/packages/eventplaneinfo/Makefile.am Removes deleted files from build, keeps only EventPlaneReco
offline/packages/eventplaneinfo/EventPlaneCalibration.h/.cc Deleted (old calibration class)
offline/packages/eventplaneinfo/EventPlaneRecov2.h/.cc Deleted (old reco+calibration class)
offline/packages/eventplaneinfo/Eventplaneinfov2.h/.cc/.LinkDef.h Deleted (old info class)
offline/packages/eventplaneinfo/EventPlaneReco.h/.cc Major rewrite: now handles centrality-aware Q-vector calibration with 1% bins and trig cache
offline/packages/eventplaneinfo/Eventplaneinfov1.h/.cc Extended with raw/recentered Q-vector storage, safe accessors, and Rule-of-Five
offline/packages/eventplaneinfo/Eventplaneinfo.h Modernized: = default dtor, const& parameters, Rule-of-Five
offline/packages/eventplaneinfo/EventplaneinfoMap.h Modernized: using aliases, = default dtor, Rule-of-Five
offline/packages/eventplaneinfo/EventplaneinfoMapv1.h Added explicit deleted copy/move (Rule-of-Five)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread offline/packages/eventplaneinfo/EventPlaneReco.cc
Comment thread offline/packages/eventplaneinfo/EventPlaneReco.cc Outdated
Comment thread offline/packages/eventplaneinfo/EventPlaneReco.cc
Comment thread offline/packages/eventplaneinfo/EventPlaneReco.cc Outdated
Comment thread offline/packages/eventplaneinfo/Eventplaneinfov1.h
bool m_doNotCalibEvent{false};

double m_cent{0.0};
double m_globalEvent{0};
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

The m_globalEvent member is declared as double but used to hold the event sequence number (an integer). The get_EvtSequence() return type is typically an integer type. Using double for this counter may lose precision for large event sequence numbers. It should be declared as an appropriate integer type (e.g., int64_t or uint64_t).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
offline/packages/eventplaneinfo/EventPlaneReco.cc (1)

179-214: Add explicit reprocessing/migration guidance for this output change.

These lines materially change calibration application and persisted event-plane payloads. Please state whether existing productions must be reprocessed and what analysis-level shifts are expected to prevent mixing incompatible outputs.

Based on learnings: If the PR changes reconstruction outputs, calibration constants, or simulation behavior, ensure the description states expected analysis impact and whether reprocessing is required.

Also applies to: 527-603


ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3312c7a and f555f0a.

📒 Files selected for processing (15)
  • offline/packages/eventplaneinfo/EventPlaneCalibration.cc
  • offline/packages/eventplaneinfo/EventPlaneCalibration.h
  • offline/packages/eventplaneinfo/EventPlaneReco.cc
  • offline/packages/eventplaneinfo/EventPlaneReco.h
  • offline/packages/eventplaneinfo/EventPlaneRecov2.cc
  • offline/packages/eventplaneinfo/EventPlaneRecov2.h
  • offline/packages/eventplaneinfo/Eventplaneinfo.h
  • offline/packages/eventplaneinfo/EventplaneinfoMap.h
  • offline/packages/eventplaneinfo/EventplaneinfoMapv1.h
  • offline/packages/eventplaneinfo/Eventplaneinfov1.cc
  • offline/packages/eventplaneinfo/Eventplaneinfov1.h
  • offline/packages/eventplaneinfo/Eventplaneinfov2.cc
  • offline/packages/eventplaneinfo/Eventplaneinfov2.h
  • offline/packages/eventplaneinfo/Eventplaneinfov2LinkDef.h
  • offline/packages/eventplaneinfo/Makefile.am
💤 Files with no reviewable changes (7)
  • offline/packages/eventplaneinfo/Eventplaneinfov2.cc
  • offline/packages/eventplaneinfo/EventPlaneRecov2.cc
  • offline/packages/eventplaneinfo/Eventplaneinfov2LinkDef.h
  • offline/packages/eventplaneinfo/EventPlaneCalibration.cc
  • offline/packages/eventplaneinfo/Eventplaneinfov2.h
  • offline/packages/eventplaneinfo/EventPlaneCalibration.h
  • offline/packages/eventplaneinfo/EventPlaneRecov2.h

Comment thread offline/packages/eventplaneinfo/EventPlaneReco.cc
Comment thread offline/packages/eventplaneinfo/EventPlaneReco.cc Outdated
Comment thread offline/packages/eventplaneinfo/EventPlaneReco.cc Outdated
std::string m_calibName{"SEPD_EventPlaneCalib"};
std::string m_inputNode{"TOWERINFO_CALIB_SEPD"};

CDBTTree *m_cdbttree {nullptr};
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.

⚠️ Potential issue | 🟠 Major

Use RAII for m_cdbttree ownership.

Line 97 introduces an owning raw pointer, and its lifetime is manually managed in the .cc. This is brittle for memory safety; please switch to std::unique_ptr<CDBTTree>.

Proposed fix
--- a/offline/packages/eventplaneinfo/EventPlaneReco.h
+++ b/offline/packages/eventplaneinfo/EventPlaneReco.h
@@
-  CDBTTree *m_cdbttree {nullptr};
+  std::unique_ptr<CDBTTree> m_cdbttree;
--- a/offline/packages/eventplaneinfo/EventPlaneReco.cc
+++ b/offline/packages/eventplaneinfo/EventPlaneReco.cc
@@
-    m_cdbttree = new CDBTTree(m_directURL_EventPlaneCalib);
+    m_cdbttree = std::make_unique<CDBTTree>(m_directURL_EventPlaneCalib);
@@
-    m_cdbttree = new CDBTTree(calibdir);
+    m_cdbttree = std::make_unique<CDBTTree>(calibdir);
@@
-  delete m_cdbttree;
-  m_cdbttree = nullptr;
+  m_cdbttree.reset();

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3


ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f555f0a and 7a8c072.

📒 Files selected for processing (4)
  • offline/packages/eventplaneinfo/EventPlaneReco.cc
  • offline/packages/eventplaneinfo/EventPlaneReco.h
  • offline/packages/eventplaneinfo/EventplaneinfoMapv1.cc
  • offline/packages/eventplaneinfo/Eventplaneinfov1.h
💤 Files with no reviewable changes (1)
  • offline/packages/eventplaneinfo/EventplaneinfoMapv1.cc

Comment thread offline/packages/eventplaneinfo/Eventplaneinfov1.h
Comment on lines 75 to 79
std::vector<std::pair<double, double>> mQvec_raw;
std::vector<std::pair<double, double>> mQvec_recentered;
std::vector<double> mPsi_Shifted;
std::vector<std::vector<std::pair<double, double>>> ring_Qvec;
ClassDefOverride(Eventplaneinfov1, 1);
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.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find the header file
hdr="$(fd Eventplaneinfov1.h | head -n1)"
if [[ -z "$hdr" ]]; then
  echo "ERROR: Eventplaneinfov1.h not found"
  exit 1
fi

echo "=== Current state of: $hdr ==="
cat -n "$hdr" | sed -n '70,85p'

echo
echo "=== Checking git history for these members ==="
git log --oneline "$hdr" | head -10

echo
echo "=== Checking if members existed in previous commit ==="
git show HEAD~1:"$hdr" 2>/dev/null | grep -n -E "mQvec_raw|mQvec_recentered|ClassDefOverride" || echo "(Members not found in previous version)"

echo
echo "=== Checking current commit for these members ==="
git show HEAD:"$hdr" 2>/dev/null | grep -n -E "mQvec_raw|mQvec_recentered|ClassDefOverride" || grep -n -E "mQvec_raw|mQvec_recentered|ClassDefOverride" "$hdr"

Repository: sPHENIX-Collaboration/coresoftware

Length of output: 1448


🏁 Script executed:

#!/bin/bash
# Check if this file was modified in the current commit
echo "=== Checking file status in current change ==="
git diff --name-only HEAD | grep -i eventplaneinfo || echo "File not in current staged changes"

echo
echo "=== Looking for all versions of ClassDefOverride in history ==="
git log -p --all -- "*Eventplaneinfov1.h" 2>/dev/null | grep -B2 -A2 "ClassDefOverride" | head -40 || echo "No history found"

Repository: sPHENIX-Collaboration/coresoftware

Length of output: 224


Bump ROOT class version after adding persistent members.

mQvec_raw and mQvec_recentered are new data members introduced in this commit, but the ROOT class version remains 1 at line 79. ROOT requires the version to be incremented whenever persistent members are added, otherwise existing serialized objects will fail to deserialize correctly with the new schema.

Proposed fix
-  ClassDefOverride(Eventplaneinfov1, 1);
+  ClassDefOverride(Eventplaneinfov1, 2);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
std::vector<std::pair<double, double>> mQvec_raw;
std::vector<std::pair<double, double>> mQvec_recentered;
std::vector<double> mPsi_Shifted;
std::vector<std::vector<std::pair<double, double>>> ring_Qvec;
ClassDefOverride(Eventplaneinfov1, 1);
std::vector<std::pair<double, double>> mQvec_raw;
std::vector<std::pair<double, double>> mQvec_recentered;
std::vector<double> mPsi_Shifted;
std::vector<std::vector<std::pair<double, double>>> ring_Qvec;
ClassDefOverride(Eventplaneinfov1, 2);

Comment thread offline/packages/eventplaneinfo/EventPlaneReco.cc
@sphenix-jenkins-ci
Copy link
Copy Markdown

Build & test report

Report for commit 7a8c072bc56fd4df97e174c0d7a37d7da75607cc:
Jenkins on fire


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7a8c072 and ba39831.

📒 Files selected for processing (1)
  • offline/packages/eventplaneinfo/EventPlaneReco.cc

Comment thread offline/packages/eventplaneinfo/EventPlaneReco.cc
@sphenix-jenkins-ci
Copy link
Copy Markdown

Build & test report

Report for commit ba39831a8890c245034a68a92c14a964740a5bfe:
Jenkins on fire


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (3)
offline/packages/eventplaneinfo/EventPlaneReco.h (1)

102-102: ⚠️ Potential issue | 🟠 Major

Use RAII for calibration-tree ownership.

This still uses an owning raw pointer, with manual lifetime management in the .cc, which is brittle for memory safety and error paths.

Proposed fix
--- a/offline/packages/eventplaneinfo/EventPlaneReco.h
+++ b/offline/packages/eventplaneinfo/EventPlaneReco.h
@@
 `#include` <string>
 `#include` <array>
 `#include` <vector>
+#include <memory>
@@
-  CDBTTree *m_cdbttree {nullptr};
+  std::unique_ptr<CDBTTree> m_cdbttree;
--- a/offline/packages/eventplaneinfo/EventPlaneReco.cc
+++ b/offline/packages/eventplaneinfo/EventPlaneReco.cc
@@
-    m_cdbttree = new CDBTTree(m_directURL_EventPlaneCalib);
+    m_cdbttree = std::make_unique<CDBTTree>(m_directURL_EventPlaneCalib);
@@
-    m_cdbttree = new CDBTTree(calibdir);
+    m_cdbttree = std::make_unique<CDBTTree>(calibdir);
@@
-  delete m_cdbttree;
-  m_cdbttree = nullptr;
+  m_cdbttree.reset();

As per coding guidelines **/*.{h,hpp,hxx,hh}: “Focus on API clarity/stability, ownership semantics (RAII), and avoiding raw new/delete.”

offline/packages/eventplaneinfo/EventPlaneReco.cc (2)

31-32: ⚠️ Potential issue | 🟠 Major

Ensure eventplaneinfo is explicitly built with C++20 (or remove C++20-only APIs).

std::format and std::ranges::max_element are C++20-only. If this package is compiled under an older default standard, this change will fail to build.

#!/bin/bash
set -euo pipefail

echo "== Build-standard settings relevant to eventplaneinfo =="
fd -HI 'configure.ac|Makefile.am|CMakeLists.txt|*.cmake' offline/packages/eventplaneinfo \
  | xargs -r rg -n 'CMAKE_CXX_STANDARD|cxx_std_[0-9]+|std=c\+\+'

echo
echo "== C++20 APIs used in EventPlaneReco =="
rg -n '\bstd::format\s*\(|\bstd::ranges::max_element\s*\(' \
  offline/packages/eventplaneinfo/EventPlaneReco.cc offline/packages/eventplaneinfo/EventPlaneReco.h

Expected: configuration explicitly enables C++20 for this package; otherwise replace these calls with C++17-compatible alternatives.

Also applies to: 547-547


571-593: ⚠️ Potential issue | 🟠 Major

Do not write zeroed recentered Q-vectors when calibration is skipped.

When m_doNotCalib or m_doNotCalibEvent is true, recentering is not performed, but qvector_recentered is still filled from m_Q_recentered (reset to zeros). That makes missing recentering look like a physical (0,0) result.

Proposed fix
-    const auto& Q_S_recentered = m_Q_recentered[h_idx][0];
+    const auto& Q_S_recentered = (m_doNotCalib || m_doNotCalibEvent) ? m_Q_raw[h_idx][0] : m_Q_recentered[h_idx][0];

-    const auto& Q_N_recentered = m_Q_recentered[h_idx][1];
+    const auto& Q_N_recentered = (m_doNotCalib || m_doNotCalibEvent) ? m_Q_raw[h_idx][1] : m_Q_recentered[h_idx][1];

-    const auto& Q_NS_recentered = m_Q_recentered[h_idx][2];
+    const auto& Q_NS_recentered = (m_doNotCalib || m_doNotCalibEvent) ? m_Q_raw[h_idx][2] : m_Q_recentered[h_idx][2];

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ba39831 and 33c91f3.

📒 Files selected for processing (2)
  • offline/packages/eventplaneinfo/EventPlaneReco.cc
  • offline/packages/eventplaneinfo/EventPlaneReco.h

Comment thread offline/packages/eventplaneinfo/EventPlaneReco.h
@sphenix-jenkins-ci
Copy link
Copy Markdown

Build & test report

Report for commit 33c91f38936dc97e301a32ced63c06bf2cd9c5c8:
Jenkins on fire


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@Steepspace Steepspace marked this pull request as draft March 3, 2026 20:22
* Pre-calculate cos(n*phi) and sin(n*phi) values during InitRun
* Store cached values in a nested vector indexed by harmonic and channel
* Replace per-tower std::cos and std::sin calls in process_sEPD with cache lookups
* Significant reduction in CPU overhead per event
- cleanup unused includes and redundant forward declarations
- Peripheral events (≥80% centrality) silently use bin 79 calibration data.
- Setting m_doNotCalibEvent = true for out-of-range centrality and storing raw Q-vectors
- Ensure channel count does not exceed trig-cache size
- Prevent potential out-of-bounds read
- Keep the default output node name unchanged ("EventplaneinfoMap")
- Allow adjusting of the output node name if needed
- Address the following existing clang-tidy warnings:
  - [hicpp-special-member-functions]
  - [hicpp-use-equals-default]
  - [modernize-use-equals-default]
  - [performance-unnecessary-value-param]
  - [modernize-use-using]
  - [readability-avoid-const-params-in-decls]
@Steepspace Steepspace force-pushed the sEPD-EventPlaneInfo branch from 33c91f3 to 8820137 Compare March 3, 2026 21:03
@sphenix-jenkins-ci
Copy link
Copy Markdown

Build & test report

Report for commit 88201372242a36404a8d4d3330870f65fee09afe:
Jenkins on fire


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@Steepspace Steepspace marked this pull request as ready for review March 8, 2026 19:31
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
offline/packages/eventplaneinfo/EventPlaneReco.h (1)

18-71: ⚠️ Potential issue | 🟠 Major

Document whether this output break requires full reprocessing.

This module now changes the reconstruction path and the event-plane output, but the PR text only calls out the downstream macro update. Please state explicitly whether old productions/DSTs can be mixed with the new 1% calibration output or whether they must be regenerated.

As per coding guidelines: "If interfaces change, ask for compatibility notes and any needed downstream updates"; based on learnings: "If the PR changes reconstruction outputs, calibration constants, or simulation behavior, ensure the description states expected analysis impact and whether reprocessing is required."

offline/packages/eventplaneinfo/EventPlaneReco.cc (1)

566-578: ⚠️ Potential issue | 🟠 Major

Apply the same fallback to qvector_recentered when calibration is skipped.

Q_S/Q_N/Q_NS already fall back to m_Q_raw in the uncalibrated path, but Q_*_recentered still come from m_Q_recentered, which ResetEvent() zero-initializes and correct_QVecs() never fills on skipped events. That writes fake recentered (0,0) vectors into DST.

Proposed fix
-    const auto& Q_S_recentered = m_Q_recentered[h_idx][0];
+    const auto& Q_S_recentered =
+        (m_doNotCalib || m_doNotCalibEvent) ? m_Q_raw[h_idx][0] : m_Q_recentered[h_idx][0];
@@
-    const auto& Q_N_recentered = m_Q_recentered[h_idx][1];
+    const auto& Q_N_recentered =
+        (m_doNotCalib || m_doNotCalibEvent) ? m_Q_raw[h_idx][1] : m_Q_recentered[h_idx][1];
@@
-    const auto& Q_NS_recentered = m_Q_recentered[h_idx][2];
+    const auto& Q_NS_recentered =
+        (m_doNotCalib || m_doNotCalibEvent) ? m_Q_raw[h_idx][2] : m_Q_recentered[h_idx][2];

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d0a37a2f-b1ae-4b4a-98f9-85dfcdb57f2f

📥 Commits

Reviewing files that changed from the base of the PR and between 33c91f3 and 8820137.

📒 Files selected for processing (8)
  • offline/packages/eventplaneinfo/EventPlaneReco.cc
  • offline/packages/eventplaneinfo/EventPlaneReco.h
  • offline/packages/eventplaneinfo/Eventplaneinfo.h
  • offline/packages/eventplaneinfo/EventplaneinfoMap.h
  • offline/packages/eventplaneinfo/EventplaneinfoMapv1.cc
  • offline/packages/eventplaneinfo/EventplaneinfoMapv1.h
  • offline/packages/eventplaneinfo/Eventplaneinfov1.h
  • offline/packages/eventplaneinfo/Eventplaneinfov2.h
💤 Files with no reviewable changes (1)
  • offline/packages/eventplaneinfo/EventplaneinfoMapv1.cc
🚧 Files skipped from review as they are similar to previous changes (1)
  • offline/packages/eventplaneinfo/Eventplaneinfov2.h

Comment on lines +382 to +395
// ensure both total charges are nonzero
if (sepd_total_charge_south == 0 || sepd_total_charge_north == 0)
{
if (Verbosity() > 1)
{
std::cout << PHWHERE << " Error: Total sEPD Charge is Zero: "
<< "South = " << sepd_total_charge_south
<< ", North = " << sepd_total_charge_north << std::endl;
}

// ensure raw Q vec is reset
m_Q_raw = {};
m_doNotCalibEvent = true;
return Fun4AllReturnCodes::EVENT_OK;
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.

⚠️ Potential issue | 🟠 Major

Do not turn zero-charge events into valid-looking raw Q-vectors.

When either arm has zero total charge, this branch zeroes m_Q_raw and returns EVENT_OK. FillNode() later serializes those zeros and derives psi from them, so an undefined event becomes a valid-looking (0,0) measurement, and a still-valid arm is discarded if only one side is empty.

Proposed fix
   if (sepd_total_charge_south == 0 || sepd_total_charge_north == 0)
   {
@@
-    // ensure raw Q vec is reset
-    m_Q_raw = {};
+    const double nan = std::numeric_limits<double>::quiet_NaN();
+    for (size_t h_idx = 0; h_idx < m_harmonics.size(); ++h_idx)
+    {
+      if (sepd_total_charge_south > 0)
+      {
+        m_Q_raw[h_idx][0].x /= sepd_total_charge_south;
+        m_Q_raw[h_idx][0].y /= sepd_total_charge_south;
+      }
+      else
+      {
+        m_Q_raw[h_idx][0] = {nan, nan};
+      }
+
+      if (sepd_total_charge_north > 0)
+      {
+        m_Q_raw[h_idx][1].x /= sepd_total_charge_north;
+        m_Q_raw[h_idx][1].y /= sepd_total_charge_north;
+      }
+      else
+      {
+        m_Q_raw[h_idx][1] = {nan, nan};
+      }
+
+      m_Q_raw[h_idx][2] = {nan, nan};
+    }
     m_doNotCalibEvent = true;
     return Fun4AllReturnCodes::EVENT_OK;
   }

- Reduce the number of static_casts by changing the type of `order` from int to unsigned int
- Improve readability
@sphenix-jenkins-ci
Copy link
Copy Markdown

Build & test report

Report for commit add82a131d1c1ee8e459990658c6928a018cc877:
Jenkins on fire


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@pinkenburg pinkenburg merged commit 523a1b0 into sPHENIX-Collaboration:master Mar 10, 2026
13 of 22 checks passed
@Steepspace Steepspace deleted the sEPD-EventPlaneInfo branch March 10, 2026 17:29
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.

3 participants