Skip to content

Commit ff88fbb

Browse files
authored
[PWGHF] Update MC matching in XicToXiPiPi workflow (#11125)
1 parent 848b9e2 commit ff88fbb

File tree

3 files changed

+128
-81
lines changed

3 files changed

+128
-81
lines changed

PWGHF/DataModel/CandidateReconstructionTables.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,8 +1733,6 @@ DECLARE_SOA_COLUMN(NSigTofPrFromLambda, nSigTofPrFromLambda, float);
17331733
// MC matching result:
17341734
DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // reconstruction level
17351735
DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); // generator level
1736-
DECLARE_SOA_COLUMN(DebugMcRec, debugMcRec, int8_t); // debug flag for mis-association reconstruction level
1737-
DECLARE_SOA_COLUMN(DebugMcGen, debugMcGen, int8_t);
17381736
DECLARE_SOA_COLUMN(OriginRec, originRec, int8_t);
17391737
DECLARE_SOA_COLUMN(OriginGen, originGen, int8_t);
17401738
// Dynamic columns
@@ -1821,14 +1819,12 @@ DECLARE_SOA_TABLE(HfCandXicKF, "AOD", "HFCANDXICKF",
18211819
// table with results of reconstruction level MC matching
18221820
DECLARE_SOA_TABLE(HfCandXicMcRec, "AOD", "HFCANDXICMCREC", //!
18231821
hf_cand_xic_to_xi_pi_pi::FlagMcMatchRec,
1824-
hf_cand_xic_to_xi_pi_pi::DebugMcRec,
18251822
hf_cand_xic_to_xi_pi_pi::OriginRec);
1826-
18271823
// table with results of generator level MC matching
18281824
DECLARE_SOA_TABLE(HfCandXicMcGen, "AOD", "HFCANDXICMCGEN", //!
18291825
hf_cand_xic_to_xi_pi_pi::FlagMcMatchGen,
1830-
hf_cand_xic_to_xi_pi_pi::DebugMcGen,
1831-
hf_cand_xic_to_xi_pi_pi::OriginGen);
1826+
hf_cand_xic_to_xi_pi_pi::OriginGen,
1827+
hf_cand::PdgBhadMotherPart);
18321828

18331829
// specific chic candidate properties
18341830
namespace hf_cand_chic

PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx

Lines changed: 88 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,17 @@ struct HfCandidateCreatorXicToXiPiPiExpressions {
858858
Produces<aod::HfCandXicMcRec> rowMcMatchRec;
859859
Produces<aod::HfCandXicMcGen> rowMcMatchGen;
860860

861+
Configurable<bool> fillMcHistograms{"fillMcHistograms", true, "Fill validation plots"};
862+
Configurable<bool> matchDecayedPions{"matchDecayedPions", true, "Match also candidates with daughter pion tracks that decay with kinked topology"};
863+
Configurable<bool> matchInteractionsWithMaterial{"matchInteractionsWithMaterial", true, "Match also candidates with daughter tracks that interact with material"};
864+
865+
HfEventSelectionMc hfEvSelMc;
866+
867+
enum DebugRec { TotalRec = 0,
868+
XicToFinalState,
869+
XiToPiPPi,
870+
LambdaToPPi };
871+
861872
using McCollisionsNoCents = soa::Join<aod::Collisions, aod::EvSels, aod::McCollisionLabels>;
862873
using McCollisionsFT0Cs = soa::Join<aod::Collisions, aod::EvSels, aod::McCollisionLabels, aod::CentFT0Cs>;
863874
using McCollisionsFT0Ms = soa::Join<aod::Collisions, aod::EvSels, aod::McCollisionLabels, aod::CentFT0Ms>;
@@ -871,14 +882,23 @@ struct HfCandidateCreatorXicToXiPiPiExpressions {
871882

872883
HistogramRegistry registry{"registry"};
873884

874-
HfEventSelectionMc hfEvSelMc;
875-
876885
void init(InitContext& initContext)
877886
{
887+
// add histograms to registry
888+
if (fillMcHistograms) {
889+
registry.add("hDecayedPions", "hDecayedPions", {HistType::kTH1F, {{5, -0.5, 4.5}}});
890+
registry.add("hInteractionsWithMaterial", "hInteractionsWithMaterial", {HistType::kTH1F, {{21, -0.5, 20.5}}});
891+
registry.add("hDebugRec", "hDebugRec", {HistType::kTH1F, {{4, -0.5, 3.5}}});
892+
registry.get<TH1>(HIST("hDebugRec"))->GetXaxis()->SetBinLabel(1 + TotalRec, "total");
893+
registry.get<TH1>(HIST("hDebugRec"))->GetXaxis()->SetBinLabel(1 + XicToFinalState, "#Xi^{+}_{c} #rightarrow #pi^{#plus}) #pi^{#plus} #pi^{#minus} p #pi^{#minus}");
894+
registry.get<TH1>(HIST("hDebugRec"))->GetXaxis()->SetBinLabel(1 + XiToPiPPi, "#Xi^{#minus} #rightarrow #pi^{#minus} p #pi^{#minus}");
895+
registry.get<TH1>(HIST("hDebugRec"))->GetXaxis()->SetBinLabel(1 + LambdaToPPi, "#Lambda #rightarrow p #pi^{#minus}");
896+
}
897+
898+
// initialize HF event selection helper
878899
const auto& workflows = initContext.services().get<RunningWorkflowInfo const>();
879900
for (const DeviceSpec& device : workflows.devices) {
880901
if (device.name.compare("hf-candidate-creator-xic-to-xi-pi-pi") == 0) {
881-
// init HF event selection helper
882902
hfEvSelMc.init(device, registry);
883903
break;
884904
}
@@ -898,20 +918,24 @@ struct HfCandidateCreatorXicToXiPiPiExpressions {
898918
int indexRecXicPlus = -1;
899919
int8_t sign = 0;
900920
int8_t flag = 0;
901-
int8_t origin = 0;
902-
int8_t debug = 0;
903-
// for resonance matching:
921+
int8_t origin = RecoDecay::OriginType::None;
922+
int8_t nPionsDecayed = 0;
923+
int8_t nInteractionsWithMaterial = 0;
924+
// for resonance matching
904925
std::vector<int> arrDaughIndex;
905926
constexpr std::size_t NDaughtersResonant{2u};
906927
std::array<int, NDaughtersResonant> arrPDGDaugh;
907928
std::array<int, NDaughtersResonant> arrXiResonance = {3324, kPiPlus}; // 3324: Ξ(1530)
929+
// for non-prompt
930+
std::vector<int> idxBhadMothers;
908931

909932
// Match reconstructed candidates.
910933
for (const auto& candidate : *rowCandidateXic) {
911-
flag = 0;
912934
sign = 0;
935+
flag = 0;
913936
origin = RecoDecay::OriginType::None;
914-
debug = 0;
937+
nPionsDecayed = 0;
938+
nInteractionsWithMaterial = 0;
915939
arrDaughIndex.clear();
916940

917941
auto arrayDaughters = std::array{candidate.pi0_as<aod::TracksWMc>(), // pi <- Xic
@@ -925,25 +949,53 @@ struct HfCandidateCreatorXicToXiPiPiExpressions {
925949
auto arrayDaughtersV0 = std::array{candidate.posTrack_as<aod::TracksWMc>(),
926950
candidate.negTrack_as<aod::TracksWMc>()};
927951

952+
if (fillMcHistograms) {
953+
registry.fill(HIST("hDebugRec"), TotalRec);
954+
}
955+
928956
// Xic → pi pi pi pi p
929-
indexRec = RecoDecay::getMatchedMCRec<false, true, false, true>(mcParticles, arrayDaughters, Pdg::kXiCPlus, std::array{+kPiPlus, +kPiPlus, +kPiMinus, +kProton, +kPiMinus}, true, &sign, 4);
930-
indexRecXicPlus = indexRec;
931-
if (indexRec == -1) {
932-
debug = 1;
957+
if (matchDecayedPions && matchInteractionsWithMaterial) {
958+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, true, true>(mcParticles, arrayDaughters, Pdg::kXiCPlus, std::array{+kPiPlus, +kPiPlus, +kPiMinus, +kProton, +kPiMinus}, true, &sign, 4, &nPionsDecayed, nullptr, &nInteractionsWithMaterial);
959+
} else if (matchDecayedPions && !matchInteractionsWithMaterial) {
960+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, true, false>(mcParticles, arrayDaughters, Pdg::kXiCPlus, std::array{+kPiPlus, +kPiPlus, +kPiMinus, +kProton, +kPiMinus}, true, &sign, 4, &nPionsDecayed, nullptr, &nInteractionsWithMaterial);
961+
} else if (!matchDecayedPions && matchInteractionsWithMaterial) {
962+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, false, true>(mcParticles, arrayDaughters, Pdg::kXiCPlus, std::array{+kPiPlus, +kPiPlus, +kPiMinus, +kProton, +kPiMinus}, true, &sign, 4, &nPionsDecayed, nullptr, &nInteractionsWithMaterial);
963+
} else {
964+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, false, false>(mcParticles, arrayDaughters, Pdg::kXiCPlus, std::array{+kPiPlus, +kPiPlus, +kPiMinus, +kProton, +kPiMinus}, true, &sign, 4, &nPionsDecayed, nullptr, &nInteractionsWithMaterial);
933965
}
966+
indexRecXicPlus = indexRec;
934967
if (indexRec > -1) {
968+
if (fillMcHistograms) {
969+
registry.fill(HIST("hDebugRec"), XicToFinalState);
970+
}
935971
// Xi- → pi pi p
936-
indexRec = RecoDecay::getMatchedMCRec<false, true, false, true>(mcParticles, arrayDaughtersCasc, +kXiMinus, std::array{+kPiMinus, +kProton, +kPiMinus}, true, &sign, 2);
937-
if (indexRec == -1) {
938-
debug = 2;
972+
if (matchDecayedPions && matchInteractionsWithMaterial) {
973+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, true, true>(mcParticles, arrayDaughtersCasc, +kXiMinus, std::array{+kPiMinus, +kProton, +kPiMinus}, true, nullptr, 2);
974+
} else if (matchDecayedPions && !matchInteractionsWithMaterial) {
975+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, true, false>(mcParticles, arrayDaughtersCasc, +kXiMinus, std::array{+kPiMinus, +kProton, +kPiMinus}, true, nullptr, 2);
976+
} else if (!matchDecayedPions && matchInteractionsWithMaterial) {
977+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, false, true>(mcParticles, arrayDaughtersCasc, +kXiMinus, std::array{+kPiMinus, +kProton, +kPiMinus}, true, nullptr, 2);
978+
} else {
979+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, false, false>(mcParticles, arrayDaughtersCasc, +kXiMinus, std::array{+kPiMinus, +kProton, +kPiMinus}, true, nullptr, 2);
939980
}
940981
if (indexRec > -1) {
982+
if (fillMcHistograms) {
983+
registry.fill(HIST("hDebugRec"), XiToPiPPi);
984+
}
941985
// Lambda → p pi
942-
indexRec = RecoDecay::getMatchedMCRec<false, true, false, true>(mcParticles, arrayDaughtersV0, +kLambda0, std::array{+kProton, +kPiMinus}, true, &sign, 1);
943-
if (indexRec == -1) {
944-
debug = 3;
986+
if (matchDecayedPions && matchInteractionsWithMaterial) {
987+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, true, true>(mcParticles, arrayDaughtersV0, +kLambda0, std::array{+kProton, +kPiMinus}, true);
988+
} else if (matchDecayedPions && !matchInteractionsWithMaterial) {
989+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, true, false>(mcParticles, arrayDaughtersV0, +kLambda0, std::array{+kProton, +kPiMinus}, true);
990+
} else if (!matchDecayedPions && matchInteractionsWithMaterial) {
991+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, false, true>(mcParticles, arrayDaughtersV0, +kLambda0, std::array{+kProton, +kPiMinus}, true);
992+
} else {
993+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, false, false>(mcParticles, arrayDaughtersV0, +kLambda0, std::array{+kProton, +kPiMinus}, true);
945994
}
946995
if (indexRec > -1) {
996+
if (fillMcHistograms) {
997+
registry.fill(HIST("hDebugRec"), LambdaToPPi);
998+
}
947999
RecoDecay::getDaughters(mcParticles.rawIteratorAt(indexRecXicPlus), &arrDaughIndex, std::array{0}, 1);
9481000
if (arrDaughIndex.size() == NDaughtersResonant) {
9491001
for (auto iProng = 0u; iProng < NDaughtersResonant; ++iProng) {
@@ -952,8 +1004,6 @@ struct HfCandidateCreatorXicToXiPiPiExpressions {
9521004
}
9531005
if ((arrPDGDaugh[0] == arrXiResonance[0] && arrPDGDaugh[1] == arrXiResonance[1]) || (arrPDGDaugh[0] == arrXiResonance[1] && arrPDGDaugh[1] == arrXiResonance[0])) {
9541006
flag = sign * (1 << aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiResPiToXiPiPi);
955-
} else {
956-
debug = 4;
9571007
}
9581008
} else {
9591009
flag = sign * (1 << aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiPiPi);
@@ -967,8 +1017,13 @@ struct HfCandidateCreatorXicToXiPiPiExpressions {
9671017
auto particle = mcParticles.rawIteratorAt(indexRecXicPlus);
9681018
origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false);
9691019
}
970-
971-
rowMcMatchRec(flag, debug, origin);
1020+
// Fill histograms
1021+
if (flag != 0 && fillMcHistograms) {
1022+
registry.fill(HIST("hDecayedPions"), nPionsDecayed);
1023+
registry.fill(HIST("hInteractionsWithMaterial"), nInteractionsWithMaterial);
1024+
}
1025+
// Fill table
1026+
rowMcMatchRec(flag, origin);
9721027
} // close loop over candidates
9731028

9741029
// Match generated particles.
@@ -994,21 +1049,20 @@ struct HfCandidateCreatorXicToXiPiPiExpressions {
9941049
if (rejectionMask != 0) {
9951050
// at least one event selection not satisfied --> reject all particles from this collision
9961051
for (unsigned int i = 0; i < mcParticlesPerMcColl.size(); ++i) {
997-
rowMcMatchGen(0, 0, -1);
1052+
rowMcMatchGen(-99, -99, -99);
9981053
}
9991054
continue;
10001055
}
10011056

10021057
for (const auto& particle : mcParticlesPerMcColl) {
1003-
flag = 0;
10041058
sign = 0;
1005-
debug = 0;
1059+
flag = 0;
10061060
origin = RecoDecay::OriginType::None;
10071061
arrDaughIndex.clear();
1062+
idxBhadMothers.clear();
10081063

10091064
// Xic → Xi pi pi
10101065
if (RecoDecay::isMatchedMCGen<false, true>(mcParticles, particle, Pdg::kXiCPlus, std::array{+kXiMinus, +kPiPlus, +kPiPlus}, true, &sign, 2)) {
1011-
debug = 1;
10121066
// Xi- -> Lambda pi
10131067
auto cascMC = mcParticles.rawIteratorAt(particle.daughtersIds().front());
10141068
// Find Xi- from Xi(1530) -> Xi pi in case of resonant decay
@@ -1020,20 +1074,16 @@ struct HfCandidateCreatorXicToXiPiPiExpressions {
10201074
}
10211075
}
10221076
if (RecoDecay::isMatchedMCGen<false, true>(mcParticles, cascMC, +kXiMinus, std::array{+kLambda0, +kPiMinus}, true)) {
1023-
debug = 2;
10241077
// Lambda -> p pi
10251078
auto v0MC = mcParticles.rawIteratorAt(cascMC.daughtersIds().front());
10261079
if (RecoDecay::isMatchedMCGen<false, true>(mcParticles, v0MC, +kLambda0, std::array{+kProton, +kPiMinus}, true)) {
1027-
debug = 3;
10281080
if (arrDaughIndex.size() == NDaughtersResonant) {
10291081
for (auto iProng = 0u; iProng < NDaughtersResonant; ++iProng) {
10301082
auto daughI = mcParticles.rawIteratorAt(arrDaughIndex[iProng]);
10311083
arrPDGDaugh[iProng] = std::abs(daughI.pdgCode());
10321084
}
10331085
if ((arrPDGDaugh[0] == arrXiResonance[0] && arrPDGDaugh[1] == arrXiResonance[1]) || (arrPDGDaugh[0] == arrXiResonance[1] && arrPDGDaugh[1] == arrXiResonance[0])) {
10341086
flag = sign * (1 << aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiResPiToXiPiPi);
1035-
} else {
1036-
debug = 4;
10371087
}
10381088
} else {
10391089
flag = sign * (1 << aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiPiPi);
@@ -1044,10 +1094,15 @@ struct HfCandidateCreatorXicToXiPiPiExpressions {
10441094

10451095
// Check whether the charm baryon is non-prompt (from a b quark).
10461096
if (flag != 0) {
1047-
origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false);
1097+
origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers);
1098+
}
1099+
// Fill table
1100+
if (origin == RecoDecay::OriginType::NonPrompt) {
1101+
auto bHadMother = mcParticles.rawIteratorAt(idxBhadMothers[0]);
1102+
rowMcMatchGen(flag, origin, bHadMother.pdgCode());
1103+
} else {
1104+
rowMcMatchGen(flag, origin, 0);
10481105
}
1049-
1050-
rowMcMatchGen(flag, debug, origin);
10511106
} // close loop over generated particles
10521107
} // close loop over McCollisions
10531108
} // close template function

0 commit comments

Comments
 (0)