From faeeae41c545fad5284149e79027805609641f8f Mon Sep 17 00:00:00 2001 From: Fabio Catalano Date: Fri, 31 May 2024 17:59:39 +0200 Subject: [PATCH 1/4] D0: move B-mother to candidate table --- PWGHF/Core/HfHelper.h | 52 ------------------- PWGHF/D2H/Tasks/taskD0.cxx | 25 ++------- .../DataModel/CandidateReconstructionTables.h | 21 +++++--- .../TableProducer/candidateCreator2Prong.cxx | 27 +++++++--- PWGHF/TableProducer/candidateCreatorDstar.cxx | 6 +-- 5 files changed, 42 insertions(+), 89 deletions(-) diff --git a/PWGHF/Core/HfHelper.h b/PWGHF/Core/HfHelper.h index 4808d9d062d..2ea6afa54ad 100644 --- a/PWGHF/Core/HfHelper.h +++ b/PWGHF/Core/HfHelper.h @@ -20,7 +20,6 @@ #include #include #include -#include #include "CommonConstants/PhysicsConstants.h" @@ -932,57 +931,6 @@ class HfHelper return true; } - /// Get the pt of the beauty hadron(non-prompt case), return negative value for prompt case - /// \param particlesMC table with MC particles - /// \param particle MC particle - /// \return a double corresponding to beauty mother pt - template - double getBeautyMotherPt(const T& particlesMC, - const typename T::iterator& particle) - { - int stage = 0; // mother tree level - - // vector of vectors with mother indices; each line corresponds to a "stage" - std::vector> arrayIds{}; - std::vector initVec{particle.globalIndex()}; - arrayIds.push_back(initVec); // the first vector contains the index of the original particle - - while (arrayIds[-stage].size() > 0) { - // vector of mother indices for the current stage - std::vector arrayIdsStage{}; - for (auto& iPart : arrayIds[-stage]) { // check all the particles that were the mothers at the previous stage - auto particleMother = particlesMC.rawIteratorAt(iPart - particlesMC.offset()); - if (particleMother.has_mothers()) { - for (auto iMother = particleMother.mothersIds().front(); iMother <= particleMother.mothersIds().back(); ++iMother) { // loop over the mother particles of the analysed particle - if (std::find(arrayIdsStage.begin(), arrayIdsStage.end(), iMother) != arrayIdsStage.end()) { // if a mother is still present in the vector, do not check it again - continue; - } - auto mother = particlesMC.rawIteratorAt(iMother - particlesMC.offset()); - // Check mother's PDG code. - auto PDGParticleIMother = std::abs(mother.pdgCode()); // PDG code of the mother - - if ((PDGParticleIMother > 500 && PDGParticleIMother < 600) || (PDGParticleIMother > 5000 && PDGParticleIMother < 6000)) { - return mother.pt(); - } - if (PDGParticleIMother == 4) { - return -999.; - } - if (PDGParticleIMother == 5) { - return -1.; - } - - // add mother index in the vector for the current stage - arrayIdsStage.push_back(iMother); - } - } - } - // add vector of mother indices for the current stage - arrayIds.push_back(arrayIdsStage); - stage--; - } - return -999.; - } - private: }; diff --git a/PWGHF/D2H/Tasks/taskD0.cxx b/PWGHF/D2H/Tasks/taskD0.cxx index a33b620465b..74a5b74f18d 100644 --- a/PWGHF/D2H/Tasks/taskD0.cxx +++ b/PWGHF/D2H/Tasks/taskD0.cxx @@ -436,9 +436,6 @@ struct HfTaskD0 { auto ctCandidate = hfHelper.ctD0(candidate); auto cpaCandidate = candidate.cpa(); auto cpaxyCandidate = candidate.cpaXY(); - float ptB = -1; - auto indexMother = RecoDecay::getMother(mcParticles, candidate.template prong0_as().template mcParticle_as>(), o2::constants::physics::Pdg::kD0, true); - auto particleMother = mcParticles.rawIteratorAt(indexMother); if (candidate.isSelD0() >= selectionFlagD0) { registry.fill(HIST("hMassSigBkgD0"), massD0, ptCandidate, rapidityCandidate); if (candidate.flagMcMatchRec() == (1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { @@ -466,10 +463,7 @@ struct HfTaskD0 { registry.fill(HIST("hDecLengthxyVsPtSig"), declengthxyCandidate, ptCandidate); registry.fill(HIST("hMassSigD0"), massD0, ptCandidate, rapidityCandidate); if constexpr (applyMl) { - if (candidate.originMcRec() == RecoDecay::OriginType::NonPrompt) { - ptB = hfHelper.getBeautyMotherPt(mcParticles, particleMother); - } - registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], massD0, ptCandidate, ptB, rapidityCandidate, candidate.originMcRec(), SigD0); + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], massD0, ptCandidate, candidate.ptBhadMotherPart(), rapidityCandidate, candidate.originMcRec(), SigD0); } } else { registry.fill(HIST("hPtProng0Bkg"), ptProng0, rapidityCandidate); @@ -489,10 +483,7 @@ struct HfTaskD0 { if (candidate.flagMcMatchRec() == -(1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { registry.fill(HIST("hMassReflBkgD0"), massD0, ptCandidate, rapidityCandidate); if constexpr (applyMl) { - if (candidate.originMcRec() == RecoDecay::OriginType::NonPrompt) { - ptB = hfHelper.getBeautyMotherPt(mcParticles, particleMother); - } - registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], massD0, ptCandidate, ptB, rapidityCandidate, candidate.originMcRec(), ReflectedD0); + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], massD0, ptCandidate, candidate.ptBhadMotherPart(), rapidityCandidate, candidate.originMcRec(), ReflectedD0); } } } @@ -502,20 +493,14 @@ struct HfTaskD0 { if (candidate.flagMcMatchRec() == -(1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { registry.fill(HIST("hMassSigD0bar"), massD0bar, ptCandidate, rapidityCandidate); if constexpr (applyMl) { - if (candidate.originMcRec() == RecoDecay::OriginType::NonPrompt) { - ptB = hfHelper.getBeautyMotherPt(mcParticles, particleMother); - } - registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], massD0bar, ptCandidate, ptB, rapidityCandidate, candidate.originMcRec(), SigD0bar); + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], massD0bar, ptCandidate, candidate.ptBhadMotherPart(), rapidityCandidate, candidate.originMcRec(), SigD0bar); } } else { registry.fill(HIST("hMassBkgD0bar"), massD0bar, ptCandidate, rapidityCandidate); if (candidate.flagMcMatchRec() == (1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { registry.fill(HIST("hMassReflBkgD0bar"), massD0bar, ptCandidate, rapidityCandidate); if constexpr (applyMl) { - if (candidate.originMcRec() == RecoDecay::OriginType::NonPrompt) { - ptB = hfHelper.getBeautyMotherPt(mcParticles, particleMother); - } - registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], massD0bar, ptCandidate, ptB, rapidityCandidate, candidate.originMcRec(), ReflectedD0bar); + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], massD0bar, ptCandidate, candidate.ptBhadMotherPart(), rapidityCandidate, candidate.originMcRec(), ReflectedD0bar); } } } @@ -539,7 +524,7 @@ struct HfTaskD0 { registry.fill(HIST("hPtVsYGenPrompt"), ptGen, yGen); registry.fill(HIST("hSparseAcc"), ptGen, ptGenB, yGen, 1); } else { - ptGenB = hfHelper.getBeautyMotherPt(mcParticles, particle); + ptGenB = mcParticles.rawIteratorAt(particle.idxBhadMotherPart()).pt();; registry.fill(HIST("hPtGenNonPrompt"), ptGen); registry.fill(HIST("hYGenNonPrompt"), yGen); registry.fill(HIST("hPtVsYGenNonPrompt"), ptGen, yGen); diff --git a/PWGHF/DataModel/CandidateReconstructionTables.h b/PWGHF/DataModel/CandidateReconstructionTables.h index 6e6c7fb583f..19c90a406dd 100644 --- a/PWGHF/DataModel/CandidateReconstructionTables.h +++ b/PWGHF/DataModel/CandidateReconstructionTables.h @@ -523,6 +523,11 @@ DECLARE_SOA_DYNAMIC_COLUMN(Ct, ct, //! DECLARE_SOA_DYNAMIC_COLUMN(ImpactParameterXY, impactParameterXY, //! [](float xVtxP, float yVtxP, float zVtxP, float xVtxS, float yVtxS, float zVtxS, float px, float py, float pz) -> float { return RecoDecay::impParXY(std::array{xVtxP, yVtxP, zVtxP}, std::array{xVtxS, yVtxS, zVtxS}, std::array{px, py, pz}); }); DECLARE_SOA_COLUMN(KfTopolChi2OverNdf, kfTopolChi2OverNdf, float); //! chi2overndf of the KFParticle topological constraint +// B-hadron mother information +DECLARE_SOA_COLUMN(PtBhadMotherPart, ptBhadMotherPart, float); //! pt of the first B-hadron mother particle (only in case of non-prompt) +DECLARE_SOA_COLUMN(PdgBhadMotherPart, pdgBhadMotherPart, int); //! pdg of the first B-hadron mother particle (only in case of non-prompt) +DECLARE_SOA_COLUMN(IdxBhadMotherPart, idxBhadMotherPart, int); //! index of the first B-hadron mother particle (only in case of non-prompt) + // method of secondary-vertex reconstruction enum VertexerType { DCAFitter = 0, @@ -638,12 +643,15 @@ DECLARE_SOA_TABLE(HfCand2ProngKF, "AOD", "HFCAND2PKF", // table with results of reconstruction level MC matching DECLARE_SOA_TABLE(HfCand2ProngMcRec, "AOD", "HFCAND2PMCREC", //! hf_cand_2prong::FlagMcMatchRec, - hf_cand_2prong::OriginMcRec); + hf_cand_2prong::OriginMcRec, + hf_cand::PtBhadMotherPart, + hf_cand::PdgBhadMotherPart); // table with results of generator level MC matching DECLARE_SOA_TABLE(HfCand2ProngMcGen, "AOD", "HFCAND2PMCGEN", //! hf_cand_2prong::FlagMcMatchGen, - hf_cand_2prong::OriginMcGen); + hf_cand_2prong::OriginMcGen, + hf_cand::IdxBhadMotherPart); // cascade decay candidate table @@ -1755,12 +1763,9 @@ DECLARE_SOA_DYNAMIC_COLUMN(PVecSoftPi, pVecSoftPi, [](float px, float py, float // MC matching result: DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); //! reconstruction level DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); //! generator level -DECLARE_SOA_COLUMN(PtBhadMotherPart, ptBhadMotherPart, float); //! pt of the first B-hadron mother particle (only in case of non-prompt) -DECLARE_SOA_COLUMN(PdgBhadMotherPart, pdgBhadMotherPart, int); //! pdg of the first B-hadron mother particle (only in case of non-prompt) DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); //! particle origin, reconstruction level DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); //! particle origin, generator level -DECLARE_SOA_COLUMN(IdxBhadMotherPart, idxBhadMotherPart, int); //! index of the first B-hadron mother particle (only in case of non-prompt) enum DecayType { DstarToD0Pi = 0, @@ -1879,14 +1884,14 @@ using HfCandDstar = HfCandDstars::iterator; DECLARE_SOA_TABLE(HfCandDstarMcRec, "AOD", "HFCANDDSTRMCREC", hf_cand_dstar::FlagMcMatchRec, hf_cand_dstar::OriginMcRec, - hf_cand_dstar::PtBhadMotherPart, - hf_cand_dstar::PdgBhadMotherPart); + hf_cand::PtBhadMotherPart, + hf_cand::PdgBhadMotherPart); // table with results of generator level MC matching DECLARE_SOA_TABLE(HfCandDstarMcGen, "AOD", "HFCANDDSTRMCGEN", hf_cand_dstar::FlagMcMatchGen, hf_cand_dstar::OriginMcGen, - hf_cand_dstar::IdxBhadMotherPart); + hf_cand::IdxBhadMotherPart); #undef HFCAND_COLUMNS diff --git a/PWGHF/TableProducer/candidateCreator2Prong.cxx b/PWGHF/TableProducer/candidateCreator2Prong.cxx index ee4c62443de..22fac323e55 100644 --- a/PWGHF/TableProducer/candidateCreator2Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator2Prong.cxx @@ -683,14 +683,19 @@ struct HfCandidateCreator2ProngExpressions { int8_t sign = 0; int8_t flag = 0; int8_t origin = 0; + float bMotherPt = -1.; + int bMotherPdg = 0; + int bMotherIdx = -1; // Match reconstructed candidates. // Spawned table can be used directly for (const auto& candidate : *rowCandidateProng2) { - flag = 0; origin = 0; + bMotherPt = -1.; + bMotherPdg = 0; auto arrayDaughters = std::array{candidate.prong0_as(), candidate.prong1_as()}; + std::vector idxBhadMothers{}; // D0(bar) → π± K∓ indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign); @@ -717,21 +722,28 @@ struct HfCandidateCreator2ProngExpressions { // Check whether the particle is non-prompt (from a b quark). if (flag != 0) { auto particle = mcParticles.rawIteratorAt(indexRec); - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle); + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); + } + if (origin == RecoDecay::OriginType::NonPrompt) { + auto bHadMother = mcParticles.rawIteratorAt(idxBhadMothers[0]); + bMotherPt = bHadMother.pt(); + bMotherPdg = bHadMother.pdgCode(); } - rowMcMatchRec(flag, origin); + rowMcMatchRec(flag, origin, bMotherPt, bMotherPdg); } // Match generated particles. for (const auto& particle : mcParticles) { flag = 0; origin = 0; + bMotherIdx = -1; + std::vector idxBhadMothers{}; auto mcCollision = particle.mcCollision(); float zPv = mcCollision.posZ(); if (zPv < -zPvPosMax || zPv > zPvPosMax) { // to avoid counting particles in collisions with Zvtx larger than the maximum, we do not match them - rowMcMatchGen(flag, origin); + rowMcMatchGen(flag, origin, bMotherIdx); continue; } @@ -756,10 +768,13 @@ struct HfCandidateCreator2ProngExpressions { // Check whether the particle is non-prompt (from a b quark). if (flag != 0) { - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle); + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); + } + if (origin == RecoDecay::OriginType::NonPrompt) { + bMotherIdx = idxBhadMothers[0]; } - rowMcMatchGen(flag, origin); + rowMcMatchGen(flag, origin, bMotherIdx); } } diff --git a/PWGHF/TableProducer/candidateCreatorDstar.cxx b/PWGHF/TableProducer/candidateCreatorDstar.cxx index ccc7828fe5a..c36cd2ea98f 100644 --- a/PWGHF/TableProducer/candidateCreatorDstar.cxx +++ b/PWGHF/TableProducer/candidateCreatorDstar.cxx @@ -578,7 +578,7 @@ struct HfCandidateCreatorDstarExpressions { } else { rowsMcMatchRecDstar(flagDstar, originDstar, -1.f, 0); } - rowsMcMatchRecD0(flagD0, originD0); + rowsMcMatchRecD0(flagD0, originD0, -1.f, 0); } // Match generated particles. @@ -593,7 +593,7 @@ struct HfCandidateCreatorDstarExpressions { float zPv = mcCollision.posZ(); if (zPv < -zPvPosMax || zPv > zPvPosMax) { // to avoid counting particles in collisions with Zvtx larger than the maximum, we do not match them rowsMcMatchGenDstar(flagDstar, originDstar, -1); - rowsMcMatchGenD0(flagD0, originD0); + rowsMcMatchGenD0(flagD0, originD0, -1); continue; } @@ -619,7 +619,7 @@ struct HfCandidateCreatorDstarExpressions { } else { rowsMcMatchGenDstar(flagDstar, originDstar, -1); } - rowsMcMatchGenD0(flagD0, originD0); + rowsMcMatchGenD0(flagD0, originD0, -1.); } } PROCESS_SWITCH(HfCandidateCreatorDstarExpressions, processMc, "Process MC", false); From 5b30fb48aa376ff009d6b082e02893cc9486ff30 Mon Sep 17 00:00:00 2001 From: Fabio Catalano Date: Fri, 31 May 2024 18:56:02 +0200 Subject: [PATCH 2/4] Fix format --- PWGHF/D2H/Tasks/taskD0.cxx | 2 +- PWGHF/DataModel/CandidateReconstructionTables.h | 1 - PWGHF/TableProducer/candidateCreator2Prong.cxx | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/PWGHF/D2H/Tasks/taskD0.cxx b/PWGHF/D2H/Tasks/taskD0.cxx index 74a5b74f18d..65bdd85eb66 100644 --- a/PWGHF/D2H/Tasks/taskD0.cxx +++ b/PWGHF/D2H/Tasks/taskD0.cxx @@ -524,7 +524,7 @@ struct HfTaskD0 { registry.fill(HIST("hPtVsYGenPrompt"), ptGen, yGen); registry.fill(HIST("hSparseAcc"), ptGen, ptGenB, yGen, 1); } else { - ptGenB = mcParticles.rawIteratorAt(particle.idxBhadMotherPart()).pt();; + ptGenB = mcParticles.rawIteratorAt(particle.idxBhadMotherPart()).pt(); registry.fill(HIST("hPtGenNonPrompt"), ptGen); registry.fill(HIST("hYGenNonPrompt"), yGen); registry.fill(HIST("hPtVsYGenNonPrompt"), ptGen, yGen); diff --git a/PWGHF/DataModel/CandidateReconstructionTables.h b/PWGHF/DataModel/CandidateReconstructionTables.h index 19c90a406dd..f1ac48400ac 100644 --- a/PWGHF/DataModel/CandidateReconstructionTables.h +++ b/PWGHF/DataModel/CandidateReconstructionTables.h @@ -528,7 +528,6 @@ DECLARE_SOA_COLUMN(PtBhadMotherPart, ptBhadMotherPart, float); //! pt of the fir DECLARE_SOA_COLUMN(PdgBhadMotherPart, pdgBhadMotherPart, int); //! pdg of the first B-hadron mother particle (only in case of non-prompt) DECLARE_SOA_COLUMN(IdxBhadMotherPart, idxBhadMotherPart, int); //! index of the first B-hadron mother particle (only in case of non-prompt) - // method of secondary-vertex reconstruction enum VertexerType { DCAFitter = 0, KfParticle }; diff --git a/PWGHF/TableProducer/candidateCreator2Prong.cxx b/PWGHF/TableProducer/candidateCreator2Prong.cxx index 22fac323e55..50191ad352b 100644 --- a/PWGHF/TableProducer/candidateCreator2Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator2Prong.cxx @@ -726,7 +726,7 @@ struct HfCandidateCreator2ProngExpressions { } if (origin == RecoDecay::OriginType::NonPrompt) { auto bHadMother = mcParticles.rawIteratorAt(idxBhadMothers[0]); - bMotherPt = bHadMother.pt(); + bMotherPt = bHadMother.pt(); bMotherPdg = bHadMother.pdgCode(); } From 20cee468fc41fe983eeff6dec885e3dbec0d1a90 Mon Sep 17 00:00:00 2001 From: Fabio Catalano Date: Mon, 3 Jun 2024 11:15:01 +0200 Subject: [PATCH 3/4] More compact filling in creator --- .../TableProducer/candidateCreator2Prong.cxx | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/PWGHF/TableProducer/candidateCreator2Prong.cxx b/PWGHF/TableProducer/candidateCreator2Prong.cxx index 50191ad352b..00b8dcd7186 100644 --- a/PWGHF/TableProducer/candidateCreator2Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator2Prong.cxx @@ -683,17 +683,12 @@ struct HfCandidateCreator2ProngExpressions { int8_t sign = 0; int8_t flag = 0; int8_t origin = 0; - float bMotherPt = -1.; - int bMotherPdg = 0; - int bMotherIdx = -1; // Match reconstructed candidates. // Spawned table can be used directly for (const auto& candidate : *rowCandidateProng2) { flag = 0; origin = 0; - bMotherPt = -1.; - bMotherPdg = 0; auto arrayDaughters = std::array{candidate.prong0_as(), candidate.prong1_as()}; std::vector idxBhadMothers{}; @@ -726,24 +721,22 @@ struct HfCandidateCreator2ProngExpressions { } if (origin == RecoDecay::OriginType::NonPrompt) { auto bHadMother = mcParticles.rawIteratorAt(idxBhadMothers[0]); - bMotherPt = bHadMother.pt(); - bMotherPdg = bHadMother.pdgCode(); + rowMcMatchRec(flag, origin, bHadMother.pt(), bHadMother.pdgCode()); + } else { + rowMcMatchRec(flag, origin, -1.f, 0); } - - rowMcMatchRec(flag, origin, bMotherPt, bMotherPdg); } // Match generated particles. for (const auto& particle : mcParticles) { flag = 0; origin = 0; - bMotherIdx = -1; std::vector idxBhadMothers{}; auto mcCollision = particle.mcCollision(); float zPv = mcCollision.posZ(); if (zPv < -zPvPosMax || zPv > zPvPosMax) { // to avoid counting particles in collisions with Zvtx larger than the maximum, we do not match them - rowMcMatchGen(flag, origin, bMotherIdx); + rowMcMatchGen(flag, origin, -1); continue; } @@ -771,10 +764,10 @@ struct HfCandidateCreator2ProngExpressions { origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); } if (origin == RecoDecay::OriginType::NonPrompt) { - bMotherIdx = idxBhadMothers[0]; + rowMcMatchGen(flag, origin, idxBhadMothers[0]); + } else { + rowMcMatchGen(flag, origin, -1); } - - rowMcMatchGen(flag, origin, bMotherIdx); } } From b4b03ed4a70b3a13fb10db47340c6859ceb6d19c Mon Sep 17 00:00:00 2001 From: Fabio Catalano Date: Mon, 3 Jun 2024 13:54:38 +0200 Subject: [PATCH 4/4] Add info to other creators --- .../DataModel/CandidateReconstructionTables.h | 37 +++++--- .../TableProducer/candidateCreator3Prong.cxx | 23 +++-- .../TableProducer/candidateCreatorCascade.cxx | 29 ++++--- .../candidateCreatorSigmac0plusplus.cxx | 28 +++--- .../candidateCreatorXic0Omegac0.cxx | 87 +++++++++++++------ 5 files changed, 138 insertions(+), 66 deletions(-) diff --git a/PWGHF/DataModel/CandidateReconstructionTables.h b/PWGHF/DataModel/CandidateReconstructionTables.h index f1ac48400ac..45d2a696420 100644 --- a/PWGHF/DataModel/CandidateReconstructionTables.h +++ b/PWGHF/DataModel/CandidateReconstructionTables.h @@ -741,12 +741,15 @@ using HfCandCascade = HfCandCascExt; // table with results of reconstruction level MC matching for Cascade DECLARE_SOA_TABLE(HfCandCascadeMcRec, "AOD", "HFCANDCASCMCREC", //! hf_cand_casc::FlagMcMatchRec, - hf_cand_casc::OriginMcRec); + hf_cand_casc::OriginMcRec, + hf_cand::PtBhadMotherPart, + hf_cand::PdgBhadMotherPart); // table with results of generator level MC matching DECLARE_SOA_TABLE(HfCandCascadeMcGen, "AOD", "HFCANDCASCMCGEN", //! hf_cand_casc::FlagMcMatchGen, - hf_cand_casc::OriginMcGen); + hf_cand_casc::OriginMcGen, + hf_cand::IdxBhadMotherPart); // specific BPlus candidate properties namespace hf_cand_bplus @@ -915,13 +918,16 @@ DECLARE_SOA_TABLE(HfCand3ProngMcRec, "AOD", "HFCAND3PMCREC", //! hf_cand_3prong::FlagMcMatchRec, hf_cand_3prong::OriginMcRec, hf_cand_3prong::IsCandidateSwapped, - hf_cand_3prong::FlagMcDecayChanRec); + hf_cand_3prong::FlagMcDecayChanRec, + hf_cand::PtBhadMotherPart, + hf_cand::PdgBhadMotherPart); // table with results of generator level MC matching DECLARE_SOA_TABLE(HfCand3ProngMcGen, "AOD", "HFCAND3PMCGEN", //! hf_cand_3prong::FlagMcMatchGen, hf_cand_3prong::OriginMcGen, - hf_cand_3prong::FlagMcDecayChanGen); + hf_cand_3prong::FlagMcDecayChanGen, + hf_cand::IdxBhadMotherPart); namespace hf_cand_casc_lf { @@ -1272,39 +1278,47 @@ DECLARE_SOA_TABLE(HfXicToXiPiMCRec, "AOD", "HFXICXIPIMCREC", //! hf_cand_xic0_omegac0::DebugMcRec, hf_cand_xic0_omegac0::OriginRec, hf_cand_xic0_omegac0::CollisionMatched, + hf_cand::PtBhadMotherPart, + hf_cand::PdgBhadMotherPart, o2::soa::Marker<1>); DECLARE_SOA_TABLE(HfOmegacToXiPiMCRec, "AOD", "HFOMCXIPIMCREC", //! hf_cand_xic0_omegac0::FlagMcMatchRec, hf_cand_xic0_omegac0::DebugMcRec, hf_cand_xic0_omegac0::OriginRec, hf_cand_xic0_omegac0::CollisionMatched, + hf_cand::PtBhadMotherPart, + hf_cand::PdgBhadMotherPart, o2::soa::Marker<2>); DECLARE_SOA_TABLE(HfToOmegaPiMCRec, "AOD", "HFTOOMEPIMCREC", //! hf_cand_xic0_omegac0::FlagMcMatchRec, hf_cand_xic0_omegac0::DebugMcRec, hf_cand_xic0_omegac0::OriginRec, hf_cand_xic0_omegac0::CollisionMatched, + hf_cand::PtBhadMotherPart, + hf_cand::PdgBhadMotherPart, o2::soa::Marker<3>); DECLARE_SOA_TABLE(HfToOmegaKMCRec, "AOD", "HFTOOMEKMCREC", //! hf_cand_xic0_omegac0::FlagMcMatchRec, hf_cand_xic0_omegac0::DebugMcRec, hf_cand_xic0_omegac0::OriginRec, hf_cand_xic0_omegac0::CollisionMatched, + hf_cand::PtBhadMotherPart, + hf_cand::PdgBhadMotherPart, o2::soa::Marker<4>); // table with results of generator level MC matching DECLARE_SOA_TABLE(HfXicToXiPiMCGen, "AOD", "HFXICXIPIMCGEN", //! hf_cand_xic0_omegac0::FlagMcMatchGen, hf_cand_xic0_omegac0::DebugGenCharmBar, hf_cand_xic0_omegac0::DebugGenCasc, hf_cand_xic0_omegac0::DebugGenLambda, - hf_cand_xic0_omegac0::PtCharmBaryonGen, hf_cand_xic0_omegac0::EtaCharmBaryonGen, hf_cand_xic0_omegac0::OriginGen, o2::soa::Marker<1>); + hf_cand_xic0_omegac0::PtCharmBaryonGen, hf_cand_xic0_omegac0::EtaCharmBaryonGen, hf_cand_xic0_omegac0::OriginGen, hf_cand::IdxBhadMotherPart, o2::soa::Marker<1>); DECLARE_SOA_TABLE(HfOmegacToXiPiMCGen, "AOD", "HFOMECXIPIMCGEN", //! hf_cand_xic0_omegac0::FlagMcMatchGen, hf_cand_xic0_omegac0::DebugGenCharmBar, hf_cand_xic0_omegac0::DebugGenCasc, hf_cand_xic0_omegac0::DebugGenLambda, - hf_cand_xic0_omegac0::PtCharmBaryonGen, hf_cand_xic0_omegac0::EtaCharmBaryonGen, hf_cand_xic0_omegac0::OriginGen, o2::soa::Marker<2>); + hf_cand_xic0_omegac0::PtCharmBaryonGen, hf_cand_xic0_omegac0::EtaCharmBaryonGen, hf_cand_xic0_omegac0::OriginGen, hf_cand::IdxBhadMotherPart, o2::soa::Marker<2>); DECLARE_SOA_TABLE(HfToOmegaPiMCGen, "AOD", "HFTOOMEPIMCGEN", //! hf_cand_xic0_omegac0::FlagMcMatchGen, hf_cand_xic0_omegac0::DebugGenCharmBar, hf_cand_xic0_omegac0::DebugGenCasc, hf_cand_xic0_omegac0::DebugGenLambda, - hf_cand_xic0_omegac0::PtCharmBaryonGen, hf_cand_xic0_omegac0::EtaCharmBaryonGen, hf_cand_xic0_omegac0::OriginGen, o2::soa::Marker<3>); + hf_cand_xic0_omegac0::PtCharmBaryonGen, hf_cand_xic0_omegac0::EtaCharmBaryonGen, hf_cand_xic0_omegac0::OriginGen, hf_cand::IdxBhadMotherPart, o2::soa::Marker<3>); DECLARE_SOA_TABLE(HfToOmegaKMCGen, "AOD", "HFTOOMEKMCGEN", //! hf_cand_xic0_omegac0::FlagMcMatchGen, hf_cand_xic0_omegac0::DebugGenCharmBar, hf_cand_xic0_omegac0::DebugGenCasc, hf_cand_xic0_omegac0::DebugGenLambda, - hf_cand_xic0_omegac0::PtCharmBaryonGen, hf_cand_xic0_omegac0::EtaCharmBaryonGen, hf_cand_xic0_omegac0::OriginGen, o2::soa::Marker<4>); + hf_cand_xic0_omegac0::PtCharmBaryonGen, hf_cand_xic0_omegac0::EtaCharmBaryonGen, hf_cand_xic0_omegac0::OriginGen, hf_cand::IdxBhadMotherPart, o2::soa::Marker<4>); // specific chic candidate properties namespace hf_cand_chic @@ -1648,12 +1662,15 @@ using HfCandSc = HfCandScExt; // table with results of reconstruction level MC matching DECLARE_SOA_TABLE(HfCandScMcRec, "AOD", "HFCANDSCMCREC", //! hf_cand_sigmac::FlagMcMatchRec, - hf_cand_sigmac::OriginMcRec); + hf_cand_sigmac::OriginMcRec, + hf_cand::PtBhadMotherPart, + hf_cand::PdgBhadMotherPart); // table with results of generation level MC matching DECLARE_SOA_TABLE(HfCandScMcGen, "AOD", "HFCANDSCMCGEN", //! hf_cand_sigmac::FlagMcMatchGen, - hf_cand_sigmac::OriginMcGen); + hf_cand_sigmac::OriginMcGen, + hf_cand::IdxBhadMotherPart); /// D*± → D0(bar) π± namespace hf_cand_dstar diff --git a/PWGHF/TableProducer/candidateCreator3Prong.cxx b/PWGHF/TableProducer/candidateCreator3Prong.cxx index cdce673b4ac..6b7b921b191 100644 --- a/PWGHF/TableProducer/candidateCreator3Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator3Prong.cxx @@ -519,6 +519,7 @@ struct HfCandidateCreator3ProngExpressions { swapping = 0; channel = 0; arrDaughIndex.clear(); + std::vector idxBhadMothers{}; auto arrayDaughters = std::array{candidate.prong0_as(), candidate.prong1_as(), candidate.prong2_as()}; // D± → π± K∓ π± @@ -597,10 +598,14 @@ struct HfCandidateCreator3ProngExpressions { // Check whether the particle is non-prompt (from a b quark). if (flag != 0) { auto particle = mcParticles.rawIteratorAt(indexRec); - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle); + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); + } + if (origin == RecoDecay::OriginType::NonPrompt) { + auto bHadMother = mcParticles.rawIteratorAt(idxBhadMothers[0]); + rowMcMatchRec(flag, origin, swapping, channel, bHadMother.pt(), bHadMother.pdgCode()); + } else { + rowMcMatchRec(flag, origin, swapping, channel, -1.f, 0); } - - rowMcMatchRec(flag, origin, swapping, channel); } // Match generated particles. @@ -609,11 +614,12 @@ struct HfCandidateCreator3ProngExpressions { origin = 0; channel = 0; arrDaughIndex.clear(); + std::vector idxBhadMothers{}; auto mcCollision = particle.mcCollision(); float zPv = mcCollision.posZ(); if (zPv < -zPvPosMax || zPv > zPvPosMax) { // to avoid counting particles in collisions with Zvtx larger than the maximum, we do not match them - rowMcMatchGen(flag, origin, channel); + rowMcMatchGen(flag, origin, channel, -1); continue; } @@ -685,10 +691,13 @@ struct HfCandidateCreator3ProngExpressions { // Check whether the particle is non-prompt (from a b quark). if (flag != 0) { - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle); + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); + } + if (origin == RecoDecay::OriginType::NonPrompt) { + rowMcMatchGen(flag, origin, channel, idxBhadMothers[0]); + } else { + rowMcMatchGen(flag, origin, channel, -1); } - - rowMcMatchGen(flag, origin, channel); } } diff --git a/PWGHF/TableProducer/candidateCreatorCascade.cxx b/PWGHF/TableProducer/candidateCreatorCascade.cxx index 2dc8bc106e3..7fa83ca38f6 100644 --- a/PWGHF/TableProducer/candidateCreatorCascade.cxx +++ b/PWGHF/TableProducer/candidateCreatorCascade.cxx @@ -466,8 +466,8 @@ struct HfCandidateCreatorCascadeMc { // Match reconstructed candidates. rowCandidateCasc->bindExternalIndices(&tracks); for (const auto& candidate : *rowCandidateCasc) { - origin = 0; + std::vector idxBhadMothers{}; const auto& bach = candidate.prong0_as(); const auto& trackV0DaughPos = candidate.posTrack_as(); @@ -476,12 +476,6 @@ struct HfCandidateCreatorCascadeMc { auto arrayDaughtersV0 = std::array{trackV0DaughPos, trackV0DaughNeg}; auto arrayDaughtersLc = std::array{bach, trackV0DaughPos, trackV0DaughNeg}; - // First we check the K0s - LOG(debug) << "\n"; - LOG(debug) << "Checking MC for candidate!"; - LOG(debug) << "Looking for K0s"; - - // if (isLc) { RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersV0, kK0Short, std::array{+kPiPlus, -kPiPlus}, false, &sign, 1); if (sign != 0) { // we have already positively checked the K0s // then we check the Lc @@ -491,21 +485,26 @@ struct HfCandidateCreatorCascadeMc { // Check whether the particle is non-prompt (from a b quark). if (sign != 0) { auto particle = mcParticles.rawIteratorAt(indexRec); - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle); + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); + } + if (origin == RecoDecay::OriginType::NonPrompt) { + auto bHadMother = mcParticles.rawIteratorAt(idxBhadMothers[0]); + rowMcMatchRec(sign, origin, bHadMother.pt(), bHadMother.pdgCode()); + } else { + rowMcMatchRec(sign, origin, -1.f, 0); } - - rowMcMatchRec(sign, origin); } //} // Match generated particles. for (const auto& particle : mcParticles) { origin = 0; + std::vector idxBhadMothers{}; auto mcCollision = particle.mcCollision(); float zPv = mcCollision.posZ(); if (zPv < -zPvPosMax || zPv > zPvPosMax) { // to avoid counting particles in collisions with Zvtx larger than the maximum, we do not match them - rowMcMatchGen(sign, origin); + rowMcMatchGen(sign, origin, -1); continue; } @@ -533,9 +532,13 @@ struct HfCandidateCreatorCascadeMc { } // Check whether the particle is non-prompt (from a b quark). if (sign != 0) { - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle); + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); + } + if (origin == RecoDecay::OriginType::NonPrompt) { + rowMcMatchGen(sign, origin, idxBhadMothers[0]); + } else { + rowMcMatchGen(sign, origin, -1); } - rowMcMatchGen(sign, origin); } } diff --git a/PWGHF/TableProducer/candidateCreatorSigmac0plusplus.cxx b/PWGHF/TableProducer/candidateCreatorSigmac0plusplus.cxx index 0e48f0b9d43..509b74d1daa 100644 --- a/PWGHF/TableProducer/candidateCreatorSigmac0plusplus.cxx +++ b/PWGHF/TableProducer/candidateCreatorSigmac0plusplus.cxx @@ -427,7 +427,6 @@ struct HfCandidateSigmac0plusplusMc { int8_t flag = 0; int8_t origin = 0; int8_t chargeSigmac = 10; - // std::vector arrDaughIndex; /// index of daughters of MC particle /// Match reconstructed Σc0,++ candidates for (const auto& candSigmac : *candidatesSigmac) { @@ -435,12 +434,12 @@ struct HfCandidateSigmac0plusplusMc { sign = 0; flag = 0; origin = 0; - // arrDaughIndex.clear(); + std::vector idxBhadMothers{}; /// skip immediately the candidate Σc0,++ w/o a Λc+ matched to MC auto candLc = candSigmac.prongLc_as(); if (!(std::abs(candLc.flagMcMatchRec()) == 1 << aod::hf_cand_3prong::DecayType::LcToPKPi)) { /// (*) - rowMCMatchScRec(flag, origin); + rowMCMatchScRec(flag, origin, -1.f, 0); continue; } @@ -475,22 +474,27 @@ struct HfCandidateSigmac0plusplusMc { /// check the origin (prompt vs. non-prompt) if (flag != 0) { auto particle = mcParticles.rawIteratorAt(indexRec); - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle); + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); } - /// fill the table with results of reconstruction level MC matching - rowMCMatchScRec(flag, origin); + if (origin == RecoDecay::OriginType::NonPrompt) { + auto bHadMother = mcParticles.rawIteratorAt(idxBhadMothers[0]); + rowMCMatchScRec(flag, origin, bHadMother.pt(), bHadMother.pdgCode()); + } else { + rowMCMatchScRec(flag, origin, -1.f, 0); + } } /// end loop over reconstructed Σc0,++ candidates /// Match generated Σc0,++ candidates for (const auto& particle : mcParticles) { flag = 0; origin = 0; + std::vector idxBhadMothers{}; auto mcCollision = particle.mcCollision(); float zPv = mcCollision.posZ(); if (zPv < -zPvPosMax || zPv > zPvPosMax) { // to avoid counting particles in collisions with Zvtx larger than the maximum, we do not match them - rowMCMatchScGen(flag, origin); + rowMCMatchScGen(flag, origin, -1); continue; } @@ -532,12 +536,14 @@ struct HfCandidateSigmac0plusplusMc { /// check the origin (prompt vs. non-prompt) if (flag != 0) { auto particle = mcParticles.rawIteratorAt(indexRec); - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle); + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); } - /// fill the table with results of generation level MC matching - rowMCMatchScGen(flag, origin); - + if (origin == RecoDecay::OriginType::NonPrompt) { + rowMCMatchScGen(flag, origin, idxBhadMothers[0]); + } else { + rowMCMatchScGen(flag, origin, -1); + } } /// end loop over mcParticles } /// end processMc PROCESS_SWITCH(HfCandidateSigmac0plusplusMc, processMc, "Process MC", false); diff --git a/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx b/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx index 330619636f5..9db0de7a57e 100644 --- a/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx +++ b/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx @@ -719,11 +719,11 @@ struct HfCandidateCreatorXic0Omegac0Mc { // Match reconstructed candidates. for (const auto& candidate : candidates) { - flag = 0; origin = RecoDecay::OriginType::None; debug = 0; collisionMatched = false; + std::vector idxBhadMothers{}; auto arrayDaughters = std::array{candidate.template bachelorFromCharmBaryon_as(), // bachelor <- charm baryon candidate.template bachelor_as(), // bachelor <- cascade @@ -763,12 +763,17 @@ struct HfCandidateCreatorXic0Omegac0Mc { // Check whether the charm baryon is non-prompt (from a b quark). if (flag != 0) { auto particle = mcParticles.rawIteratorAt(indexRecCharmBaryon); - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, true); + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, true, &idxBhadMothers); + } + if (origin == RecoDecay::OriginType::NonPrompt) { + auto bHadMother = mcParticles.rawIteratorAt(idxBhadMothers[0]); + rowMCMatchRecXicToXiPi(flag, debug, origin, collisionMatched, bHadMother.pt(), bHadMother.pdgCode()); + } else { + rowMCMatchRecXicToXiPi(flag, debug, origin, collisionMatched, -1.f, 0); } if (debug == 2 || debug == 3) { LOGF(info, "WARNING: Xic0ToXiPi decays in the expected final state but the condition on the intermediate states are not fulfilled"); } - rowMCMatchRecXicToXiPi(flag, debug, origin, collisionMatched); } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToXiPi) { // Omegac -> xi pi matching // Omegac → pi pi pi p indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, pdgCodeOmegac0, std::array{pdgCodePiPlus, pdgCodePiMinus, pdgCodeProton, pdgCodePiMinus}, true, &sign, 3); @@ -797,12 +802,17 @@ struct HfCandidateCreatorXic0Omegac0Mc { // Check whether the charm baryon is non-prompt (from a b quark). if (flag != 0) { auto particle = mcParticles.rawIteratorAt(indexRecCharmBaryon); - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, true); + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, true, &idxBhadMothers); + } + if (origin == RecoDecay::OriginType::NonPrompt) { + auto bHadMother = mcParticles.rawIteratorAt(idxBhadMothers[0]); + rowMCMatchRecOmegacToXiPi(flag, debug, origin, collisionMatched, bHadMother.pt(), bHadMother.pdgCode()); + } else { + rowMCMatchRecOmegacToXiPi(flag, debug, origin, collisionMatched, -1.f, 0); } if (debug == 2 || debug == 3) { LOGF(info, "WARNING: Omegac0ToXiPi decays in the expected final state but the condition on the intermediate states are not fulfilled"); } - rowMCMatchRecOmegacToXiPi(flag, debug, origin, collisionMatched); } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPi) { // Omegac0 -> omega pi matching // Omegac → pi K pi p indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, pdgCodeOmegac0, std::array{pdgCodePiPlus, pdgCodeKaonMinus, pdgCodeProton, pdgCodePiMinus}, true, &sign, 3); @@ -831,12 +841,17 @@ struct HfCandidateCreatorXic0Omegac0Mc { // Check whether the charm baryon is non-prompt (from a b quark). if (flag != 0) { auto particle = mcParticles.rawIteratorAt(indexRecCharmBaryon); - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, true); + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, true, &idxBhadMothers); + } + if (origin == RecoDecay::OriginType::NonPrompt) { + auto bHadMother = mcParticles.rawIteratorAt(idxBhadMothers[0]); + rowMCMatchRecToOmegaPi(flag, debug, origin, collisionMatched, bHadMother.pt(), bHadMother.pdgCode()); + } else { + rowMCMatchRecToOmegaPi(flag, debug, origin, collisionMatched, -1.f, 0); } if (debug == 2 || debug == 3) { LOGF(info, "WARNING: Omegac0ToOmegaPi decays in the expected final state but the condition on the intermediate states are not fulfilled"); } - rowMCMatchRecToOmegaPi(flag, debug, origin, collisionMatched); } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaK) { // Omegac0 -> omega K matching // Omegac → K K pi p indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, pdgCodeOmegac0, std::array{pdgCodeKaonPlus, pdgCodeKaonMinus, pdgCodeProton, pdgCodePiMinus}, true, &sign, 3); @@ -865,12 +880,17 @@ struct HfCandidateCreatorXic0Omegac0Mc { // Check whether the charm baryon is non-prompt (from a b quark). if (flag != 0) { auto particle = mcParticles.rawIteratorAt(indexRecCharmBaryon); - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, true); + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, true, &idxBhadMothers); + } + if (origin == RecoDecay::OriginType::NonPrompt) { + auto bHadMother = mcParticles.rawIteratorAt(idxBhadMothers[0]); + rowMCMatchRecToOmegaK(flag, debug, origin, collisionMatched, bHadMother.pt(), bHadMother.pdgCode()); + } else { + rowMCMatchRecToOmegaK(flag, debug, origin, collisionMatched, -1.f, 0); } if (debug == 2 || debug == 3) { LOGF(info, "WARNING: Omegac0ToOmegaK decays in the expected final state but the condition on the intermediate states are not fulfilled"); } - rowMCMatchRecToOmegaK(flag, debug, origin, collisionMatched); } } // close loop over candidates @@ -884,6 +904,7 @@ struct HfCandidateCreatorXic0Omegac0Mc { debugGenCasc = 0; debugGenLambda = 0; origin = RecoDecay::OriginType::None; + std::vector idxBhadMothers{}; // accept only mc particles coming from bc that are far away from TF border and ITSROFrame if (rejGenTFAndITSROFBorders) { @@ -891,13 +912,13 @@ struct HfCandidateCreatorXic0Omegac0Mc { auto bc = coll.bc_as(); if (!bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder) || !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi) { - rowMCMatchGenXicToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin); + rowMCMatchGenXicToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin, -1); } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToXiPi) { - rowMCMatchGenOmegacToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin); + rowMCMatchGenOmegacToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin, -1); } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPi) { - rowMCMatchGenToOmegaPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin); + rowMCMatchGenToOmegaPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin, -1); } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaK) { - rowMCMatchGenToOmegaK(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin); + rowMCMatchGenToOmegaK(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin, -1); } continue; } @@ -907,13 +928,13 @@ struct HfCandidateCreatorXic0Omegac0Mc { float zPv = mcCollision.posZ(); if (zPv < -zPvPosMax || zPv > zPvPosMax) { // to avoid counting particles in collisions with Zvtx larger than the maximum, we do not match them if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi) { - rowMCMatchGenXicToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin); + rowMCMatchGenXicToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin, -1); } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToXiPi) { - rowMCMatchGenOmegacToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin); + rowMCMatchGenOmegacToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin, -1); } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPi) { - rowMCMatchGenToOmegaPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin); + rowMCMatchGenToOmegaPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin, -1); } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaK) { - rowMCMatchGenToOmegaK(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin); + rowMCMatchGenToOmegaK(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin, -1); } continue; } @@ -946,9 +967,13 @@ struct HfCandidateCreatorXic0Omegac0Mc { } // Check whether the charm baryon is non-prompt (from a b quark) if (flag != 0) { - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, true); + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, true, &idxBhadMothers); + } + if (origin == RecoDecay::OriginType::NonPrompt) { + rowMCMatchGenXicToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin, idxBhadMothers[0]); + } else { + rowMCMatchGenXicToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin, -1); } - rowMCMatchGenXicToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin); } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToXiPi) { // Omegac → Xi pi @@ -978,9 +1003,13 @@ struct HfCandidateCreatorXic0Omegac0Mc { } // Check whether the charm baryon is non-prompt (from a b quark) if (flag != 0) { - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, true); + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, true, &idxBhadMothers); + } + if (origin == RecoDecay::OriginType::NonPrompt) { + rowMCMatchGenOmegacToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin, idxBhadMothers[0]); + } else { + rowMCMatchGenOmegacToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin, -1); } - rowMCMatchGenOmegacToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin); } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPi) { // Omegac → Omega pi @@ -1010,9 +1039,13 @@ struct HfCandidateCreatorXic0Omegac0Mc { } // Check whether the charm baryon is non-prompt (from a b quark) if (flag != 0) { - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, true); + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, true, &idxBhadMothers); + } + if (origin == RecoDecay::OriginType::NonPrompt) { + rowMCMatchGenToOmegaPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin, idxBhadMothers[0]); + } else { + rowMCMatchGenToOmegaPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin, -1); } - rowMCMatchGenToOmegaPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin); } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaK) { // Omegac → Omega K @@ -1042,9 +1075,13 @@ struct HfCandidateCreatorXic0Omegac0Mc { } // Check whether the charm baryon is non-prompt (from a b quark) if (flag != 0) { - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, true); + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, true, &idxBhadMothers); + } + if (origin == RecoDecay::OriginType::NonPrompt) { + rowMCMatchGenToOmegaK(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin, idxBhadMothers[0]); + } else { + rowMCMatchGenToOmegaK(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin, -1); } - rowMCMatchGenToOmegaK(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin); } } // close loop on MCParticles } // close process