Skip to content

New setters for lamination fitting code#4270

Merged
pinkenburg merged 1 commit into
sPHENIX-Collaboration:masterfrom
bkimelman:master
May 19, 2026
Merged

New setters for lamination fitting code#4270
pinkenburg merged 1 commit into
sPHENIX-Collaboration:masterfrom
bkimelman:master

Conversation

@bkimelman
Copy link
Copy Markdown
Contributor

@bkimelman bkimelman commented May 18, 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, ...)

New setter functions to allow for easy toggling of layer standard deviation cut and adc weighting of histograms. Also new function to set the number of phi and R bins of the lamination histograms. All setters default to the same settings as before.

TODOs (if applicable)

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

Motivation

This PR adds three new configurable setter methods to the TPC lamination fitting calibration code, enabling physics analysts to tune lamination histogram binning and adjust event selection and weighting strategies without code modifications. These settings control how lamination distortions are measured and corrected for the TPC detector's space charge effects. The changes maintain backward compatibility by preserving existing default behavior.

Key Changes

  • Lamination histogram grid configuration: New set_lam_grid_dimensions(int phibins, int rbins) setter allows customization of lamination histogram bin counts in the φ (azimuthal) and R (radial) dimensions (default: 200 bins each). Previously hardcoded, these dimensions are now applied during InitRun() for all 18 laminations on both TPC sides (lines 101, 109 in TpcLaminationFitting.cc).

  • Structured digit (SD) layer cut toggle: New set_useSDLayerCut(bool useCut) setter enables/disables SD-layer-based filtering (default: true to maintain existing behavior). The logic is inverted from typical naming:

    • When m_useSDLayerCut = true: Clusters with high SD-weighted layer values (> 0.5) are excluded from petal histogram filling (line 248-250) but included in lamination filling (line 225)
    • When m_useSDLayerCut = false: All clusters pass through to petal histogram filling without SD filtering
  • ADC-weighted histogram filling: New set_adcWeight(bool useADC) setter enables optional cluster ADC-value-based event weighting (default: false). When enabled, each cluster's ADC value is used as a weight when filling both lamination and petal histograms (lines 206-209, 243, 267).

  • Member variables added: m_useSDLayerCut, m_adcWeight, m_lamPhiBins, and m_lamRBins with appropriate defaults.

Potential Risk Areas

  • Non-intuitive SD-layer cut logic: The m_useSDLayerCut flag performs different filtering for laminations (includes high-SD clusters) versus petal histograms (excludes high-SD clusters). This asymmetric behavior could lead to unexpected results if analysts misunderstand the intent.

  • Reconstruction behavior changes: The conditional SD-layer filtering for petal histogram affects which clusters contribute to the global R-matching and overall distortion correction strategy, potentially impacting the final distortion maps when the flag is toggled.

  • ADC weighting impact: The optional ADC weighting changes the statistical weight of events and could affect lamination fitting convergence, especially for events with very high or very low ADC values. Unvalidated ADC weighting configurations could bias the extracted corrections.

  • Histogram resolution sensitivity: Different phi/R bin dimensions directly affect histogram granularity and fitting precision. Under-binned histograms may increase statistical noise in fits; over-binned histograms may lose spatial resolution of lamination features.

  • Silent configuration dependency: Default-disabled features may lead to subtle behavior changes if users forget to enable ADC weighting when expected, or if different analyses use different m_useSDLayerCut settings without documentation.

Possible Future Improvements

  • Add getter methods to query current configuration state
  • Clarify or rename m_useSDLayerCut to better convey the filtering logic (e.g., m_filterHighSDClusters)
  • Provide validation or warning messages for extreme bin count choices (e.g., < 10 or > 1000 bins)
  • Document the asymmetric SD-layer filtering behavior and rationale in code comments and configuration guides
  • Add debug output or logging to track which configuration is active during initialization
  • Consider extending configuration to other histogram parameters (bin ranges, axis scaling)

Note: This summary is AI-generated and may contain inaccuracies. The asymmetric SD-layer filtering logic (different behavior for laminations vs. petal histograms) warrants careful review with collaboration experts to confirm the intended physics behavior.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

📝 Walkthrough

Walkthrough

