Skip to content

Comments

sEPD Event Plane Calibration - Application#4127

Draft
Steepspace wants to merge 4 commits intosPHENIX-Collaboration:masterfrom
Steepspace:sEPD-Calib
Draft

sEPD Event Plane Calibration - Application#4127
Steepspace wants to merge 4 commits intosPHENIX-Collaboration:masterfrom
Steepspace:sEPD-Calib

Conversation

@Steepspace
Copy link
Contributor

@Steepspace Steepspace commented Jan 20, 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, ...)

Introduces a new sEPD event plane reconstruction module (v2) and an expanded info container (v2) to support a full calibration chain including recentering and flattening.

Eventplaneinfov2:

  • Inherits from Eventplaneinfo.
  • Adds dedicated storage for raw, recentered, and final (flattened) Q-vectors.
  • Provides getters/setters for extended Q-vector stages to allow for systematic studies of calibration effects.

EventPlaneRecov2:

  • New SubsysReco module specifically for sEPD Q-vector calibration.
  • Implements a multi-step calibration workflow:
    1. Raw Q-vector calculation from sEPD channel charges and geometry.
    2. Recentering: Subtracts offsets per centrality bin.
    3. Flattening: Applies a 2x2 correction matrix calculated from Q-vector variances (Qxx, Qyy, Qxy).
  • Features integration with CDBTTree to load calibration parameters dynamically via the Calibration Database.
  • Processes harmonics n=2,3, and 4 for South, North, and Combined (NS) subdetectors.
  • Automatically handles centrality-based binning (8 bins) for calibrations.
  • Populates EventplaneinfoMap with Eventplaneinfov2 objects for downstream analysis.
  • Includes diagnostic verbosity levels for inspecting calibration matrices and per-event vector transformations.

Presentations:

TODOs (if applicable)

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

sEPD Q Vector Calibration Generation: #4106
sEPD Q Vector Calibration Generation (macros): sPHENIX-Collaboration/macros#1270

