From 7b62012b2dad50240a0ce15c55cf9fb7925b8fbf Mon Sep 17 00:00:00 2001 From: GiorgioAlbertoLucia Date: Mon, 28 Jul 2025 15:38:04 +0200 Subject: [PATCH 01/19] more compact flags for mc --- PWGLF/DataModel/LFhe3HadronTables.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/PWGLF/DataModel/LFhe3HadronTables.h b/PWGLF/DataModel/LFhe3HadronTables.h index f0dbc5cc3dd..60ee803fca7 100644 --- a/PWGLF/DataModel/LFhe3HadronTables.h +++ b/PWGLF/DataModel/LFhe3HadronTables.h @@ -75,9 +75,14 @@ DECLARE_SOA_COLUMN(Multiplicity, multiplicity, uint16_t); DECLARE_SOA_COLUMN(CentralityFT0C, centFT0C, float); DECLARE_SOA_COLUMN(MultiplicityFT0C, multiplicityFT0C, float); -DECLARE_SOA_COLUMN(IsMotherLi4, isMotherLi4, bool); -DECLARE_SOA_COLUMN(IsHe3Primary, isHe3Primary, bool); -DECLARE_SOA_COLUMN(IsHadPrimary, isHadPrimary, bool); +/* Flags: 0 - primary, + 1 - from Li4, + 2 - from hypertriton, + 3 - from other decay, + 4 - from material +*/ +DECLARE_SOA_COLUMN(FlagHe3, flagHe3, uint8_t); +DECLARE_SOA_COLUMN(FlagHad, flagHad, uint8_t); } // namespace he3HadronTablesNS @@ -120,9 +125,8 @@ DECLARE_SOA_TABLE(he3HadronTableMC, "AOD", "HE3HADTABLEMC", he3HadronTablesNS::PhiMCHad, he3HadronTablesNS::SignedPtMC, he3HadronTablesNS::MassMC, - he3HadronTablesNS::IsMotherLi4, - he3HadronTablesNS::IsHe3Primary, - he3HadronTablesNS::IsHadPrimary) + he3HadronTablesNS::FlagHe3, + he3HadronTablesNS::FlagHad) DECLARE_SOA_TABLE(he3HadronMult, "AOD", "HE3HADMULT", he3HadronTablesNS::CollisionId, he3HadronTablesNS::ZVertex, From 962cfc273f1bfc8356f4d9b3ea85bd9e66465084 Mon Sep 17 00:00:00 2001 From: GiorgioAlbertoLucia Date: Mon, 28 Jul 2025 15:40:57 +0200 Subject: [PATCH 02/19] added enum with mc flags --- PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx index 547d4b08c3b..29a812949e8 100644 --- a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx +++ b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx @@ -103,6 +103,14 @@ enum Selections { kAll }; +enum Flags { + kPrimary = BIT(0), + kFromLi4 = BIT(1), + kFromHypertriton = BIT(2), + kFromOtherDecay = BIT(3), + kFromMaterial = BIT(4) +}; + } // namespace struct He3HadCandidate { From 7ac68ab2a5d8adb1d7c8e3c61410881d6026fdd6 Mon Sep 17 00:00:00 2001 From: GiorgioAlbertoLucia Date: Mon, 28 Jul 2025 15:44:45 +0200 Subject: [PATCH 03/19] removed useless comments, added pdg code from the constants file --- PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx index 29a812949e8..25c772b52fb 100644 --- a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx +++ b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx @@ -86,15 +86,11 @@ namespace constexpr double betheBlochDefault[1][6]{{-1.e32, -1.e32, -1.e32, -1.e32, -1.e32, -1.e32}}; static const std::vector betheBlochParNames{"p0", "p1", "p2", "p3", "p4", "resolution"}; -// constexpr float he3Mass = o2::constants::physics::MassHelium3; -// constexpr float protonMass = o2::constants::physics::MassProton; -// constexpr float pionchargedMass = o2::constants::physics::MassPiPlus; -constexpr int Li4PDG = 1000030040; +constexpr int Li4PDG = o2::constants::physics::Pdg::kLithium4; constexpr int ProtonPDG = PDG_t::kProton; constexpr int PionPDG = PDG_t::kPiPlus; constexpr int He3PDG = o2::constants::physics::Pdg::kHelium3; constexpr float CommonInite = 0.0f; -// constexpr int pichargedPDG = 211; enum Selections { kNoCuts = 0, From 094c70831dc08525bfd3a14b29ab3899388dc2a2 Mon Sep 17 00:00:00 2001 From: GiorgioAlbertoLucia Date: Mon, 28 Jul 2025 16:21:18 +0200 Subject: [PATCH 04/19] removed older table columns, added new ones --- PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx index 25c772b52fb..e4a2ae6f20b 100644 --- a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx +++ b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx @@ -167,9 +167,8 @@ struct He3HadCandidate { float etaHadMC = -99.f; float phiHadMC = -99.f; - bool isHe3Primary = false; - bool isHadPrimary = false; - bool isMotherLi4 = false; + uint8_t flagsHe3 = 0; // flags for He3 + uint8_t flagsHad = 0; // flags for hadron // collision information int32_t collisionID = 0; @@ -666,7 +665,6 @@ struct he3HadronFemto { he3Hadcand.l4PtMC = mctrackMother.pt() * (mctrackMother.pdgCode() > 0 ? 1 : -1); const double eLit = mctrackHe3.e() + mctrackHad.e(); he3Hadcand.l4MassMC = std::sqrt(eLit * eLit - mctrackMother.p() * mctrackMother.p()); - he3Hadcand.isMotherLi4 = std::abs(mctrackMother.pdgCode()) == Li4PDG; } template @@ -782,9 +780,8 @@ struct he3HadronFemto { he3Hadcand.phiHadMC, he3Hadcand.l4PtMC, he3Hadcand.l4MassMC, - he3Hadcand.isMotherLi4, - he3Hadcand.isHe3Primary, - he3Hadcand.isHadPrimary); + he3Hadcand.flagsHe3, + he3Hadcand.flagsHad); } if (settingFillMultiplicity) { outputMultiplicityTable( From e90bdbe27efd1b3d96ee91aeac73ab14b3361762 Mon Sep 17 00:00:00 2001 From: GiorgioAlbertoLucia Date: Mon, 28 Jul 2025 16:47:47 +0200 Subject: [PATCH 05/19] better choice for columns --- PWGLF/DataModel/LFhe3HadronTables.h | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/PWGLF/DataModel/LFhe3HadronTables.h b/PWGLF/DataModel/LFhe3HadronTables.h index 60ee803fca7..1d69beafe92 100644 --- a/PWGLF/DataModel/LFhe3HadronTables.h +++ b/PWGLF/DataModel/LFhe3HadronTables.h @@ -75,14 +75,12 @@ DECLARE_SOA_COLUMN(Multiplicity, multiplicity, uint16_t); DECLARE_SOA_COLUMN(CentralityFT0C, centFT0C, float); DECLARE_SOA_COLUMN(MultiplicityFT0C, multiplicityFT0C, float); -/* Flags: 0 - primary, - 1 - from Li4, - 2 - from hypertriton, - 3 - from other decay, - 4 - from material +/* Flags: 0 - both primary, + 1 - both from Li4, + 2 - both from hypertriton, + 3 - mixed pair (a primary and one from Li4/hypertriton/material/other decays) */ -DECLARE_SOA_COLUMN(FlagHe3, flagHe3, uint8_t); -DECLARE_SOA_COLUMN(FlagHad, flagHad, uint8_t); +DECLARE_SOA_COLUMN(Flags, flags, uint8_t); } // namespace he3HadronTablesNS @@ -125,8 +123,7 @@ DECLARE_SOA_TABLE(he3HadronTableMC, "AOD", "HE3HADTABLEMC", he3HadronTablesNS::PhiMCHad, he3HadronTablesNS::SignedPtMC, he3HadronTablesNS::MassMC, - he3HadronTablesNS::FlagHe3, - he3HadronTablesNS::FlagHad) + he3HadronTablesNS::Flags) DECLARE_SOA_TABLE(he3HadronMult, "AOD", "HE3HADMULT", he3HadronTablesNS::CollisionId, he3HadronTablesNS::ZVertex, From 905ba83d0d9d1ef7c1fdf0f0d5764a635685e529 Mon Sep 17 00:00:00 2001 From: GiorgioAlbertoLucia Date: Mon, 28 Jul 2025 16:48:51 +0200 Subject: [PATCH 06/19] fixed comment --- PWGLF/DataModel/LFhe3HadronTables.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGLF/DataModel/LFhe3HadronTables.h b/PWGLF/DataModel/LFhe3HadronTables.h index 1d69beafe92..d012be80a82 100644 --- a/PWGLF/DataModel/LFhe3HadronTables.h +++ b/PWGLF/DataModel/LFhe3HadronTables.h @@ -78,7 +78,7 @@ DECLARE_SOA_COLUMN(MultiplicityFT0C, multiplicityFT0C, float); /* Flags: 0 - both primary, 1 - both from Li4, 2 - both from hypertriton, - 3 - mixed pair (a primary and one from Li4/hypertriton/material/other decays) + 3 - mixed pair (a primary and one from Li4/hypertriton/material/other decays or any other combination) */ DECLARE_SOA_COLUMN(Flags, flags, uint8_t); From a39f1e8d1253db4d65ed415502da38777b798607 Mon Sep 17 00:00:00 2001 From: GiorgioAlbertoLucia Date: Tue, 29 Jul 2025 08:57:40 +0200 Subject: [PATCH 07/19] new logic for the mc process that allows to store also he3-had pairs not coming from decay --- PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx | 125 +++++++++++++++--- 1 file changed, 104 insertions(+), 21 deletions(-) diff --git a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx index e4a2ae6f20b..f9291aa2081 100644 --- a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx +++ b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx @@ -100,11 +100,18 @@ enum Selections { }; enum Flags { - kPrimary = BIT(0), - kFromLi4 = BIT(1), - kFromHypertriton = BIT(2), - kFromOtherDecay = BIT(3), - kFromMaterial = BIT(4) + kBothPrimaries = BIT(0), + kBothFromLi4 = BIT(1), + kBothFromHypertriton = BIT(2), + kMixedPair = BIT(3), // a primary and one from Li4/hypertriton/material/other decays (or any other combination) +}; + +enum ParticleFlags { + kPhysicalPrimary = BIT(0), // primary particle + kFromLi4 = BIT(1), // from Li4 decay + kFromHypertriton = BIT(2), // from hypertriton decay + kFromMaterial = BIT(3), // from material + kFromOtherDecays = BIT(4), // from other decays }; } // namespace @@ -169,6 +176,7 @@ struct He3HadCandidate { uint8_t flagsHe3 = 0; // flags for He3 uint8_t flagsHad = 0; // flags for hadron + uint8_t flags = 0; // flags for the pair // collision information int32_t collisionID = 0; @@ -655,8 +663,6 @@ struct he3HadronFemto { he3Hadcand.momHadMC = mctrackHad.pt() * (mctrackHad.pdgCode() > 0 ? 1 : -1); he3Hadcand.etaHadMC = mctrackHad.eta(); he3Hadcand.phiHadMC = mctrackHad.phi(); - he3Hadcand.isHe3Primary = mctrackHe3.isPhysicalPrimary(); - he3Hadcand.isHadPrimary = mctrackHad.isPhysicalPrimary(); } template @@ -780,8 +786,7 @@ struct he3HadronFemto { he3Hadcand.phiHadMC, he3Hadcand.l4PtMC, he3Hadcand.l4MassMC, - he3Hadcand.flagsHe3, - he3Hadcand.flagsHad); + he3Hadcand.flags); } if (settingFillMultiplicity) { outputMultiplicityTable( @@ -827,6 +832,47 @@ struct he3HadronFemto { } } + template + void setMcParticleFlag(const TmcParticle& mcParticle, std::vector& mothers, uint8_t& flag) + { + if (mcParticle.isPhysicalPrimary() == true) { + + flag |= ParticleFlags::kPhysicalPrimary; + if (!mcParticle.has_mothers()) { + return; + } + + for (const auto& mother : mcParticle.mothers_as()) { + mothers.push_back(mother.globalIndex()); + if (std::abs(mother.pdgCode()) == Li4PDG) { + flag |= ParticleFlags::kFromLi4; + } else if (std::abs(mother.pdgCode()) == o2::constants::physics::Pdg::kHyperTriton) { + flag |= ParticleFlags::kFromHypertriton; + } else { + flag |= ParticleFlags::kFromOtherDecays; + } + } + + } else { + + if (!mcParticle.has_mothers()) { + flag |= ParticleFlags::kFromMaterial; + return; + } + + for (const auto& mother : mothers) { + mothers.push_back(mother.globalIndex()); + if (std::abs(mother.pdgCode()) == Li4PDG) { + flag |= ParticleFlags::kFromLi4; + } else if (std::abs(mother.pdgCode()) == o2::constants::physics::Pdg::kHyperTriton) { + flag |= ParticleFlags::kFromHypertriton; + } else { + flag |= ParticleFlags::kFromOtherDecays; + } + } + } + } + template void fillMcParticles(const Tcollisions& collisions, const TmcParticles& mcParticles, std::vector& filledMothers) { @@ -953,25 +999,62 @@ struct he3HadronFemto { continue; } - for (const auto& mothertrack : mctrackHe3.mothers_as()) { - for (const auto& mothertrackHad : mctrackHad.mothers_as()) { - - if (mothertrack != mothertrackHad || std::abs(mothertrack.pdgCode()) != Li4PDG || std::abs(mothertrack.y()) > 1) { + He3HadCandidate he3Hadcand; + McIter motherParticle; + std::vector motherHe3Idxs, motherHadIdxs; + setMcParticleFlag(mctrackHe3, motherHe3Idxs, he3Hadcand.flagsHe3); + setMcParticleFlag(mctrackHad, motherHadIdxs, he3Hadcand.flagsHad); + + if ((he3Hadcand.flagsHe3 == ParticleFlags::kPhysicalPrimary && he3Hadcand.flagsHad == ParticleFlags::kPhysicalPrimary)) { + he3Hadcand.flags |= Flags::kBothPrimaries; + + } else if ((he3Hadcand.flagsHe3 & ParticleFlags::kFromLi4) && (he3Hadcand.flagsHad & ParticleFlags::kFromLi4)) { + he3Hadcand.flags |= Flags::kFromLi4; + + std::unordered_set motherHe3SetIdxs(motherHe3Idxs.begin(), motherHe3Idxs.end()); + for (const auto& motherHadIdx : motherHadIdxs) { + if (motherHe3SetIdxs.contains(motherHadIdx)) { continue; } + + motherParticle = mcParticles.rawIteratorAt(motherHadIdx); + if (!motherParticle.pdgCode() == Li4PDG || std::abs(motherParticle.y()) > 1) { + continue; + } + } + + } else if ((he3Hadcand.flagsHe3 & ParticleFlags::kFromHypertriton) && (he3Hadcand.flagsHad & ParticleFlags::kFromHypertriton)) { + he3Hadcand.flags |= Flags::kFromHypertriton; - He3HadCandidate he3Hadcand; - if (!fillCandidateInfo(heTrack, prTrack, collBracket, collisions, he3Hadcand, tracks, /*mix*/ false)) { + std::unordered_set motherHe3SetIdxs(motherHe3Idxs.begin(), motherHe3Idxs.end()); + for (const auto& motherHadIdx : motherHadIdxs) { + if (motherHe3SetIdxs.contains(motherHadIdx)) { continue; } - fillCandidateInfoMC(mctrackHe3, mctrackHad, he3Hadcand); - fillMotherInfoMC(mctrackHe3, mctrackHad, mothertrack, he3Hadcand); - fillHistograms(he3Hadcand); - auto collision = collisions.rawIteratorAt(he3Hadcand.collisionID); - fillTable(he3Hadcand, collision, /*isMC*/ true); - filledMothers.push_back(mothertrack.globalIndex()); + + motherParticle = mcParticles.rawIteratorAt(motherHadIdx); + if (!motherParticle.pdgCode() == o2::constants::physics::Pdg::kHyperTriton || std::abs(motherParticle.y()) > 1) { + continue; + } } + + } else { + he3Hadcand.flags |= Flags::kMixedPair; } + + if (!fillCandidateInfo(heTrack, prTrack, collBracket, collisions, he3Hadcand, tracks, /*mix*/ false)) { + continue; + } + fillCandidateInfoMC(mctrackHe3, mctrackHad, he3Hadcand); + + if ((he3Hadcand.flags == Flags::kBothFromLi4) || (he3Hadcand.flags == Flags::kBothFromHypertriton)) { + fillMotherInfoMC(mctrackHe3, mctrackHad, mothertrack, he3Hadcand); + filledMothers.push_back(motherParticle.globalIndex()); + } + + fillHistograms(he3Hadcand); + auto collision = collisions.rawIteratorAt(he3Hadcand.collisionID); + fillTable(he3Hadcand, collision, /*isMC*/ true); } } From 811dbd60c40344bd2db9e980b3b70322e6939629 Mon Sep 17 00:00:00 2001 From: GiorgioAlbertoLucia Date: Tue, 29 Jul 2025 09:05:03 +0200 Subject: [PATCH 08/19] now storing the dca of the he3-had pair --- PWGLF/DataModel/LFhe3HadronTables.h | 2 ++ PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx | 21 +++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/PWGLF/DataModel/LFhe3HadronTables.h b/PWGLF/DataModel/LFhe3HadronTables.h index d012be80a82..07ce17853ea 100644 --- a/PWGLF/DataModel/LFhe3HadronTables.h +++ b/PWGLF/DataModel/LFhe3HadronTables.h @@ -36,6 +36,7 @@ DECLARE_SOA_COLUMN(DCAxyHe3, dcaxyHe3, float); DECLARE_SOA_COLUMN(DCAzHe3, dcazHe3, float); DECLARE_SOA_COLUMN(DCAxyHad, dcaxyHad, float); DECLARE_SOA_COLUMN(DCAzHad, dcazHad, float); +DECLARE_SOA_COLUMN(DCApair, dcapair, float); DECLARE_SOA_COLUMN(SignalTPCHe3, signalTPCHe3, float); DECLARE_SOA_COLUMN(InnerParamTPCHe3, innerParamTPCHe3, float); @@ -95,6 +96,7 @@ DECLARE_SOA_TABLE(he3HadronTable, "AOD", "HE3HADTABLE", he3HadronTablesNS::DCAzHe3, he3HadronTablesNS::DCAxyHad, he3HadronTablesNS::DCAzHad, + he3HadronTablesNS::DCApair, he3HadronTablesNS::SignalTPCHe3, he3HadronTablesNS::InnerParamTPCHe3, he3HadronTablesNS::SignalTPCHad, diff --git a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx index f9291aa2081..ea185fb6a06 100644 --- a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx +++ b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx @@ -135,6 +135,7 @@ struct He3HadCandidate { float dcazHe3 = -10.f; float dcaxyHad = -10.f; float dcazHad = -10.f; + float dcaPair = -10.f; // DCA between the two tracks uint16_t tpcSignalHe3 = 0u; uint16_t tpcSignalHad = 0u; @@ -596,10 +597,21 @@ struct he3HadronFemto { he3Hadcand.signHe3 = trackHe3.sign(); he3Hadcand.signHad = trackHad.sign(); - he3Hadcand.dcaxyHe3 = trackHe3.dcaXY(); - he3Hadcand.dcaxyHad = trackHad.dcaXY(); - he3Hadcand.dcazHe3 = trackHe3.dcaZ(); - he3Hadcand.dcazHad = trackHad.dcaZ(); + //he3Hadcand.dcaxyHe3 = trackHe3.dcaXY(); + //he3Hadcand.dcaxyHad = trackHad.dcaXY(); + //he3Hadcand.dcazHe3 = trackHe3.dcaZ(); + //he3Hadcand.dcazHad = trackHad.dcaZ(); + auto trackCovHe3 = getTrackParCov(trackHe3); + auto trackCovHad = getTrackParCov(trackHad); + std::array dcaInfo; + o2::base::Propagator::Instance()->propagateToDCABxByBz({collisionVertex[0], collisionVertex[1], collisionVertex[2]}, trackCovHe3, 2.f, mFitter.getMatCorrType(), &dcaInfo); + he3Hadcand.dcaxyHe3 = dcaInfo[0]; + he3Hadcand.dcazHe3 = dcaInfo[1]; + o2::base::Propagator::Instance()->propagateToDCABxByBz({collisionVertex[0], collisionVertex[1], collisionVertex[2]}, trackCovHad, 2.f, mFitter.getMatCorrType(), &dcaInfo); + he3Hadcand.dcaxyHad = dcaInfo[0]; + he3Hadcand.dcazHad = dcaInfo[1]; + he3Hadcand.dcaPair = std::sqrt(std::abs(mFitter.getChi2AtPCACandidate())); + he3Hadcand.tpcSignalHe3 = trackHe3.tpcSignal(); bool heliumPID = trackHe3.pidForTracking() == o2::track::PID::Helium3 || trackHe3.pidForTracking() == o2::track::PID::Alpha; @@ -757,6 +769,7 @@ struct he3HadronFemto { he3Hadcand.dcazHe3, he3Hadcand.dcaxyHad, he3Hadcand.dcazHad, + he3Hadcand.dcaPair, he3Hadcand.tpcSignalHe3, he3Hadcand.momHe3TPC, he3Hadcand.tpcSignalHad, From 11246e67a8eb6b2574293f6105370b81fcffa4f7 Mon Sep 17 00:00:00 2001 From: GiorgioAlbertoLucia Date: Tue, 29 Jul 2025 17:14:21 +0200 Subject: [PATCH 09/19] fixed syntax and bugs --- PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx | 141 +++++++++++------- 1 file changed, 87 insertions(+), 54 deletions(-) diff --git a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx index ea185fb6a06..db7c9576333 100644 --- a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx +++ b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx @@ -382,13 +382,14 @@ struct he3HadronFemto { mQaRegistry.fill(HIST("hEvents"), 0); mQaRegistry.fill(HIST("hVtxZBefore"), collision.posZ()); + auto bc = collision.template bc_as(); + initCCDB(bc); + if constexpr (isMC) { if (/*!collision.sel8() ||*/ std::abs(collision.posZ()) > settingCutVertex) { return false; } } else { - auto bc = collision.template bc_as(); - initCCDB(bc); if (!collision.sel8() || std::abs(collision.posZ()) > settingCutVertex) { return false; @@ -528,53 +529,66 @@ struct he3HadronFemto { // ================================================================================================================== - template - bool fillCandidateInfo(const Ttrack& trackHe3, const Ttrack& trackHad, const CollBracket& collBracket, const Tcollisions& collisions, He3HadCandidate& he3Hadcand, const Ttracks& /*trackTable*/, bool isMixedEvent) + template + std::array getCollisionVertex(const Tcollisions& collisions, int32_t collisionID) { - const int numCoordinates = 3; - if (!isMixedEvent) { - auto trackCovHe3 = getTrackParCov(trackHe3); - auto trackCovHad = getTrackParCov(trackHad); - int nCand = CommonInite; - try { - nCand = mFitter.process(trackCovHe3, trackCovHad); - } catch (...) { - LOG(error) << "Exception caught in DCA fitter process call!"; - return false; - } - if (nCand == 0) { - return false; - } + auto collision = collisions.rawIteratorAt(collisionID); + std::array collisionVertex = {collision.posX(), collision.posY(), collision.posZ()}; + return collisionVertex; + } - // associate collision id as the one that minimises the distance between the vertex and the PCAs of the daughters - double distanceMin = -1; - unsigned int collIdxMin = 0; - const float defaultTodistance = 0.0f; - for (int collIdx = collBracket.getMin(); collIdx <= collBracket.getMax(); collIdx++) { - auto collision = collisions.rawIteratorAt(collIdx); - std::array collVtx = {collision.posX(), collision.posY(), collision.posZ()}; - const auto& pca = mFitter.getPCACandidate(); - float distance = defaultTodistance; - for (int i = 0; i < numCoordinates; i++) { - distance += (pca[i] - collVtx[i]) * (pca[i] - collVtx[i]); - } - if (distanceMin < 0 || distance < distanceMin) { - distanceMin = distance; - collIdxMin = collIdx; - } - } + template + int32_t getCollisionID(const Ttrack& trackHe3, const Ttrack& trackHad, const CollBracket& collBracket, const Tcollisions& collisions, bool isMixedEvent) + { + if (isMixedEvent) { + return collBracket.getMin(); + } - if (!mGoodCollisions[collIdxMin]) { - return false; + auto trackCovHe3 = getTrackParCov(trackHe3); + auto trackCovHad = getTrackParCov(trackHad); + int nCand = CommonInite; + try { + nCand = mFitter.process(trackCovHe3, trackCovHad); + } catch (...) { + LOG(error) << "Exception caught in DCA fitter process call!"; + return false; + } + if (nCand == 0) { + return false; + } + + // associate collision id as the one that minimises the distance between the vertex and the PCAs of the daughters + double distanceMin = -1; + unsigned int collIdxMin = 0; + const float defaultTodistance = 0.0f; + for (int collIdx = collBracket.getMin(); collIdx <= collBracket.getMax(); collIdx++) { + std::array collisionVertex = getCollisionVertex(collisions, collIdx); + const auto& pca = mFitter.getPCACandidate(); + float distance = defaultTodistance; + for (int i = 0; i < 3; i++) { + distance += (pca[i] - collisionVertex[i]) * (pca[i] - collisionVertex[i]); + } + if (distanceMin < 0 || distance < distanceMin) { + distanceMin = distance; + collIdxMin = collIdx; } - he3Hadcand.collisionID = collIdxMin; + } - } else { - he3Hadcand.collisionID = collBracket.getMin(); + if (!mGoodCollisions[collIdxMin]) { + return false; } + return collIdxMin; + + } + + template + bool fillCandidateInfo(const Ttrack& trackHe3, const Ttrack& trackHad, const CollBracket& collBracket, const Tcollisions& collisions, He3HadCandidate& he3Hadcand, const Ttracks& /*trackTable*/, bool isMixedEvent) + { + he3Hadcand.collisionID = getCollisionID(trackHe3, trackHad, collBracket, collisions, isMixedEvent); + std::array collisionVertex = getCollisionVertex(collisions, he3Hadcand.collisionID); he3Hadcand.momHe3 = std::array{trackHe3.px(), trackHe3.py(), trackHe3.pz()}; - for (int i = 0; i < numCoordinates; i++) + for (int i = 0; i < 3; i++) he3Hadcand.momHe3[i] = he3Hadcand.momHe3[i] * 2; he3Hadcand.momHad = std::array{trackHad.px(), trackHad.py(), trackHad.pz()}; float invMass = CommonInite; @@ -668,7 +682,6 @@ struct he3HadronFemto { template void fillCandidateInfoMC(const Mc& mctrackHe3, const Mc& mctrackHad, He3HadCandidate& he3Hadcand) { - LOG(info) << "--------------------------Filling candidate info MC"; he3Hadcand.momHe3MC = mctrackHe3.pt() * (mctrackHe3.pdgCode() > 0 ? 1 : -1); he3Hadcand.etaHe3MC = mctrackHe3.eta(); he3Hadcand.phiHe3MC = mctrackHe3.phi(); @@ -680,6 +693,7 @@ struct he3HadronFemto { template void fillMotherInfoMC(const Mc& mctrackHe3, const Mc& mctrackHad, const Mc& mctrackMother, He3HadCandidate& he3Hadcand) { + LOG(info) << "Mother track: " << mctrackMother.pdgCode() << " " << mctrackMother.pt() << " " << mctrackMother.eta() << " " << mctrackMother.phi(); he3Hadcand.l4PtMC = mctrackMother.pt() * (mctrackMother.pdgCode() > 0 ? 1 : -1); const double eLit = mctrackHe3.e() + mctrackHad.e(); he3Hadcand.l4MassMC = std::sqrt(eLit * eLit - mctrackMother.p() * mctrackMother.p()); @@ -848,15 +862,16 @@ struct he3HadronFemto { template void setMcParticleFlag(const TmcParticle& mcParticle, std::vector& mothers, uint8_t& flag) { - if (mcParticle.isPhysicalPrimary() == true) { + if (mcParticle.isPhysicalPrimary()) { flag |= ParticleFlags::kPhysicalPrimary; if (!mcParticle.has_mothers()) { return; } - for (const auto& mother : mcParticle.mothers_as()) { + for (const auto& mother : mcParticle.template mothers_as()) { mothers.push_back(mother.globalIndex()); + LOG(info) << "Mother PDG code: " << mother.pdgCode() << ", global index: " << mother.globalIndex(); if (std::abs(mother.pdgCode()) == Li4PDG) { flag |= ParticleFlags::kFromLi4; } else if (std::abs(mother.pdgCode()) == o2::constants::physics::Pdg::kHyperTriton) { @@ -873,8 +888,9 @@ struct he3HadronFemto { return; } - for (const auto& mother : mothers) { + for (const auto& mother : mcParticle.template mothers_as()) { mothers.push_back(mother.globalIndex()); + LOG(info) << "Mother PDG code: " << mother.pdgCode() << ", global index: " << mother.globalIndex(); if (std::abs(mother.pdgCode()) == Li4PDG) { flag |= ParticleFlags::kFromLi4; } else if (std::abs(mother.pdgCode()) == o2::constants::physics::Pdg::kHyperTriton) { @@ -1014,44 +1030,61 @@ struct he3HadronFemto { He3HadCandidate he3Hadcand; McIter motherParticle; + unsigned int motherIdx; std::vector motherHe3Idxs, motherHadIdxs; setMcParticleFlag(mctrackHe3, motherHe3Idxs, he3Hadcand.flagsHe3); setMcParticleFlag(mctrackHad, motherHadIdxs, he3Hadcand.flagsHad); + bool isMixedPair = true; + if ((he3Hadcand.flagsHe3 == ParticleFlags::kPhysicalPrimary && he3Hadcand.flagsHad == ParticleFlags::kPhysicalPrimary)) { he3Hadcand.flags |= Flags::kBothPrimaries; + isMixedPair = false; } else if ((he3Hadcand.flagsHe3 & ParticleFlags::kFromLi4) && (he3Hadcand.flagsHad & ParticleFlags::kFromLi4)) { - he3Hadcand.flags |= Flags::kFromLi4; std::unordered_set motherHe3SetIdxs(motherHe3Idxs.begin(), motherHe3Idxs.end()); for (const auto& motherHadIdx : motherHadIdxs) { - if (motherHe3SetIdxs.contains(motherHadIdx)) { + if (!motherHe3SetIdxs.contains(motherHadIdx)) { continue; } motherParticle = mcParticles.rawIteratorAt(motherHadIdx); - if (!motherParticle.pdgCode() == Li4PDG || std::abs(motherParticle.y()) > 1) { + motherIdx = motherHadIdx; + if (std::abs(motherParticle.pdgCode()) != Li4PDG || std::abs(motherParticle.y()) > 1) { continue; } + isMixedPair = false; + break; + } + if (!isMixedPair) { + he3Hadcand.flags |= Flags::kBothFromLi4; } } else if ((he3Hadcand.flagsHe3 & ParticleFlags::kFromHypertriton) && (he3Hadcand.flagsHad & ParticleFlags::kFromHypertriton)) { - he3Hadcand.flags |= Flags::kFromHypertriton; std::unordered_set motherHe3SetIdxs(motherHe3Idxs.begin(), motherHe3Idxs.end()); for (const auto& motherHadIdx : motherHadIdxs) { - if (motherHe3SetIdxs.contains(motherHadIdx)) { + if (!motherHe3SetIdxs.contains(motherHadIdx)) { continue; } motherParticle = mcParticles.rawIteratorAt(motherHadIdx); - if (!motherParticle.pdgCode() == o2::constants::physics::Pdg::kHyperTriton || std::abs(motherParticle.y()) > 1) { + motherIdx = motherHadIdx; + if (std::abs(motherParticle.pdgCode()) != o2::constants::physics::Pdg::kHyperTriton || std::abs(motherParticle.y()) > 1) { continue; } + isMixedPair = false; + break; } - } else { + if (!isMixedPair) { + he3Hadcand.flags |= Flags::kBothFromHypertriton; + } + + } + + if (isMixedPair) { he3Hadcand.flags |= Flags::kMixedPair; } @@ -1061,8 +1094,8 @@ struct he3HadronFemto { fillCandidateInfoMC(mctrackHe3, mctrackHad, he3Hadcand); if ((he3Hadcand.flags == Flags::kBothFromLi4) || (he3Hadcand.flags == Flags::kBothFromHypertriton)) { - fillMotherInfoMC(mctrackHe3, mctrackHad, mothertrack, he3Hadcand); - filledMothers.push_back(motherParticle.globalIndex()); + fillMotherInfoMC(mctrackHe3, mctrackHad, motherParticle, he3Hadcand); + filledMothers.push_back(motherIdx); } fillHistograms(he3Hadcand); From d50b1d25a7b5e936f58558202eee4f23c6bf3f40 Mon Sep 17 00:00:00 2001 From: GiorgioAlbertoLucia Date: Tue, 29 Jul 2025 17:14:57 +0200 Subject: [PATCH 10/19] removed unnecessary log --- PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx index db7c9576333..e1768d01202 100644 --- a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx +++ b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx @@ -693,7 +693,6 @@ struct he3HadronFemto { template void fillMotherInfoMC(const Mc& mctrackHe3, const Mc& mctrackHad, const Mc& mctrackMother, He3HadCandidate& he3Hadcand) { - LOG(info) << "Mother track: " << mctrackMother.pdgCode() << " " << mctrackMother.pt() << " " << mctrackMother.eta() << " " << mctrackMother.phi(); he3Hadcand.l4PtMC = mctrackMother.pt() * (mctrackMother.pdgCode() > 0 ? 1 : -1); const double eLit = mctrackHe3.e() + mctrackHad.e(); he3Hadcand.l4MassMC = std::sqrt(eLit * eLit - mctrackMother.p() * mctrackMother.p()); From ebcad9d7ef75f162cdeeca08f83df8f371cf9646 Mon Sep 17 00:00:00 2001 From: GiorgioAlbertoLucia Date: Tue, 29 Jul 2025 17:17:52 +0200 Subject: [PATCH 11/19] fixed histogram names --- PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx index e1768d01202..b796f55dbfe 100644 --- a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx +++ b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx @@ -262,30 +262,30 @@ struct he3HadronFemto { { {"hVtxZBefore", "Vertex distribution in Z before selections;Z (cm)", {HistType::kTH1F, {{400, -20.0, 20.0}}}}, {"hVtxZ", "Vertex distribution in Z;Z (cm)", {HistType::kTH1F, {{400, -20.0, 20.0}}}}, - {"hCentralityFT0A", ";Centrality FT0A", {HistType::kTH1F, {{100, 0, 100.0}}}}, - {"hCentralityFT0C", ";Centrality FT0C", {HistType::kTH1F, {{100, 0, 100.0}}}}, + {"hCentralityFT0A", ";Centrality FT0A (%)", {HistType::kTH1F, {{100, 0, 100.0}}}}, + {"hCentralityFT0C", ";Centrality FT0C (%)", {HistType::kTH1F, {{100, 0, 100.0}}}}, {"hNcontributor", "Number of primary vertex contributor", {HistType::kTH1F, {{2000, 0.0f, 2000.0f}}}}, {"hTrackSel", "Accepted tracks", {HistType::kTH1F, {{Selections::kAll, -0.5, static_cast(Selections::kAll) - 0.5}}}}, {"hEvents", "; Events;", {HistType::kTH1F, {{3, -0.5, 2.5}}}}, {"hEmptyPool", "svPoolCreator did not find track pairs false/true", {HistType::kTH1F, {{2, -0.5, 1.5}}}}, - {"hDCAxyHe3", ";DCA_{xy} (cm)", {HistType::kTH1F, {{200, -5.0f, 5.0f}}}}, - {"hDCAzHe3", ";DCA_{z} (cm)", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}}, - {"hNClsHe3ITS", ";N_{ITS} Cluster", {HistType::kTH1F, {{20, -10.0f, 10.0f}}}}, - {"hNClsHadITS", ";N_{ITS} Cluster", {HistType::kTH1F, {{20, -10.0f, 10.0f}}}}, - {"hChi2NClHe3ITS", ";Chi2_{ITS} Ncluster", {HistType::kTH1F, {{100, 0, 100.0f}}}}, - {"hChi2NClHadITS", ";Chi2_{ITS} Ncluster", {HistType::kTH1F, {{100, 0, 100.0f}}}}, + {"hDCAxyHe3", "^{3}He;DCA_{xy} (cm)", {HistType::kTH1F, {{200, -5.0f, 5.0f}}}}, + {"hDCAzHe3", "^{3}He;DCA_{z} (cm)", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}}, + {"hNClsHe3ITS", "^{3}He;N_{ITS} Cluster", {HistType::kTH1F, {{20, -10.0f, 10.0f}}}}, + {"hNClsHadITS", "had;N_{ITS} Cluster", {HistType::kTH1F, {{20, -10.0f, 10.0f}}}}, + {"hChi2NClHe3ITS", "^{3}He;Chi2_{ITS} Ncluster", {HistType::kTH1F, {{100, 0, 100.0f}}}}, + {"hChi2NClHadITS", "had;Chi2_{ITS} Ncluster", {HistType::kTH1F, {{100, 0, 100.0f}}}}, {"hhe3HadtInvMass", "; M(^{3}He + p) (GeV/#it{c}^{2})", {HistType::kTH1F, {{300, 3.74f, 4.34f}}}}, - {"hHe3Pt", "#it{p}_{T} distribution; #it{p}_{T} (GeV/#it{c})", {HistType::kTH1F, {{240, -6.0f, 6.0f}}}}, - {"hHadronPt", "Pt distribution; #it{p}_{T} (GeV/#it{c})", {HistType::kTH1F, {{120, -3.0f, 3.0f}}}}, + {"hHe3Pt", "^{3}He; #it{p}_{T} (GeV/#it{c})", {HistType::kTH1F, {{240, -6.0f, 6.0f}}}}, + {"hHadronPt", "had; #it{p}_{T} (GeV/#it{c})", {HistType::kTH1F, {{120, -3.0f, 3.0f}}}}, {"h2dEdxHe3candidates", "dEdx distribution; #it{p} (GeV/#it{c}); dE/dx (a.u.)", {HistType::kTH2F, {{200, -5.0f, 5.0f}, {100, 0.0f, 2000.0f}}}}, {"h2NsigmaHe3TPC", "NsigmaHe3 TPC distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{TPC}(^{3}He)", {HistType::kTH2F, {{20, -5.0f, 5.0f}, {200, -5.0f, 5.0f}}}}, {"h2NsigmaHe3TPC_preselection", "NsigmaHe3 TPC distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{TPC}(^{3}He)", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {400, -10.0f, 10.0f}}}}, {"h2NSigmaHe3ITS_preselection", "NsigmaHe3 ITS distribution; signed #it{p}_{T} (GeV/#it{c}); n#sigma_{ITS} ^{3}He", {HistType::kTH2F, {{50, -5.0f, 5.0f}, {120, -3.0f, 3.0f}}}}, {"h2NSigmaHe3ITS", "NsigmaHe3 ITS distribution; signed #it{p}_{T} (GeV/#it{c}); n#sigma_{ITS} ^{3}He", {HistType::kTH2F, {{50, -5.0f, 5.0f}, {120, -3.0f, 3.0f}}}}, - {"h2NsigmaHadronTPC", "NsigmaHadron TPC distribution; #it{p}_{T}(GeV/#it{c}); n#sigma_{TPC}(p)", {HistType::kTH2F, {{20, -5.0f, 5.0f}, {200, -5.0f, 5.0f}}}}, - {"h2NsigmaHadronTPC_preselection", "NsigmaHe3 TPC distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{TPC}(^{3}He)", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {400, -10.0f, 10.0f}}}}, - {"h2NsigmaHadronTOF", "NsigmaHadron TOF distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{TOF}(p)", {HistType::kTH2F, {{20, -5.0f, 5.0f}, {200, -5.0f, 5.0f}}}}, - {"h2NsigmaHadronTOF_preselection", "NsigmaHadron TOF distribution; #iit{p}_{T} (GeV/#it{c}); n#sigma_{TOF}(p)", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {400, -10.0f, 10.0f}}}}, + {"h2NsigmaHadronTPC", "NsigmaHadron TPC distribution; #it{p}_{T}(GeV/#it{c}); n#sigma_{TPC}(had)", {HistType::kTH2F, {{20, -5.0f, 5.0f}, {200, -5.0f, 5.0f}}}}, + {"h2NsigmaHadronTPC_preselection", "NsigmaHe3 TPC distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{TPC}(had)", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {400, -10.0f, 10.0f}}}}, + {"h2NsigmaHadronTOF", "NsigmaHadron TOF distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{TOF}(had)", {HistType::kTH2F, {{20, -5.0f, 5.0f}, {200, -5.0f, 5.0f}}}}, + {"h2NsigmaHadronTOF_preselection", "NsigmaHadron TOF distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{TOF}(had)", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {400, -10.0f, 10.0f}}}}, }, OutputObjHandlingPolicy::AnalysisObject, false, From 1129bfdd1f7d73517658cb329d8097ff2925918a Mon Sep 17 00:00:00 2001 From: GiorgioAlbertoLucia Date: Tue, 29 Jul 2025 17:19:41 +0200 Subject: [PATCH 12/19] clang format --- PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx | 105 +++++++++--------- 1 file changed, 50 insertions(+), 55 deletions(-) diff --git a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx index b796f55dbfe..c8b0b118b32 100644 --- a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx +++ b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx @@ -15,30 +15,9 @@ /// \author Your Name (your.email@cern.ch) /// \since April 2025 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include // std::prev - -#include "Framework/ASoAHelpers.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/StepTHn.h" +#include "PWGLF/DataModel/EPCalibrationTables.h" +#include "PWGLF/DataModel/LFhe3HadronTables.h" +#include "PWGLF/Utils/svPoolCreator.h" #include "Common/Core/PID/PIDTOF.h" #include "Common/Core/PID/TPCPIDResponse.h" @@ -52,21 +31,40 @@ #include "Common/DataModel/PIDResponseITS.h" #include "Common/DataModel/TrackSelectionTables.h" #include "Common/TableProducer/PID/pidTOFBase.h" - #include "EventFiltering/Zorro.h" #include "EventFiltering/ZorroSummary.h" #include "CCDB/BasicCCDBManager.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsTPC/BetheBlochAleph.h" -#include "DataFormatsParameters/GRPObject.h" #include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsTPC/BetheBlochAleph.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" #include "ReconstructionDataFormats/Track.h" -#include "PWGLF/DataModel/EPCalibrationTables.h" -#include "PWGLF/DataModel/LFhe3HadronTables.h" -#include "PWGLF/Utils/svPoolCreator.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include // std::prev +#include +#include using namespace o2; using namespace o2::framework; @@ -100,7 +98,7 @@ enum Selections { }; enum Flags { - kBothPrimaries = BIT(0), + kBothPrimaries = BIT(0), kBothFromLi4 = BIT(1), kBothFromHypertriton = BIT(2), kMixedPair = BIT(3), // a primary and one from Li4/hypertriton/material/other decays (or any other combination) @@ -108,9 +106,9 @@ enum Flags { enum ParticleFlags { kPhysicalPrimary = BIT(0), // primary particle - kFromLi4 = BIT(1), // from Li4 decay + kFromLi4 = BIT(1), // from Li4 decay kFromHypertriton = BIT(2), // from hypertriton decay - kFromMaterial = BIT(3), // from material + kFromMaterial = BIT(3), // from material kFromOtherDecays = BIT(4), // from other decays }; @@ -177,7 +175,7 @@ struct He3HadCandidate { uint8_t flagsHe3 = 0; // flags for He3 uint8_t flagsHad = 0; // flags for hadron - uint8_t flags = 0; // flags for the pair + uint8_t flags = 0; // flags for the pair // collision information int32_t collisionID = 0; @@ -578,7 +576,6 @@ struct he3HadronFemto { return false; } return collIdxMin; - } template @@ -611,10 +608,10 @@ struct he3HadronFemto { he3Hadcand.signHe3 = trackHe3.sign(); he3Hadcand.signHad = trackHad.sign(); - //he3Hadcand.dcaxyHe3 = trackHe3.dcaXY(); - //he3Hadcand.dcaxyHad = trackHad.dcaXY(); - //he3Hadcand.dcazHe3 = trackHe3.dcaZ(); - //he3Hadcand.dcazHad = trackHad.dcaZ(); + // he3Hadcand.dcaxyHe3 = trackHe3.dcaXY(); + // he3Hadcand.dcaxyHad = trackHad.dcaXY(); + // he3Hadcand.dcazHe3 = trackHe3.dcaZ(); + // he3Hadcand.dcazHad = trackHad.dcaZ(); auto trackCovHe3 = getTrackParCov(trackHe3); auto trackCovHad = getTrackParCov(trackHad); std::array dcaInfo; @@ -626,7 +623,6 @@ struct he3HadronFemto { he3Hadcand.dcazHad = dcaInfo[1]; he3Hadcand.dcaPair = std::sqrt(std::abs(mFitter.getChi2AtPCACandidate())); - he3Hadcand.tpcSignalHe3 = trackHe3.tpcSignal(); bool heliumPID = trackHe3.pidForTracking() == o2::track::PID::Helium3 || trackHe3.pidForTracking() == o2::track::PID::Alpha; float correctedTPCinnerParamHe3 = (heliumPID && settingCompensatePIDinTracking) ? trackHe3.tpcInnerParam() / 2.f : trackHe3.tpcInnerParam(); @@ -862,7 +858,7 @@ struct he3HadronFemto { void setMcParticleFlag(const TmcParticle& mcParticle, std::vector& mothers, uint8_t& flag) { if (mcParticle.isPhysicalPrimary()) { - + flag |= ParticleFlags::kPhysicalPrimary; if (!mcParticle.has_mothers()) { return; @@ -879,9 +875,9 @@ struct he3HadronFemto { flag |= ParticleFlags::kFromOtherDecays; } } - + } else { - + if (!mcParticle.has_mothers()) { flag |= ParticleFlags::kFromMaterial; return; @@ -896,7 +892,7 @@ struct he3HadronFemto { flag |= ParticleFlags::kFromHypertriton; } else { flag |= ParticleFlags::kFromOtherDecays; - } + } } } } @@ -1039,19 +1035,19 @@ struct he3HadronFemto { if ((he3Hadcand.flagsHe3 == ParticleFlags::kPhysicalPrimary && he3Hadcand.flagsHad == ParticleFlags::kPhysicalPrimary)) { he3Hadcand.flags |= Flags::kBothPrimaries; isMixedPair = false; - + } else if ((he3Hadcand.flagsHe3 & ParticleFlags::kFromLi4) && (he3Hadcand.flagsHad & ParticleFlags::kFromLi4)) { - + std::unordered_set motherHe3SetIdxs(motherHe3Idxs.begin(), motherHe3Idxs.end()); for (const auto& motherHadIdx : motherHadIdxs) { if (!motherHe3SetIdxs.contains(motherHadIdx)) { continue; } - + motherParticle = mcParticles.rawIteratorAt(motherHadIdx); motherIdx = motherHadIdx; if (std::abs(motherParticle.pdgCode()) != Li4PDG || std::abs(motherParticle.y()) > 1) { - continue; + continue; } isMixedPair = false; break; @@ -1067,11 +1063,11 @@ struct he3HadronFemto { if (!motherHe3SetIdxs.contains(motherHadIdx)) { continue; } - + motherParticle = mcParticles.rawIteratorAt(motherHadIdx); motherIdx = motherHadIdx; if (std::abs(motherParticle.pdgCode()) != o2::constants::physics::Pdg::kHyperTriton || std::abs(motherParticle.y()) > 1) { - continue; + continue; } isMixedPair = false; break; @@ -1080,9 +1076,8 @@ struct he3HadronFemto { if (!isMixedPair) { he3Hadcand.flags |= Flags::kBothFromHypertriton; } + } - } - if (isMixedPair) { he3Hadcand.flags |= Flags::kMixedPair; } @@ -1091,7 +1086,7 @@ struct he3HadronFemto { continue; } fillCandidateInfoMC(mctrackHe3, mctrackHad, he3Hadcand); - + if ((he3Hadcand.flags == Flags::kBothFromLi4) || (he3Hadcand.flags == Flags::kBothFromHypertriton)) { fillMotherInfoMC(mctrackHe3, mctrackHad, motherParticle, he3Hadcand); filledMothers.push_back(motherIdx); From eb56457644b8efa556c4fc41845130b1fefb7e53 Mon Sep 17 00:00:00 2001 From: GiorgioAlbertoLucia Date: Wed, 30 Jul 2025 08:16:23 +0200 Subject: [PATCH 13/19] process MC works with both hadrons --- PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx index c8b0b118b32..75d2e752a22 100644 --- a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx +++ b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx @@ -1019,7 +1019,7 @@ struct he3HadronFemto { auto mctrackHe3 = heTrack.mcParticle(); auto mctrackHad = prTrack.mcParticle(); - if (std::abs(mctrackHe3.pdgCode()) != He3PDG || std::abs(mctrackHad.pdgCode()) != ProtonPDG) { + if (std::abs(mctrackHe3.pdgCode()) != He3PDG || std::abs(mctrackHad.pdgCode()) != settingHadPDGCode) { continue; } From b5cca9a982d7c5dae89b914de80e3f4bb582b490 Mon Sep 17 00:00:00 2001 From: GiorgioAlbertoLucia Date: Wed, 30 Jul 2025 08:19:37 +0200 Subject: [PATCH 14/19] removed unnecessary print --- PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx index 75d2e752a22..daff44ef610 100644 --- a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx +++ b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx @@ -866,7 +866,6 @@ struct he3HadronFemto { for (const auto& mother : mcParticle.template mothers_as()) { mothers.push_back(mother.globalIndex()); - LOG(info) << "Mother PDG code: " << mother.pdgCode() << ", global index: " << mother.globalIndex(); if (std::abs(mother.pdgCode()) == Li4PDG) { flag |= ParticleFlags::kFromLi4; } else if (std::abs(mother.pdgCode()) == o2::constants::physics::Pdg::kHyperTriton) { @@ -885,7 +884,6 @@ struct he3HadronFemto { for (const auto& mother : mcParticle.template mothers_as()) { mothers.push_back(mother.globalIndex()); - LOG(info) << "Mother PDG code: " << mother.pdgCode() << ", global index: " << mother.globalIndex(); if (std::abs(mother.pdgCode()) == Li4PDG) { flag |= ParticleFlags::kFromLi4; } else if (std::abs(mother.pdgCode()) == o2::constants::physics::Pdg::kHyperTriton) { @@ -1082,6 +1080,8 @@ struct he3HadronFemto { he3Hadcand.flags |= Flags::kMixedPair; } + + if (!fillCandidateInfo(heTrack, prTrack, collBracket, collisions, he3Hadcand, tracks, /*mix*/ false)) { continue; } From eb0f28148f03beb321714e74f19c7e42a40e168a Mon Sep 17 00:00:00 2001 From: GiorgioAlbertoLucia Date: Wed, 30 Jul 2025 08:26:40 +0200 Subject: [PATCH 15/19] added configurable to only save li4/hypertriton tracks --- PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx index daff44ef610..7647395cd94 100644 --- a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx +++ b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx @@ -210,6 +210,7 @@ struct he3HadronFemto { Configurable settingSaveUSandLS{"settingSaveUSandLS", true, "Save All Pairs"}; Configurable settingIsMC{"settingIsMC", false, "Run MC"}; Configurable settingFillMultiplicity{"settingFillMultiplicity", false, "Fill multiplicity table"}; + Configurable settingFillPrimariesAndMixedMc{"settingFillPrimariesAndMixedMc", false, "Fill primary MC tracks and mixed tracks (e.g. a primary track and one from Li4)"}; // Zorro Configurable settingSkimmedProcessing{"settingSkimmedProcessing", false, "Skimmed dataset processing"}; @@ -1080,7 +1081,9 @@ struct he3HadronFemto { he3Hadcand.flags |= Flags::kMixedPair; } - + if (settingFillPrimariesAndMixedMc && ((he3Hadcand.flags & Flags::kMixedPair) || he3Hadcand.flags == Flags::kBothPrimaries)) { + continue; + } if (!fillCandidateInfo(heTrack, prTrack, collBracket, collisions, he3Hadcand, tracks, /*mix*/ false)) { continue; From c2e5881c07374b718b4ac17f9204080721671508 Mon Sep 17 00:00:00 2001 From: GiorgioAlbertoLucia Date: Wed, 30 Jul 2025 08:34:27 +0200 Subject: [PATCH 16/19] slimmer version of the logic to search for a common mother --- PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx | 55 ++++++++----------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx index 7647395cd94..b8247d0ca68 100644 --- a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx +++ b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx @@ -896,6 +896,27 @@ struct he3HadronFemto { } } + void searchForCommonMotherTrack(std::vector& motherHe3Idxs, std::vector& motherHadIdxs, McIter& motherParticle, bool & isMixedPair, const int motherPdgCode) + { + std::unordered_set motherHe3SetIdxs(motherHe3Idxs.begin(), motherHe3Idxs.end()); + for (const auto& motherHadIdx : motherHadIdxs) { + if (!motherHe3SetIdxs.contains(motherHadIdx)) { + continue; + } + + motherParticle = mcParticles.rawIteratorAt(motherHadIdx); + if (std::abs(motherParticle.pdgCode()) != motherPdgCode || std::abs(motherParticle.y()) > 1) { + continue; + } + isMixedPair = false; + break; + } + if (!isMixedPair) { + he3Hadcand.flags |= Flags::kBothFromLi4; + } + + } + template void fillMcParticles(const Tcollisions& collisions, const TmcParticles& mcParticles, std::vector& filledMothers) { @@ -1024,7 +1045,6 @@ struct he3HadronFemto { He3HadCandidate he3Hadcand; McIter motherParticle; - unsigned int motherIdx; std::vector motherHe3Idxs, motherHadIdxs; setMcParticleFlag(mctrackHe3, motherHe3Idxs, he3Hadcand.flagsHe3); setMcParticleFlag(mctrackHad, motherHadIdxs, he3Hadcand.flagsHad); @@ -1037,41 +1057,14 @@ struct he3HadronFemto { } else if ((he3Hadcand.flagsHe3 & ParticleFlags::kFromLi4) && (he3Hadcand.flagsHad & ParticleFlags::kFromLi4)) { - std::unordered_set motherHe3SetIdxs(motherHe3Idxs.begin(), motherHe3Idxs.end()); - for (const auto& motherHadIdx : motherHadIdxs) { - if (!motherHe3SetIdxs.contains(motherHadIdx)) { - continue; - } - - motherParticle = mcParticles.rawIteratorAt(motherHadIdx); - motherIdx = motherHadIdx; - if (std::abs(motherParticle.pdgCode()) != Li4PDG || std::abs(motherParticle.y()) > 1) { - continue; - } - isMixedPair = false; - break; - } + searchForCommonMotherTrack(motherHe3Idxs, motherHadIdxs, motherParticle, isMixedPair, Li4PDG); if (!isMixedPair) { he3Hadcand.flags |= Flags::kBothFromLi4; } } else if ((he3Hadcand.flagsHe3 & ParticleFlags::kFromHypertriton) && (he3Hadcand.flagsHad & ParticleFlags::kFromHypertriton)) { - std::unordered_set motherHe3SetIdxs(motherHe3Idxs.begin(), motherHe3Idxs.end()); - for (const auto& motherHadIdx : motherHadIdxs) { - if (!motherHe3SetIdxs.contains(motherHadIdx)) { - continue; - } - - motherParticle = mcParticles.rawIteratorAt(motherHadIdx); - motherIdx = motherHadIdx; - if (std::abs(motherParticle.pdgCode()) != o2::constants::physics::Pdg::kHyperTriton || std::abs(motherParticle.y()) > 1) { - continue; - } - isMixedPair = false; - break; - } - + searchForCommonMotherTrack(motherHe3Idxs, motherHadIdxs, motherParticle, isMixedPair, o2::constants::physics::Pdg::kHyperTriton); if (!isMixedPair) { he3Hadcand.flags |= Flags::kBothFromHypertriton; } @@ -1092,7 +1085,7 @@ struct he3HadronFemto { if ((he3Hadcand.flags == Flags::kBothFromLi4) || (he3Hadcand.flags == Flags::kBothFromHypertriton)) { fillMotherInfoMC(mctrackHe3, mctrackHad, motherParticle, he3Hadcand); - filledMothers.push_back(motherIdx); + filledMothers.push_back(motherParticle.globalIndex()); } fillHistograms(he3Hadcand); From 38182f20178d1f19812fbd20c34032d8effdce13 Mon Sep 17 00:00:00 2001 From: GiorgioAlbertoLucia Date: Wed, 30 Jul 2025 08:54:33 +0200 Subject: [PATCH 17/19] bug fixes, added shortcut for the hypertriton pdg --- PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx index b8247d0ca68..302d69cb9e0 100644 --- a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx +++ b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx @@ -85,6 +85,7 @@ constexpr double betheBlochDefault[1][6]{{-1.e32, -1.e32, -1.e32, -1.e32, -1.e32 static const std::vector betheBlochParNames{"p0", "p1", "p2", "p3", "p4", "resolution"}; constexpr int Li4PDG = o2::constants::physics::Pdg::kLithium4; +constexpr int H3LPDG = o2::constants::physics::Pdg::kHyperTriton; constexpr int ProtonPDG = PDG_t::kProton; constexpr int PionPDG = PDG_t::kPiPlus; constexpr int He3PDG = o2::constants::physics::Pdg::kHelium3; @@ -869,7 +870,7 @@ struct he3HadronFemto { mothers.push_back(mother.globalIndex()); if (std::abs(mother.pdgCode()) == Li4PDG) { flag |= ParticleFlags::kFromLi4; - } else if (std::abs(mother.pdgCode()) == o2::constants::physics::Pdg::kHyperTriton) { + } else if (std::abs(mother.pdgCode()) == H3LPDG) { flag |= ParticleFlags::kFromHypertriton; } else { flag |= ParticleFlags::kFromOtherDecays; @@ -887,7 +888,7 @@ struct he3HadronFemto { mothers.push_back(mother.globalIndex()); if (std::abs(mother.pdgCode()) == Li4PDG) { flag |= ParticleFlags::kFromLi4; - } else if (std::abs(mother.pdgCode()) == o2::constants::physics::Pdg::kHyperTriton) { + } else if (std::abs(mother.pdgCode()) == H3LPDG) { flag |= ParticleFlags::kFromHypertriton; } else { flag |= ParticleFlags::kFromOtherDecays; @@ -896,7 +897,7 @@ struct he3HadronFemto { } } - void searchForCommonMotherTrack(std::vector& motherHe3Idxs, std::vector& motherHadIdxs, McIter& motherParticle, bool & isMixedPair, const int motherPdgCode) + void searchForCommonMotherTrack(const std::vector& motherHe3Idxs, const std::vector& motherHadIdxs, const aod::McParticles& mcParticles, McIter& motherParticle, He3HadCandidate& he3Hadcand, bool & isMixedPair, const int motherPdgCode) { std::unordered_set motherHe3SetIdxs(motherHe3Idxs.begin(), motherHe3Idxs.end()); for (const auto& motherHadIdx : motherHadIdxs) { @@ -1057,14 +1058,14 @@ struct he3HadronFemto { } else if ((he3Hadcand.flagsHe3 & ParticleFlags::kFromLi4) && (he3Hadcand.flagsHad & ParticleFlags::kFromLi4)) { - searchForCommonMotherTrack(motherHe3Idxs, motherHadIdxs, motherParticle, isMixedPair, Li4PDG); + searchForCommonMotherTrack(motherHe3Idxs, motherHadIdxs, mcParticles, motherParticle, he3Hadcand, isMixedPair, Li4PDG); if (!isMixedPair) { he3Hadcand.flags |= Flags::kBothFromLi4; } } else if ((he3Hadcand.flagsHe3 & ParticleFlags::kFromHypertriton) && (he3Hadcand.flagsHad & ParticleFlags::kFromHypertriton)) { - searchForCommonMotherTrack(motherHe3Idxs, motherHadIdxs, motherParticle, isMixedPair, o2::constants::physics::Pdg::kHyperTriton); + searchForCommonMotherTrack(motherHe3Idxs, motherHadIdxs, mcParticles, motherParticle, he3Hadcand, isMixedPair, H3LPDG); if (!isMixedPair) { he3Hadcand.flags |= Flags::kBothFromHypertriton; } From add6c102d2f7be591541b42cb29c303115f7d109 Mon Sep 17 00:00:00 2001 From: GiorgioAlbertoLucia Date: Wed, 30 Jul 2025 08:55:26 +0200 Subject: [PATCH 18/19] clang format --- PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx index 302d69cb9e0..4383cad9fa8 100644 --- a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx +++ b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx @@ -897,7 +897,7 @@ struct he3HadronFemto { } } - void searchForCommonMotherTrack(const std::vector& motherHe3Idxs, const std::vector& motherHadIdxs, const aod::McParticles& mcParticles, McIter& motherParticle, He3HadCandidate& he3Hadcand, bool & isMixedPair, const int motherPdgCode) + void searchForCommonMotherTrack(const std::vector& motherHe3Idxs, const std::vector& motherHadIdxs, const aod::McParticles& mcParticles, McIter& motherParticle, He3HadCandidate& he3Hadcand, bool& isMixedPair, const int motherPdgCode) { std::unordered_set motherHe3SetIdxs(motherHe3Idxs.begin(), motherHe3Idxs.end()); for (const auto& motherHadIdx : motherHadIdxs) { @@ -915,7 +915,6 @@ struct he3HadronFemto { if (!isMixedPair) { he3Hadcand.flags |= Flags::kBothFromLi4; } - } template From 92a1a995e5fe0dc902c74674fd415ba304fcf097 Mon Sep 17 00:00:00 2001 From: GiorgioAlbertoLucia Date: Wed, 30 Jul 2025 09:13:51 +0200 Subject: [PATCH 19/19] fixed logic error --- PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx index 4383cad9fa8..f50262bd998 100644 --- a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx +++ b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx @@ -1074,7 +1074,7 @@ struct he3HadronFemto { he3Hadcand.flags |= Flags::kMixedPair; } - if (settingFillPrimariesAndMixedMc && ((he3Hadcand.flags & Flags::kMixedPair) || he3Hadcand.flags == Flags::kBothPrimaries)) { + if (!settingFillPrimariesAndMixedMc && ((he3Hadcand.flags == Flags::kMixedPair) || he3Hadcand.flags == Flags::kBothPrimaries)) { continue; }