Skip to content

Commit 6f23ff8

Browse files
committed
update the algorithm of removing daughter tracks
1 parent f7e83c0 commit 6f23ff8

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

PWGHF/D2H/Tasks/taskPtFlucCharmHadrons.cxx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,24 +252,31 @@ struct HfTaskPtFlucCharmHadrons {
252252
template <DecayChannel Channel, typename CandT>
253253
float removeDaughtersFromMeanPt(const CandT& cand, float rawMeanPt, int n, const std::vector<int>& trkIDs)
254254
{
255-
float meanPt{0.f};
255+
float meanPt = rawMeanPt;
256+
int removedCount = 0;
257+
float removedSumPt = 0.f;
258+
auto removeDaug = [&] (int daugID, float daugPt) {
259+
if (std::binary_search(trkIDs.begin(), trkIDs.end(), daugID)) {
260+
removedSumPt += daugPt;
261+
++removedCount;
262+
}
263+
};
256264
if constexpr (Channel == DecayChannel::DplusToPiKPi) {
257265
std::array<int, 3> daugIDs = {cand.prong0Id(), cand.prong1Id(), cand.prong2Id()};
258266
std::array<float, 3> daugPts = {cand.ptProng0(), cand.ptProng1(), cand.ptProng2()};
259-
for (int iProng = 0; iProng < 3; ++iProng) { // o2-linter: disable=magic-number (for 3-prong)
260-
if (std::binary_search(trkIDs.begin(), trkIDs.end(), daugIDs[iProng])) {
261-
meanPt = (rawMeanPt * n - daugPts[iProng]) / (n - 1);
262-
}
267+
for (int iProng = 0; iProng < 3; ++iProng) {
268+
removeDaug(daugIDs[iProng], daugPts[iProng]);
263269
}
264270
} else if constexpr (Channel == DecayChannel::D0ToPiK || Channel == DecayChannel::D0ToKPi) {
265271
std::array<int, 2> daugIDs = {cand.prong0Id(), cand.prong1Id()};
266272
std::array<float, 2> daugPts = {cand.ptProng0(), cand.ptProng1()};
267273
for (int iProng = 0; iProng < 2; ++iProng) { // o2-linter: disable=magic-number (for 2-prong)
268-
if (std::binary_search(trkIDs.begin(), trkIDs.end(), daugIDs[iProng])) {
269-
meanPt = (rawMeanPt * n - daugPts[iProng]) / (n - 1);
270-
}
274+
removeDaug(daugIDs[iProng], daugPts[iProng]);
271275
}
272276
}
277+
if (removedCount > 0) {
278+
meanPt = (rawMeanPt * n - removedSumPt) / (n - removedCount);
279+
}
273280
return meanPt;
274281
}
275282

0 commit comments

Comments
 (0)