sEPD Event Plane Calibration – Application (PR #4127)

Motivation & Context

This PR delivers an application-layer implementation for sEPD event-plane calibration to support a full Q‑vector calibration chain (raw → recentered → flattened) and to provide calibrated event‑plane outputs for downstream consumers. Motivation and context:

  • Replace the TProfile-based calibration storage with a compact CDBTTree format to reduce storage and simplify calibration I/O.
  • Introduce centrality-dependent calibrations (8 bins) missing from the prior EventPlaneReco.
  • Operate directly on Q‑vectors including second‑order flattening (2×2 correction matrices) to enable more accurate event‑plane extraction.
  • Ship as a v2 module (EventPlaneRecov2 / Eventplaneinfov2) rather than overwrite existing code to avoid breaking current users; EventPlaneRecov2 is intended as the replacement path.

Key Changes

  • New data type: Eventplaneinfov2

    • Derived from Eventplaneinfo; stores raw, recentered, and final (flattened) Q‑vectors plus shifted‑psi values and ring Q‑vector accessors to enable systematic studies.
    • Adds virtual accessors to the base interface for raw/recentered Q‑vectors.
  • New reconstruction module: EventPlaneRecov2 (SubsysReco)

    • Complete workflow: compute raw Q‑vectors from sEPD charges and geometry → recenter per‑centrality-bin offsets → flatten using precomputed 2×2 matrices.
    • Processes harmonics n = 2, 3, 4 for South, North, and Combined (NS) subdetectors.
    • Uses 8 centrality bins; loads calibration parameters from CDBTTree in the Calibration DB.
    • Populates EventplaneinfoMap with Eventplaneinfov2 objects (raw, recentered, flattened) and computes shifted psi values.
    • Diagnostic verbosity to print calibration matrices and per‑event Q‑vector transformations.
  • Build and infra updates

    • Added headers/sources/dictionary entries (Eventplaneinfov2, EventPlaneRecov2) and updated Makefile.am to include new artifacts.
    • CaloTowerStatus: hot-map calibration selection extended to include SEPD alongside CEMC.
  • Safety/bugfix commits

    • Guards added for empty calibration URL, divide‑by‑zero when order == 0, bounds checks for Q‑vector indexing, and removal of unused state.

Potential Risk Areas

  • IO / On‑disk format: Calibrations now use CDBTTree; consumers and calibration tooling must handle this format. Calibration file availability and correctness are critical.
  • Reconstruction behavior changes: EventPlaneRecov2 changes the event‑plane extraction chain and centrality dependence; physics comparisons with previousReco needed to characterize systematic shifts.
  • Downstream compatibility: EventplaneinfoMap entries now use Eventplaneinfov2 objects and new virtual methods — downstream code that assumes the old layout may require updates.
  • Numerical stability: Flattening matrix inversion and determinant checks include guards, but extreme Q‑vector conditions may still cause instabilities; pay attention to zero/near‑zero charge events.
  • Thread‑safety / concurrency: SubsysReco state and calibration containers appear per‑instance, but multi‑threaded execution or shared calibration object usage should be validated.
  • Performance: Per‑event Q‑vector math and centrality lookups are lightweight, but throughput impact should be validated on full workflows.
  • Failure modes: Config flags can abort or skip when calibrations are missing; behavior depends on configuration and must be verified in batch workflows.

Possible Future Improvements

  • Add unit tests for flattening matrix computation and edge cases (zero charge, singular matrices).
  • Provide commissioning/validation plots (calibration matrices, before/after Q‑vector distributions by centrality) and CI comparisons vs. legacy EventPlaneReco.
  • Make calibration parameters (harmonics, centrality bins, thresholds) configurable at runtime (e.g., via job options).
  • Add documentation describing expected CDBTTree calibration format and migration guidance for existing workflows.
  • Consider optimized linear algebra/path for high-rate processing if profiling shows hotspots.
  • Plan migration strategy and compatibility shims for downstream packages that depend on the previous EventPlaneReco layout.

Note: AI-generated summaries can contain mistakes. Reviewers should inspect the code (Q‑vector math, calibration loading, and node population) and validate results with real calibration data before adoption.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 20, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds EventPlaneRecov2 subsystem and Eventplaneinfov2 container for event-plane calibration and Q‑vector corrections across harmonics and subdetectors; extends Eventplaneinfo with raw/recentered accessors; includes SEPD in CaloTowerStatus hot-map selection; updates build to expose new headers/sources.

Changes

Cohort / File(s) Summary
Calorimeter Calibration
offline/packages/CaloReco/CaloTowerStatus.cc
Expanded hot-map calibration condition to include SEPD alongside CEMC when selecting BadTowerMap.
Event Plane Recovery Subsystem
offline/packages/eventplaneinfo/EventPlaneRecov2.h, offline/packages/eventplaneinfo/EventPlaneRecov2.cc
New SubsysReco component implementing calibration loading, centrality handling, sEPD tower processing, Q‑vector accumulation (raw), recentring and flattening (per-harmonic, per-centrality), and DST node population.
Event Plane Info Interface
offline/packages/eventplaneinfo/Eventplaneinfo.h
Added four virtual methods: set_qvector_raw(), set_qvector_recentered(), get_qvector_raw(), get_qvector_recentered().
Event Plane Info v2 Implementation
offline/packages/eventplaneinfo/Eventplaneinfov2.h, offline/packages/eventplaneinfo/Eventplaneinfov2.cc, offline/packages/eventplaneinfo/Eventplaneinfov2LinkDef.h
New Eventplaneinfov2 class: stores standard/raw/recentered Q‑vectors, shifted psi, ring Q‑vectors; implements identify() and GetPsi(); provides ROOT dictionary entry.
Build Configuration
offline/packages/eventplaneinfo/Makefile.am
Updated to install and build new headers/sources and to generate ROOT dictionaries for v2 and Recov2 artifacts.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Recov as EventPlaneRecov2
    participant CDB as CDB/Calib
    participant EH as EventHeader
    participant SEPD as SEPD Towers
    participant Cent as Centrality
    participant DST as DST/Nodes

    Client->>Recov: Init(topNode)
    Recov->>CDB: Load calibration (direct URL or calib dir)
    CDB-->>Recov: CorrectionData (avg/Q-matrix per harmonic/cent)
    Recov->>Recov: LoadCalib() (store matrices)

    Client->>Recov: process_event(topNode)
    Recov->>EH: Read global event index
    Recov->>Cent: Read CentralityInfo
    Cent-->>Recov: cent_bin

    Recov->>SEPD: process_sEPD() (accumulate per-tower charge)
    SEPD-->>Recov: Q_raw (S, N)
    Recov->>Recov: correct_QVecs() (recenter then flatten using X-matrices)

    Recov->>DST: FillNode(topNode) (create/insert EventplaneinfoMap entries)
    DST-->>Recov: confirmation

    Client->>Recov: ResetEvent(topNode)
    Recov->>Recov: clear per-event Q-vector state
Loading

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.

@sphenix-jenkins-ci
Copy link

Build & test report

Report for commit eb122648a02f13af194f74a9af44e64934e2ea02:
Jenkins passed


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@pinkenburg
Copy link
Contributor

There will be more comments but why do you add a version 2 of the reconstruction class? As far as I know this here is a replacement - is there any point in running the old version?

@Steepspace
Copy link
Contributor Author

There will be more comments but why do you add a version 2 of the reconstruction class? As far as I know this here is a replacement - is there any point in running the old version?

Hi Chris, yes this will be a replacement for the EventPlaneReco module as there are a few key differences:

  • The calibrations are stored more compactly in CDBTTree format vs the old approach that stored the many TProfile histograms that took up lots of space.
  • The calibrations are now centrality dependent whereas before they were not.
  • The calibration acts directly on the Q Vectors (especially the second order correction (flattening)).

I did not want to just outright delete and replace the contents of EventPlaneReco in case that would cause breakages downstream for any existing code that uses the EventPlaneReco module.

@sphenix-jenkins-ci
Copy link

Build & test report

Report for commit 760d32daa74846e600de6a512c93824da8d4f684:
Jenkins on fire

Build & test report

Report for commit 561e967652518788cb59cd7b23a726994d5bef0e:
Jenkins on fire

Build & test report

Report for commit 3fa48da17176b340a61716e6a0ab2aa69ea4894d:
Jenkins on fire

Build & test report

Report for commit 9ec298fb7d3b94a243e8056445b7879d11f58659:
Jenkins on fire

Build & test report

Report for commit 18c5a2c56900618bcf9798bb091f064b628994a4:
Jenkins on fire

Build & test report

Report for commit f704495167ff5a179e3b400f49850351b7084714:
Jenkins passed


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@sphenix-jenkins-ci
Copy link

Build & test report

Report for commit 1e206178d882a77d662fe8517b6f9901b826eab1:
Jenkins on fire


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@Steepspace Steepspace marked this pull request as ready for review January 30, 2026 19:04
Copilot AI review requested due to automatic review settings January 30, 2026 19:04
Copy link

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 adds an sEPD-specific event-plane reconstruction and calibration application, wiring it to the new CDB-based Q-vector calibration payloads and extending the event-plane info container to hold multiple calibration stages.

Changes:

  • Introduces Eventplaneinfov2, extending the event-plane info interface to hold raw, recentered, and final (flattened) Q-vectors and derived angles.
  • Adds EventPlaneRecov2, a SubsysReco module that computes sEPD Q-vectors for harmonics 2–4, applies centrality-binned recentering and 2×2 flattening matrices from CDBTTree, and fills the EventplaneinfoMap with Eventplaneinfov2 nodes.
  • Extends CaloTowerStatus handling so SEPD uses the _BadTowerMap convention for hot/bad channel maps, aligning sEPD operations with CEMC.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
offline/packages/eventplaneinfo/Makefile.am Registers Eventplaneinfov2 and EventPlaneRecov2 headers, implementations, and ROOT dictionaries with the build, so the new container and module are compiled and available.
offline/packages/eventplaneinfo/Eventplaneinfov2LinkDef.h Adds ROOT CINT dictionary directives for Eventplaneinfov2, enabling persistence and I/O via ROOT.
offline/packages/eventplaneinfo/Eventplaneinfov2.h Defines Eventplaneinfov2 as a subclass of Eventplaneinfo, adding storage and accessors for raw, recentered, and flattened Q-vectors, plus ring-resolved Q-vectors and psi accessors.
offline/packages/eventplaneinfo/Eventplaneinfov2.cc Implements identify and a concrete GetPsi method (handling the Q=(0,0) case with NaN), providing core angle computation for the new container.
offline/packages/eventplaneinfo/Eventplaneinfo.h Extends the base interface to include virtual hooks for raw and recentered Q-vectors, so downstream code can use these in a type-agnostic way via Eventplaneinfo*.
offline/packages/eventplaneinfo/EventPlaneRecov2.h Declares the new EventPlaneRecov2 SubsysReco module, including configuration knobs, CDBTTree handle, correction-data structures, and internal Q-vector state for harmonics 2–4 across S/N/NS.
offline/packages/eventplaneinfo/EventPlaneRecov2.cc Implements the sEPD event-plane reconstruction pipeline: loads per-harmonic, per-centrality recentering and flattening data from CDB, computes charge-weighted Q-vectors from TOWERINFO_CALIB_SEPD, applies recentering and 2×2 matrix flattening, and populates EventplaneinfoMap with Eventplaneinfov2 records for sEPDS, sEPDN, and sEPDNS (including raw and recentered vectors).
offline/packages/eventplaneinfo/Eventplaneinfo.cc (unchanged content, but used by new code) Existing implementation remains the common base; new v2 class plugs into this hierarchy without altering behavior of v1 users.
offline/packages/CaloReco/CaloTowerStatus.cc Adjusts hot-map calibration name selection so SEPD uses the same _BadTowerMap naming convention as CEMC, allowing SEPD bad tower maps produced by the calibration pipeline to be picked up automatically.

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

Copy link
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: 5

@Steepspace Steepspace marked this pull request as draft January 30, 2026 19:18
@Steepspace
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 1, 2026

✅ Actions performed

Review triggered.

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.

@sphenix-jenkins-ci
Copy link

Build & test report

Report for commit 67ab2c156e2c3998324091661011e038f35cb04c:
Jenkins on fire


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

Introduces a new sEPD event plane reconstruction module (v2) and an expanded info container (v2) to support a full calibration chain including recentering and flattening.

Eventplaneinfov2:
- Inherits from Eventplaneinfo.
- Adds dedicated storage for raw, recentered, and final (flattened) Q-vectors.
- Provides getters/setters for extended Q-vector stages to allow for systematic studies of calibration effects.

EventPlaneRecov2:
- New SubsysReco module specifically for sEPD Q-vector calibration.
- Implements a multi-step calibration workflow:
    1. Raw Q-vector calculation from sEPD channel charges and geometry.
    2. Recentering: Subtracts <Q> offsets per centrality bin.
    3. Flattening: Applies a 2x2 correction matrix calculated from Q-vector variances (Qxx, Qyy, Qxy).
- Features integration with CDBTTree to load calibration parameters dynamically via the Calibration Database.
- Processes harmonics n=2,3, and 4 for South, North, and Combined (NS) subdetectors.
- Automatically handles centrality-based binning (8 bins) for calibrations.
- Populates EventplaneinfoMap with Eventplaneinfov2 objects for downstream analysis.
- Includes diagnostic verbosity levels for inspecting calibration matrices and per-event vector transformations.
- Allow the sEPD bad tower maps to be processed via the CaloTowerStatus module.
Integrate the "Combined NS" calibration strategy into the reconstruction pipeline to improve event plane resolution and flatness. This update treats the combined North-South detector as a distinct third entity for flattening, while preserving multiplicity-based resolution weighting through individual sub-detector recentering.

Core Logic Updates:
- Calibration Loading: Updated LoadCalib to retrieve North-South specific second moments (⟨Qx2​⟩, ⟨Qy2​⟩, ⟨Qx​Qy​⟩) from the Calibration Database (CDB).
- Matrix Computation: Implemented unique flattening matrix calculation for the NS detector slot (Index 2) during initialization.
1) "Best of Both Worlds" Correction: Refactored correct_QVecs to implement the optimized combination logic:
2) Recenters South and North vectors individually.
3) Sums the recentered components to form the combined recentered vector: Q_NS,rec​ = Q_S,rec ​+ Q_N,rec​.

