Skip to content

Commit ae803ec

Browse files
authored
[PWGHF] Add information to get generated signals with daughters in acceptance (#18377)
1 parent d83fd36 commit ae803ec

1 file changed

Lines changed: 134 additions & 6 deletions

File tree

‎PWGHF/TableProducer/treeCreatorXicToXiPiPi.cxx‎

Lines changed: 134 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,20 @@ DECLARE_SOA_COLUMN(CpaXY, cpaXY, float); //!
7070
DECLARE_SOA_COLUMN(PtXi, ptXi, float); //! Transverse momentum of Xi (prong0) (GeV/c)
7171
DECLARE_SOA_COLUMN(ImpactParameterXi, impactParameterXi, float); //! Impact parameter of Xi (prong0)
7272
DECLARE_SOA_COLUMN(ImpactParameterNormalisedXi, impactParameterNormalisedXi, float); //! Normalised impact parameter of Xi (prong0)
73+
DECLARE_SOA_COLUMN(EtaBachelorPi, etaBachelorPi, float); //! Pseudorapidity of bachelor Pi
7374
DECLARE_SOA_COLUMN(PPi0, pPi0, float); //! Momentum of Pi0 (prong1) (GeV/c)
7475
DECLARE_SOA_COLUMN(PtPi0, ptPi0, float); //! Transverse momentum of Pi0 (prong1) (GeV/c)
76+
DECLARE_SOA_COLUMN(EtaPi0, etaPi0, float); //! Pseudorapidity of Pi0 (prong1
7577
DECLARE_SOA_COLUMN(ImpactParameterPi0, impactParameterPi0, float); //! Impact parameter of Pi0 (prong1)
7678
DECLARE_SOA_COLUMN(ImpactParameterNormalisedPi0, impactParameterNormalisedPi0, float); //! Normalised impact parameter of Pi0 (prong1)
7779
DECLARE_SOA_COLUMN(PPi1, pPi1, float); //! Momentum of Pi1 (prong2) (GeV/c)
7880
DECLARE_SOA_COLUMN(PtPi1, ptPi1, float); //! Transverse momentum of Pi1 (prong2) (GeV/c)
79-
DECLARE_SOA_COLUMN(ImpactParameterPi1, impactParameterPi1, float); //! Normalised impact parameter of Pi1 (prong2)
81+
DECLARE_SOA_COLUMN(EtaPi1, etaPi1, float); //! Pseudorapidity of Pi1 (prong2)
82+
DECLARE_SOA_COLUMN(PtPiFromLambda, ptPiFromLambda, float); //! Transverse momentum of pion from Lambda (GeV/c)
83+
DECLARE_SOA_COLUMN(EtaPiFromLambda, etaPiFromLambda, float); //! Pseudorapidity of pion from Lambda (GeV/c)
84+
DECLARE_SOA_COLUMN(PtPrFromLambda, ptPrFromLambda, float); //! Transverse momentum of proton from Lambda (GeV/c)
85+
DECLARE_SOA_COLUMN(EtaPrFromLambda, etaPrFromLambda, float); //! Pseudorapidity of proton from Lambda (GeV/c)
86+
DECLARE_SOA_COLUMN(ImpactParameterPi1, impactParameterPi1, float); //! Impact parameter of Pi1 (prong2)
8087
DECLARE_SOA_COLUMN(ImpactParameterNormalisedPi1, impactParameterNormalisedPi1, float); //! Normalised impact parameter of Pi1 (prong2)
8188
DECLARE_SOA_COLUMN(MaxNormalisedDeltaIP, maxNormalisedDeltaIP, float); //! Maximum normalized difference between measured and expected impact parameter of candidate prongs
8289
DECLARE_SOA_COLUMN(MlScoreBkg, mlScoreBkg, float); //! ML score for background class
@@ -367,7 +374,17 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiFullPs, "AOD", "HFXICXI2PIFULLP",
367374
full::Eta,
368375
full::Phi,
369376
full::Y,
370-
hf_cand_xic_to_xi_pi_pi::DecayLengthMcGen);
377+
hf_cand_xic_to_xi_pi_pi::DecayLengthMcGen,
378+
full::PtPi0,
379+
full::PtPi1,
380+
hf_cand_xic_to_xi_pi_pi::PtBachelorPi,
381+
full::PtPiFromLambda,
382+
full::PtPrFromLambda,
383+
full::EtaPi0,
384+
full::EtaPi1,
385+
full::EtaBachelorPi,
386+
full::EtaPiFromLambda,
387+
full::EtaPrFromLambda);
371388
} // namespace o2::aod
372389

