Skip to content

Commit 167ddd3

Browse files
committed
implement retrieveMatchedGenParticle() and pass it to fillCandidateTable()
1 parent b2f2c7d commit 167ddd3

1 file changed

Lines changed: 26 additions & 8 deletions

File tree

‎PWGHF/TableProducer/treeCreatorXicToXiPiPi.cxx‎

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
/// \author Jaeyoon Cho <jaeyoon.cho@cern.ch>, Inha University
1818

1919
#include "PWGHF/Core/DecayChannelsLegacy.h"
20+
#include "PWGHF/DataModel/AliasTables.h"
2021
#include "PWGHF/DataModel/CandidateReconstructionTables.h"
2122
#include "PWGHF/DataModel/CandidateSelectionTables.h"
2223

@@ -37,6 +38,7 @@
3738

3839
#include <cstdint>
3940
#include <numeric>
41+
#include <optional>
4042
#include <vector>
4143

4244
using namespace o2;
@@ -418,10 +420,9 @@ struct HfTreeCreatorXicToXiPiPi {
418420
using SelectedCandidatesMc = soa::Filtered<soa::Join<aod::HfCandXic, aod::HfCandXicMcRec, aod::HfSelXicToXiPiPi>>;
419421
using SelectedCandidatesKfMc = soa::Filtered<soa::Join<aod::HfCandXic, aod::HfCandXicKF, aod::HfCandXicMcRec, aod::HfSelXicToXiPiPi>>;
420422
using SelectedCandidatesMcML = soa::Filtered<soa::Join<aod::HfCandXic, aod::HfMlXicToXiPiPi, aod::HfCandXicMcRec, aod::HfSelXicToXiPiPi>>;
421-
using MatchedGenXicToXiPiPi = soa::Filtered<soa::Join<aod::McParticles, aod::HfCandXicMcGen>>;
423+
using MatchedGenXicToXiPiPi = soa::Join<aod::McParticles, aod::HfCandXicMcGen>;
422424

423425
Filter filterSelectCandidates = aod::hf_sel_candidate_xic::isSelXicToXiPiPi >= selectionFlagXic;
424-
Filter filterGenXicToXiPiPi = (nabs(aod::hf_cand_mc_flag::flagMcMatchGen) == static_cast<int8_t>(BIT(aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiPiPi)) || nabs(aod::hf_cand_mc_flag::flagMcMatchGen) == static_cast<int8_t>(BIT(aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiResPiToXiPiPi)) || fillGenInfoForAcceptance == true);
425426

426427
Partition<SelectedCandidatesMc> recSig = nabs(aod::hf_cand_mc_flag::flagMcMatchRec) != static_cast<int8_t>(0);
427428
Partition<SelectedCandidatesMc> recBg = nabs(aod::hf_cand_mc_flag::flagMcMatchRec) == static_cast<int8_t>(0);
@@ -437,7 +438,7 @@ struct HfTreeCreatorXicToXiPiPi {
437438
}
438439

439440
template <bool DoMc, bool DoKf, bool DoMl, typename T>
440-
void fillCandidateTable(const T& candidate)
441+
void fillCandidateTable(const T& candidate, const std::optional<MatchedGenXicToXiPiPi::iterator>& particle = std::nullopt)
441442
{
442443
int8_t particleFlag = candidate.sign();
443444
int8_t originMc = 0;
@@ -792,6 +793,18 @@ struct HfTreeCreatorXicToXiPiPi {
792793
}
793794
}
794795

796+
template <typename CandType>
797+
std::optional<MatchedGenXicToXiPiPi::iterator> retrieveMatchedGenParticle(CandType const& candidate, MatchedGenXicToXiPiPi const& particles)
798+
{
799+
const auto mcParticlePi0 = candidate.template pi0_as<o2::aod::TracksWMc>().template mcParticle_as<MatchedGenXicToXiPiPi>();
800+
const auto indexMother = RecoDecay::getMother(particles, mcParticlePi0, o2::constants::physics::Pdg::kXiCPlus, true);
801+
if (indexMother < 0) {
802+
return std::nullopt;
803+
}
804+
const auto particleMother = particles.rawIteratorAt(indexMother);
805+
return particleMother;
806+
}
807+
795808
void processData(SelectedCandidates const& candidates)
796809
{
797810
// Filling candidate properties
@@ -854,7 +867,8 @@ struct HfTreeCreatorXicToXiPiPi {
854867
rowCandidateFull.reserve(recSig.size());
855868
}
856869
for (const auto& candidate : recSig) {
857-
fillCandidateTable<true, false, false>(candidate);
870+
const auto matchedGenParticle = retrieveMatchedGenParticle(candidate, particles);
871+
fillCandidateTable<true, false, false>(candidate, matchedGenParticle);
858872
}
859873
} else if (fillOnlyBackground) {
860874
if (fillCandidateLiteTable) {
@@ -876,7 +890,8 @@ struct HfTreeCreatorXicToXiPiPi {
876890
rowCandidateFull.reserve(candidates.size());
877891
}
878892
for (const auto& candidate : candidates) {
879-
fillCandidateTable<true, false, false>(candidate);
893+
const auto matchedGenParticle = retrieveMatchedGenParticle(candidate, particles);
894+
fillCandidateTable<true, false, false>(candidate, matchedGenParticle);
880895
}
881896
}
882897

@@ -917,7 +932,8 @@ struct HfTreeCreatorXicToXiPiPi {
917932
PROCESS_SWITCH(HfTreeCreatorXicToXiPiPi, processMc, "Process MC with DCAFitter reconstruction", false);
918933

919934
void processMcKf(SelectedCandidatesKfMc const& candidates,
920-
MatchedGenXicToXiPiPi const& particles)
935+
MatchedGenXicToXiPiPi const& particles,
936+
o2::aod::TracksWMc const&)
921937
{
922938
// Filling candidate properties
923939
if (fillOnlySignal) {
@@ -927,7 +943,8 @@ struct HfTreeCreatorXicToXiPiPi {
927943
rowCandidateFull.reserve(recSigKf.size());
928944
}
929945
for (const auto& candidate : recSigKf) {
930-
fillCandidateTable<true, true, false>(candidate);
946+
const auto matchedGenParticle = retrieveMatchedGenParticle(candidate, particles);
947+
fillCandidateTable<true, true, false>(candidate, matchedGenParticle);
931948
}
932949
} else if (fillOnlyBackground) {
933950
if (fillCandidateLiteTable) {
@@ -949,7 +966,8 @@ struct HfTreeCreatorXicToXiPiPi {
949966
rowCandidateFull.reserve(candidates.size());
950967
}
951968
for (const auto& candidate : candidates) {
952-
fillCandidateTable<true, true, false>(candidate);
969+
const auto matchedGenParticle = retrieveMatchedGenParticle(candidate, particles);
970+
fillCandidateTable<true, true, false>(candidate, matchedGenParticle);
953971
}
954972
}
955973

0 commit comments

Comments
 (0)