From 3aa1446577ff4c941df2d6b40aec746f847c0823 Mon Sep 17 00:00:00 2001 From: JaeYoonCHO Date: Mon, 18 Aug 2025 21:34:01 +0200 Subject: [PATCH 1/3] Add a variable of the generated particle to the tree for QA --- PWGHF/DataModel/CandidateReconstructionTables.h | 4 +++- PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx | 12 +++++++++--- PWGHF/TableProducer/treeCreatorXicToXiPiPi.cxx | 9 ++++++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/PWGHF/DataModel/CandidateReconstructionTables.h b/PWGHF/DataModel/CandidateReconstructionTables.h index d4b6a74a867..36bfe383f3b 100644 --- a/PWGHF/DataModel/CandidateReconstructionTables.h +++ b/PWGHF/DataModel/CandidateReconstructionTables.h @@ -1905,6 +1905,7 @@ DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // reconstruction le DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); // generator level DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); +DECLARE_SOA_COLUMN(DecayLengthMcGen, decayLengthMcGen, float); // Residuals and pulls DECLARE_SOA_COLUMN(PtResidual, ptResidual, float); DECLARE_SOA_COLUMN(PResidual, pResidual, float); @@ -2012,7 +2013,8 @@ DECLARE_SOA_TABLE(HfCandXicMcRec, "AOD", "HFCANDXICMCREC", DECLARE_SOA_TABLE(HfCandXicMcGen, "AOD", "HFCANDXICMCGEN", hf_cand_xic_to_xi_pi_pi::FlagMcMatchGen, hf_cand_xic_to_xi_pi_pi::OriginMcGen, - hf_cand::PdgBhadMotherPart); + hf_cand::PdgBhadMotherPart, + hf_cand_xic_to_xi_pi_pi::DecayLengthMcGen); // table with residuals and pulls of PV DECLARE_SOA_TABLE(HfCandXicResid, "AOD", "HFCANDXICRESID", diff --git a/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx b/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx index 192465b5e33..467f6b28922 100644 --- a/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx +++ b/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx @@ -912,6 +912,7 @@ struct HfCandidateCreatorXicToXiPiPiExpressions { int8_t sign = 0; int8_t flag = 0; int8_t origin = RecoDecay::OriginType::None; + float decayLengthGen = -999.f; int8_t nPionsDecayed = 0; int8_t nInteractionsWithMaterial = 0; // for resonance matching @@ -1088,7 +1089,7 @@ struct HfCandidateCreatorXicToXiPiPiExpressions { if (rejectionMask != 0) { // at least one event selection not satisfied --> reject all particles from this collision for (unsigned int i = 0; i < mcParticlesPerMcColl.size(); ++i) { - rowMcMatchGen(-99, -99, -99); + rowMcMatchGen(-99, -99, -99, decayLengthGen); } continue; } @@ -1134,13 +1135,18 @@ struct HfCandidateCreatorXicToXiPiPiExpressions { // Check whether the charm baryon is non-prompt (from a b quark). if (flag != 0) { origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); + // Calculate the decay length of the generated particle + auto dau0 = particle.template daughters_as().begin(); + double vtxDau[3] = {dau0.vx(), dau0.vy(), dau0.vz()}; + double vtxPV[3] = {mcCollision.posX(), mcCollision.posY(), mcCollision.posZ()}; + decayLengthGen = RecoDecay::distance(vtxPV, vtxDau); } // Fill table if (origin == RecoDecay::OriginType::NonPrompt) { auto bHadMother = mcParticles.rawIteratorAt(idxBhadMothers[0]); - rowMcMatchGen(flag, origin, bHadMother.pdgCode()); + rowMcMatchGen(flag, origin, bHadMother.pdgCode(), decayLengthGen); } else { - rowMcMatchGen(flag, origin, 0); + rowMcMatchGen(flag, origin, 0, decayLengthGen); } } // close loop over generated particles } // close loop over McCollisions diff --git a/PWGHF/TableProducer/treeCreatorXicToXiPiPi.cxx b/PWGHF/TableProducer/treeCreatorXicToXiPiPi.cxx index 52a12a02b91..ca2f34ae5d3 100644 --- a/PWGHF/TableProducer/treeCreatorXicToXiPiPi.cxx +++ b/PWGHF/TableProducer/treeCreatorXicToXiPiPi.cxx @@ -334,7 +334,8 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiFullPs, "AOD", "HFXICXI2PIFULLP", full::Pt, full::Eta, full::Phi, - full::Y); + full::Y, + hf_cand_xic_to_xi_pi_pi::DecayLengthMcGen); } // namespace o2::aod /// Writes the full information in an output TTree @@ -723,7 +724,8 @@ struct HfTreeCreatorXicToXiPiPi { particle.pt(), particle.eta(), particle.phi(), - RecoDecay::y(particle.pVector(), o2::constants::physics::MassXiCPlus)); + RecoDecay::y(particle.pVector(), o2::constants::physics::MassXiCPlus), + particle.decayLengthMcGen()); } } } @@ -776,7 +778,8 @@ struct HfTreeCreatorXicToXiPiPi { particle.pt(), particle.eta(), particle.phi(), - RecoDecay::y(particle.pVector(), o2::constants::physics::MassXiCPlus)); + RecoDecay::y(particle.pVector(), o2::constants::physics::MassXiCPlus), + particle.decayLengthMcGen()); } } } From cd96dc0cd1276e11383b8bc49b66d8896dd0f78e Mon Sep 17 00:00:00 2001 From: JaeYoonCHO Date: Wed, 20 Aug 2025 14:18:12 +0200 Subject: [PATCH 2/3] Replace double[3] arrays with std::array --- PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx b/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx index 467f6b28922..cc87166fa57 100644 --- a/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx +++ b/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx @@ -1137,8 +1137,8 @@ struct HfCandidateCreatorXicToXiPiPiExpressions { origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); // Calculate the decay length of the generated particle auto dau0 = particle.template daughters_as().begin(); - double vtxDau[3] = {dau0.vx(), dau0.vy(), dau0.vz()}; - double vtxPV[3] = {mcCollision.posX(), mcCollision.posY(), mcCollision.posZ()}; + std::array vtxDau = {dau0.vx(), dau0.vy(), dau0.vz()}; + std::array vtxPV = {mcCollision.posX(), mcCollision.posY(), mcCollision.posZ()}; decayLengthGen = RecoDecay::distance(vtxPV, vtxDau); } // Fill table From 2ed8131c57e0a0e97e07b84c9ac5610d52146ced Mon Sep 17 00:00:00 2001 From: JaeYoonCHO Date: Wed, 20 Aug 2025 16:59:36 +0200 Subject: [PATCH 3/3] Address reviewer's comments --- PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx b/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx index cc87166fa57..f88a6d573c9 100644 --- a/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx +++ b/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx @@ -1137,8 +1137,8 @@ struct HfCandidateCreatorXicToXiPiPiExpressions { origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); // Calculate the decay length of the generated particle auto dau0 = particle.template daughters_as().begin(); - std::array vtxDau = {dau0.vx(), dau0.vy(), dau0.vz()}; - std::array vtxPV = {mcCollision.posX(), mcCollision.posY(), mcCollision.posZ()}; + const std::array vtxDau{dau0.vx(), dau0.vy(), dau0.vz()}; + const std::array vtxPV{mcCollision.posX(), mcCollision.posY(), mcCollision.posZ()}; decayLengthGen = RecoDecay::distance(vtxPV, vtxDau); } // Fill table