Skip to content

Conversation

@MartijnLaarhoven
Copy link
Contributor

Adding an option to reject the inner or outher rings of the FT0 detectors, and adding the option to fill the 'dead' parts of the detector with the mirrored parts.

MartijnLaarhoven and others added 12 commits December 12, 2025 15:01
Added option to reject the inside or the outside of the detector ring of FT0
Added option to reject the inside or the outside of the detector ring of FT0
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
making the rejection of the rejection of part of the detector more distinctive
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings December 17, 2025 15:35
@github-actions github-actions bot added the pwgcf label Dec 17, 2025
@github-actions github-actions bot changed the title Adding an option to reject the inner or outher rings of the FT0 detectors, and adding the option to fill the 'dead' parts of the detector with the mirrored parts. [PWGCF] Adding an option to reject the inner or outher rings of the FT0 detectors, and adding the option to fill the 'dead' parts of the detector with the mirrored parts. Dec 17, 2025
@github-actions
Copy link

O2 linter results: ❌ 9 errors, ⚠️ 0 warnings, 🔕 0 disabled

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 functionality to handle dead channels and selectively reject detector rings in the FT0A and FT0C detectors for long-range dihadron correlation analysis. The implementation allows remapping dead detector channels to mirror working channels and provides options to exclude inner or outer rings from the analysis.

Key changes:

  • Added six new configuration options to control FT0 detector channel rejection and remapping
  • Introduced a DetectorChannels enum defining inner/outer ring boundaries for FT0A and FT0C
  • Implemented dead channel remapping and ring rejection logic in the getChannel function

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

Comment on lines +679 to +685
ampl = ft0.amplitudeA()[92];
else if (id == 61)
ampl = ft0.amplitudeA()[93];
else if (id == 62)
ampl = ft0.amplitudeA()[94];
else if (id == 63)
ampl = ft0.amplitudeA()[95];
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

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

The channel remapping does not match the PR description. The description states "remap FT0A channels 60-63 to amplitudes from 28,30,29,31 respectively", but the code maps channels 60-63 to amplitudes from indices 92,93,94,95. Please verify which mapping is correct and update either the code or the description accordingly.

Suggested change
ampl = ft0.amplitudeA()[92];
else if (id == 61)
ampl = ft0.amplitudeA()[93];
else if (id == 62)
ampl = ft0.amplitudeA()[94];
else if (id == 63)
ampl = ft0.amplitudeA()[95];
ampl = ft0.amplitudeA()[28];
else if (id == 61)
ampl = ft0.amplitudeA()[30];
else if (id == 62)
ampl = ft0.amplitudeA()[29];
else if (id == 63)
ampl = ft0.amplitudeA()[31];