373390
/// Writes the full information in an output TTree
@@ -382,6 +399,7 @@ struct HfTreeCreatorXicToXiPiPi {
382399
Configurable<int> selectionFlagXic{"selectionFlagXic", 1, "Selection Flag for Xic"};
383400
Configurable<bool> fillCandidateLiteTable{"fillCandidateLiteTable", false, "Switch to fill lite table with candidate properties"};
384401
Configurable<bool> fillGenParticleTable{"fillGenParticleTable", false, "Switch to fill table with MC truth for generated particles"};
402+
Configurable<bool> fillGenInfoForAcceptance{"fillGenInfoForAcceptance", true, "Enable filling of information for acceptance computation"};
385403
// parameters for production of training samples
386404
Configurable<bool> fillOnlySignal{"fillOnlySignal", false, "Flag to fill derived tables with signal for ML trainings"};
387405
Configurable<bool> fillOnlyBackground{"fillOnlyBackground", false, "Flag to fill derived tables with background for ML trainings"};
@@ -399,7 +417,7 @@ struct HfTreeCreatorXicToXiPiPi {
399417
using MatchedGenXicToXiPiPi = soa::Filtered<soa::Join<aod::McParticles, aod::HfCandXicMcGen>>;
400418

401419
Filter filterSelectCandidates = aod::hf_sel_candidate_xic::isSelXicToXiPiPi >= selectionFlagXic;
402-
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)));
420+
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);
403421

404422
Partition<SelectedCandidatesMc> recSig = nabs(aod::hf_cand_mc_flag::flagMcMatchRec) != int8_t(0);
405423
Partition<SelectedCandidatesMc> recBg = nabs(aod::hf_cand_mc_flag::flagMcMatchRec) == int8_t(0);
@@ -715,6 +733,61 @@ struct HfTreeCreatorXicToXiPiPi {
715733
}
716734
}
717735

