diff --git a/PWGHF/D2H/DataModel/ReducedDataModel.h b/PWGHF/D2H/DataModel/ReducedDataModel.h index 62e52032538..4e799a85c06 100644 --- a/PWGHF/D2H/DataModel/ReducedDataModel.h +++ b/PWGHF/D2H/DataModel/ReducedDataModel.h @@ -888,7 +888,8 @@ using HfRedCandLb = soa::Join; namespace hf_cand_mc_flag { -DECLARE_SOA_COLUMN(FlagWrongCollision, flagWrongCollision, int8_t); //! reconstruction level +DECLARE_SOA_COLUMN(FlagWrongCollision, flagWrongCollision, int8_t); //! reconstruction level +DECLARE_SOA_COLUMN(IsHadronLeptonSwapped, isHadronLeptonSwapped, bool); //! flag to tag candidates with swapped hypotheses between leptons and hadrons } namespace hf_b0_mc @@ -951,7 +952,8 @@ DECLARE_SOA_TABLE(HfMcRecRedJPK0ss, "AOD", "HFMCRECREDJPK0S", //! Table with rec hf_cand_mc_flag::FlagMcDecayChanRec, hf_cand_mc_flag::FlagWrongCollision, hf_cand_mc_flag::DebugMcRec, - hf_b0_mc::PtMother); + hf_b0_mc::PtMother, + hf_cand_mc_flag::IsHadronLeptonSwapped); // Table with same size as HFCANDB0 DECLARE_SOA_TABLE(HfMcRecRedB0s, "AOD", "HFMCRECREDB0", //! Reconstruction-level MC information on B0 candidates for reduced workflow @@ -1041,7 +1043,8 @@ DECLARE_SOA_TABLE(HfMcRecRedJPKs, "AOD", "HFMCRECREDJPK", //! Table with reconst hf_cand_mc_flag::FlagMcDecayChanRec, hf_cand_mc_flag::FlagWrongCollision, hf_cand_mc_flag::DebugMcRec, - hf_bplus_mc::PtMother); + hf_bplus_mc::PtMother, + hf_cand_mc_flag::IsHadronLeptonSwapped); // DECLARE_SOA_EXTENDED_TABLE_USER(ExTable, Tracks, "EXTABLE", DECLARE_SOA_TABLE(HfMcCheckD0Pis, "AOD", "HFMCCHECKD0PI", //! Table with reconstructed MC information on D0Pi(<-B0) pairs for MC checks in reduced workflow @@ -1143,7 +1146,8 @@ DECLARE_SOA_TABLE(HfMcRecRedJPPhis, "AOD", "HFMCRECREDJPPHI", //! Table with rec hf_cand_mc_flag::FlagMcDecayChanRec, hf_cand_mc_flag::FlagWrongCollision, hf_cand_mc_flag::DebugMcRec, - hf_bs_mc::PtMother); + hf_bs_mc::PtMother, + hf_cand_mc_flag::IsHadronLeptonSwapped); // try with extended table ? // DECLARE_SOA_EXTENDED_TABLE_USER(ExTable, Tracks, "EXTABLE", @@ -1288,6 +1292,9 @@ DECLARE_SOA_TABLE(HfCandLbConfigs, "AOD", "HFCANDLBCONFIG", //! Table with confi hf_cand_lb_config::MySelectionFlagLc, hf_cand_lb_config::MyInvMassWindowLcPi); +DECLARE_SOA_TABLE(HfMcRecBJpSwaps, "AOD", "HFMCRECBJPSWAP", //! Table with configurables information for reduced workflow + hf_cand_mc_flag::IsHadronLeptonSwapped); + // Charm resonances analysis namespace hf_reso_3_prong { diff --git a/PWGHF/D2H/TableProducer/candidateCreatorBToJpsiReduced.cxx b/PWGHF/D2H/TableProducer/candidateCreatorBToJpsiReduced.cxx index b2b550aefb1..7e902602361 100644 --- a/PWGHF/D2H/TableProducer/candidateCreatorBToJpsiReduced.cxx +++ b/PWGHF/D2H/TableProducer/candidateCreatorBToJpsiReduced.cxx @@ -554,6 +554,7 @@ struct HfCandidateCreatorBToJpsiReducedExpressions { Produces rowBplusMcRec; Produces rowB0McRec; Produces rowBsMcRec; + Produces rowBToJPsiSwap; /// Fill candidate information at MC reconstruction level /// \param rowsJpsiHadMcRec MC reco information on Jpsi hadron pairs @@ -569,11 +570,13 @@ struct HfCandidateCreatorBToJpsiReducedExpressions { continue; } rowBplusMcRec(rowJpsiHadMcRec.flagMcMatchRec(), rowJpsiHadMcRec.flagMcDecayChanRec(), rowJpsiHadMcRec.flagWrongCollision(), rowJpsiHadMcRec.debugMcRec(), rowJpsiHadMcRec.ptMother()); + rowBToJPsiSwap(rowJpsiHadMcRec.isHadronLeptonSwapped()); filledMcInfo = true; break; } if (!filledMcInfo) { // protection to get same size tables in case something went wrong: we created a candidate that was not preselected in the Jpsi-K creator rowBplusMcRec(0, -1, -1, -1, -1.f); + rowBToJPsiSwap(false); } } else if constexpr (DecChannel == DecayChannel::B0ToJpsiK0Star) { for (const auto& rowJpsiHadMcRec : rowsJpsiHadMcRec) { @@ -581,11 +584,13 @@ struct HfCandidateCreatorBToJpsiReducedExpressions { continue; } rowB0McRec(rowJpsiHadMcRec.flagMcMatchRec(), rowJpsiHadMcRec.flagMcDecayChanRec(), rowJpsiHadMcRec.flagWrongCollision(), rowJpsiHadMcRec.debugMcRec(), rowJpsiHadMcRec.ptMother()); + rowBToJPsiSwap(rowJpsiHadMcRec.isHadronLeptonSwapped()); filledMcInfo = true; break; } if (!filledMcInfo) { // protection to get same size tables in case something went wrong: we created a candidate that was not preselected in the Jpsi-K creator rowB0McRec(0, -1, -1, -1, -1.f); + rowBToJPsiSwap(false); } } else if constexpr (DecChannel == DecayChannel::BsToJpsiPhi) { for (const auto& rowJpsiHadMcRec : rowsJpsiHadMcRec) { @@ -593,11 +598,13 @@ struct HfCandidateCreatorBToJpsiReducedExpressions { continue; } rowBsMcRec(rowJpsiHadMcRec.flagMcMatchRec(), rowJpsiHadMcRec.flagMcDecayChanRec(), rowJpsiHadMcRec.flagWrongCollision(), rowJpsiHadMcRec.debugMcRec(), rowJpsiHadMcRec.ptMother()); + rowBToJPsiSwap(rowJpsiHadMcRec.isHadronLeptonSwapped()); filledMcInfo = true; break; } if (!filledMcInfo) { // protection to get same size tables in case something went wrong: we created a candidate that was not preselected in the Jpsi-K creator rowBsMcRec(0, -1, -1, -1, -1.f); + rowBToJPsiSwap(false); } } } diff --git a/PWGHF/D2H/TableProducer/dataCreatorJpsiHadReduced.cxx b/PWGHF/D2H/TableProducer/dataCreatorJpsiHadReduced.cxx index 6f75e15e2ae..6c24a1339c4 100644 --- a/PWGHF/D2H/TableProducer/dataCreatorJpsiHadReduced.cxx +++ b/PWGHF/D2H/TableProducer/dataCreatorJpsiHadReduced.cxx @@ -516,6 +516,7 @@ struct HfDataCreatorJpsiHadReduced { // we check the MC matching to be stored int8_t sign{0}, flag{0}, channel{0}; + bool flagSwapped{false}; int8_t flagWrongCollision{WrongCollisionType::None}; int8_t debug{0}; float motherPt{-1.f}; @@ -532,7 +533,6 @@ struct HfDataCreatorJpsiHadReduced { // Since J/Psi is self-conjugate, we need to set acceptAntiParticles to false if (RecoDecay::isMatchedMCGen(particlesMc, bParticle, signB * Pdg::kBPlus, std::array{+kJPsi, signB * kKPlus}, false, nullptr, 1, &dauIndices)) { const auto& jpsiPart = particlesMc.rawIteratorAt(dauIndices[0]); - // Now we check that subtracting gammas from bremsstrahlung, the number of daughters of the J/Psi is 2 (µ+µ-) // In EVTGEN, bremmstralhung photons are considered as daughters of the J/Psi std::vector jpsiDauPdgs{}; @@ -541,6 +541,10 @@ struct HfDataCreatorJpsiHadReduced { } if (jpsiDauPdgs.size() - std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kGamma) == nProngsJpsi) { flag = signB * o2::hf_decay::hf_cand_beauty::BplusToJpsiKToMuMuK; + auto const& kaonPart = vecDaughtersB[2].template mcParticle_as(); + if (std::abs(kaonPart.pdgCode()) == +kMuonMinus) { + flagSwapped = true; + } } } @@ -574,6 +578,10 @@ struct HfDataCreatorJpsiHadReduced { } if (jpsiDauPdgs.size() - std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kGamma) == nProngsJpsi) { flag = signB * o2::hf_decay::hf_cand_beauty::BplusToJpsiKToEEK; + auto const& kaonPart = vecDaughtersB[2].template mcParticle_as(); + if (std::abs(kaonPart.pdgCode()) == +kElectron) { + flagSwapped = true; + } } } } @@ -604,21 +612,21 @@ struct HfDataCreatorJpsiHadReduced { } } } - rowHfJpsiKMcRecReduced(indexHfCandJpsi, selectedTracksBach[0][vecDaughtersB[2].globalIndex()], flag, channel, flagWrongCollision, debug, motherPt); + rowHfJpsiKMcRecReduced(indexHfCandJpsi, selectedTracksBach[0][vecDaughtersB[2].globalIndex()], flag, channel, flagWrongCollision, debug, motherPt, flagSwapped); } else if constexpr (DecChannel == DecayChannel::B0ToJpsiK0Star) { // B0 → J/Psi K0* → (µ+µ-) (K+pi-) int indexRec = -1; // We set acceptIncompleteReco to true to accept the case of bremsstrahlung - indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kB0, std::array{-kMuonMinus, +kMuonMinus, +kKPlus, -kPiPlus}, true, &sign, 3); + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kB0, std::array{-kMuonMinus, +kMuonMinus, +kKPlus, -kPiPlus}, true, &sign, 2); if (indexRec > -1) { const auto& bParticle = particlesMc.rawIteratorAt(indexRec); std::vector dauIndices{}; const int8_t signB = sign; // Since J/Psi is self-conjugate, we need to set acceptAntiParticles to false - if (RecoDecay::isMatchedMCGen(particlesMc, bParticle, signB * Pdg::kB0, std::array{+kJPsi, signB * Pdg::kK0Star892}, false, nullptr, 1, &dauIndices)) { + if (RecoDecay::isMatchedMCGen(particlesMc, bParticle, signB * Pdg::kB0, std::array{+kJPsi, signB * kKPlus, -1 * signB * kPiPlus}, false, nullptr, 2, &dauIndices) || RecoDecay::isMatchedMCGen(particlesMc, bParticle, signB * Pdg::kB0, std::array{+kJPsi, signB * kKPlus, -1 * signB * kPiPlus, +kGamma}, false, nullptr, 2, &dauIndices)) { const auto& jpsiPart = particlesMc.rawIteratorAt(dauIndices[0]); - // Now we check that subtracting gammas from bremsstrahlung, the number of daughters of the J/Psi is 2 (e+e-) + // Now we check that subtracting gammas from bremsstrahlung, the number of daughters of the J/Psi is 2 (µ+µ-) // In EVTGEN, bremmstralhung photons are considered as daughters of the J/Psi std::vector jpsiDauPdgs{}; for (const auto& dau : jpsiPart.template daughters_as()) { @@ -627,6 +635,19 @@ struct HfDataCreatorJpsiHadReduced { if (jpsiDauPdgs.size() - std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kGamma) == nProngsJpsi) { flag = signB * o2::hf_decay::hf_cand_beauty::B0ToJpsiPiKToMuMuPiK; indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kK0Star892, std::array{+kKPlus, -kPiPlus}, true, &sign, 1); + // we also test pi(K)-mu swapping + if (indexRec < 0) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[3]}, Pdg::kK0Star892, std::array{+kKPlus, -kPiPlus}, true, &sign, 1); + if (indexRec > -1) { + flagSwapped = true; + } + } + if (indexRec < 0) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[2], vecDaughtersB[1]}, Pdg::kK0Star892, std::array{+kKPlus, -kPiPlus}, true, &sign, 1); + if (indexRec > -1) { + flagSwapped = true; + } + } if (indexRec > -1) { channel = o2::hf_decay::hf_cand_beauty::B0ToJpsiKstar0; } @@ -645,14 +666,14 @@ struct HfDataCreatorJpsiHadReduced { if (checkDecayTypeMc) { // B0 → J/Psi K*0 → (e+e-) K+pi- if (!flag) { - indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kB0, std::array{-kElectron, +kElectron, +kKPlus, -kPiPlus}, true, &sign, 3); + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kB0, std::array{-kElectron, +kElectron, +kKPlus, -kPiPlus}, true, &sign, 2); if (indexRec > -1) { const auto& bParticle = particlesMc.rawIteratorAt(indexRec); std::vector dauIndices{}; const int8_t signB = sign; // Since J/Psi is self-conjugate, we need to set acceptAntiParticles to false - if (RecoDecay::isMatchedMCGen(particlesMc, bParticle, signB * Pdg::kB0, std::array{+kJPsi, signB * Pdg::kK0Star892}, false, nullptr, 1, &dauIndices)) { + if (RecoDecay::isMatchedMCGen(particlesMc, bParticle, signB * Pdg::kB0, std::array{+kJPsi, signB * kKPlus, -1 * signB * kPiPlus}, false, nullptr, 2, &dauIndices) || RecoDecay::isMatchedMCGen(particlesMc, bParticle, signB * Pdg::kB0, std::array{+kJPsi, signB * kKPlus, -1 * signB * kPiPlus, +kGamma}, false, nullptr, 2, &dauIndices)) { const auto& jpsiPart = particlesMc.rawIteratorAt(dauIndices[0]); // Now we check that subtracting gammas from bremsstrahlung, the number of daughters of the J/Psi is 2 (e+e-) @@ -664,6 +685,19 @@ struct HfDataCreatorJpsiHadReduced { if (jpsiDauPdgs.size() - std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kGamma) == nProngsJpsi) { flag = signB * o2::hf_decay::hf_cand_beauty::B0ToJpsiPiKToEEPiK; indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kK0Star892, std::array{+kKPlus, -kPiPlus}, true, &sign, 1); + // we also test pi(K)-mu swapping + if (indexRec < 0) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[3]}, Pdg::kK0Star892, std::array{+kKPlus, -kPiPlus}, true, &sign, 1); + if (indexRec > -1) { + flagSwapped = true; + } + } + if (indexRec < 0) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[2], vecDaughtersB[1]}, Pdg::kK0Star892, std::array{+kKPlus, -kPiPlus}, true, &sign, 1); + if (indexRec > -1) { + flagSwapped = true; + } + } if (indexRec > -1) { channel = o2::hf_decay::hf_cand_beauty::B0ToJpsiKstar0; } @@ -704,18 +738,18 @@ struct HfDataCreatorJpsiHadReduced { } } } - rowHfJpsiK0StarMcRecReduced(indexHfCandJpsi, selectedTracksBach[0][vecDaughtersB[2].globalIndex()], selectedTracksBach[1][vecDaughtersB[3].globalIndex()], flag, channel, flagWrongCollision, debug, motherPt); + rowHfJpsiK0StarMcRecReduced(indexHfCandJpsi, selectedTracksBach[0][vecDaughtersB[2].globalIndex()], selectedTracksBach[1][vecDaughtersB[3].globalIndex()], flag, channel, flagWrongCollision, debug, motherPt, flagSwapped); } else if constexpr (DecChannel == DecayChannel::BsToJpsiPhi) { // Bs → J/Psi phi → (µ+µ-) (K+K-) int indexRec = -1; // We set acceptIncompleteReco to true to accept the case of bremsstrahlung - indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kBS, std::array{-kMuonMinus, +kMuonMinus, +kKPlus, -kKPlus}, true, &sign, 3); + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kBS, std::array{-kMuonMinus, +kMuonMinus, +kKPlus, -kKPlus}, true, &sign, 2); if (indexRec > -1) { const auto& bParticle = particlesMc.rawIteratorAt(indexRec); std::vector dauIndices{}; const int8_t signB = sign; // Since J/Psi and phi are self-conjugate, we need to set acceptAntiParticles to false - if (RecoDecay::isMatchedMCGen(particlesMc, bParticle, signB * Pdg::kBS, std::array{+kJPsi, +Pdg::kPhi}, false, nullptr, 1, &dauIndices)) { + if (RecoDecay::isMatchedMCGen(particlesMc, bParticle, signB * Pdg::kBS, std::array{+kJPsi, +kKPlus, -kKPlus}, false, nullptr, 2, &dauIndices) || RecoDecay::isMatchedMCGen(particlesMc, bParticle, signB * Pdg::kBS, std::array{+kJPsi, +kKPlus, -kKPlus, +kGamma}, false, nullptr, 2, &dauIndices)) { const auto& jpsiPart = particlesMc.rawIteratorAt(dauIndices[0]); // Now we check that subtracting gammas from bremsstrahlung, the number of daughters of the J/Psi is 2 (e+e-) @@ -727,6 +761,18 @@ struct HfDataCreatorJpsiHadReduced { if (jpsiDauPdgs.size() - std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kGamma) == nProngsJpsi) { flag = signB * o2::hf_decay::hf_cand_beauty::BsToJpsiKKToMuMuKK; indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kPhi, std::array{+kKPlus, -kKPlus}, true, &sign, 1); + if (indexRec < 0) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[3]}, Pdg::kPhi, std::array{+kKPlus, -kKPlus}, true, &sign, 1); + if (indexRec > -1) { + flagSwapped = true; + } + } + if (indexRec < 0) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[2], vecDaughtersB[1]}, Pdg::kPhi, std::array{+kKPlus, -kKPlus}, true, &sign, 1); + if (indexRec > -1) { + flagSwapped = true; + } + } if (indexRec > -1) { channel = o2::hf_decay::hf_cand_beauty::BsToJpsiPhi; } @@ -745,14 +791,14 @@ struct HfDataCreatorJpsiHadReduced { if (checkDecayTypeMc) { // Bs → J/Psi phi → (e+e-) K+K- if (!flag) { - indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kBS, std::array{-kElectron, +kElectron, +kKPlus, -kKPlus}, true, &sign, 3); + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kBS, std::array{-kElectron, +kElectron, +kKPlus, -kKPlus}, true, &sign, 2); if (indexRec > -1) { const auto& bParticle = particlesMc.rawIteratorAt(indexRec); std::vector dauIndices{}; const int8_t signB = sign; // Since J/Psi and phi are self-conjugate, we need to set acceptAntiParticles to false - if (RecoDecay::isMatchedMCGen(particlesMc, bParticle, signB * Pdg::kBS, std::array{+kJPsi, +Pdg::kPhi}, false, nullptr, 1, &dauIndices)) { + if (RecoDecay::isMatchedMCGen(particlesMc, bParticle, signB * Pdg::kBS, std::array{+kJPsi, +kKPlus, -kKPlus}, false, nullptr, 2, &dauIndices) || RecoDecay::isMatchedMCGen(particlesMc, bParticle, signB * Pdg::kBS, std::array{+kJPsi, +kKPlus, -kKPlus, +kGamma}, false, nullptr, 2, &dauIndices)) { const auto& jpsiPart = particlesMc.rawIteratorAt(dauIndices[0]); // Now we check that subtracting gammas from bremsstrahlung, the number of daughters of the J/Psi is 2 (e+e-) @@ -764,6 +810,18 @@ struct HfDataCreatorJpsiHadReduced { if (jpsiDauPdgs.size() - std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kGamma) == nProngsJpsi) { flag = signB * o2::hf_decay::hf_cand_beauty::BsToJpsiKKToEEKK; indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kPhi, std::array{+kKPlus, -kKPlus}, true, &sign, 1); + if (indexRec < 0) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[3]}, Pdg::kPhi, std::array{+kKPlus, -kKPlus}, true, &sign, 1); + if (indexRec > -1) { + flagSwapped = true; + } + } + if (indexRec < 0) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[2], vecDaughtersB[1]}, Pdg::kPhi, std::array{+kKPlus, -kKPlus}, true, &sign, 1); + if (indexRec > -1) { + flagSwapped = true; + } + } if (indexRec > -1) { channel = o2::hf_decay::hf_cand_beauty::BsToJpsiPhi; } @@ -805,7 +863,7 @@ struct HfDataCreatorJpsiHadReduced { } } } - rowHfJpsiPhiMcRecReduced(indexHfCandJpsi, selectedTracksBach[0][vecDaughtersB[2].globalIndex()], selectedTracksBach[1][vecDaughtersB[3].globalIndex()], flag, channel, flagWrongCollision, debug, motherPt); + rowHfJpsiPhiMcRecReduced(indexHfCandJpsi, selectedTracksBach[0][vecDaughtersB[2].globalIndex()], selectedTracksBach[1][vecDaughtersB[3].globalIndex()], flag, channel, flagWrongCollision, debug, motherPt, flagSwapped); } } @@ -889,22 +947,23 @@ struct HfDataCreatorJpsiHadReduced { } else if constexpr (DecChannel == DecayChannel::B0ToJpsiK0Star) { // B0 → J/Psi K*0 → (µ+µ-) (K+pi-) // Since J/Psi is self-conjugate, we need to set acceptAntiParticles to false - if (RecoDecay::isMatchedMCGen(particlesMc, particle, sign * Pdg::kB0, std::array{static_cast(Pdg::kJPsi), sign * kKPlus, -1 * sign * kPiPlus}, false, nullptr, 2)) { + if (RecoDecay::isMatchedMCGen(particlesMc, particle, sign * Pdg::kB0, std::array{static_cast(Pdg::kJPsi), sign * kKPlus, -1 * sign * kPiPlus}, false, nullptr, 2) || RecoDecay::isMatchedMCGen(particlesMc, particle, sign * Pdg::kB0, std::array{static_cast(Pdg::kJPsi), sign * kKPlus, -1 * sign * kPiPlus, +kGamma}, false, nullptr, 2)) { // Match J/Psi -> µ+µ- and K*0 -> K+pi- const auto& jpsiPart = particlesMc.rawIteratorAt(particle.daughtersIds().front()); // Now we check that subtracting gammas from bremsstrahlung, the number of daughters of the J/Psi is 2 (µ+µ-) // In EVTGEN bremmstralhung photons are considered as daughters of the J/Psi + // Same happens for the K*0 std::vector jpsiDauPdgs{}; for (const auto& dau : jpsiPart.template daughters_as()) { jpsiDauPdgs.push_back(dau.pdgCode()); } if (std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kMuonMinus) == 1 && std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), -kMuonMinus) == 1 && jpsiDauPdgs.size() - std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kGamma) == nProngsJpsi) { flag = sign * o2::hf_decay::hf_cand_beauty::B0ToJpsiPiKToMuMuPiK; - } - const auto& kStarPart = particlesMc.rawIteratorAt(particle.daughtersIds().back()); - // Check K*0 -> K+pi- - if (RecoDecay::isMatchedMCGen(particlesMc, kStarPart, static_cast(Pdg::kK0Star892), std::array{+kKPlus, -kPiPlus}, true)) { - channel = o2::hf_decay::hf_cand_beauty::B0ToJpsiKstar0; + // Check K*0 -> K+pi- + const auto& kStarPart = particlesMc.rawIteratorAt(particle.daughtersIds().back()); + if (RecoDecay::isMatchedMCGen(particlesMc, kStarPart, static_cast(Pdg::kK0Star892), std::array{+kKPlus, -kPiPlus}, true) || RecoDecay::isMatchedMCGen(particlesMc, kStarPart, static_cast(Pdg::kK0Star892), std::array{+kKPlus, -kPiPlus, +kGamma}, true)) { + channel = o2::hf_decay::hf_cand_beauty::B0ToJpsiKstar0; + } } } @@ -933,7 +992,7 @@ struct HfDataCreatorJpsiHadReduced { } else if constexpr (DecChannel == DecayChannel::BsToJpsiPhi) { // Bs → J/Psi phi → (µ+µ-) (K+K-) // Since J/Psi is self-conjugate, we need to set acceptAntiParticles to false - if (RecoDecay::isMatchedMCGen(particlesMc, particle, sign * Pdg::kBS, std::array{static_cast(Pdg::kJPsi), sign * kKPlus, -1 * sign * kKPlus}, false, nullptr, 2)) { + if (RecoDecay::isMatchedMCGen(particlesMc, particle, sign * Pdg::kBS, std::array{static_cast(Pdg::kJPsi), sign * kKPlus, -1 * sign * kKPlus}, false, nullptr, 2) || RecoDecay::isMatchedMCGen(particlesMc, particle, sign * Pdg::kBS, std::array{static_cast(Pdg::kJPsi), sign * kKPlus, -1 * sign * kKPlus, +kGamma}, false, nullptr, 2)) { // Match J/Psi -> µ+µ- and phi -> K+K- const auto& jpsiPart = particlesMc.rawIteratorAt(particle.daughtersIds().front()); // Now we check that subtracting gammas from bremsstrahlung, the number of daughters of the J/Psi is 2 (µ+µ-) @@ -944,11 +1003,11 @@ struct HfDataCreatorJpsiHadReduced { } if (std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kMuonMinus) == 1 && std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), -kMuonMinus) == 1 && jpsiDauPdgs.size() - std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kGamma) == nProngsJpsi) { flag = sign * o2::hf_decay::hf_cand_beauty::BsToJpsiKKToMuMuKK; - } - const auto& phiPart = particlesMc.rawIteratorAt(particle.daughtersIds().back()); - // Check phi -> K+K- - if (RecoDecay::isMatchedMCGen(particlesMc, phiPart, static_cast(Pdg::kPhi), std::array{-kKPlus, +kKPlus}, false)) { - channel = o2::hf_decay::hf_cand_beauty::BsToJpsiPhi; + // Check phi -> K+K- + const auto& phiPart = particlesMc.rawIteratorAt(particle.daughtersIds().back()); + if (RecoDecay::isMatchedMCGen(particlesMc, phiPart, static_cast(Pdg::kPhi), std::array{-kKPlus, +kKPlus}, false) || RecoDecay::isMatchedMCGen(particlesMc, phiPart, static_cast(Pdg::kPhi), std::array{-kKPlus, +kKPlus, +kGamma}, false)) { + channel = o2::hf_decay::hf_cand_beauty::BsToJpsiPhi; + } } } diff --git a/PWGHF/D2H/Tasks/taskB0ToJpsiK0StarReduced.cxx b/PWGHF/D2H/Tasks/taskB0ToJpsiK0StarReduced.cxx index 15d69d2f1bb..1ca03e38744 100644 --- a/PWGHF/D2H/Tasks/taskB0ToJpsiK0StarReduced.cxx +++ b/PWGHF/D2H/Tasks/taskB0ToJpsiK0StarReduced.cxx @@ -231,7 +231,8 @@ DECLARE_SOA_TABLE(HfRedCandB0Lites, "AOD", "HFREDCANDB0LITE", //! Table with som hf_cand_mc_flag::FlagMcDecayChanRec, hf_cand_mc_flag::OriginMcRec, hf_cand_b0tojpsik0star_lite::FlagWrongCollision, - hf_cand_b0tojpsik0star_lite::PtGen); + hf_cand_b0tojpsik0star_lite::PtGen, + hf_cand_mc_flag::IsHadronLeptonSwapped); } // namespace o2::aod @@ -425,10 +426,12 @@ struct HfTaskB0ToJpsiK0StarReduced { int8_t flagMcMatchRec{0}, flagMcDecayChanRec{0}, flagWrongCollision{0}; bool isSignal = false; + bool swapped{false}; if constexpr (DoMc) { flagMcMatchRec = candidate.flagMcMatchRec(); flagMcDecayChanRec = candidate.flagMcDecayChanRec(); flagWrongCollision = candidate.flagWrongCollision(); + swapped = candidate.isHadronLeptonSwapped(); isSignal = std::abs(flagMcMatchRec) == o2::hf_decay::hf_cand_beauty::B0ToJpsiPiKToMuMuPiK && flagMcDecayChanRec == o2::hf_decay::hf_cand_beauty::B0ToJpsiKstar0; } @@ -654,7 +657,8 @@ struct HfTaskB0ToJpsiK0StarReduced { flagMcDecayChanRec, isSignal, flagWrongCollision, - ptMother); + ptMother, + swapped); }; if (statusB0KPi >= selectionFlagB0) { @@ -716,7 +720,7 @@ struct HfTaskB0ToJpsiK0StarReduced { } // processDataWithB0Ml PROCESS_SWITCH(HfTaskB0ToJpsiK0StarReduced, processDataWithB0Ml, "Process data with ML for B0", false); - void processMc(soa::Join const& candidates, + void processMc(soa::Join const& candidates, aod::HfMcGenRedB0s const& mcParticles, JPsis const& candidatesJpsi, aod::HfRedBach0Tracks const& kaon0Tracks, @@ -737,7 +741,7 @@ struct HfTaskB0ToJpsiK0StarReduced { } // processMc PROCESS_SWITCH(HfTaskB0ToJpsiK0StarReduced, processMc, "Process MC without ML for B0", false); - void processMcWithB0Ml(soa::Join const& candidates, + void processMcWithB0Ml(soa::Join const& candidates, aod::HfMcGenRedB0s const& mcParticles, JPsis const& candidatesJpsi, aod::HfRedBach0Tracks const& kaon0Tracks, diff --git a/PWGHF/D2H/Tasks/taskBplusToJpsiKReduced.cxx b/PWGHF/D2H/Tasks/taskBplusToJpsiKReduced.cxx index 316bdad3a22..5fdd4eaca40 100644 --- a/PWGHF/D2H/Tasks/taskBplusToJpsiKReduced.cxx +++ b/PWGHF/D2H/Tasks/taskBplusToJpsiKReduced.cxx @@ -192,7 +192,8 @@ DECLARE_SOA_TABLE(HfRedCandBpLites, "AOD", "HFREDCANDBPLITE", //! Table with som hf_cand_mc_flag::FlagMcDecayChanRec, hf_cand_mc_flag::OriginMcRec, hf_cand_bplustojpsik_lite::FlagWrongCollision, - hf_cand_bplustojpsik_lite::PtGen); + hf_cand_bplustojpsik_lite::PtGen, + hf_cand_mc_flag::IsHadronLeptonSwapped); // DECLARE_SOA_TABLE(HfRedBpMcCheck, "AOD", "HFREDBPMCCHECK", //! Table with MC decay type check // hf_cand_mc_flag::FlagMcMatchRec, @@ -378,11 +379,13 @@ struct HfTaskBplusToJpsiKReduced { uint8_t statusBplus = 0; int8_t flagMcMatchRec{0}, flagMcDecayChanRec{0}, flagWrongCollision{0}; + bool swapped{false}; bool isSignal = false; if constexpr (DoMc) { flagMcMatchRec = candidate.flagMcMatchRec(); flagMcDecayChanRec = candidate.flagMcDecayChanRec(); flagWrongCollision = candidate.flagWrongCollision(); + swapped = candidate.isHadronLeptonSwapped(); isSignal = std::abs(flagMcMatchRec) == o2::hf_decay::hf_cand_beauty::BplusToJpsiKToMuMuK; } @@ -508,7 +511,8 @@ struct HfTaskBplusToJpsiKReduced { flagMcDecayChanRec, isSignal, flagWrongCollision, - ptMother); + ptMother, + swapped); } } @@ -561,7 +565,7 @@ struct HfTaskBplusToJpsiKReduced { } // processDataWithBplusMl PROCESS_SWITCH(HfTaskBplusToJpsiKReduced, processDataWithBplusMl, "Process data with ML for B+", false); - void processMc(soa::Join const& candidates, + void processMc(soa::Join const& candidates, aod::HfMcGenRedBps const& mcParticles, JPsis const& candidatesJpsi, aod::HfRedBach0Tracks const& kaonTracks) @@ -581,7 +585,7 @@ struct HfTaskBplusToJpsiKReduced { } // processMc PROCESS_SWITCH(HfTaskBplusToJpsiKReduced, processMc, "Process MC without ML for B+", false); - void processMcWithBplusMl(soa::Join const& candidates, + void processMcWithBplusMl(soa::Join const& candidates, aod::HfMcGenRedBps const& mcParticles, JPsis const& candidatesJpsi, aod::HfRedBach0Tracks const& kaonTracks) diff --git a/PWGHF/D2H/Tasks/taskBsToJpsiPhiReduced.cxx b/PWGHF/D2H/Tasks/taskBsToJpsiPhiReduced.cxx index 4cc6089befb..f47802846cf 100644 --- a/PWGHF/D2H/Tasks/taskBsToJpsiPhiReduced.cxx +++ b/PWGHF/D2H/Tasks/taskBsToJpsiPhiReduced.cxx @@ -216,7 +216,8 @@ DECLARE_SOA_TABLE(HfRedCandBsLites, "AOD", "HFREDCANDBSLITE", //! Table with som hf_cand_mc_flag::FlagMcDecayChanRec, hf_cand_mc_flag::OriginMcRec, hf_cand_bstojpsiphi_lite::FlagWrongCollision, - hf_cand_bstojpsiphi_lite::PtGen); + hf_cand_bstojpsiphi_lite::PtGen, + hf_cand_mc_flag::IsHadronLeptonSwapped); // DECLARE_SOA_TABLE(HfRedBsMcCheck, "AOD", "HFREDBPMCCHECK", //! Table with MC decay type check // hf_cand_mc_flag::FlagMcMatchRec, @@ -412,10 +413,12 @@ struct HfTaskBsToJpsiPhiReduced { int8_t flagMcMatchRec{0}, flagMcDecayChanRec{0}, flagWrongCollision{0}; bool isSignal = false; + bool swapped{false}; if constexpr (DoMc) { flagMcMatchRec = candidate.flagMcMatchRec(); flagMcDecayChanRec = candidate.flagMcDecayChanRec(); flagWrongCollision = candidate.flagWrongCollision(); + swapped = candidate.isHadronLeptonSwapped(); isSignal = std::abs(flagMcMatchRec) == o2::hf_decay::hf_cand_beauty::BsToJpsiKKToMuMuKK && flagMcDecayChanRec == o2::hf_decay::hf_cand_beauty::BsToJpsiPhi; } @@ -557,7 +560,8 @@ struct HfTaskBsToJpsiPhiReduced { flagMcDecayChanRec, isSignal, flagWrongCollision, - ptMother); + ptMother, + swapped); } } @@ -612,7 +616,7 @@ struct HfTaskBsToJpsiPhiReduced { } // processDataWithBsMl PROCESS_SWITCH(HfTaskBsToJpsiPhiReduced, processDataWithBsMl, "Process data with ML for Bs", false); - void processMc(soa::Join const& candidates, + void processMc(soa::Join const& candidates, aod::HfMcGenRedBss const& mcParticles, JPsis const& candidatesJpsi, aod::HfRedBach0Tracks const& kaon0Tracks, @@ -633,7 +637,7 @@ struct HfTaskBsToJpsiPhiReduced { } // processMc PROCESS_SWITCH(HfTaskBsToJpsiPhiReduced, processMc, "Process MC without ML for Bs", false); - void processMcWithBsMl(soa::Join const& candidates, + void processMcWithBsMl(soa::Join const& candidates, aod::HfMcGenRedBss const& mcParticles, JPsis const& candidatesJpsi, aod::HfRedBach0Tracks const& kaon0Tracks,