Skip to content

Comments

Fixes for maps.#4175

Merged
osbornjd merged 9 commits intosPHENIX-Collaboration:masterfrom
Ishangoel11:master
Feb 17, 2026
Merged

Fixes for maps.#4175
osbornjd merged 9 commits intosPHENIX-Collaboration:masterfrom
Ishangoel11:master

Conversation

@Ishangoel11
Copy link
Contributor

@Ishangoel11 Ishangoel11 commented Feb 12, 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, ...)

TODOs (if applicable)

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

Summary

This PR adds dual-mode channel masking in the TPC clusterizer to support both simulation and data channel-map formats and includes input validation for masked-channel entries.

Motivation / context

Simulation and data channel maps use different layer/pad encodings and sector conventions. Without explicit mode selection and remapping, masks from one domain can be mis-applied to the other, degrading reconstruction. This change provides an explicit data/simulation mode and remaps sectors for simulation input.

Key changes

  • API:
    • Added public method SetIsData(bool) to select data (true) or simulation (false) mode.
    • Added private member bool m_is_data.
    • Added private array int mc_sectors[12] = {5,4,3,2,1,0,11,10,9,8,7,6} used for sector remapping in simulation mode.
  • Channel-masking parsing:
    • Supports dual inputs from the mask source: layer0/pad0 (simulation) and layer1/pad1 (data).
    • If m_is_data == false (simulation): use layer0/pad0 and map sector via mc_sectors[Sec].
    • If m_is_data == true (data): use layer1/pad1 and use sector as provided.
  • Input validation:
    • Warns and skips mask entries with out-of-range values: Sector not in [0,11], Layer not in [7,48], Side not in [0,1].
  • Logging:
    • Verbose logging prints resolved Layer, Sector, Side, Pad for each mask entry.

Potential risk areas

  • IO format expectations: Mask sources must provide layer0/pad0 and layer1/pad1 fields (schema change). Missing fields or older maps may cause incorrect or skipped masks.
  • Reconstruction behavior: Simulation remapping changes which channels are masked for simulated events; this can affect cluster finding and downstream reconstruction/analyses.
  • Hard-coded sector mapping: mc_sectors is fixed in code; changes to detector labeling or conventions require a code change and rebuild.
  • Thread-safety & initialization: m_is_data and mc_sectors are instance members — ensure the mode is set before parallel processing starts to avoid inconsistent masking across threads or jobs.
  • Silent defaults: If SetIsData(...) is not called, the default mode may be incorrect for the input data and lead to misapplied masks.

Possible future improvements

  • Make sector mapping configurable (input file, job options, or external calibration).
  • Add runtime checks that required mask fields (layer0/pad0 and layer1/pad1) exist and emit clearer errors if missing.
  • Log the active mode (sim/data) at job start and include counts of skipped/invalid mask entries.
  • Consider unit/integration tests exercising both modes and various malformed mask inputs.

AI note: This summary was produced with AI assistance. Please verify the exact method name, default mode behavior, and that the hard-coded sector mapping matches detector conventions before merging.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 12, 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

TpcClusterizer: adds an m_is_data flag and mc_sectors mapping; refactors channel-masking input to read paired fields (layer0/layer1, pad0/pad1) and select layer/pad/sector based on simulation vs data, validates Sector/Layer/Side ranges with warnings/skips, and retains verbose masking logs.

Changes

Cohort / File(s) Summary
API & state
offline/packages/tpc/TpcClusterizer.h
Adds void SetIsData(bool) setter, new private bool m_is_data, and private int mc_sectors[12] = {5,4,3,2,1,0,11,10,9,8,7,6} for sim→data sector mapping.
Channel masking logic
offline/packages/tpc/TpcClusterizer.cc
Refactors channel-masking to read layer0/layer1 and pad0/pad1, choose Layer/Pad and Sector depending on m_is_data (uses mc_sectors mapping when not data), adds Sector/Layer/Side range validation with warnings and skips out-of-range entries, and preserves verbose logging of resolved masking parameters.

Sequence Diagram(s)


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
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: 2

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
offline/packages/tpc/TpcClusterizer.cc (1)

1875-1903: ⚠️ Potential issue | 🟠 Major

Add missing validation for Layer and Side from CDB data — external calibration bounds must be checked.

The bounds check on Sec (lines 1884–1890) correctly validates external calibration data. However, Layer and Side are also sourced from the CDB without validation. TPC layers must fall within [7, 48] (confirmed by validation patterns in TpcRawWriter.cc), and Side must be 0 or 1. If the CDB contains an unexpected value, TpcDefs::genHitSetKey(Layer, Sector, Side) at line 1901 will produce a hitsetkey that never matches any actual TPC hitset, silently causing the mask entry to be ignored with no diagnostic output.