736+
template <typename Parts>
737+
void getMcDaughterInformation(Parts const& particles,
738+
Parts::iterator const& particle,
739+
float& ptPi0,
740+
float& ptPi1,
741+
float& ptPiBachelor,
742+
float& ptPiFromLambda,
743+
float& ptPrFromLambda,
744+
float& etaPi0,
745+
float& etaPi1,
746+
float& etaPiBachelor,
747+
float& etaPiFromLambda,
748+
float& etaPrFromLambda)
749+
{
750+
std::vector<int> arrDaughIndex = {};
751+
RecoDecay::getDaughters<true>(particle, &arrDaughIndex, std::array{+kXiMinus, +kPiPlus, +kPiPlus}, 2);
752+
bool foundFirstPi{false};
753+
for (const int iProng : arrDaughIndex) {
754+
auto daugh = particles.rawIteratorAt(iProng);
755+
if (std::abs(daugh.pdgCode()) == +kPiPlus) {
756+
if (foundFirstPi) {
757+
ptPi1 = daugh.pt();
758+
etaPi1 = daugh.eta();
759+
} else {
760+
ptPi0 = daugh.pt();
761+
etaPi0 = daugh.eta();
762+
foundFirstPi = true;
763+
}
764+
} else if (std::abs(daugh.pdgCode()) == +kXiMinus) {
765+
std::vector<int> arrDaughIndexXi = {};
766+
RecoDecay::getDaughters<true>(daugh, &arrDaughIndexXi, std::array{+kLambda0, -kPiPlus}, 1);
767+
for (const int iProngXi : arrDaughIndexXi) {
768+
auto daughXi = particles.rawIteratorAt(iProngXi);
769+
if (std::abs(daughXi.pdgCode()) == +kPiPlus) {
770+
ptPiBachelor = daughXi.pt();
771+
etaPiBachelor = daughXi.eta();
772+
} else {
773+
std::vector<int> arrDaughIndexLambda = {};
774+
RecoDecay::getDaughters<true>(daughXi, &arrDaughIndexLambda, std::array{+kProton, -kPiPlus}, 1);
775+
for (const int iProngLambda : arrDaughIndexLambda) {
776+
auto daughLambda = particles.rawIteratorAt(iProngLambda);
777+
if (std::abs(daughLambda.pdgCode()) == +kPiPlus) {
778+
ptPiFromLambda = daughLambda.pt();
779+
etaPiFromLambda = daughLambda.eta();
780+
} else {
781+
ptPrFromLambda = daughLambda.pt();
782+
etaPrFromLambda = daughLambda.eta();
783+
}
784+
}
785+
}
786+
}
787+
}
788+
}
789+
}
790+
718791
void processData(SelectedCandidates const& candidates)
719792
{
720793
// Filling candidate properties
@@ -806,6 +879,14 @@ struct HfTreeCreatorXicToXiPiPi {
806879
if (fillGenParticleTable) {
807880
rowCandidateFullParticles.reserve(particles.size());
808881
for (const auto& particle : particles) {
882+
float ptPi0{-1.f}, ptPi1{-1.f}, ptPiBachelor{-1.f}, ptPiFromLambda{-1.f}, ptPrFromLambda{-1.f};
883+
float etaPi0{-1.f}, etaPi1{-1.f}, etaPiBachelor{-1.f}, etaPiFromLambda{-1.f}, etaPrFromLambda{-1.f};
884+
if (fillGenInfoForAcceptance) {
885+
if (!TESTBIT(particle.flagMcMatchGen(), aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiPiPi) && !TESTBIT(particle.flagMcMatchGen(), aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiResPiToXiPiPi)) { // we cannot filter, otherwise we have no daughter particles in the filtered table
886+
continue;
887+
}
888+
getMcDaughterInformation(particles, particle, ptPi0, ptPi1, ptPiBachelor, ptPiFromLambda, ptPrFromLambda, etaPi0, etaPi1, etaPiBachelor, etaPiFromLambda, etaPrFromLambda);
889+
}
809890
rowCandidateFullParticles(
810891
particle.flagMcMatchGen(),
811892
particle.originMcGen(),
@@ -814,7 +895,17 @@ struct HfTreeCreatorXicToXiPiPi {
814895
particle.eta(),
815896
particle.phi(),
816897
RecoDecay::y(particle.pVector(), o2::constants::physics::MassXiCPlus),
817-
particle.decayLengthMcGen());
898+
particle.decayLengthMcGen(),
899+
ptPi0,
900+
ptPi1,
901+
ptPiBachelor,
902+
ptPiFromLambda,
903+
ptPrFromLambda,
904+
etaPi0,
905+
etaPi1,
906+
etaPiBachelor,
907+
etaPiFromLambda,
908+
etaPrFromLambda);
818909
}
819910
}
820911
}
@@ -860,6 +951,14 @@ struct HfTreeCreatorXicToXiPiPi {
860951
if (fillGenParticleTable) {
861952
rowCandidateFullParticles.reserve(particles.size());
862953
for (const auto& particle : particles) {
954+
float ptPi0{-1.f}, ptPi1{-1.f}, ptPiBachelor{-1.f}, ptPiFromLambda{-1.f}, ptPrFromLambda{-1.f};
955+
float etaPi0{-1.f}, etaPi1{-1.f}, etaPiBachelor{-1.f}, etaPiFromLambda{-1.f}, etaPrFromLambda{-1.f};
956+
if (fillGenInfoForAcceptance) {
957+
if (!TESTBIT(particle.flagMcMatchGen(), aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiPiPi) && !TESTBIT(particle.flagMcMatchGen(), aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiResPiToXiPiPi)) { // we cannot filter, otherwise we have no daughter particles in the filtered table
958+
continue;
959+
}
960+
getMcDaughterInformation(particles, particle, ptPi0, ptPi1, ptPiBachelor, ptPiFromLambda, ptPrFromLambda, etaPi0, etaPi1, etaPiBachelor, etaPiFromLambda, etaPrFromLambda);
961+
}
863962
rowCandidateFullParticles(
864963
particle.flagMcMatchGen(),
865964
particle.originMcGen(),
@@ -868,7 +967,17 @@ struct HfTreeCreatorXicToXiPiPi {
868967
particle.eta(),
869968
particle.phi(),
870969
RecoDecay::y(particle.pVector(), o2::constants::physics::MassXiCPlus),
871-
particle.decayLengthMcGen());
970+
particle.decayLengthMcGen(),
971+
ptPi0,
972+
ptPi1,
973+
ptPiBachelor,
974+
ptPiFromLambda,
975+
ptPrFromLambda,
976+
etaPi0,
977+
etaPi1,
978+
etaPiBachelor,
979+
etaPiFromLambda,
980+
etaPrFromLambda);
872981
}
873982
}
874983
}
@@ -906,6 +1015,15 @@ struct HfTreeCreatorXicToXiPiPi {
9061015
if (fillGenParticleTable) {
9071016
rowCandidateFullParticles.reserve(particles.size());
9081017
for (const auto& particle : particles) {
1018+
float ptPi0{-1.f}, ptPi1{-1.f}, ptPiBachelor{-1.f}, ptPiFromLambda{-1.f}, ptPrFromLambda{-1.f};
1019+
float etaPi0{-1.f}, etaPi1{-1.f}, etaPiBachelor{-1.f}, etaPiFromLambda{-1.f}, etaPrFromLambda{-1.f};
1020+
if (fillGenInfoForAcceptance) {
1021+
if (!TESTBIT(particle.flagMcMatchGen(), aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiPiPi) && !TESTBIT(particle.flagMcMatchGen(), aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiResPiToXiPiPi)) { // we cannot filter, otherwise we have no daughter particles in the filtered table
1022+
continue;
1023+
}
1024+
getMcDaughterInformation(particles, particle, ptPi0, ptPi1, ptPiBachelor, ptPiFromLambda, ptPrFromLambda, etaPi0, etaPi1, etaPiBachelor, etaPiFromLambda, etaPrFromLambda);
1025+
}
1026+
9091027
rowCandidateFullParticles(
9101028
particle.flagMcMatchGen(),
9111029
particle.originMcGen(),
@@ -914,7 +1032,17 @@ struct HfTreeCreatorXicToXiPiPi {
9141032
particle.eta(),
9151033
particle.phi(),
9161034
RecoDecay::y(particle.pVector(), o2::constants::physics::MassXiCPlus),
917-
particle.decayLengthMcGen());
1035+
particle.decayLengthMcGen(),
1036+
ptPi0,
1037+
ptPi1,
1038+
ptPiBachelor,
1039+
ptPiFromLambda,
1040+
ptPrFromLambda,
1041+
etaPi0,
1042+
etaPi1,
1043+
etaPiBachelor,
1044+
etaPiFromLambda,
1045+
etaPrFromLambda);
9181046
}
9191047
}
9201048
}

0 commit comments

Comments
 (0)