From 13336cd05f7fd7f69599ac3fa81dd5bf0655465c Mon Sep 17 00:00:00 2001 From: creetz16 Date: Thu, 10 Sep 2026 15:53:15 +0200 Subject: [PATCH 1/6] Add centrality and gen daughter momenta --- PWGLF/DataModel/Vtx3BodyTables.h | 38 ++++++-- .../Nuspex/decay3bodybuilder.cxx | 42 ++++----- .../Nuspex/trackedHypertritonRecoTask.cxx | 87 +++++++++++++------ 3 files changed, 110 insertions(+), 57 deletions(-) diff --git a/PWGLF/DataModel/Vtx3BodyTables.h b/PWGLF/DataModel/Vtx3BodyTables.h index bb0dcc89fe1..fbfb258a0f1 100644 --- a/PWGLF/DataModel/Vtx3BodyTables.h +++ b/PWGLF/DataModel/Vtx3BodyTables.h @@ -17,6 +17,8 @@ #ifndef PWGLF_DATAMODEL_VTX3BODYTABLES_H_ #define PWGLF_DATAMODEL_VTX3BODYTABLES_H_ +#include "PWGLF/DataModel/LFHypernucleiTables.h" + #include "Common/Core/RecoDecay.h" #include @@ -128,12 +130,15 @@ DECLARE_SOA_COLUMN(GenCt, genCt, float); // generated Ct of the hy DECLARE_SOA_COLUMN(GenPhi, genPhi, float); // generated Phi of the hypertriton DECLARE_SOA_COLUMN(GenEta, genEta, float); // Eta of the hypertriton DECLARE_SOA_COLUMN(GenRap, genRap, float); // generated rapidity of the hypertriton -DECLARE_SOA_COLUMN(GenPPr, genPPr, float); //! generated momentum proton daughter particle -DECLARE_SOA_COLUMN(GenPPi, genPPi, float); //! generated momentum pion daughter particle -DECLARE_SOA_COLUMN(GenPDe, genPDe, float); //! generated momentum deuteron daughter particle -DECLARE_SOA_COLUMN(GenPtPr, genPtPr, float); //! generated transverse momentum proton daughter particle -DECLARE_SOA_COLUMN(GenPtPi, genPtPi, float); //! generated transverse momentum pion daughter particle -DECLARE_SOA_COLUMN(GenPtDe, genPtDe, float); //! generated transverse momentum deuteron daughter particle +DECLARE_SOA_COLUMN(GenPxPr, genPxPr, float); //! generated Px of proton daughter particle +DECLARE_SOA_COLUMN(GenPyPr, genPyPr, float); //! generated Py of proton daughter particle +DECLARE_SOA_COLUMN(GenPzPr, genPzPr, float); //! generated Pz of proton daughter particle +DECLARE_SOA_COLUMN(GenPxPi, genPxPi, float); //! generated Px of pion daughter particle +DECLARE_SOA_COLUMN(GenPyPi, genPyPi, float); //! generated Py of pion daughter particle +DECLARE_SOA_COLUMN(GenPzPi, genPzPi, float); //! generated Pz of pion daughter particle +DECLARE_SOA_COLUMN(GenPxDe, genPxDe, float); //! generated Px of deuteron daughter particle +DECLARE_SOA_COLUMN(GenPyDe, genPyDe, float); //! generated Py of deuteron daughter particle +DECLARE_SOA_COLUMN(GenPzDe, genPzDe, float); //! generated Pz of deuteron daughter particle DECLARE_SOA_COLUMN(MotherPdgCode, motherPdgCode, int); //! PDG code of the mother particle DECLARE_SOA_COLUMN(PrPdgCode, prPdgCode, int); //! MC particle proton PDG code DECLARE_SOA_COLUMN(PiPdgCode, piPdgCode, int); //! MC particle pion PDG code @@ -271,6 +276,22 @@ DECLARE_SOA_TABLE(Vtx3BodyTrackedInfo, "AOD", "VTX3BODYTR", //! vtx3body::ITSTrackDCAXYToSV, vtx3body::ITSTrackDCAZToSV); +// collision info table +DECLARE_SOA_TABLE(Vtx3BodyCollision, "AOD", "VTX3BODYCOLL", //! + o2::soa::Index<>, + hyperrec::CentralityFT0A, hyperrec::CentralityFT0C, hyperrec::CentralityFT0M, + hyperrec::TrackOccupancyInTimeRange, hyperrec::Ft0cOccupancyInTimeRange, + hyperrec::XPrimVtx, hyperrec::YPrimVtx, hyperrec::ZPrimVtx, + hyperrec::RunNumber); + +DECLARE_SOA_TABLE(McVtx3BodyCollision, "AOD", "MCVTX3BODYCOLL", //! + o2::soa::Index<>, + hyperrec::IsRecoMCCollision, + hyperrec::CentralityFT0A, hyperrec::CentralityFT0C, hyperrec::CentralityFT0M, + hyperrec::TrackOccupancyInTimeRange, hyperrec::Ft0cOccupancyInTimeRange, + hyperrec::XPrimVtx, hyperrec::YPrimVtx, hyperrec::ZPrimVtx, + hyperrec::RunNumber); + // MC candidate table for analysis DECLARE_SOA_TABLE(McVtx3BodyDatas, "AOD", "MC3BODYDATA", //! o2::soa::Index<>, @@ -303,8 +324,9 @@ DECLARE_SOA_TABLE(McVtx3BodyDatas, "AOD", "MC3BODYDATA", //! vtx3body::GenX, vtx3body::GenY, vtx3body::GenZ, vtx3body::GenCt, vtx3body::GenPhi, vtx3body::GenEta, vtx3body::GenRap, - vtx3body::GenPPr, vtx3body::GenPPi, vtx3body::GenPDe, - vtx3body::GenPtPr, vtx3body::GenPtPi, vtx3body::GenPtDe, + vtx3body::GenPxPr, vtx3body::GenPyPr, vtx3body::GenPzPr, + vtx3body::GenPxPi, vtx3body::GenPyPi, vtx3body::GenPzPi, + vtx3body::GenPxDe, vtx3body::GenPyDe, vtx3body::GenPzDe, vtx3body::IsReco, vtx3body::MotherLabel, vtx3body::MotherPdgCode, diff --git a/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx b/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx index b71c38eb678..2f96571ae61 100644 --- a/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx +++ b/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx @@ -227,12 +227,9 @@ struct decay3bodyBuilder { float genPhi; float genEta; float genRapidity; - float genMomProton; - float genMomPion; - float genMomDeuteron; - float genPtProton; - float genPtPion; - float genPtDeuteron; + std::array genMomProton{0.f}; + std::array genMomPion{0.f}; + std::array genMomDeuteron{0.f}; bool isReco; int motherLabel; int motherPdgCode; @@ -822,12 +819,9 @@ struct decay3bodyBuilder { this3BodyMCInfo.daughterPiPdgCode = mcTrackPion.pdgCode(); this3BodyMCInfo.daughterDePdgCode = mcTrackDeuteron.pdgCode(); this3BodyMCInfo.isDeuteronPrimary = mcTrackDeuteron.isPhysicalPrimary(); - this3BodyMCInfo.genMomProton = mcTrackProton.p(); - this3BodyMCInfo.genMomPion = mcTrackPion.p(); - this3BodyMCInfo.genMomDeuteron = mcTrackDeuteron.p(); - this3BodyMCInfo.genPtProton = mcTrackProton.pt(); - this3BodyMCInfo.genPtPion = mcTrackPion.pt(); - this3BodyMCInfo.genPtDeuteron = mcTrackDeuteron.pt(); + this3BodyMCInfo.genMomProton = {mcTrackProton.px(), mcTrackProton.py(), mcTrackProton.pz()}; + this3BodyMCInfo.genMomPion = {mcTrackPion.px(), mcTrackPion.py(), mcTrackPion.pz()}; + this3BodyMCInfo.genMomDeuteron = {mcTrackDeuteron.px(), mcTrackDeuteron.py(), mcTrackDeuteron.pz()}; // daughters are matched to MC, now we check if reco mother is true H3L/Anti-H3l and decayed via three-body decay this3BodyMCInfo.motherLabel = checkH3LTruth(mcTrackProton, mcTrackPion, mcTrackDeuteron); // returns global index of mother if true H3L/Anti-H3L mother decaying via three-body decay, otherwise negative value for background @@ -905,17 +899,14 @@ struct decay3bodyBuilder { // get daughters for (const auto& mcparticleDaughter : mcparticle.template daughters_as()) { if (std::abs(mcparticleDaughter.pdgCode()) == PDG_t::kProton) { // proton - this3BodyMCInfo.genMomProton = mcparticleDaughter.p(); - this3BodyMCInfo.genPtProton = mcparticleDaughter.pt(); + this3BodyMCInfo.genMomProton = {mcparticleDaughter.px(), mcparticleDaughter.py(), mcparticleDaughter.pz()}; this3BodyMCInfo.daughterPrPdgCode = mcparticleDaughter.pdgCode(); this3BodyMCInfo.genDecVtx = {mcparticleDaughter.vx(), mcparticleDaughter.vy(), mcparticleDaughter.vz()}; } else if (std::abs(mcparticleDaughter.pdgCode()) == PDG_t::kPiPlus) { // pion - this3BodyMCInfo.genMomPion = mcparticleDaughter.p(); - this3BodyMCInfo.genPtPion = mcparticleDaughter.pt(); + this3BodyMCInfo.genMomPion = {mcparticleDaughter.px(), mcparticleDaughter.py(), mcparticleDaughter.pz()}; this3BodyMCInfo.daughterPiPdgCode = mcparticleDaughter.pdgCode(); } else if (std::abs(mcparticleDaughter.pdgCode()) == o2::constants::physics::Pdg::kDeuteron) { // deuteron - this3BodyMCInfo.genMomDeuteron = mcparticleDaughter.p(); - this3BodyMCInfo.genPtDeuteron = mcparticleDaughter.pt(); + this3BodyMCInfo.genMomDeuteron = {mcparticleDaughter.px(), mcparticleDaughter.py(), mcparticleDaughter.pz()}; this3BodyMCInfo.daughterDePdgCode = mcparticleDaughter.pdgCode(); this3BodyMCInfo.isDeuteronPrimary = mcparticleDaughter.isPhysicalPrimary(); } @@ -957,8 +948,9 @@ struct decay3bodyBuilder { this3BodyMCInfo.genDecVtx[0], this3BodyMCInfo.genDecVtx[1], this3BodyMCInfo.genDecVtx[2], this3BodyMCInfo.genCt, mcparticle.phi(), mcparticle.eta(), mcparticle.y(), - this3BodyMCInfo.genMomProton, this3BodyMCInfo.genMomPion, this3BodyMCInfo.genMomDeuteron, - this3BodyMCInfo.genPtProton, this3BodyMCInfo.genPtPion, this3BodyMCInfo.genPtDeuteron, + this3BodyMCInfo.genMomProton[0], this3BodyMCInfo.genMomProton[1], this3BodyMCInfo.genMomProton[2], + this3BodyMCInfo.genMomPion[0], this3BodyMCInfo.genMomPion[1], this3BodyMCInfo.genMomPion[2], + this3BodyMCInfo.genMomDeuteron[0], this3BodyMCInfo.genMomDeuteron[1], this3BodyMCInfo.genMomDeuteron[2], this3BodyMCInfo.isReco, mcparticle.globalIndex(), // motherLabel mcparticle.pdgCode(), // motherPdgCode @@ -1153,8 +1145,9 @@ struct decay3bodyBuilder { this3BodyMCInfo.genDecVtx[0], this3BodyMCInfo.genDecVtx[1], this3BodyMCInfo.genDecVtx[2], this3BodyMCInfo.genCt, this3BodyMCInfo.genPhi, this3BodyMCInfo.genEta, this3BodyMCInfo.genRapidity, - this3BodyMCInfo.genMomProton, this3BodyMCInfo.genMomPion, this3BodyMCInfo.genMomDeuteron, - this3BodyMCInfo.genPtProton, this3BodyMCInfo.genPtPion, this3BodyMCInfo.genPtDeuteron, + this3BodyMCInfo.genMomProton[0], this3BodyMCInfo.genMomProton[1], this3BodyMCInfo.genMomProton[2], + this3BodyMCInfo.genMomPion[0], this3BodyMCInfo.genMomPion[1], this3BodyMCInfo.genMomPion[2], + this3BodyMCInfo.genMomDeuteron[0], this3BodyMCInfo.genMomDeuteron[1], this3BodyMCInfo.genMomDeuteron[2], this3BodyMCInfo.isReco, this3BodyMCInfo.motherLabel, this3BodyMCInfo.motherPdgCode, @@ -1280,8 +1273,9 @@ struct decay3bodyBuilder { mcInfo.genDecVtx[0] = -1., mcInfo.genDecVtx[1] = -1., mcInfo.genDecVtx[2] = -1.; mcInfo.genCt = -1.; mcInfo.genPhi = -1., mcInfo.genEta = -1., mcInfo.genRapidity = -1.; - mcInfo.genMomProton = -1., mcInfo.genMomPion = -1., mcInfo.genMomDeuteron = -1.; - mcInfo.genPtProton = -1., mcInfo.genPtPion = -1., mcInfo.genPtDeuteron = -1.; + mcInfo.genMomProton[0] = -1., mcInfo.genMomProton[1] = -1., mcInfo.genMomProton[2] = -1.; + mcInfo.genMomPion[0] = -1., mcInfo.genMomPion[1] = -1., mcInfo.genMomPion[2] = -1.; + mcInfo.genMomDeuteron[0] = -1., mcInfo.genMomDeuteron[1] = -1., mcInfo.genMomDeuteron[2] = -1.; mcInfo.isReco = false; mcInfo.motherPdgCode = 0; mcInfo.daughterPrPdgCode = -1, mcInfo.daughterPiPdgCode = -1, mcInfo.daughterDePdgCode = -1; diff --git a/PWGLF/TableProducer/Nuspex/trackedHypertritonRecoTask.cxx b/PWGLF/TableProducer/Nuspex/trackedHypertritonRecoTask.cxx index da2ca3ee1ee..c8bc8cdb20d 100644 --- a/PWGLF/TableProducer/Nuspex/trackedHypertritonRecoTask.cxx +++ b/PWGLF/TableProducer/Nuspex/trackedHypertritonRecoTask.cxx @@ -101,7 +101,9 @@ struct TrackedHypertritonRecoTask { Produces vtx3BodyDatas; Produces vtx3BodyCovs; Produces vtx3BodyTrackedInfo; + Produces vtx3BodyCollision; Produces mcVtx3BodyDatas; + Produces mcVtx3BodyCollision; Service ccdb{}; HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -238,12 +240,9 @@ struct TrackedHypertritonRecoTask { float genPhi = -1.f; float genEta = -1.f; float genRapidity = -1.f; - float genMomentumProton = -1.f; - float genMomentumPion = -1.f; - float genMomentumDeuteron = -1.f; - float genPtProton = -1.f; - float genPtPion = -1.f; - float genPtDeuteron = -1.f; + std::array genMomProton{-1.f, -1.f, -1.f}; + std::array genMomPion{-1.f, -1.f, -1.f}; + std::array genMomDeuteron{-1.f, -1.f, -1.f}; bool isReco = true; int motherLabel = -1; int motherPdgCode = 0; @@ -251,6 +250,7 @@ struct TrackedHypertritonRecoTask { int pionPdgCode = -1; int deuteronPdgCode = -1; bool isDeuteronPrimary = false; + bool isRecoMCCollision = false; bool survivedEventSelection = false; }; @@ -521,12 +521,9 @@ struct TrackedHypertritonRecoTask { info.pionPdgCode = mcPion.pdgCode(); info.deuteronPdgCode = mcDeuteron.pdgCode(); info.isDeuteronPrimary = mcDeuteron.isPhysicalPrimary(); - info.genMomentumProton = mcProton.p(); - info.genMomentumPion = mcPion.p(); - info.genMomentumDeuteron = mcDeuteron.p(); - info.genPtProton = mcProton.pt(); - info.genPtPion = mcPion.pt(); - info.genPtDeuteron = mcDeuteron.pt(); + info.genMomProton = {mcProton.px(), mcProton.py(), mcProton.pz()}; + info.genMomPion = {mcPion.px(), mcPion.py(), mcPion.pz()}; + info.genMomDeuteron = {mcDeuteron.px(), mcDeuteron.py(), mcDeuteron.pz()}; const int motherLabel = findCommonMother(mcProton, mcPion, mcDeuteron); if (motherLabel < 0) { @@ -548,7 +545,8 @@ struct TrackedHypertritonRecoTask { info.genPhi = mother.phi(); info.genEta = mother.eta(); info.genRapidity = mother.y(); - if (mother.mcCollisionId() >= 0 && mother.mcCollisionId() < static_cast(survivedMCEventSelection.size())) { + if (mother.mcCollisionId() >= 0 && mother.mcCollisionId() < static_cast(recoCollisionForMC.size())) { + info.isRecoMCCollision = recoCollisionForMC[mother.mcCollisionId()] >= 0; info.survivedEventSelection = survivedMCEventSelection[mother.mcCollisionId()]; } return info; @@ -790,7 +788,8 @@ struct TrackedHypertritonRecoTask { return dcaInfo; } - void fillThreeBodyTables() + template + void fillThreeBodyTables(TCollision const& collision) { const auto& candidate = builder3Body.decay3body; vtx3BodyDatas(static_cast(candidate.sign), @@ -816,6 +815,10 @@ struct TrackedHypertritonRecoTask { static_cast(candidate.pidForTrackingDeuteron)); vtx3BodyCovs(candidate.covProton.data(), candidate.covPion.data(), candidate.covDeuteron.data(), candidate.covariance.data()); vtx3BodyTrackedInfo(candidate.itsTrackDCAToSV[0], candidate.itsTrackDCAToSV[1]); + vtx3BodyCollision(collision.centFT0A(), collision.centFT0C(), collision.centFT0M(), + collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange(), + collision.posX(), collision.posY(), collision.posZ(), + runNumber); } void fillThreeBodyMCTable(ThreeBodyMCInfo const& info) @@ -845,8 +848,9 @@ struct TrackedHypertritonRecoTask { info.genMomentum[0], info.genMomentum[1], info.genMomentum[2], info.genDecayVertex[0], info.genDecayVertex[1], info.genDecayVertex[2], info.genCt, info.genPhi, info.genEta, info.genRapidity, - info.genMomentumProton, info.genMomentumPion, info.genMomentumDeuteron, - info.genPtProton, info.genPtPion, info.genPtDeuteron, + info.genMomProton[0], info.genMomProton[1], info.genMomProton[2], + info.genMomPion[0], info.genMomPion[1], info.genMomPion[2], + info.genMomDeuteron[0], info.genMomDeuteron[1], info.genMomDeuteron[2], static_cast(info.isReco), info.motherLabel, info.motherPdgCode, info.protonPdgCode, info.pionPdgCode, info.deuteronPdgCode, info.isDeuteronPrimary, static_cast(info.survivedEventSelection)); @@ -879,8 +883,9 @@ struct TrackedHypertritonRecoTask { info.genMomentum[0], info.genMomentum[1], info.genMomentum[2], info.genDecayVertex[0], info.genDecayVertex[1], info.genDecayVertex[2], info.genCt, info.genPhi, info.genEta, info.genRapidity, - info.genMomentumProton, info.genMomentumPion, info.genMomentumDeuteron, - info.genPtProton, info.genPtPion, info.genPtDeuteron, + info.genMomProton[0], info.genMomProton[1], info.genMomProton[2], + info.genMomPion[0], info.genMomPion[1], info.genMomPion[2], + info.genMomDeuteron[0], info.genMomDeuteron[1], info.genMomDeuteron[2], 0, info.motherLabel, info.motherPdgCode, info.protonPdgCode, info.pionPdgCode, info.deuteronPdgCode, info.isDeuteronPrimary, static_cast(info.survivedEventSelection)); @@ -972,7 +977,7 @@ struct TrackedHypertritonRecoTask { } fillQAHistograms(trackProton, trackPion, trackDeuteron, true); - fillThreeBodyTables(); + fillThreeBodyTables(collision); } } } @@ -1077,6 +1082,12 @@ struct TrackedHypertritonRecoTask { } fillThreeBodyMCTable(mcInfo); + mcVtx3BodyCollision(true, // IsRecoMCCollision + collision.centFT0A(), collision.centFT0C(), collision.centFT0M(), + collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange(), + collision.posX(), collision.posY(), collision.posZ(), + runNumber); + if (mcInfo.motherLabel >= 0) { reconstructedThreeBody[mcInfo.motherLabel] = true; } @@ -1117,19 +1128,16 @@ struct TrackedHypertritonRecoTask { hasPionTwoBody = true; hasPionThreeBody = true; threeBodyInfo.pionPdgCode = daughter.pdgCode(); - threeBodyInfo.genMomentumPion = daughter.p(); - threeBodyInfo.genPtPion = daughter.pt(); + threeBodyInfo.genMomPion = {daughter.px(), daughter.py(), daughter.pz()}; } else if (daughter.pdgCode() == sign * PDG_t::kProton) { hasProton = true; threeBodyInfo.protonPdgCode = daughter.pdgCode(); - threeBodyInfo.genMomentumProton = daughter.p(); - threeBodyInfo.genPtProton = daughter.pt(); + threeBodyInfo.genMomProton = {daughter.px(), daughter.py(), daughter.pz()}; threeBodyInfo.genDecayVertex = {daughter.vx(), daughter.vy(), daughter.vz()}; } else if (daughter.pdgCode() == sign * constants::physics::Pdg::kDeuteron) { hasDeuteron = true; threeBodyInfo.deuteronPdgCode = daughter.pdgCode(); - threeBodyInfo.genMomentumDeuteron = daughter.p(); - threeBodyInfo.genPtDeuteron = daughter.pt(); + threeBodyInfo.genMomDeuteron = {daughter.px(), daughter.py(), daughter.pz()}; threeBodyInfo.isDeuteronPrimary = daughter.isPhysicalPrimary(); } } @@ -1178,11 +1186,40 @@ struct TrackedHypertritonRecoTask { } if (hasProton && hasPionThreeBody && hasDeuteron && !reconstructedThreeBody[mother.globalIndex()]) { + float centralityFT0A = -1.f; + float centralityFT0C = -1.f; + float centralityFT0M = -1.f; + int trackOccupancyInTimeRange = -1; + float ft0cOccupancyInTimeRange = -1.f; + float primaryVertexX = -1.f; + float primaryVertexY = -1.f; + float primaryVertexZ = -1.f; + bool isRecoMCCollision = false; + if (mother.mcCollisionId() >= 0 && mother.mcCollisionId() < static_cast(recoCollisionForMC.size())) { + const int recoCollisionId = recoCollisionForMC[mother.mcCollisionId()]; + isRecoMCCollision = recoCollisionId >= 0; + if (isRecoMCCollision) { + const auto collision = collisions.rawIteratorAt(recoCollisionId); + centralityFT0A = collision.centFT0A(); + centralityFT0C = collision.centFT0C(); + centralityFT0M = collision.centFT0M(); + trackOccupancyInTimeRange = collision.trackOccupancyInTimeRange(); + ft0cOccupancyInTimeRange = collision.ft0cOccupancyInTimeRange(); + primaryVertexX = collision.posX(); + primaryVertexY = collision.posY(); + primaryVertexZ = collision.posZ(); + } + } threeBodyInfo.genCt = RecoDecay::sqrtSumOfSquares(threeBodyInfo.genDecayVertex[0] - mother.vx(), threeBodyInfo.genDecayVertex[1] - mother.vy(), threeBodyInfo.genDecayVertex[2] - mother.vz()) * constants::physics::MassHyperTriton / (mother.p() + 1.e-10f); fillGeneratedThreeBodyMCTable(threeBodyInfo); + mcVtx3BodyCollision(isRecoMCCollision, + centralityFT0A, centralityFT0C, centralityFT0M, + trackOccupancyInTimeRange, ft0cOccupancyInTimeRange, + primaryVertexX, primaryVertexY, primaryVertexZ, + runNumber); } } } From 415e27a7e1a0e509078d6c4678513bed6de99e93 Mon Sep 17 00:00:00 2001 From: creetz16 Date: Thu, 10 Sep 2026 19:59:55 +0200 Subject: [PATCH 2/6] Linter fixes --- .../Nuspex/decay3bodybuilder.cxx | 103 +++++++++--------- .../Nuspex/trackedHypertritonRecoTask.cxx | 2 +- 2 files changed, 54 insertions(+), 51 deletions(-) diff --git a/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx b/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx index 2f96571ae61..7b139b735f4 100644 --- a/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx +++ b/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx @@ -75,7 +75,7 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -o2::common::core::MetadataHelper metadataInfo; +o2::common::core::MetadataHelper metadataInfo{}; static constexpr int nParameters = 1; static const std::vector tableNames{ @@ -220,31 +220,31 @@ struct decay3bodyBuilder { // Helper struct to contain MC information prior to filling struct mc3Bodyinfo { - int label; - std::array genDecVtx{0.f}; - std::array genMomentum{0.f}; - float genCt; - float genPhi; - float genEta; - float genRapidity; - std::array genMomProton{0.f}; - std::array genMomPion{0.f}; - std::array genMomDeuteron{0.f}; - bool isReco; - int motherLabel; - int motherPdgCode; - int daughterPrPdgCode; - int daughterPiPdgCode; - int daughterDePdgCode; - bool isDeuteronPrimary; - bool survivedEventSel; + int label = -1; + std::array genDecVtx{-1.f, -1.f, -1.f}; + std::array genMomentum{-1.f, -1.f, -1.f}; + float genCt = -1.f; + float genPhi = -1.f; + float genEta = -1.f; + float genRapidity = -1.f; + std::array genMomProton{-1.f, -1.f, -1.f}; + std::array genMomPion{-1.f, -1.f, -1.f}; + std::array genMomDeuteron{-1.f, -1.f, -1.f}; + bool isReco = false; + int motherLabel = -1; + int motherPdgCode = -1; + int daughterPrPdgCode = -1; + int daughterPiPdgCode = -1; + int daughterDePdgCode = -1; + bool isDeuteronPrimary = false; + bool survivedEventSel = false; }; mc3Bodyinfo this3BodyMCInfo; // CCDB and magnetic field - int mRunNumber; - float d_bz; - Service ccdb; + int mRunNumber = 0; + float d_bz = 0.f; + Service ccdb{}; o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; std::unordered_map ccdbCache; // Maps runNumber -> d_bz o2::base::MatLayerCylSet* lut = nullptr; @@ -379,7 +379,7 @@ struct decay3bodyBuilder { // list enabled tables for (int i = 0; i < nTables; i++) { - if (mEnabledTables[i]) { + if (mEnabledTables[i] != 0) { LOGF(info, " -~> Table enabled: %s", tableNames[i]); } } @@ -433,26 +433,26 @@ struct decay3bodyBuilder { } } - if (mEnabledTables[kVtx3BodyDatas] && mEnabledTables[kMcVtx3BodyDatas]) { + if (mEnabledTables[kVtx3BodyDatas] != 0 && mEnabledTables[kMcVtx3BodyDatas] != 0) { LOG(fatal) << "Tables Vtx3BodyDatas and McVtx3BodyDatas cannot both be enabled at the same time. Choose one!"; } // Add histograms separately for different process functions - if (doprocessRealData == true || doprocessMonteCarlo == true) { + if (doprocessRealData || doprocessMonteCarlo) { auto hEventCounter = registry.add("Counters/hEventCounter", "hEventCounter", HistType::kTH1D, {{2, 0.0f, 2.0f}}); hEventCounter->GetXaxis()->SetBinLabel(1, "all"); hEventCounter->GetXaxis()->SetBinLabel(2, "selected"); hEventCounter->LabelsOption("v"); } - if (doprocessMonteCarlo == true) { + if (doprocessMonteCarlo) { auto hMcEventCounter = registry.add("Counters/hMcEventCounter", "hMcEventCounter", HistType::kTH1D, {{2, 0.0f, 2.0f}}); hMcEventCounter->GetXaxis()->SetBinLabel(1, "all"); hMcEventCounter->GetXaxis()->SetBinLabel(2, "reconstructed"); hMcEventCounter->LabelsOption("v"); } - if (doprocessRealData == true || doprocessRealDataReduced == true || doprocessMonteCarlo == true) { + if (doprocessRealData || doprocessRealDataReduced || doprocessMonteCarlo) { if (doTrackQA) { // histograms for all daughter tracks of (selected) 3body candidates registry.add("QA/Tracks/hTrackProtonTPCNcls", "hTrackProtonTPCNcls", HistType::kTH1F, {{152, 0, 152, "# TPC clusters"}}); registry.add("QA/Tracks/hTrackPionTPCNcls", "hTrackPionTPCNcls", HistType::kTH1F, {{152, 0, 152, "# TPC clusters"}}); @@ -482,7 +482,7 @@ struct decay3bodyBuilder { } } - if (doprocessRealDataReduced3bodyMixing == true) { + if (doprocessRealDataReduced3bodyMixing) { auto h3bodyCombinationCounter = registry.add("Mixing/h3bodyCombinationCounter", "h3bodyCombinationCounter", HistType::kTH1D, {{4, 0.0f, 4.0f}}); h3bodyCombinationCounter->GetXaxis()->SetBinLabel(1, "total"); h3bodyCombinationCounter->GetXaxis()->SetBinLabel(2, "not same collision"); @@ -513,7 +513,7 @@ struct decay3bodyBuilder { } auto timestamp = bc.timestamp(); - o2::parameters::GRPMagField* grpmag = 0x0; + o2::parameters::GRPMagField* grpmag = nullptr; ccdb->clearCache(ccdbConfigurations.grpmagPath); grpmag = ccdb->getSpecific(ccdbConfigurations.grpmagPath, timestamp); if (!grpmag) { @@ -550,9 +550,9 @@ struct decay3bodyBuilder { float getMagFieldFromRunNumber(int runNumber) { - float magField; + float magField{}; // Check if the CCDB data for this run is already cached - if (ccdbCache.find(runNumber) != ccdbCache.end()) { + if (ccdbCache.contains(runNumber)) { LOG(debug) << "CCDB data already cached for run " << runNumber; magField = ccdbCache[runNumber]; // if not, retrieve it from CCDB @@ -729,7 +729,7 @@ struct decay3bodyBuilder { auto trackPion = protonSign > 0 ? trackNeg : trackPos; // get deuteron TOF PID - float tofNSigmaDeuteron; + float tofNSigmaDeuteron{}; if constexpr (!soa::is_table) { // running over derived data tofNSigmaDeuteron = trackDeuteron.tofNSigmaDe(); } else if constexpr (soa::is_table) { // running over AO2Ds @@ -803,11 +803,10 @@ struct decay3bodyBuilder { if (!trackProton.has_mcParticle() || !trackPion.has_mcParticle() || !trackDeuteron.has_mcParticle()) { if (!doStoreMcBkg) { continue; // if not storing MC background, skip candidates where at least one daughter is not matched to MC particle - } else { - this3BodyMCInfo.motherLabel = -5; // at least one of the daughters not matched to MC particle - // fill analysis table (only McVtx3BodyDatas is filled here) - fillAnalysisTables(); } + this3BodyMCInfo.motherLabel = -5; // at least one of the daughters not matched to MC particle + // fill analysis table (only McVtx3BodyDatas is filled here) + fillAnalysisTables(); } else { // all daughters are matched to MC particles, get their MC info // get MC daughter particles auto mcTrackProton = trackProton.template mcParticle_as(); @@ -880,18 +879,24 @@ struct decay3bodyBuilder { bool haveProton = false, havePion = false, haveDeuteron = false; bool haveAntiProton = false, haveAntiPion = false, haveAntiDeuteron = false; for (const auto& mcparticleDaughter : mcparticle.template daughters_as()) { - if (mcparticleDaughter.pdgCode() == PDG_t::kProton) + if (mcparticleDaughter.pdgCode() == PDG_t::kProton) { haveProton = true; - if (mcparticleDaughter.pdgCode() == PDG_t::kProtonBar) + } + if (mcparticleDaughter.pdgCode() == PDG_t::kProtonBar) { haveAntiProton = true; - if (mcparticleDaughter.pdgCode() == PDG_t::kPiPlus) + } + if (mcparticleDaughter.pdgCode() == PDG_t::kPiPlus) { havePion = true; - if (mcparticleDaughter.pdgCode() == PDG_t::kPiMinus) + } + if (mcparticleDaughter.pdgCode() == PDG_t::kPiMinus) { haveAntiPion = true; - if (mcparticleDaughter.pdgCode() == o2::constants::physics::Pdg::kDeuteron) + } + if (mcparticleDaughter.pdgCode() == o2::constants::physics::Pdg::kDeuteron) { haveDeuteron = true; - if (mcparticleDaughter.pdgCode() == -o2::constants::physics::Pdg::kDeuteron) + } + if (mcparticleDaughter.pdgCode() == -o2::constants::physics::Pdg::kDeuteron) { haveAntiDeuteron = true; + } } // check if hypertriton decayed via 3-body decay and is particle or anti-particle @@ -1077,13 +1082,13 @@ struct decay3bodyBuilder { void fillAnalysisTables() { // generate analysis tables - if (mEnabledTables[kDecay3BodyIndices]) { + if (mEnabledTables[kDecay3BodyIndices] != 0) { products.decay3bodyindices(helper.decay3body.decay3bodyID, helper.decay3body.protonID, helper.decay3body.pionID, helper.decay3body.deuteronID, helper.decay3body.collisionID); registry.fill(HIST("Counters/hTableBuildingStatistics"), kDecay3BodyIndices); } - if (mEnabledTables[kVtx3BodyDatas]) { + if (mEnabledTables[kVtx3BodyDatas] != 0) { products.vtx3bodydatas(helper.decay3body.sign, helper.decay3body.mass, helper.decay3body.massV0, helper.decay3body.position[0], helper.decay3body.position[1], helper.decay3body.position[2], @@ -1109,14 +1114,14 @@ struct decay3bodyBuilder { helper.decay3body.pidForTrackingDeuteron); registry.fill(HIST("Counters/hTableBuildingStatistics"), kVtx3BodyDatas); } - if (mEnabledTables[kVtx3BodyCovs]) { + if (mEnabledTables[kVtx3BodyCovs] != 0) { products.vtx3bodycovs(helper.decay3body.covProton.data(), helper.decay3body.covPion.data(), helper.decay3body.covDeuteron.data(), helper.decay3body.covariance.data()); registry.fill(HIST("Counters/hTableBuildingStatistics"), kVtx3BodyCovs); } - if (mEnabledTables[kMcVtx3BodyDatas]) { + if (mEnabledTables[kMcVtx3BodyDatas] != 0) { products.mcvtx3bodydatas(helper.decay3body.sign, helper.decay3body.mass, helper.decay3body.massV0, helper.decay3body.position[0], helper.decay3body.position[1], helper.decay3body.position[2], @@ -1182,9 +1187,8 @@ struct decay3bodyBuilder { // fill analysis tables with built candidate fillAnalysisTables(); return; - } else { - return; } + return; } // ______________________________________________________________ @@ -1259,9 +1263,8 @@ struct decay3bodyBuilder { // check if the common mother is a hypertriton if (std::abs(momPdgCode) == o2::constants::physics::Pdg::kHyperTriton) { return momID; - } else { - return -1; // common mother found but not a hypertriton } + return -1; // common mother found but not a hypertriton } // ______________________________________________________________ diff --git a/PWGLF/TableProducer/Nuspex/trackedHypertritonRecoTask.cxx b/PWGLF/TableProducer/Nuspex/trackedHypertritonRecoTask.cxx index c8bc8cdb20d..8cfa800ee75 100644 --- a/PWGLF/TableProducer/Nuspex/trackedHypertritonRecoTask.cxx +++ b/PWGLF/TableProducer/Nuspex/trackedHypertritonRecoTask.cxx @@ -228,7 +228,7 @@ struct TrackedHypertritonRecoTask { bool isSignal = false; bool isRecoMCCollision = false; bool survivedEventSelection = false; - uint8_t fakeHeITSLayerMap = 0; + uint8_t fakeHeITSLayerMap{}; int motherLabel = -1; int statusCode = 0; }; From 3a73d724b64e630854e6e508f1a0ed7ebfbaad60 Mon Sep 17 00:00:00 2001 From: creetz16 Date: Thu, 10 Sep 2026 20:11:55 +0200 Subject: [PATCH 3/6] More fixes --- PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx b/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx index 7b139b735f4..5f5e33fa1f0 100644 --- a/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx +++ b/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx @@ -521,7 +521,7 @@ struct decay3bodyBuilder { } o2::base::Propagator::initFieldFromGRP(grpmag); // Fetch magnetic field from ccdb for current collision - auto d_bz = o2::base::Propagator::Instance()->getNominalBz(); + d_bz = o2::base::Propagator::Instance()->getNominalBz(); LOG(info) << "Retrieved GRP for timestamp " << timestamp << " with magnetic field of " << d_bz << " kG"; // set magnetic field value for DCA fitter @@ -732,7 +732,7 @@ struct decay3bodyBuilder { float tofNSigmaDeuteron{}; if constexpr (!soa::is_table) { // running over derived data tofNSigmaDeuteron = trackDeuteron.tofNSigmaDe(); - } else if constexpr (soa::is_table) { // running over AO2Ds + } else { // running over AO2Ds if constexpr (soa::is_table) { // running over MC (track table with labels) tofNSigmaDeuteron = getTOFnSigma(mRespParamsV3, collision, trackDeuteron); } else { // running over real data From cf661581dc80c3fe23cd9487927cb6eb184ad9a9 Mon Sep 17 00:00:00 2001 From: creetz16 Date: Thu, 10 Sep 2026 20:13:14 +0200 Subject: [PATCH 4/6] Formatting --- PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx b/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx index 5f5e33fa1f0..c15684c5041 100644 --- a/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx +++ b/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx @@ -732,7 +732,7 @@ struct decay3bodyBuilder { float tofNSigmaDeuteron{}; if constexpr (!soa::is_table) { // running over derived data tofNSigmaDeuteron = trackDeuteron.tofNSigmaDe(); - } else { // running over AO2Ds + } else { // running over AO2Ds if constexpr (soa::is_table) { // running over MC (track table with labels) tofNSigmaDeuteron = getTOFnSigma(mRespParamsV3, collision, trackDeuteron); } else { // running over real data From a91449ed701c3cc15c3df71f46866eebb576f5a1 Mon Sep 17 00:00:00 2001 From: creetz16 Date: Thu, 10 Sep 2026 20:36:35 +0200 Subject: [PATCH 5/6] Initialisation --- PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx b/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx index c15684c5041..7466a973bcb 100644 --- a/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx +++ b/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx @@ -1342,7 +1342,7 @@ struct decay3bodyBuilder { auto yAxis = registry.get(HIST("Mixing/hDecay3BodyRadiusPhi"))->GetYaxis(); for (const auto& decay3body : decay3bodys) { - int bin_Radius, bin_Phi; + int bin_Radius{}, bin_Phi{}; if (decay3bodyBuilderOpts.useKFParticle) { bin_Radius = xAxis->FindBin(decay3body.radiusKF()); bin_Phi = yAxis->FindBin(decay3body.phiKF()); From 6448d74669b7a1e564fc3553910f62b70184664c Mon Sep 17 00:00:00 2001 From: creetz16 Date: Thu, 10 Sep 2026 20:38:35 +0200 Subject: [PATCH 6/6] Passing reference --- PWGLF/TableProducer/Nuspex/trackedHypertritonRecoTask.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGLF/TableProducer/Nuspex/trackedHypertritonRecoTask.cxx b/PWGLF/TableProducer/Nuspex/trackedHypertritonRecoTask.cxx index f6908590871..d63be90ba45 100644 --- a/PWGLF/TableProducer/Nuspex/trackedHypertritonRecoTask.cxx +++ b/PWGLF/TableProducer/Nuspex/trackedHypertritonRecoTask.cxx @@ -779,7 +779,7 @@ struct TrackedHypertritonRecoTask { } template - std::array getItsTrackDCAToSV(TTracked3body tracked3Body) + std::array getItsTrackDCAToSV(TTracked3body const& tracked3Body) { const auto itsTrack = tracked3Body.template itsTrack_as(); auto itsTrackParCov = getTrackParCov(itsTrack);