Copilot uses AI. Check for mistakes.
Comment on lines 655 to +688
id = ft0.channelC()[iCh];
id = id + Ft0IndexA;
ampl = ft0.amplitudeC()[iCh];
if (cfgRemapFT0CDeadCha if (id == 177)
ampl = ft0.amplitudeC()[145];
else if (id == 176)
ampl = ft0.amplitudeC()[144];
else if (id == 178)
ampl = ft0.amplitudeC()[146];
else if (id == 179)
ampl = ft0.amplitudeC()[147];
else if (id == 139)
ampl = ft0.amplitudeC()[115];
}
if ((cfgRejectFT0CInside && (id >= kFT0CInnerRingMin && id <= kFT0CInnerRingMax)) || (cfgRejectFT0COutside && (id >= kFT0COuterRingMin && id <= kFT0COuterRingMax)))
ampl = 0.;
registry.fill(HIST("FT0Amp"), id, ampl);
ampl = ampl / cstFT0RelGain[iCh];
registry.fill(HIST("FT0AmpCorrect"), id, ampl);
} else if (fitType == kFT0A) {
id = ft0.channelA()[iCh];
ampl = ft0.amplitudeA()[iCh];
if (cfgRemapFT0ADeadChannels) {
if (id == 60)
ampl = ft0.amplitudeA()[92];
else if (id == 61)
ampl = ft0.amplitudeA()[93];
else if (id == 62)
ampl = ft0.amplitudeA()[94];
else if (id == 63)
ampl = ft0.amplitudeA()[95];
}
if ((cfgRejectFT0AInside && (id >= kFT0AInnerRingMin && id <= kFT0AInnerRingMax)) || (cfgRejectFT0AOutside && (id >= kFT0AOuterRingMin && id <= kFT0AOuterRingMax)))
ampl = 0.;
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

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

The remapping logic incorrectly uses adjusted channel IDs as array indices. The arrays channelC() and amplitudeC() are indexed by position (0 to size-1), not by channel ID. To remap channel 177 to use the amplitude from channel 145, you need to: (1) find the position in the array where channelC()[j] + 96 == 145 (i.e., where channelC()[j] == 49), then (2) use amplitudeC()[j]. The current implementation directly accesses amplitudeC()[145] which attempts to access array index 145, likely causing out-of-bounds access if the array has fewer than 146 elements. The same issue affects all remapping statements in this block.

Suggested change
id = ft0.channelC()[iCh];
id = id + Ft0IndexA;
ampl = ft0.amplitudeC()[iCh];
if (cfgRemapFT0CDeadCha if (id == 177)
ampl = ft0.amplitudeC()[145];
else if (id == 176)
ampl = ft0.amplitudeC()[144];
else if (id == 178)
ampl = ft0.amplitudeC()[146];
else if (id == 179)
ampl = ft0.amplitudeC()[147];
else if (id == 139)
ampl = ft0.amplitudeC()[115];
}
if ((cfgRejectFT0CInside && (id >= kFT0CInnerRingMin && id <= kFT0CInnerRingMax)) || (cfgRejectFT0COutside && (id >= kFT0COuterRingMin && id <= kFT0COuterRingMax)))
ampl = 0.;
registry.fill(HIST("FT0Amp"), id, ampl);
ampl = ampl / cstFT0RelGain[iCh];
registry.fill(HIST("FT0AmpCorrect"), id, ampl);
} else if (fitType == kFT0A) {
id = ft0.channelA()[iCh];
ampl = ft0.amplitudeA()[iCh];
if (cfgRemapFT0ADeadChannels) {
if (id == 60)
ampl = ft0.amplitudeA()[92];
else if (id == 61)
ampl = ft0.amplitudeA()[93];
else if (id == 62)
ampl = ft0.amplitudeA()[94];
else if (id == 63)
ampl = ft0.amplitudeA()[95];
}
if ((cfgRejectFT0AInside && (id >= kFT0AInnerRingMin && id <= kFT0AInnerRingMax)) || (cfgRejectFT0AOutside && (id >= kFT0AOuterRingMin && id <= kFT0AOuterRingMax)))
ampl = 0.;
const auto& channelsC = ft0.channelC();
const auto& amplitudesC = ft0.amplitudeC();
id = channelsC[iCh];
id = id + Ft0IndexA;
ampl = amplitudesC[iCh];
if (cfgRemapFT0CDeadCha) {
auto getRemappedAmplitudeC = [&](int sourceChannelId) -> float {
for (std::size_t j = 0; j < channelsC.size(); ++j) {
if (channelsC[j] + Ft0IndexA == sourceChannelId) {
return amplitudesC[j];
}
}
// If the requested source channel is not present, treat it as having zero amplitude.
return 0.f;
};
if (id == 177) {
ampl = getRemappedAmplitudeC(145);
} else if (id == 176) {
ampl = getRemappedAmplitudeC(144);
} else if (id == 178) {
ampl = getRemappedAmplitudeC(146);
} else if (id == 179) {
ampl = getRemappedAmplitudeC(147);
} else if (id == 139) {
ampl = getRemappedAmplitudeC(115);
}
}
if ((cfgRejectFT0CInside && (id >= kFT0CInnerRingMin && id <= kFT0CInnerRingMax)) || (cfgRejectFT0COutside && (id >= kFT0COuterRingMin && id <= kFT0COuterRingMax)))
ampl = 0.f;
registry.fill(HIST("FT0Amp"), id, ampl);
ampl = ampl / cstFT0RelGain[iCh];
registry.fill(HIST("FT0AmpCorrect"), id, ampl);
} else if (fitType == kFT0A) {
const auto& channelsA = ft0.channelA();
const auto& amplitudesA = ft0.amplitudeA();
id = channelsA[iCh];
ampl = amplitudesA[iCh];
if (cfgRemapFT0ADeadChannels) {
auto getRemappedAmplitudeA = [&](int sourceChannelId) -> float {
for (std::size_t j = 0; j < channelsA.size(); ++j) {
if (channelsA[j] == sourceChannelId) {
return amplitudesA[j];
}
}
// If the requested source channel is not present, treat it as having zero amplitude.
return 0.f;
};
if (id == 60) {
ampl = getRemappedAmplitudeA(92);
} else if (id == 61) {
ampl = getRemappedAmplitudeA(93);
} else if (id == 62) {
ampl = getRemappedAmplitudeA(94);
} else if (id == 63) {
ampl = getRemappedAmplitudeA(95);
}
}
if ((cfgRejectFT0AInside && (id >= kFT0AInnerRingMin && id <= kFT0AInnerRingMax)) || (cfgRejectFT0AOutside && (id >= kFT0AOuterRingMin && id <= kFT0AOuterRingMax)))
ampl = 0.f;

Copilot uses AI. Check for mistakes.
id = ft0.channelC()[iCh];
id = id + Ft0IndexA;
ampl = ft0.amplitudeC()[iCh];
if (cfgRemapFT0CDeadCha if (id == 177)
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

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

Syntax error: The line appears to be corrupted or incomplete. The condition if (cfgRemapFT0CDeadCha is truncated and missing the closing parenthesis and opening brace. It should likely be if (cfgRemapFT0CDeadChannels) { to match the pattern used for FT0A on line 677.

Suggested change
if (cfgRemapFT0CDeadCha if (id == 177)
if (cfgRemapFT0CDeadChannels) {
if (id == 177)

Copilot uses AI. Check for mistakes.
@vkucera vkucera marked this pull request as draft December 17, 2025 15:54
@vkucera
Copy link
Collaborator

vkucera commented Dec 17, 2025

Please always validate your formatting before opening a PR for review to avoid useless compilation tests.

@vkucera
Copy link
Collaborator

vkucera commented Dec 17, 2025

Please always validate your formatting before opening a PR for review to avoid useless compilation tests.

Your code doesn't even compile!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants