Skip to content
Closed
41 changes: 41 additions & 0 deletions PWGCF/TwoParticleCorrelations/Tasks/longRangeDihadronCor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@
O2_DEFINE_CONFIGURABLE(cfgLocalEfficiency, bool, false, "Use local efficiency object")
O2_DEFINE_CONFIGURABLE(cfgUseEventWeights, bool, false, "Use event weights for mixed event")
O2_DEFINE_CONFIGURABLE(cfgDrawEtaPhiDis, bool, false, "draw eta-phi distribution for detectors in used")
O2_DEFINE_CONFIGURABLE(cfgRejectFT0AInside, bool, false, "Rejection of inner ring channels of the FT0A detector")
O2_DEFINE_CONFIGURABLE(cfgRejectFT0AOutside, bool, false, "Rejection of outer ring channels of the FT0A detector")
O2_DEFINE_CONFIGURABLE(cfgRejectFT0CInside, bool, false, "Rejection of inner ring channels of the FT0C detector")
O2_DEFINE_CONFIGURABLE(cfgRejectFT0COutside, bool, false, "Rejection of outer ring channels of the FT0C detector")
O2_DEFINE_CONFIGURABLE(cfgRemapFT0ADeadChannels, bool, false, "If true, remap FT0A channels 60-63 to amplitudes from 28,30,29,31 respectively")
O2_DEFINE_CONFIGURABLE(cfgRemapFT0CDeadChannels, bool, false, "If true, remap FT0C channels 177->145, 176->144, 178->146, 179->147, 139->115")
struct : ConfigurableGroup {
O2_DEFINE_CONFIGURABLE(cfgMultCentHighCutFunction, std::string, "[0] + [1]*x + [2]*x*x + [3]*x*x*x + [4]*x*x*x*x + 10.*([5] + [6]*x + [7]*x*x + [8]*x*x*x + [9]*x*x*x*x)", "Functional for multiplicity correlation cut");
O2_DEFINE_CONFIGURABLE(cfgMultCentLowCutFunction, std::string, "[0] + [1]*x + [2]*x*x + [3]*x*x*x + [4]*x*x*x*x - 3.*([5] + [6]*x + [7]*x*x + [8]*x*x*x + [9]*x*x*x*x)", "Functional for multiplicity correlation cut");
Expand Down Expand Up @@ -236,6 +242,16 @@
kTOF,
kITS
};
enum DetectorChannels {
kFT0AInnerRingMin = 0,
kFT0AInnerRingMax = 31,
kFT0AOuterRingMin = 32,
kFT0AOuterRingMax = 95,
kFT0CInnerRingMin = 96,
kFT0CInnerRingMax = 143,
kFT0COuterRingMin = 144,
kFT0COuterRingMax = 207
};
std::array<float, 6> tofNsigmaCut;
std::array<float, 6> itsNsigmaCut;
std::array<float, 6> tpcNsigmaCut;
Expand Down Expand Up @@ -639,12 +655,37 @@
id = ft0.channelC()[iCh];
id = id + Ft0IndexA;
ampl = ft0.amplitudeC()[iCh];
if (cfgRemapFT0CDeadCha if (id == 177)

Check failure on line 658 in PWGCF/TwoParticleCorrelations/Tasks/longRangeDihadronCor.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
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.
ampl = ft0.amplitudeC()[145];
else if (id == 176)

Check failure on line 660 in PWGCF/TwoParticleCorrelations/Tasks/longRangeDihadronCor.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
ampl = ft0.amplitudeC()[144];
else if (id == 178)

Check failure on line 662 in PWGCF/TwoParticleCorrelations/Tasks/longRangeDihadronCor.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
ampl = ft0.amplitudeC()[146];
else if (id == 179)

Check failure on line 664 in PWGCF/TwoParticleCorrelations/Tasks/longRangeDihadronCor.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
ampl = ft0.amplitudeC()[147];
else if (id == 139)

Check failure on line 666 in PWGCF/TwoParticleCorrelations/Tasks/longRangeDihadronCor.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
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)

Check failure on line 678 in PWGCF/TwoParticleCorrelations/Tasks/longRangeDihadronCor.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
ampl = ft0.amplitudeA()[92];
else if (id == 61)

Check failure on line 680 in PWGCF/TwoParticleCorrelations/Tasks/longRangeDihadronCor.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
ampl = ft0.amplitudeA()[93];
else if (id == 62)

Check failure on line 682 in PWGCF/TwoParticleCorrelations/Tasks/longRangeDihadronCor.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
ampl = ft0.amplitudeA()[94];
else if (id == 63)

Check failure on line 684 in PWGCF/TwoParticleCorrelations/Tasks/longRangeDihadronCor.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
ampl = ft0.amplitudeA()[95];
Comment on lines +679 to +685
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.
}
if ((cfgRejectFT0AInside && (id >= kFT0AInnerRingMin && id <= kFT0AInnerRingMax)) || (cfgRejectFT0AOutside && (id >= kFT0AOuterRingMin && id <= kFT0AOuterRingMax)))
ampl = 0.;
Comment on lines 655 to +688
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.
registry.fill(HIST("FT0Amp"), id, ampl);
ampl = ampl / cstFT0RelGain[iCh];
registry.fill(HIST("FT0AmpCorrect"), id, ampl);
Expand Down
Loading