@@ -252,32 +252,27 @@ 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 = rawMeanPt;
256255 int removedCount = 0 ;
257256 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- }
257+ auto removeDaug = [&](int daugID, float daugPt) {
258+ if (std::binary_search (trkIDs.begin (), trkIDs.end (), daugID)) {
259+ removedSumPt += daugPt;
260+ ++removedCount;
261+ }
263262 };
264263 if constexpr (Channel == DecayChannel::DplusToPiKPi) {
265- std::array<int , 3 > daugIDs = {cand.prong0Id (), cand.prong1Id (), cand.prong2Id ()};
266- std::array<float , 3 > daugPts = {cand.ptProng0 (), cand.ptProng1 (), cand.ptProng2 ()};
267- for (int iProng = 0 ; iProng < 3 ; ++iProng) {
268- removeDaug (daugIDs[iProng], daugPts[iProng]);
269- }
264+ removeDaug (cand.prong0Id (), cand.ptProng0 ());
265+ removeDaug (cand.prong1Id (), cand.ptProng1 ());
266+ removeDaug (cand.prong2Id (), cand.ptProng2 ());
270267 } else if constexpr (Channel == DecayChannel::D0ToPiK || Channel == DecayChannel::D0ToKPi) {
271- std::array<int , 2 > daugIDs = {cand.prong0Id (), cand.prong1Id ()};
272- std::array<float , 2 > daugPts = {cand.ptProng0 (), cand.ptProng1 ()};
273- for (int iProng = 0 ; iProng < 2 ; ++iProng) { // o2-linter: disable=magic-number (for 2-prong)
274- removeDaug (daugIDs[iProng], daugPts[iProng]);
275- }
268+ removeDaug (cand.prong0Id (), cand.ptProng0 ());
269+ removeDaug (cand.prong1Id (), cand.ptProng1 ());
276270 }
277271 if (removedCount > 0 ) {
278- meanPt = (rawMeanPt * n - removedSumPt) / (n - removedCount);
272+ double totalSum = static_cast <double >(rawMeanPt) * n;
273+ return static_cast <float >((totalSum - removedSumPt) / (n - removedCount));
279274 }
280- return meanPt ;
275+ return rawMeanPt ;
281276 }
282277
283278 // ---------------------------------------------------------------------------
0 commit comments