Skip to content

Tpc conditions time dependent kEff - #4445

Merged
osbornjd merged 6 commits into
sPHENIX-Collaboration:masterfrom
mcyoren:TpcConditions_TimeDependent_kEff
Sep 24, 2026
Merged

osbornjd merged 6 commits into
sPHENIX-Collaboration:masterfrom
mcyoren:TpcConditions_TimeDependent_kEff

Conversation

@mcyoren

@mcyoren mcyoren commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • [ x] 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, ...)

This PR updates the handling of TPC conditions and PHGarfield configuration used by the TPC PolyClusterizer.

Main changes:

  • Configure the IFC voltage correction based on the run number, so the appropriate IFC voltage settings are selected automatically for different running periods.
  • Add support for time-dependent TPC GEM current conditions through TpcConditions (segment-by-segment).
  • Move run-dependent configuration and calibration handling into PHGarfield by default.
  • Load the TPC space-charge kEff values from CDB by default, while preserving explicit user overrides.
  • Apply the GEM-current correction to kEff only when valid TpcConditions are available.
  • If TPC_CONDITIONS is unavailable for a run, or the TpcConditions node is missing, reconstruction continues using the unscaled CDB kEff values and prints a warning instead of aborting.
  • Handle missing or empty TPC conditions payloads.
  • Add ConditionsAvailable to distinguish unavailable conditions from valid condition values.
  • Keep manual PHGarfield/PolyClusterizer configuration available through the existing configuration interface.

The updated TpcConditions, PHGarfield, and Tpc_PolyClusterizer packages were tested successfully.

The modified source files were also checked with clang-tidy and clang-format.

TODOs (if applicable)

Update CDB callibrations for kEffs.
Add TpcConditions to Macro

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

Motivation

Add time-dependent TPC condition handling to the TPC PolyClusterizer. Use CDB inputs by default while preserving explicit user configuration.

Key changes

  • Select IFC voltage distortion by run number.
  • Load electric-field maps, geometry, kEff values, and field-cage settings through PHGarfield.
  • Apply segment-level GEM-current corrections when valid TpcConditions are available.
  • Continue reconstruction with unscaled kEff values when conditions are missing or invalid.
  • Add ConditionsAvailable and GEM-current accessors to TpcConditions.
  • Interpolate GEM currents and populate conditions from CDB payloads.
  • Preserve manual PHGarfield and PolyClusterizer overrides.
  • Add required library dependencies and the IFC voltage change run boundary.

Potential risk areas

  • Reconstruction results can change when CDB conditions become available.
  • Missing conditions now produce warnings and continued processing instead of event failure.
  • CDB payload interpretation and compatibility require validation.
  • No thread-safety or performance assessment is provided.
  • Current review severity counts are unavailable from the supplied information.

Future improvements

  • Add focused tests for empty, missing, and time-dependent condition payloads.
  • Validate corrected kEff values against reference runs.
  • Measure the performance impact of interpolation and CDB loading.
  • Document the override precedence and run-dependent configuration.

AI-generated summaries can contain errors. Contributors should verify the implementation and physics behavior against the source code and reference data.

@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

Changes

TPC field and condition integration

