Skip to content

Commit 6b46975

Browse files
authored
[PWGHF] Fix matching to MC for B2JPsi analyses to account for photons produced by EVTGEN (#18668)
1 parent 9318d3a commit 6b46975

4 files changed

Lines changed: 73 additions & 48 deletions

File tree

‎PWGHF/D2H/TableProducer/dataCreatorJpsiHadReduced.cxx‎

Lines changed: 58 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -535,11 +535,11 @@ struct HfDataCreatorJpsiHadReduced {
535535

536536
// Now we check that subtracting gammas from bremsstrahlung, the number of daughters of the J/Psi is 2 (µ+µ-)
537537
// In EVTGEN, bremmstralhung photons are considered as daughters of the J/Psi
538-
std::vector<int> jpsiDauIndices{};
538+
std::vector<int> jpsiDauPdgs{};
539539
for (const auto& dau : jpsiPart.template daughters_as<PParticles>()) {
540-
jpsiDauIndices.push_back(dau.pdgCode());
540+
jpsiDauPdgs.push_back(dau.pdgCode());
541541
}
542-
if (jpsiDauIndices.size() - std::count(jpsiDauIndices.begin(), jpsiDauIndices.end(), kGamma) == nProngsJpsi) {
542+
if (jpsiDauPdgs.size() - std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kGamma) == nProngsJpsi) {
543543
flag = signB * o2::hf_decay::hf_cand_beauty::BplusToJpsiKToMuMuK;
544544
}
545545
}
@@ -568,11 +568,11 @@ struct HfDataCreatorJpsiHadReduced {
568568

569569
// Now we check that subtracting gammas from bremsstrahlung, the number of daughters of the J/Psi is 2 (e+e-)
570570
// In EVTGEN, bremmstralhung photons are considered as daughters of the J/Psi
571-
std::vector<int> jpsiDauIndices{};
571+
std::vector<int> jpsiDauPdgs{};
572572
for (const auto& dau : jpsiPart.template daughters_as<PParticles>()) {
573-
jpsiDauIndices.push_back(dau.pdgCode());
573+
jpsiDauPdgs.push_back(dau.pdgCode());
574574
}
575-
if (jpsiDauIndices.size() - std::count(jpsiDauIndices.begin(), jpsiDauIndices.end(), kGamma) == nProngsJpsi) {
575+
if (jpsiDauPdgs.size() - std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kGamma) == nProngsJpsi) {
576576
flag = signB * o2::hf_decay::hf_cand_beauty::BplusToJpsiKToEEK;
577577
}
578578
}
@@ -615,16 +615,16 @@ struct HfDataCreatorJpsiHadReduced {
615615
std::vector<int> dauIndices{};
616616
const int8_t signB = sign;
617617
// Since J/Psi is self-conjugate, we need to set acceptAntiParticles to false
618-
if (RecoDecay::isMatchedMCGen<false>(particlesMc, bParticle, signB * Pdg::kB0, std::array{+kJPsi, signB * Pdg::kK0Star892}, false, nullptr, 1, &dauIndices)) {
618+
if (RecoDecay::isMatchedMCGen(particlesMc, bParticle, signB * Pdg::kB0, std::array{+kJPsi, signB * Pdg::kK0Star892}, false, nullptr, 1, &dauIndices)) {
619619
const auto& jpsiPart = particlesMc.rawIteratorAt(dauIndices[0]);
620620

621621
// Now we check that subtracting gammas from bremsstrahlung, the number of daughters of the J/Psi is 2 (e+e-)
622622
// In EVTGEN, bremmstralhung photons are considered as daughters of the J/Psi
623-
std::vector<int> jpsiDauIndices{};
623+
std::vector<int> jpsiDauPdgs{};
624624
for (const auto& dau : jpsiPart.template daughters_as<PParticles>()) {
625-
jpsiDauIndices.push_back(dau.pdgCode());
625+
jpsiDauPdgs.push_back(dau.pdgCode());
626626
}
627-
if (jpsiDauIndices.size() - std::count(jpsiDauIndices.begin(), jpsiDauIndices.end(), kGamma) == nProngsJpsi) {
627+
if (jpsiDauPdgs.size() - std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kGamma) == nProngsJpsi) {
628628
flag = signB * o2::hf_decay::hf_cand_beauty::B0ToJpsiPiKToMuMuPiK;
629629
indexRec = RecoDecay::getMatchedMCRec<false, false, false, true, true>(particlesMc, std::array{vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kK0Star892, std::array{+kKPlus, -kPiPlus}, true, &sign, 1);
630630
if (indexRec > -1) {
@@ -652,16 +652,16 @@ struct HfDataCreatorJpsiHadReduced {
652652
const int8_t signB = sign;
653653

654654
// Since J/Psi is self-conjugate, we need to set acceptAntiParticles to false
655-
if (RecoDecay::isMatchedMCGen<false>(particlesMc, bParticle, signB * Pdg::kB0, std::array{+kJPsi, signB * Pdg::kK0Star892}, false, nullptr, 1, &dauIndices)) {
655+
if (RecoDecay::isMatchedMCGen(particlesMc, bParticle, signB * Pdg::kB0, std::array{+kJPsi, signB * Pdg::kK0Star892}, false, nullptr, 1, &dauIndices)) {
656656
const auto& jpsiPart = particlesMc.rawIteratorAt(dauIndices[0]);
657657

658658
// Now we check that subtracting gammas from bremsstrahlung, the number of daughters of the J/Psi is 2 (e+e-)
659659
// In EVTGEN, bremmstralhung photons are considered as daughters of the J/Psi
660-
std::vector<int> jpsiDauIndices{};
660+
std::vector<int> jpsiDauPdgs{};
661661
for (const auto& dau : jpsiPart.template daughters_as<PParticles>()) {
662-
jpsiDauIndices.push_back(dau.pdgCode());
662+
jpsiDauPdgs.push_back(dau.pdgCode());
663663
}
664-
if (jpsiDauIndices.size() - std::count(jpsiDauIndices.begin(), jpsiDauIndices.end(), kGamma) == nProngsJpsi) {
664+
if (jpsiDauPdgs.size() - std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kGamma) == nProngsJpsi) {
665665
flag = signB * o2::hf_decay::hf_cand_beauty::B0ToJpsiPiKToEEPiK;
666666
indexRec = RecoDecay::getMatchedMCRec<false, false, false, true, true>(particlesMc, std::array{vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kK0Star892, std::array{+kKPlus, -kPiPlus}, true, &sign, 1);
667667
if (indexRec > -1) {
@@ -715,16 +715,16 @@ struct HfDataCreatorJpsiHadReduced {
715715
std::vector<int> dauIndices{};
716716
const int8_t signB = sign;
717717
// Since J/Psi and phi are self-conjugate, we need to set acceptAntiParticles to false
718-
if (RecoDecay::isMatchedMCGen<false>(particlesMc, bParticle, signB * Pdg::kBS, std::array{+kJPsi, +Pdg::kPhi}, false, nullptr, 1, &dauIndices)) {
718+
if (RecoDecay::isMatchedMCGen(particlesMc, bParticle, signB * Pdg::kBS, std::array{+kJPsi, +Pdg::kPhi}, false, nullptr, 1, &dauIndices)) {
719719
const auto& jpsiPart = particlesMc.rawIteratorAt(dauIndices[0]);
720720

721721
// Now we check that subtracting gammas from bremsstrahlung, the number of daughters of the J/Psi is 2 (e+e-)
722722
// In EVTGEN, bremmstralhung photons are considered as daughters of the J/Psi
723-
std::vector<int> jpsiDauIndices{};
723+
std::vector<int> jpsiDauPdgs{};
724724
for (const auto& dau : jpsiPart.template daughters_as<PParticles>()) {
725-
jpsiDauIndices.push_back(dau.pdgCode());
725+
jpsiDauPdgs.push_back(dau.pdgCode());
726726
}
727-
if (jpsiDauIndices.size() - std::count(jpsiDauIndices.begin(), jpsiDauIndices.end(), kGamma) == nProngsJpsi) {
727+
if (jpsiDauPdgs.size() - std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kGamma) == nProngsJpsi) {
728728
flag = signB * o2::hf_decay::hf_cand_beauty::BsToJpsiKKToMuMuKK;
729729
indexRec = RecoDecay::getMatchedMCRec<false, false, false, true, true>(particlesMc, std::array{vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kPhi, std::array{+kKPlus, -kKPlus}, true, &sign, 1);
730730
if (indexRec > -1) {
@@ -752,16 +752,16 @@ struct HfDataCreatorJpsiHadReduced {
752752
const int8_t signB = sign;
753753

754754
// Since J/Psi and phi are self-conjugate, we need to set acceptAntiParticles to false
755-
if (RecoDecay::isMatchedMCGen<false>(particlesMc, bParticle, signB * Pdg::kBS, std::array{+kJPsi, +Pdg::kPhi}, false, nullptr, 1, &dauIndices)) {
755+
if (RecoDecay::isMatchedMCGen(particlesMc, bParticle, signB * Pdg::kBS, std::array{+kJPsi, +Pdg::kPhi}, false, nullptr, 1, &dauIndices)) {
756756
const auto& jpsiPart = particlesMc.rawIteratorAt(dauIndices[0]);
757757

758758
// Now we check that subtracting gammas from bremsstrahlung, the number of daughters of the J/Psi is 2 (e+e-)
759759
// In EVTGEN, bremmstralhung photons are considered as daughters of the J/Psi
760-
std::vector<int> jpsiDauIndices{};
760+
std::vector<int> jpsiDauPdgs{};
761761
for (const auto& dau : jpsiPart.template daughters_as<PParticles>()) {
762-
jpsiDauIndices.push_back(dau.pdgCode());
762+
jpsiDauPdgs.push_back(dau.pdgCode());
763763
}
764-
if (jpsiDauIndices.size() - std::count(jpsiDauIndices.begin(), jpsiDauIndices.end(), kGamma) == nProngsJpsi) {
764+
if (jpsiDauPdgs.size() - std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kGamma) == nProngsJpsi) {
765765
flag = signB * o2::hf_decay::hf_cand_beauty::BsToJpsiKKToEEKK;
766766
indexRec = RecoDecay::getMatchedMCRec<false, false, false, true, true>(particlesMc, std::array{vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kPhi, std::array{+kKPlus, -kKPlus}, true, &sign, 1);
767767
if (indexRec > -1) {
@@ -844,14 +844,21 @@ struct HfDataCreatorJpsiHadReduced {
844844

845845
// Match generated particles.
846846
for (const auto& particle : mcParticlesPerMcColl) {
847-
int8_t sign{0}, flag{0}, channel{0};
847+
int8_t sign = particle.pdgCode() > 0 ? 1 : -1;
848+
int8_t flag{0}, channel{0};
848849
if constexpr (DecChannel == DecayChannel::BplusToJpsiK) {
849850
// B+ → J/Psi K+ → (µ+µ-) K+
850-
if (RecoDecay::isMatchedMCGen<false>(particlesMc, particle, Pdg::kBPlus, std::array{static_cast<int>(Pdg::kJPsi), +kKPlus}, true, &sign)) {
851+
// Since J/Psi is self-conjugate, we need to set acceptAntiParticles to false
852+
if (RecoDecay::isMatchedMCGen(particlesMc, particle, sign * Pdg::kBPlus, std::array{static_cast<int>(Pdg::kJPsi), sign * kKPlus}, false)) {
851853
// Match J/Psi -> µ+µ-
852-
auto candJpsiMC = particlesMc.rawIteratorAt(particle.daughtersIds().front());
853-
// Printf("Checking J/Psi -> µ+µ-");
854-
if (RecoDecay::isMatchedMCGen(particlesMc, candJpsiMC, static_cast<int>(Pdg::kJPsi), std::array{-kMuonMinus, +kMuonMinus}, true)) {
854+
const auto& jpsiPart = particlesMc.rawIteratorAt(particle.daughtersIds().front());
855+
// Now we check that subtracting gammas from bremsstrahlung, the number of daughters of the J/Psi is 2 (µ+µ-)
856+
// In EVTGEN, bremmstralhung photons are considered as daughters of the J/Psi
857+
std::vector<int> jpsiDauPdgs{};
858+
for (const auto& dau : jpsiPart.template daughters_as<aod::McParticles>()) {
859+
jpsiDauPdgs.push_back(dau.pdgCode());
860+
}
861+
if (std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kMuonMinus) == 1 && std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), -kMuonMinus) && jpsiDauPdgs.size() - std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kGamma) == nProngsJpsi) {
855862
flag = sign * o2::hf_decay::hf_cand_beauty::BplusToJpsiKToMuMuK;
856863
}
857864
}
@@ -880,16 +887,22 @@ struct HfDataCreatorJpsiHadReduced {
880887
ptProngs[1], yProngs[1], etaProngs[1], hfRejMap, centFT0C, centFT0M);
881888
} else if constexpr (DecChannel == DecayChannel::B0ToJpsiK0Star) {
882889
// B0 → J/Psi K*0 → (µ+µ-) (K+pi-)
883-
if (RecoDecay::isMatchedMCGen<true>(particlesMc, particle, Pdg::kB0, std::array{static_cast<int>(Pdg::kJPsi), +kKPlus, -kPiPlus}, true, &sign, 2)) {
890+
// Since J/Psi is self-conjugate, we need to set acceptAntiParticles to false
891+
if (RecoDecay::isMatchedMCGen(particlesMc, particle, sign * Pdg::kB0, std::array{static_cast<int>(Pdg::kJPsi), sign * kKPlus, -1 * sign * kPiPlus}, false, nullptr, 2)) {
884892
// Match J/Psi -> µ+µ- and K*0 -> K+pi-
885-
auto candJpsiMC = particlesMc.rawIteratorAt(particle.daughtersIds().front());
886-
auto candK0StarMC = particlesMc.rawIteratorAt(particle.daughtersIds().back());
887-
// Printf("Checking J/Psi -> µ+µ- and K*0 -> K+pi-");
888-
if (RecoDecay::isMatchedMCGen(particlesMc, candJpsiMC, static_cast<int>(Pdg::kJPsi), std::array{-kMuonMinus, +kMuonMinus}, true)) {
893+
const auto& jpsiPart = particlesMc.rawIteratorAt(particle.daughtersIds().front());
894+
// Now we check that subtracting gammas from bremsstrahlung, the number of daughters of the J/Psi is 2 (µ+µ-)
895+
// In EVTGEN bremmstralhung photons are considered as daughters of the J/Psi
896+
std::vector<int> jpsiDauPdgs{};
897+
for (const auto& dau : jpsiPart.template daughters_as<aod::McParticles>()) {
898+
jpsiDauPdgs.push_back(dau.pdgCode());
899+
}
900+
if (std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kMuonMinus) == 1 && std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), -kMuonMinus) && jpsiDauPdgs.size() - std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kGamma) == nProngsJpsi) {
889901
flag = sign * o2::hf_decay::hf_cand_beauty::B0ToJpsiPiKToMuMuPiK;
890902
}
903+
const auto& kStarPart = particlesMc.rawIteratorAt(particle.daughtersIds().back());
891904
// Check K*0 -> K+pi-
892-
if (RecoDecay::isMatchedMCGen(particlesMc, candK0StarMC, static_cast<int>(Pdg::kK0Star892), std::array{+kKPlus, -kPiPlus}, true)) {
905+
if (RecoDecay::isMatchedMCGen(particlesMc, kStarPart, static_cast<int>(Pdg::kK0Star892), std::array{+kKPlus, -kPiPlus}, true)) {
893906
channel = o2::hf_decay::hf_cand_beauty::B0ToJpsiKstar0;
894907
}
895908
}
@@ -918,16 +931,22 @@ struct HfDataCreatorJpsiHadReduced {
918931
ptProngs[1], yProngs[1], etaProngs[1], hfRejMap, centFT0C, centFT0M);
919932
} else if constexpr (DecChannel == DecayChannel::BsToJpsiPhi) {
920933
// Bs → J/Psi phi → (µ+µ-) (K+K-)
921-
if (RecoDecay::isMatchedMCGen<true>(particlesMc, particle, Pdg::kBS, std::array{static_cast<int>(Pdg::kJPsi), +kKPlus, -kKPlus}, true, &sign, 2)) {
934+
// Since J/Psi is self-conjugate, we need to set acceptAntiParticles to false
935+
if (RecoDecay::isMatchedMCGen(particlesMc, particle, sign * Pdg::kBS, std::array{static_cast<int>(Pdg::kJPsi), sign * kKPlus, -1 * sign * kKPlus}, false, nullptr, 2)) {
922936
// Match J/Psi -> µ+µ- and phi -> K+K-
923-
auto candJpsiMC = particlesMc.rawIteratorAt(particle.daughtersIds().front());
924-
auto candPhiMC = particlesMc.rawIteratorAt(particle.daughtersIds().back());
925-
// Printf("Checking J/Psi -> µ+µ- and phi -> K+K-");
926-
if (RecoDecay::isMatchedMCGen(particlesMc, candJpsiMC, static_cast<int>(Pdg::kJPsi), std::array{-kMuonMinus, +kMuonMinus}, true)) {
937+
const auto& jpsiPart = particlesMc.rawIteratorAt(particle.daughtersIds().front());
938+
// Now we check that subtracting gammas from bremsstrahlung, the number of daughters of the J/Psi is 2 (µ+µ-)
939+
// In EVTGEN, bremmstralhung photons are considered as daughters of the J/Psi
940+
std::vector<int> jpsiDauPdgs{};
941+
for (const auto& dau : jpsiPart.template daughters_as<aod::McParticles>()) {
942+
jpsiDauPdgs.push_back(dau.pdgCode());
943+
}
944+
if (std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kMuonMinus) == 1 && std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), -kMuonMinus) && jpsiDauPdgs.size() - std::count(jpsiDauPdgs.begin(), jpsiDauPdgs.end(), kGamma) == nProngsJpsi) {
927945
flag = sign * o2::hf_decay::hf_cand_beauty::BsToJpsiKKToMuMuKK;
928946
}
947+
const auto& phiPart = particlesMc.rawIteratorAt(particle.daughtersIds().back());
929948
// Check phi -> K+K-
930-
if (RecoDecay::isMatchedMCGen(particlesMc, candPhiMC, static_cast<int>(Pdg::kPhi), std::array{-kKPlus, +kKPlus}, true)) {
949+
if (RecoDecay::isMatchedMCGen(particlesMc, phiPart, static_cast<int>(Pdg::kPhi), std::array{-kKPlus, +kKPlus}, true)) {
931950
channel = o2::hf_decay::hf_cand_beauty::BsToJpsiPhi;
932951
}
933952
}

‎PWGHF/D2H/Tasks/taskB0ToJpsiK0StarReduced.cxx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ struct HfTaskB0ToJpsiK0StarReduced {
342342
const AxisSpec axisImpactPar{200, -0.05, 0.05};
343343
const AxisSpec axisPtJpsi{100, 0., 50.};
344344
const AxisSpec axisRapidity{100, -2., 2.};
345-
const AxisSpec axisPtB{std::vector<double>(binsPt), "#it{p}_{T}^{B^{0}} (GeV/#it{c})"};
345+
const AxisSpec axisPtB{500, 0., 50., "#it{p}_{T}^{B^{0}} (GeV/#it{c})"};
346346
const AxisSpec axisPtK0Star{100, 0.f, 10.f};
347347

348348
registry.add("hMass", b0CandTitle + "inv. mass J/#Psi K*^{0} (GeV/#it{c}^{2});" + stringPt, {HistType::kTH2F, {axisMassB0, axisPtB}});
@@ -353,7 +353,8 @@ struct HfTaskB0ToJpsiK0StarReduced {
353353
if (doprocessMc || doprocessMcWithB0Ml) {
354354
registry.add("hPtJpsiGen", mcParticleMatched + "J/#Psi #it{p}_{T}^{gen} (GeV/#it{c}); B^{0} " + stringPt, {HistType::kTH2F, {axisPtProng, axisPtB}});
355355
registry.add("hPtK0StarGen", mcParticleMatched + "K*^{0} #it{p}_{T}^{gen} (GeV/#it{c}); B^{0} " + stringPt, {HistType::kTH2F, {axisPtK0Star, axisPtB}});
356-
registry.add("hYGenWithProngsInAcceptance", mcParticleMatched + "B^{0} #it{p}_{T}^{gen} (GeV/#it{c}); B^{0} #it{y}", {HistType::kTH2F, {axisPtProng, axisRapidity}});
356+
registry.add("hPtYGenSig", mcParticleMatched + "B^{0} #it{p}_{T}^{gen} (GeV/#it{c}); B^{0} #it{y}", {HistType::kTH2F, {axisPtB, axisRapidity}});
357+
registry.add("hPtYWithProngsInAccepanceGenSig", mcParticleMatched + "B^{0} #it{p}_{T}^{gen} (GeV/#it{c}); B^{0} #it{y}", {HistType::kTH2F, {axisPtB, axisRapidity}});
357358
registry.add("hMassRecSig", b0CandMatch + "inv. mass J/#Psi K*^{0} (GeV/#it{c}^{2}); B^{0} " + stringPt, {HistType::kTH2F, {axisMassB0, axisPtB}});
358359
registry.add("hMassJpsiRecSig", b0CandMatch + "inv. mass #mu^{+}#mu^{#minus} (GeV/#it{c}^{2}); J/#Psi " + stringPt, {HistType::kTH2F, {axisMassJpsi, axisPtJpsi}});
359360
registry.add("hMassK0StarRecSig", b0CandMatch + "inv. mass K^{+}#pi^{#minus} (GeV/#it{c}^{2}); K*^{0} " + stringPt, {HistType::kTH2F, {axisMassK0Star, axisPtK0Star}});
@@ -679,9 +680,10 @@ struct HfTaskB0ToJpsiK0StarReduced {
679680
registry.fill(HIST("hPtJpsiGen"), ptProngs[0], ptParticle);
680681
registry.fill(HIST("hPtK0StarGen"), ptProngs[1], ptParticle);
681682

683+
registry.fill(HIST("hPtYGenSig"), ptParticle, yParticle);
682684
// generated B0 with daughters in geometrical acceptance
683685
if (prongsInAcc) {
684-
registry.fill(HIST("hYGenWithProngsInAcceptance"), ptParticle, yParticle);
686+
registry.fill(HIST("hPtYWithProngsInAccepanceGenSig"), ptParticle, yParticle);
685687
}
686688
}
687689

0 commit comments

Comments
 (0)