Skip to content

Commit 8961541

Browse files
authored
[PWGHF] Fixed MC matching of partly reconstructed resonances (#13380)
1 parent 551d6ff commit 8961541

File tree

5 files changed

+72
-28
lines changed

5 files changed

+72
-28
lines changed

PWGHF/D2H/DataModel/ReducedDataModel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,7 @@ DECLARE_SOA_TABLE(HfMcRecRedResos, "AOD", "HFMCRECREDRESO", //! Reconstruction-l
16461646
hf_reso_cand_reduced::Origin,
16471647
hf_reso_cand_reduced::PtGen,
16481648
hf_reso_cand_reduced::InvMassGen,
1649+
hf_cand::NTracksDecayed,
16491650
o2::soa::Marker<1>);
16501651
} // namespace aod
16511652

PWGHF/D2H/TableProducer/candidateCreatorCharmResoReduced.cxx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -957,31 +957,32 @@ struct HfCandidateCreatorCharmResoReducedExpressions {
957957
{
958958
for (const auto& candReso : candsReso) {
959959
bool filledMcInfo{false};
960-
for (const auto& rowDV0McRec : rowsMcRec) {
961-
if ((rowDV0McRec.prong0Id() != candReso.prong0Id()) || (rowDV0McRec.prong1Id() != candReso.prong1Id())) {
960+
for (const auto& rowMcRec : rowsMcRec) {
961+
if ((rowMcRec.prong0Id() != candReso.prong0Id()) || (rowMcRec.prong1Id() != candReso.prong1Id())) {
962962
continue;
963963
}
964-
rowResoMcRec(rowDV0McRec.flagMcMatchRec(),
965-
rowDV0McRec.flagMcMatchRecD(),
966-
rowDV0McRec.flagMcMatchChanD(),
967-
rowDV0McRec.debugMcRec(),
968-
rowDV0McRec.origin(),
969-
rowDV0McRec.ptGen(),
970-
rowDV0McRec.invMassGen());
964+
rowResoMcRec(rowMcRec.flagMcMatchRec(),
965+
rowMcRec.flagMcMatchRecD(),
966+
rowMcRec.flagMcMatchChanD(),
967+
rowMcRec.debugMcRec(),
968+
rowMcRec.origin(),
969+
rowMcRec.ptGen(),
970+
rowMcRec.invMassGen(),
971+
rowMcRec.nTracksDecayed());
971972
filledMcInfo = true;
972-
if (std::abs(rowDV0McRec.flagMcMatchRec()) > 0 &&
973-
!TESTBIT(rowDV0McRec.debugMcRec(), hf_decay::hf_cand_reso::PartialMatchMc::ResoPartlyMatched)) {
973+
if (std::abs(rowMcRec.flagMcMatchRec()) > 0 &&
974+
!TESTBIT(rowMcRec.debugMcRec(), hf_decay::hf_cand_reso::PartialMatchMc::ResoPartlyMatched)) {
974975
registry.fill(HIST("hMassMcMatched"), candReso.invMass(), candReso.pt());
975-
} else if (std::abs(rowDV0McRec.flagMcMatchRec()) > 0 &&
976-
TESTBIT(rowDV0McRec.debugMcRec(), hf_decay::hf_cand_reso::PartialMatchMc::ResoPartlyMatched)) {
976+
} else if (std::abs(rowMcRec.flagMcMatchRec()) > 0 &&
977+
TESTBIT(rowMcRec.debugMcRec(), hf_decay::hf_cand_reso::PartialMatchMc::ResoPartlyMatched)) {
977978
registry.fill(HIST("hMassMcMatchedIncomplete"), candReso.invMass(), candReso.pt());
978979
} else {
979980
registry.fill(HIST("hMassMcUnmatched"), candReso.invMass(), candReso.pt());
980981
}
981982
break;
982983
}
983984
if (!filledMcInfo) { // protection to get same size tables in case something went wrong: we created a candidate that was not preselected in the D-Pi creator
984-
rowResoMcRec(0, 0, 0, 0, 0, -1.f, -1.f);
985+
rowResoMcRec(0, 0, 0, 0, 0, -1.f, -1.f, 0);
985986
registry.fill(HIST("hMassMcNoEntry"), candReso.invMass(), candReso.pt());
986987
}
987988
}

PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ struct HfDataCreatorCharmResoReduced {
680680
std::array<int, 5> const pdgCodesDaughters = {+kPiPlus, -kKPlus, +kPiPlus, +kPiPlus, -kPiPlus};
681681
auto arrDaughtersReso = std::array{vecDaughtersReso[0], vecDaughtersReso[1], vecDaughtersReso[2], vecDaughtersReso[3], vecDaughtersReso[4]};
682682
for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToDstarK0s) {
683-
indexRec = RecoDecay::getMatchedMCRec<false, true, true, true, true>(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks);
683+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, true, true>(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks);
684684
if (indexRec > -1) {
685685
flagReso = sign * decayChannelFlag;
686686
break;
@@ -734,19 +734,31 @@ struct HfDataCreatorCharmResoReduced {
734734
auto pdgCodesDplusDaughters = hf_decay::hf_cand_3prong::daughtersDplusMain.at(static_cast<hf_decay::hf_cand_3prong::DecayChannelMain>(std::abs(flagCharmBach)));
735735
auto pdgCodesDaughters = std::array{pdgCodesDplusDaughters[0], pdgCodesDplusDaughters[1], pdgCodesDplusDaughters[2], +kPiPlus, -kPiPlus};
736736
for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToDplusK0s) {
737-
indexRec = RecoDecay::getMatchedMCRec<false, true, true, true, true>(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks);
737+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, true, true>(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks);
738738
if (indexRec > -1) {
739739
flagReso = sign * decayChannelFlag;
740740
break;
741741
}
742742
}
743+
// Partial matching of Dsj -> D*K0s -> (D+ pi0) (K0s) with missing neutral
744+
if (indexRec < 0) {
745+
for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToDstarK0s) {
746+
indexRec = RecoDecay::getMatchedMCRec<false, true, true, true, true>(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks);
747+
if (indexRec > -1) {
748+
flagReso = sign * decayChannelFlag;
749+
SETBIT(debugMcRec, hf_decay::hf_cand_reso::PartialMatchMc::ResoPartlyMatched);
750+
break;
751+
}
752+
}
753+
}
754+
743755
} else if (hf_decay::hf_cand_3prong::daughtersDplusMain.contains(static_cast<hf_decay::hf_cand_3prong::DecayChannelMain>(std::abs(flagCharmBach))) && std::abs(flagV0) == hf_decay::hf_cand_reso::PartialMatchMc::LambdaMatched) {
744756
// Peaking background of D+Lambda <- Ds* with spurious soft pion
745757
auto arrDaughtersReso = std::array{vecDaughtersReso[0], vecDaughtersReso[1], vecDaughtersReso[2], vecDaughtersReso[3], vecDaughtersReso[4]};
746758
auto pdgCodesDplusDaughters = hf_decay::hf_cand_3prong::daughtersDplusMain.at(static_cast<hf_decay::hf_cand_3prong::DecayChannelMain>(std::abs(flagCharmBach)));
747759
auto pdgCodesDaughters = std::array{pdgCodesDplusDaughters[0], pdgCodesDplusDaughters[1], pdgCodesDplusDaughters[2], +kProton, -kPiPlus};
748760
for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToDplusLambda) {
749-
indexRec = RecoDecay::getMatchedMCRec<false, true, true, true, true>(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks);
761+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, true, true>(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks);
750762
if (indexRec > -1) {
751763
flagReso = sign * decayChannelFlag;
752764
break;
@@ -787,7 +799,7 @@ struct HfDataCreatorCharmResoReduced {
787799
auto pdgCodesDzeroDaughters = hf_decay::hf_cand_2prong::daughtersD0Main.at(static_cast<hf_decay::hf_cand_2prong::DecayChannelMain>(std::abs(flagCharmBach)));
788800
auto pdgCodesDaughters = std::array{pdgCodesDzeroDaughters[0], pdgCodesDzeroDaughters[1], +kProton, -kPiPlus};
789801
for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToD0Lambda) {
790-
indexRec = RecoDecay::getMatchedMCRec<false, true, true, true, true>(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks);
802+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, true, true>(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks);
791803
if (indexRec > -1) {
792804
flagReso = sign * decayChannelFlag;
793805
break;
@@ -878,7 +890,7 @@ struct HfDataCreatorCharmResoReduced {
878890
auto arrDaughtersReso = std::array{vecDaughtersReso[0], vecDaughtersReso[1], vecDaughtersReso[2], bachelorTrack};
879891
auto pdgCodesDaughters = std::array{+kPiPlus, -kKPlus, +kPiPlus, -kPiPlus};
880892
for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToDstarPi) {
881-
indexRec = RecoDecay::getMatchedMCRec<false, true, true, true, true>(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks);
893+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, true, true>(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks);
882894
if (indexRec > -1) {
883895
flagReso = sign * decayChannelFlag;
884896
break;
@@ -918,12 +930,23 @@ struct HfDataCreatorCharmResoReduced {
918930
auto pdgCodesDplusDaughters = hf_decay::hf_cand_3prong::daughtersDplusMain.at(static_cast<hf_decay::hf_cand_3prong::DecayChannelMain>(std::abs(flagCharmBach)));
919931
auto pdgCodesDaughters = std::array{pdgCodesDplusDaughters[0], pdgCodesDplusDaughters[1], pdgCodesDplusDaughters[2], -kPiPlus};
920932
for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToDplusPi) {
921-
indexRec = RecoDecay::getMatchedMCRec<false, true, true, true, true>(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks);
933+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, true, true>(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks);
922934
if (indexRec > -1) {
923935
flagReso = sign * decayChannelFlag;
924936
break;
925937
}
926938
}
939+
// Partial matching of Dj -> D*Pi -> (D+ pi0) (pi) with missing neutral
940+
if (indexRec < 0) {
941+
for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToDstarPi) {
942+
indexRec = RecoDecay::getMatchedMCRec<false, true, true, true, true>(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks);
943+
if (indexRec > -1) {
944+
flagReso = sign * decayChannelFlag;
945+
SETBIT(debugMcRec, hf_decay::hf_cand_reso::PartialMatchMc::ResoPartlyMatched);
946+
break;
947+
}
948+
}
949+
}
927950
}
928951
// No channels in D+K+ or D+Pr
929952
if (indexRec > -1) {
@@ -955,18 +978,29 @@ struct HfDataCreatorCharmResoReduced {
955978
auto pdgCodesDzeroDaughters = hf_decay::hf_cand_2prong::daughtersD0Main.at(static_cast<hf_decay::hf_cand_2prong::DecayChannelMain>(std::abs(flagCharmBach)));
956979
auto pdgCodesDaughters = std::array{pdgCodesDzeroDaughters[0], pdgCodesDzeroDaughters[1], +kPiPlus};
957980
for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToD0Pi) {
958-
indexRec = RecoDecay::getMatchedMCRec<false, true, true, true, true>(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks);
981+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, true, true>(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks);
959982
if (indexRec > -1) {
960983
flagReso = sign * decayChannelFlag;
961984
break;
962985
}
963986
}
987+
// Partial matching of Dj -> D*Pi -> (D0 pi) (pi) with missing pion
988+
if (indexRec < 0) {
989+
for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToDstarPi) {
990+
indexRec = RecoDecay::getMatchedMCRec<false, true, true, true, true>(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks);
991+
if (indexRec > -1) {
992+
flagReso = sign * decayChannelFlag;
993+
SETBIT(debugMcRec, hf_decay::hf_cand_reso::PartialMatchMc::ResoPartlyMatched);
994+
break;
995+
}
996+
}
997+
}
964998
} else if (hf_decay::hf_cand_2prong::daughtersD0Main.contains(static_cast<hf_decay::hf_cand_2prong::DecayChannelMain>(std::abs(flagCharmBach))) && flagTrack == hf_decay::hf_cand_reso::PartialMatchMc::KaonMatched) {
965999
auto arrDaughtersReso = std::array{vecDaughtersReso[0], vecDaughtersReso[1], bachelorTrack};
9661000
auto pdgCodesDzeroDaughters = hf_decay::hf_cand_2prong::daughtersD0Main.at(static_cast<hf_decay::hf_cand_2prong::DecayChannelMain>(std::abs(flagCharmBach)));
9671001
auto pdgCodesDaughters = std::array{pdgCodesDzeroDaughters[0], pdgCodesDzeroDaughters[1], +kKPlus};
9681002
for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToD0Kplus) {
969-
indexRec = RecoDecay::getMatchedMCRec<false, true, true, true, true>(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks);
1003+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, true, true>(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks);
9701004
if (indexRec > -1) {
9711005
flagReso = sign * decayChannelFlag;
9721006
break;

PWGHF/D2H/Tasks/taskCharmResoToDTrkReduced.cxx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ DECLARE_SOA_COLUMN(PtGen, ptGen, float);
8383
DECLARE_SOA_COLUMN(InvMassGen, invMassGen, float); //! Invariant mass of candidate (GeV/c2)
8484
DECLARE_SOA_COLUMN(FlagCharmBach, flagCharmBach, int8_t); //! Flag for charm bachelor classification
8585
DECLARE_SOA_COLUMN(FlagCharmBachInterm, flagCharmBachInterm, int8_t); //! Flag for charm bachelor classification intermediate
86+
DECLARE_SOA_COLUMN(NKinkedTracks, nKinkedTracks, int8_t); //! Number of kinked tracks found in MC matching
8687
} // namespace hf_cand_reso_to_trk_lite
8788

8889
DECLARE_SOA_TABLE(HfCandDTrkLites, "AOD", "HFCANDDTRKLITE", //! Table with some B0 properties
@@ -119,7 +120,8 @@ DECLARE_SOA_TABLE(HfCandDTrkLites, "AOD", "HFCANDDTRKLITE", //! Table with some
119120
hf_cand_reso_to_trk_lite::PtGen,
120121
hf_cand_reso_to_trk_lite::InvMassGen,
121122
hf_cand_reso_to_trk_lite::FlagCharmBach,
122-
hf_cand_reso_to_trk_lite::FlagCharmBachInterm);
123+
hf_cand_reso_to_trk_lite::FlagCharmBachInterm,
124+
hf_cand_reso_to_trk_lite::NKinkedTracks);
123125

124126
DECLARE_SOA_TABLE(HfGenResoLites, "AOD", "HFGENRESOLITE", //! Table with some B0 properties
125127
hf_cand_reso_to_trk_lite::Pt,
@@ -227,7 +229,7 @@ struct HfTaskCharmResoToDTrkReduced {
227229

228230
// MC Rec
229231
float ptGen{-1.}, invMassGen{-1};
230-
int8_t origin{0}, flagMcMatchRec{0}, flagCharmBach{0}, flagCharmBachInterm{0};
232+
int8_t origin{0}, flagMcMatchRec{0}, flagCharmBach{0}, flagCharmBachInterm{0}, nKinkedTracks{0};
231233
int debugMcRec{-1};
232234
if constexpr (DoMc) {
233235
ptGen = candidate.ptGen();
@@ -237,6 +239,7 @@ struct HfTaskCharmResoToDTrkReduced {
237239
invMassGen = candidate.invMassGen();
238240
flagCharmBach = candidate.flagMcMatchRecD();
239241
flagCharmBachInterm = candidate.flagMcMatchChanD();
242+
nKinkedTracks = candidate.nTracksDecayed();
240243
if (fillOnlySignal) {
241244
if (Channel == DecayChannel::D0Kplus &&
242245
!hf_decay::hf_cand_reso::particlesToD0Kplus.contains(static_cast<hf_decay::hf_cand_reso::DecayChannelMain>(std::abs(flagMcMatchRec)))) {
@@ -324,7 +327,8 @@ struct HfTaskCharmResoToDTrkReduced {
324327
ptGen,
325328
invMassGen,
326329
flagCharmBach,
327-
flagCharmBachInterm);
330+
flagCharmBachInterm,
331+
nKinkedTracks);
328332
}
329333
} // fillCand
330334

PWGHF/D2H/Tasks/taskCharmResoToDV0Reduced.cxx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ DECLARE_SOA_COLUMN(PtGen, ptGen, float);
8888
DECLARE_SOA_COLUMN(InvMassGen, invMassGen, float); //! Invariant mass of candidate (GeV/c2)
8989
DECLARE_SOA_COLUMN(FlagCharmBach, flagCharmBach, int8_t); //! Flag for charm bachelor classification
9090
DECLARE_SOA_COLUMN(FlagCharmBachInterm, flagCharmBachInterm, int8_t); //! Flag for charm bachelor classification intermediate
91+
DECLARE_SOA_COLUMN(NKinkedTracks, nKinkedTracks, int8_t); //! Number of kinked tracks found in MC matching
9192
} // namespace hf_cand_reso_to_v0_lite
9293

9394
DECLARE_SOA_TABLE(HfCandDV0Lites, "AOD", "HFCANDDV0LITE", //! Table with some Resonances properties
@@ -128,7 +129,8 @@ DECLARE_SOA_TABLE(HfCandDV0Lites, "AOD", "HFCANDDV0LITE", //! Table with some Re
128129
hf_cand_reso_to_v0_lite::PtGen,
129130
hf_cand_reso_to_v0_lite::InvMassGen,
130131
hf_cand_reso_to_v0_lite::FlagCharmBach,
131-
hf_cand_reso_to_v0_lite::FlagCharmBachInterm);
132+
hf_cand_reso_to_v0_lite::FlagCharmBachInterm,
133+
hf_cand_reso_to_v0_lite::NKinkedTracks);
132134

133135
DECLARE_SOA_TABLE(HfGenResoLites, "AOD", "HFGENRESOLITE", //! Table with some B0 properties
134136
hf_cand_reso_to_v0_lite::Pt,
@@ -258,7 +260,7 @@ struct HfTaskCharmResoToDV0Reduced {
258260

259261
// MC Rec
260262
float ptGen{-1.}, invMassGen{-1};
261-
int8_t origin{0}, flagMcMatchRec{0}, flagCharmBach{0}, flagCharmBachInterm{0};
263+
int8_t origin{0}, flagMcMatchRec{0}, flagCharmBach{0}, flagCharmBachInterm{0}, nKinkedTracks{0};
262264
int debugMcRec{-1};
263265
if constexpr (DoMc) {
264266
ptGen = candidate.ptGen();
@@ -268,6 +270,7 @@ struct HfTaskCharmResoToDV0Reduced {
268270
invMassGen = candidate.invMassGen();
269271
flagCharmBach = candidate.flagMcMatchRecD();
270272
flagCharmBachInterm = candidate.flagMcMatchChanD();
273+
nKinkedTracks = candidate.nTracksDecayed();
271274
if (fillOnlySignal) {
272275
if (Channel == DecayChannel::DstarK0s &&
273276
!hf_decay::hf_cand_reso::particlesToDstarK0s.contains(static_cast<hf_decay::hf_cand_reso::DecayChannelMain>(std::abs(flagMcMatchRec)))) {
@@ -372,7 +375,8 @@ struct HfTaskCharmResoToDV0Reduced {
372375
ptGen,
373376
invMassGen,
374377
flagCharmBach,
375-
flagCharmBachInterm);
378+
flagCharmBachInterm,
379+
nKinkedTracks);
376380
}
377381
} // fillCand
378382

0 commit comments

Comments
 (0)