TpcLaminationFitting adds public configuration methods for histogram binning, SD-layer cut behavior, and ADC weighting. Private state stores these settings. InitRun uses configurable bin dimensions for histogram creation. Event processing applies optional ADC-derived weights to fills and conditionally applies SD-layer selection based on the configuration flags.

Changes

Lamination Fitting Configuration and Weighting

Layer / File(s) Summary
Configuration Interface and Member State
offline/packages/tpccalib/TpcLaminationFitting.h, offline/packages/tpccalib/TpcLaminationFitting.cc
Public setters expose configuration for histogram binning (set_lam_grid_dimensions), SD-layer cuts (set_useSDLayerCut), and ADC weighting (set_adcWeight). Private members store bin counts (m_lamPhiBins, m_lamRBins) and behavior flags (m_useSDLayerCut, m_adcWeight).
Histogram Initialization with Configurable Binning
offline/packages/tpccalib/TpcLaminationFitting.cc
InitRun constructs lamination histograms using configured bin counts for both field-off and nominal branches, replacing prior hard-coded dimensions.
Event Processing with Weighted Filling and Conditional Selection
offline/packages/tpccalib/TpcLaminationFitting.cc
process_event computes per-cluster ADC weight when enabled, applies weight to lamination and petal histogram fills, and gates the SD-layer threshold cut based on the m_useSDLayerCut flag.

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.

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
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0c2d59e9-30fd-418b-afec-f0d176ccca36

📥 Commits

Reviewing files that changed from the base of the PR and between 3381348 and f919460.

📒 Files selected for processing (2)
  • offline/packages/tpccalib/TpcLaminationFitting.cc
  • offline/packages/tpccalib/TpcLaminationFitting.h

Comment on lines +61 to +65
void TpcLaminationFitting::set_lam_grid_dimensions(int phibins, int rbins)
{
m_lamPhiBins = phibins;
m_lamRBins = rbins;
}
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 | ⚡ Quick win

Validate lamination grid dimensions before storing them.

Line 61 accepts unchecked bin counts, and Lines 101/109 use them directly in TH2D allocation. Non-positive or extreme values can create invalid histograms or trigger large memory spikes.

Proposed fix
 void TpcLaminationFitting::set_lam_grid_dimensions(int phibins, int rbins)
 {
-  m_lamPhiBins = phibins;
-  m_lamRBins = rbins;
+  constexpr int kMinBins = 1;
+  constexpr int kMaxBins = 2000;
+  if (phibins < kMinBins || rbins < kMinBins || phibins > kMaxBins || rbins > kMaxBins)
+  {
+    std::cout << PHWHERE
+              << " invalid lamination grid dimensions (phi=" << phibins
+              << ", r=" << rbins << "), keeping previous values (phi="
+              << m_lamPhiBins << ", r=" << m_lamRBins << ")"
+              << std::endl;
+    return;
+  }
+  m_lamPhiBins = phibins;
+  m_lamRBins = rbins;
 }

As per coding guidelines, **/*.{cc,cpp,cxx,c} files should prioritize correctness and error handling.

📝 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
void TpcLaminationFitting::set_lam_grid_dimensions(int phibins, int rbins)
{
m_lamPhiBins = phibins;
m_lamRBins = rbins;
}
void TpcLaminationFitting::set_lam_grid_dimensions(int phibins, int rbins)
{
constexpr int kMinBins = 1;
constexpr int kMaxBins = 2000;
if (phibins < kMinBins || rbins < kMinBins || phibins > kMaxBins || rbins > kMaxBins)
{
std::cout << PHWHERE
<< " invalid lamination grid dimensions (phi=" << phibins
<< ", r=" << rbins << "), keeping previous values (phi="
<< m_lamPhiBins << ", r=" << m_lamRBins << ")"
<< std::endl;
return;
}
m_lamPhiBins = phibins;
m_lamRBins = rbins;
}

@sphenix-jenkins-ci
Copy link
Copy Markdown

Build & test report

Report for commit f919460f19f1c0d100eb3fae03e3eadc88e7d07c:
Jenkins passed


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@pinkenburg
Copy link
Copy Markdown
Contributor

clang-tidy warnings are from another PR which fixed those

@pinkenburg pinkenburg merged commit c416f2f into sPHENIX-Collaboration:master May 19, 2026
21 of 22 checks passed
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