Skip to content

Commit 54e8364

Browse files
committed
Fixed generated invariant mass calculation
1 parent 84af1bc commit 54e8364

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

PWGHF/D2H/TableProducer/candidateCreatorCharmResoReduced.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,10 +389,11 @@ struct HfCandidateCreatorCharmResoReduced {
389389
if (TESTBIT(candV0Tr.v0Type(), V0Type::Lambda)) {
390390
invMassV0Tr = candV0Tr.invMassLambda();
391391
signReso = candD.sign();
392+
isWrongSign = candD.sign() < 0 ? 1 : 0;
392393
} else if (TESTBIT(candV0Tr.v0Type(), V0Type::AntiLambda)) {
393394
invMassV0Tr = candV0Tr.invMassAntiLambda();
394395
signReso = candD.sign();
395-
isWrongSign = 1;
396+
isWrongSign = candD.sign() > 0 ? 1 : 0;
396397
}
397398
if (useDeltaMass) {
398399
invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassLambda}) - invMassD;

PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,17 @@ struct HfDataCreatorCharmResoReduced {
620620
return flagV0; // Placeholder, should return the actual flag based on matching logic
621621
}
622622

623+
template <typename PParticles>
624+
double computeInvMassGen(PParticles const& particlesMc, int indexRec)
625+
{
626+
auto particleReso = particlesMc.iteratorAt(indexRec);
627+
auto dau1 = particlesMc.iteratorAt(particleReso.daughtersIds().front());
628+
auto dau2 = particlesMc.iteratorAt(particleReso.daughtersIds().back());
629+
std::array<std::array<float, 3>, 2> pArr = {{{dau1.px(), dau1.py(), dau1.pz()}, {dau2.px(), dau2.py(), dau2.pz()}}};
630+
std::array<float, 2> mArr = {static_cast<float>(pdg->Mass(dau1.pdgCode())), static_cast<float>(pdg->Mass(dau2.pdgCode()))};
631+
return RecoDecay::m(pArr, mArr);
632+
}
633+
623634
/// Function for filling MC reco information of DV0 candidates in the tables
624635
/// \tparam dType is the D meson type (Dstar, Dplus or D0)
625636
/// \param particlesMc is the table with MC particles
@@ -690,7 +701,7 @@ struct HfDataCreatorCharmResoReduced {
690701
if (indexRec > -1) {
691702
auto particleReso = particlesMc.iteratorAt(indexRec);
692703
ptGen = particleReso.pt();
693-
invMassGen = RecoDecay::m(particleReso.p(), particleReso.e());
704+
invMassGen = computeInvMassGen(particlesMc, indexRec);
694705
}
695706
rowHfDstarV0McRecReduced(indexHfCandCharm, indexCandV0Bach,
696707
flagReso, flagCharmBach,
@@ -743,7 +754,7 @@ struct HfDataCreatorCharmResoReduced {
743754
if (indexRec > -1) {
744755
auto particleReso = particlesMc.iteratorAt(indexRec);
745756
ptGen = particleReso.pt();
746-
invMassGen = RecoDecay::m(particleReso.p(), particleReso.e());
757+
invMassGen = computeInvMassGen(particlesMc, indexRec);
747758
}
748759
rowHf3PrV0McRecReduced(indexHfCandCharm, indexCandV0Bach,
749760
flagReso, flagCharmBach,
@@ -784,7 +795,7 @@ struct HfDataCreatorCharmResoReduced {
784795
if (indexRec > -1) {
785796
auto particleReso = particlesMc.iteratorAt(indexRec);
786797
ptGen = particleReso.pt();
787-
invMassGen = RecoDecay::m(particleReso.p(), particleReso.e());
798+
invMassGen = computeInvMassGen(particlesMc, indexRec);
788799
}
789800
rowHf2PrV0McRecReduced(indexHfCandCharm, indexCandV0Bach,
790801
flagReso, flagCharmBach,
@@ -874,7 +885,7 @@ struct HfDataCreatorCharmResoReduced {
874885
if (indexRec > -1) {
875886
auto particleReso = particlesMc.iteratorAt(indexRec);
876887
ptGen = particleReso.pt();
877-
invMassGen = RecoDecay::m(particleReso.p(), particleReso.e());
888+
invMassGen = computeInvMassGen(particlesMc, indexRec);
878889
}
879890
rowHfDstarTrkMcRecReduced(indexHfCandCharm, indexCandTrBach,
880891
flagReso, flagCharmBach,
@@ -914,7 +925,7 @@ struct HfDataCreatorCharmResoReduced {
914925
if (indexRec > -1) {
915926
auto particleReso = particlesMc.iteratorAt(indexRec);
916927
ptGen = particleReso.pt();
917-
invMassGen = RecoDecay::m(particleReso.p(), particleReso.e());
928+
invMassGen = computeInvMassGen(particlesMc, indexRec);
918929
}
919930
rowHf3PrTrkMcRecReduced(indexHfCandCharm, indexCandTrBach,
920931
flagReso, flagCharmBach,
@@ -961,7 +972,7 @@ struct HfDataCreatorCharmResoReduced {
961972
if (indexRec > -1) {
962973
auto particleReso = particlesMc.iteratorAt(indexRec);
963974
ptGen = particleReso.pt();
964-
invMassGen = RecoDecay::m(particleReso.p(), particleReso.e());
975+
invMassGen = computeInvMassGen(particlesMc, indexRec);
965976
}
966977
rowHf2PrTrkMcRecReduced(indexHfCandCharm, indexCandTrBach,
967978
flagReso, flagCharmBach,
@@ -1679,7 +1690,7 @@ struct HfDataCreatorCharmResoReduced {
16791690
origin = RecoDecay::getCharmHadronOrigin(mcParticlesPerMcColl, particle, false, &idxBhadMothers);
16801691
registry.fill(HIST("hMCGenOrigin"), origin);
16811692
auto ptParticle = particle.pt();
1682-
auto invMassGen = RecoDecay::m(particle.p(), particle.e());
1693+
auto invMassGen = computeInvMassGen(mcParticles, particle.globalIndex());
16831694
auto yParticle = RecoDecay::y(particle.pVector(), invMassGen);
16841695
auto etaParticle = particle.eta();
16851696

0 commit comments

Comments
 (0)