From 54e8364648eb433906bc606048e05a18fe41eff8 Mon Sep 17 00:00:00 2001 From: Luca610 Date: Tue, 30 Sep 2025 17:55:39 +0200 Subject: [PATCH 1/2] Fixed generated invariant mass calculation --- .../candidateCreatorCharmResoReduced.cxx | 3 ++- .../dataCreatorCharmResoReduced.cxx | 25 +++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/PWGHF/D2H/TableProducer/candidateCreatorCharmResoReduced.cxx b/PWGHF/D2H/TableProducer/candidateCreatorCharmResoReduced.cxx index 052626a6ef3..baef99914fb 100644 --- a/PWGHF/D2H/TableProducer/candidateCreatorCharmResoReduced.cxx +++ b/PWGHF/D2H/TableProducer/candidateCreatorCharmResoReduced.cxx @@ -389,10 +389,11 @@ struct HfCandidateCreatorCharmResoReduced { if (TESTBIT(candV0Tr.v0Type(), V0Type::Lambda)) { invMassV0Tr = candV0Tr.invMassLambda(); signReso = candD.sign(); + isWrongSign = candD.sign() < 0 ? 1 : 0; } else if (TESTBIT(candV0Tr.v0Type(), V0Type::AntiLambda)) { invMassV0Tr = candV0Tr.invMassAntiLambda(); signReso = candD.sign(); - isWrongSign = 1; + isWrongSign = candD.sign() > 0 ? 1 : 0; } if (useDeltaMass) { invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassLambda}) - invMassD; diff --git a/PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx b/PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx index c2d7d6f3047..9960ca23200 100644 --- a/PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx +++ b/PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx @@ -620,6 +620,17 @@ struct HfDataCreatorCharmResoReduced { return flagV0; // Placeholder, should return the actual flag based on matching logic } + template + double computeInvMassGen(PParticles const& particlesMc, int indexRec) + { + auto particleReso = particlesMc.iteratorAt(indexRec); + auto dau1 = particlesMc.iteratorAt(particleReso.daughtersIds().front()); + auto dau2 = particlesMc.iteratorAt(particleReso.daughtersIds().back()); + std::array, 2> pArr = {{{dau1.px(), dau1.py(), dau1.pz()}, {dau2.px(), dau2.py(), dau2.pz()}}}; + std::array mArr = {static_cast(pdg->Mass(dau1.pdgCode())), static_cast(pdg->Mass(dau2.pdgCode()))}; + return RecoDecay::m(pArr, mArr); + } + /// Function for filling MC reco information of DV0 candidates in the tables /// \tparam dType is the D meson type (Dstar, Dplus or D0) /// \param particlesMc is the table with MC particles @@ -690,7 +701,7 @@ struct HfDataCreatorCharmResoReduced { if (indexRec > -1) { auto particleReso = particlesMc.iteratorAt(indexRec); ptGen = particleReso.pt(); - invMassGen = RecoDecay::m(particleReso.p(), particleReso.e()); + invMassGen = computeInvMassGen(particlesMc, indexRec); } rowHfDstarV0McRecReduced(indexHfCandCharm, indexCandV0Bach, flagReso, flagCharmBach, @@ -743,7 +754,7 @@ struct HfDataCreatorCharmResoReduced { if (indexRec > -1) { auto particleReso = particlesMc.iteratorAt(indexRec); ptGen = particleReso.pt(); - invMassGen = RecoDecay::m(particleReso.p(), particleReso.e()); + invMassGen = computeInvMassGen(particlesMc, indexRec); } rowHf3PrV0McRecReduced(indexHfCandCharm, indexCandV0Bach, flagReso, flagCharmBach, @@ -784,7 +795,7 @@ struct HfDataCreatorCharmResoReduced { if (indexRec > -1) { auto particleReso = particlesMc.iteratorAt(indexRec); ptGen = particleReso.pt(); - invMassGen = RecoDecay::m(particleReso.p(), particleReso.e()); + invMassGen = computeInvMassGen(particlesMc, indexRec); } rowHf2PrV0McRecReduced(indexHfCandCharm, indexCandV0Bach, flagReso, flagCharmBach, @@ -874,7 +885,7 @@ struct HfDataCreatorCharmResoReduced { if (indexRec > -1) { auto particleReso = particlesMc.iteratorAt(indexRec); ptGen = particleReso.pt(); - invMassGen = RecoDecay::m(particleReso.p(), particleReso.e()); + invMassGen = computeInvMassGen(particlesMc, indexRec); } rowHfDstarTrkMcRecReduced(indexHfCandCharm, indexCandTrBach, flagReso, flagCharmBach, @@ -914,7 +925,7 @@ struct HfDataCreatorCharmResoReduced { if (indexRec > -1) { auto particleReso = particlesMc.iteratorAt(indexRec); ptGen = particleReso.pt(); - invMassGen = RecoDecay::m(particleReso.p(), particleReso.e()); + invMassGen = computeInvMassGen(particlesMc, indexRec); } rowHf3PrTrkMcRecReduced(indexHfCandCharm, indexCandTrBach, flagReso, flagCharmBach, @@ -961,7 +972,7 @@ struct HfDataCreatorCharmResoReduced { if (indexRec > -1) { auto particleReso = particlesMc.iteratorAt(indexRec); ptGen = particleReso.pt(); - invMassGen = RecoDecay::m(particleReso.p(), particleReso.e()); + invMassGen = computeInvMassGen(particlesMc, indexRec); } rowHf2PrTrkMcRecReduced(indexHfCandCharm, indexCandTrBach, flagReso, flagCharmBach, @@ -1679,7 +1690,7 @@ struct HfDataCreatorCharmResoReduced { origin = RecoDecay::getCharmHadronOrigin(mcParticlesPerMcColl, particle, false, &idxBhadMothers); registry.fill(HIST("hMCGenOrigin"), origin); auto ptParticle = particle.pt(); - auto invMassGen = RecoDecay::m(particle.p(), particle.e()); + auto invMassGen = computeInvMassGen(mcParticles, particle.globalIndex()); auto yParticle = RecoDecay::y(particle.pVector(), invMassGen); auto etaParticle = particle.eta(); From da31f19fa359d2774f6e7afb3bcf8e39692964e1 Mon Sep 17 00:00:00 2001 From: Luca610 Date: Wed, 1 Oct 2025 10:39:00 +0200 Subject: [PATCH 2/2] Casting to float --- PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx b/PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx index 9960ca23200..b5bedc4e8ee 100644 --- a/PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx +++ b/PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx @@ -621,14 +621,14 @@ struct HfDataCreatorCharmResoReduced { } template - double computeInvMassGen(PParticles const& particlesMc, int indexRec) + float computeInvMassGen(PParticles const& particlesMc, int indexRec) { auto particleReso = particlesMc.iteratorAt(indexRec); auto dau1 = particlesMc.iteratorAt(particleReso.daughtersIds().front()); auto dau2 = particlesMc.iteratorAt(particleReso.daughtersIds().back()); std::array, 2> pArr = {{{dau1.px(), dau1.py(), dau1.pz()}, {dau2.px(), dau2.py(), dau2.pz()}}}; std::array mArr = {static_cast(pdg->Mass(dau1.pdgCode())), static_cast(pdg->Mass(dau2.pdgCode()))}; - return RecoDecay::m(pArr, mArr); + return static_cast(RecoDecay::m(pArr, mArr)); } /// Function for filling MC reco information of DV0 candidates in the tables