- Applies the dedicated NS flattening matrix to the resulting sum to ensure a circular (flat) distribution.
- Raw Vector Summation: Updated process_sEPD to populate the raw NS vector by summing normalized sub-detector components, facilitating direct QA comparisons.

Infrastructure & Efficiency:
- Array Expansion: Increased internal storage arrays for m_correction_data, m_Q_raw, m_Q_recentered, and m_Q_flat from size 2 to size 3 to accommodate the NS detector index.

Diagnostics & Quality Assurance:
- Print Methods: Expanded print_correction_data and print_QVectors to display diagnostic information for all three detector slots (South, North, and NorthSouth).
- Fallback Safety: Maintained fallback logic that utilizes raw Q-vectors in the event of missing calibration data or invalid event centrality, preventing empty output nodes.
Address Major Issues:
- Ensure m_directURL_EventPlaneCalib is not empty before passing it to hasValidTree
- Removed unused vectors in EventPlaneRecov2 (south_psi, north_psi, northsouth_psi)
- Guard against order == 0 to avoid divide-by-zero.
- Add bounds checks before indexing Q-vector storage.
@sphenix-jenkins-ci
Copy link

Build & test report

Report for commit 8b5c354c39a7ed64cae634b3bc9139e6a699c85d:
Jenkins passed


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

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