Layer / File(s) Summary
TPC conditions reconstruction
offline/packages/TpcConditions/*
TpcConditions now stores average loads and availability. TpcConditionsReco loads condition data, interpolates loads by BCO, and returns EVENT_OK when condition inputs are unavailable.
Garfield CDB configuration
offline/framework/phool/RunnumberRange.h, offline/packages/PHGarfield/*
PHGarfield now loads field maps, kEff values, geometry, and current corrections from CDB while preserving manual overrides. Field-cage voltages depend on the run number.
Clusterizer Garfield integration
offline/packages/tpctrackreco/*
Tpc_PolyClusterizer selects Garfield defaults or manual settings and scales side-specific kEff values from TpcConditions. Build files add the required library dependencies.

Sequence Diagram(s)

sequenceDiagram
  participant CDB
  participant TpcConditionsReco
  participant Tpc_PolyClusterizer
  participant PHGarfield
  CDB->>TpcConditionsReco: Load TPC conditions
  TpcConditionsReco->>Tpc_PolyClusterizer: Provide BCO-dependent loads
  Tpc_PolyClusterizer->>PHGarfield: Configure maps, kEff, geometry, and voltages
  PHGarfield-->>Tpc_PolyClusterizer: Initialize Garfield field configuration
Loading

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to f0d8c

Manual and run-dependent reconstruction can use incorrect calibration settings, while existing PHGarfield users may see changed defaults or initialization failures. Resolve these compatibility and configuration issues before merging.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

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.

@sphenix-jenkins-ci

Copy link
Copy Markdown

Build & test report

Report for commit f0d8c9cefaa22ccdd6203c1956d0889cccbd1b46:
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 f0d8c9cefaa22ccdd6203c1956d0889cccbd1b46:
Jenkins passed


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@osbornjd osbornjd left a comment

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.

This passes the QA and similarly to your slides from today, the jenkins QA shows no change for 79513. I think if you are ready for this to go in we should merge it so that it is in the next ana build

@mcyoren
mcyoren marked this pull request as ready for review September 22, 2026 18:16

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: sPHENIX-Collaboration/coresoftware/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 99cdff8c-25e4-435c-a735-bfa666e8d8ed

📥 Commits

Reviewing files that changed from the base of the PR and between 7726f1a and f0d8c9c.

📒 Files selected for processing (10)
  • offline/framework/phool/RunnumberRange.h
  • offline/packages/PHGarfield/Makefile.am
  • offline/packages/PHGarfield/PHGarfield.cc
  • offline/packages/PHGarfield/PHGarfield.h
  • offline/packages/TpcConditions/TpcConditions.h
  • offline/packages/TpcConditions/TpcConditionsReco.cc
  • offline/packages/TpcConditions/TpcConditionsReco.h
  • offline/packages/tpctrackreco/Makefile.am
  • offline/packages/tpctrackreco/Tpc_PolyClusterizer.cc
  • offline/packages/tpctrackreco/Tpc_PolyClusterizer.h

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

Comment thread offline/packages/PHGarfield/PHGarfield.cc
Comment on lines +34 to +35
double spaceChargeScale_side0 = std::numeric_limits<double>::quiet_NaN(),
double spaceChargeScale_side1 = std::numeric_limits<double>::quiet_NaN());

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Find all PHGarfield constructions and scale/voltage setter calls outside the clusterizer.
rg -nP -C3 '\bPHGarfield\s*\(' --type=cpp -g '!offline/packages/PHGarfield/**'
rg -nP -C2 'SetFrameChargeScale|SetCMVoltageDefault|SetSpaceChargeScale' --type=cpp

Repository: sPHENIX-Collaboration/coresoftware

Length of output: 7830


🏁 Script executed:

#!/bin/bash
set -o pipefail
printf '%s\n' '--- header constructor and defaults ---'
sed -n '20,45p;315,360p' offline/packages/PHGarfield/PHGarfield.h
printf '%s\n' '--- implementation constructor and CDB/init paths ---'
rg -n -C5 'PHGarfield::PHGarfield|LoadCDBInputs|ConfigureRunDependentFieldCage|spaceChargeScaleOverride|m_CMVoltageDefault|m_frameChargeScale_side' offline/packages/PHGarfield/PHGarfield.cc
printf '%s\n' '--- all repository PHGarfield references ---'
rg -n -P '\bPHGarfield\b|\bPHGarfield\s*\(' --glob '!offline/packages/PHGarfield/PHGarfield.h' --glob '!offline/packages/PHGarfield/PHGarfield.cc' .

Repository: sPHENIX-Collaboration/coresoftware

Length of output: 23662


🏁 Script executed:

#!/bin/bash
set -o pipefail
printf '%s\n' '--- TpcCrossingFinder configuration ---'
sed -n '130,155p;220,245p' offline/packages/tpctrackreco/TpcCrossingFinder.cc
printf '%s\n' '--- Tpc_PolyClusterizer construction and configuration ---'
sed -n '330,445p;455,485p;515,575p' offline/packages/tpctrackreco/Tpc_PolyClusterizer.cc
printf '%s\n' '--- LaserClusterHelper construction and configuration ---'
sed -n '55,85p' offline/packages/tpc/LaserClusterHelper.cc
printf '%s\n' '--- focused PHGarfield diff ---'
git diff -- offline/packages/PHGarfield/PHGarfield.h offline/packages/PHGarfield/PHGarfield.cc | sed -n '1,260p'

Repository: sPHENIX-Collaboration/coresoftware

Length of output: 10128


Document the changed public defaults and update downstream users.

The constructor now treats omitted space-charge scales as non-overrides. LoadCDBInputs then loads Tpc_PolyClusterizer_kEff and, when available, applies the TpcConditions current correction. A missing kEff payload causes InitRun to return ABORTRUN.

The defaults also change from 380.0 to 375.0 V/cm and from 1.0 to -180.0 for both frame-charge scales. Add compatibility notes and update downstream macros or modules that depend on the previous defaults.

Source: Path instructions

Comment on lines +260 to +264
if (averageSR1 != 0.0 && averageNR1 != 0.0)
{
m_kEffSide0 *= m_conditions->get_LoadSR1() / averageSR1;
m_kEffSide1 *= m_conditions->get_LoadNR1() / averageNR1;
}

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Manual kEff values are scaled here, unlike in PHGarfield.

Lines 262-263 apply the current correction to m_kEffSide0 and m_kEffSide1 without checking m_kEffSide0Override / m_kEffSide1Override. A user who calls setKEffSide0() therefore does not get the value that was set. The printout at line 272 still labels it [manual value], so the discrepancy is not visible. PHGarfield::LoadCDBInputs lines 301-323 does guard each side with m_spaceChargeScaleOverride, so the two configuration paths now disagree for the same macro settings.

Proposed fix to match the PHGarfield behavior
       if (averageSR1 != 0.0 && averageNR1 != 0.0)
       {
-        m_kEffSide0 *= m_conditions->get_LoadSR1() / averageSR1;
-        m_kEffSide1 *= m_conditions->get_LoadNR1() / averageNR1;
+        if (!m_kEffSide0Override)
+        {
+          m_kEffSide0 *= m_conditions->get_LoadSR1() / averageSR1;
+        }
+        if (!m_kEffSide1Override)
+        {
+          m_kEffSide1 *= m_conditions->get_LoadNR1() / averageNR1;
+        }
       }
📝 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
if (averageSR1 != 0.0 && averageNR1 != 0.0)
{
m_kEffSide0 *= m_conditions->get_LoadSR1() / averageSR1;
m_kEffSide1 *= m_conditions->get_LoadNR1() / averageNR1;
}
if (averageSR1 != 0.0 && averageNR1 != 0.0)
{
if (!m_kEffSide0Override)
{
m_kEffSide0 *= m_conditions->get_LoadSR1() / averageSR1;
}
if (!m_kEffSide1Override)
{
m_kEffSide1 *= m_conditions->get_LoadNR1() / averageNR1;
}
}

@osbornjd
osbornjd merged commit 521579b into sPHENIX-Collaboration:master Sep 24, 2026
32 of 41 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