Proposed fix
     if (Sec < 0 || Sec >= 12)
     {
       std::cout << PHWHERE << "WARNING: sector index " << Sec
                 << " out of range [0,11] in " << dbName
                 << ", skipping channel " << i << std::endl;
       continue;
     }

     int Layer  = (m_isSimulation) ? Layer0          : Layer1;
     int Pad    = (m_isSimulation) ? Pad0            : Pad1;
     int Sector = (m_isSimulation) ? mc_sectors[Sec] : Sec;

+    if (Layer < 7 || Layer > 48)
+    {
+      std::cout << PHWHERE << "WARNING: layer " << Layer
+                << " out of TPC range [7,48] in " << dbName
+                << ", skipping channel " << i << std::endl;
+      continue;
+    }
+
+    if (Side < 0 || Side > 1)
+    {
+      std::cout << PHWHERE << "WARNING: side " << Side
+                << " out of range [0,1] in " << dbName
+                << ", skipping channel " << i << std::endl;
+      continue;
+    }
+
     if (Verbosity() > VERBOSITY_A_LOT)

Ishan Goel added 2 commits February 11, 2026 22:25
@sphenix-jenkins-ci
Copy link

Build & test report

Report for commit 3fd2a487f9877573ef098986a781258ab695ae7b:
Jenkins passed


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@sphenix-jenkins-ci
Copy link

Build & test report

Report for commit edb448dc40e7f45f05790f4baddd6c2c779a39be:
Jenkins passed


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@sphenix-jenkins-ci
Copy link

Build & test report

Report for commit 0bc9fe491953708645e1909132a86570ebad9d9d:
Jenkins passed


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@sphenix-jenkins-ci
Copy link

Build & test report

Report for commit 2305b2220986f5576c5fcd7782d2e79a0c7bd1b7:
Jenkins passed


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

Copy link
Contributor

@osbornjd osbornjd left a comment

Choose a reason for hiding this comment

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

There is a flag at the macro level that is set based on the CDB tag to determine whether or not the reconstruction is being run on data or simulation
https://github.com/sPHENIX-Collaboration/macros/blob/b8edb9fd697616a3250dabd2608ced54b446ed89/common/GlobalVariables.C#L136
Let's use that so that all modules are consistent


if (Sec < 0 || Sec >= 12)
{
std::cout << PHWHERE << "WARNING: sector index " << Sec
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we wrap these into Verbosity() statements?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess so!


int m_runNumber = -1; // Store run number from Event Header
bool m_isSimulation = true; // Default true; Updated based on run number
int mc_sectors[12]{5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6};
Copy link
Contributor

Choose a reason for hiding this comment

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

I am nervous about having this hard coded. If it ever changes, this will silently break functionality. Why is the sector numbering scheme in the CDB object different for data and sim?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed runNumber and m_isSimulation.

The reason there is different numbering scheme in data and sim is because that is how TPC is. I made a map which can work for both data and sim. And the numbering scheme is therefore have to be fixed carefully. Now Is it ok?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand because the sector and layer should be coming from the same object, the hitsetkey (regardless of data or sim) , e.g. here. For a given sector, side, and layer the same hitsetkey should be generated. If there is some difference between data and simulation that implies there is a problem in the numbering scheme the hit unpacker is providing. Can you make a slide that shows the numbering scheme for data and simulation as you are finding them here? I'm thinking of a plot for data and sim where you show the phi distribution of hits or clusters, and where the sectors are for each. You could also check that for the same hitsetkey in either data or sim you get different phi regions - that would indicate a problem upstream from the clusterizer that should be fixed

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: 1

@sphenix-jenkins-ci
Copy link

Build & test report

Report for commit b42fdf57f3efbd78048290d274d421ac2e8478ca:
Jenkins passed


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@sphenix-jenkins-ci
Copy link

Build & test report

Report for commit 89772f9056642c741f192da7953b23a5002c3df1:
Jenkins passed


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@sphenix-jenkins-ci
Copy link

Build & test report

Report for commit 4a18fc36a8b4747579510b222890db26799e2a96:
Jenkins passed


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@sphenix-jenkins-ci
Copy link

Build & test report

Report for commit f03fde5c4c04238a0c4d157abe7ec30dfc10a669:
Jenkins on fire


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@sphenix-jenkins-ci
Copy link

Build & test report

Report for commit 4c4fdf492349cc2d3b8fd16219d98ffde2260131:
Jenkins passed


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@Ishangoel11 Ishangoel11 requested a review from osbornjd February 17, 2026 15:48
Copy link
Contributor

@osbornjd osbornjd left a comment

Choose a reason for hiding this comment

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

Looks good, the clang-tidy errors are benign

@osbornjd osbornjd merged commit 0fdd99a into sPHENIX-Collaboration:master Feb 17, 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