From 8ed4c9905384ca449fd61b9f13b4fa416c801ed9 Mon Sep 17 00:00:00 2001 From: fmazzasc Date: Mon, 4 Sep 2023 17:43:50 +0200 Subject: [PATCH 1/5] Fix MC association --- PWGLF/TableProducer/lithium4analysis.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGLF/TableProducer/lithium4analysis.cxx b/PWGLF/TableProducer/lithium4analysis.cxx index e0b487bd951..2080cca04ba 100644 --- a/PWGLF/TableProducer/lithium4analysis.cxx +++ b/PWGLF/TableProducer/lithium4analysis.cxx @@ -376,7 +376,7 @@ struct lithium4analysis { for (auto& mothertrack : mctrackHe3.mothers_as()) { for (auto& mothertrackPr : mctrackPr.mothers_as()) { - if (mothertrack != mothertrackPr || mothertrack.pdgCode() != lithium4PDG) { + if (mothertrack != mothertrackPr || std::abs(mothertrack.pdgCode()) != lithium4PDG) { continue; } @@ -401,7 +401,7 @@ struct lithium4analysis { continue; } - if (std::abs(mcParticle.y()) > 1) { + if (std::abs(mcParticle.y()) > 1 || mcParticle.isPhysicalPrimary() == false) { continue; } From 64931ec8a8c1068a7af27f818ad88307b96338c7 Mon Sep 17 00:00:00 2001 From: fmazzasc Date: Fri, 8 Sep 2023 16:10:33 +0200 Subject: [PATCH 2/5] Fix MC --- PWGLF/TableProducer/lithium4analysis.cxx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/PWGLF/TableProducer/lithium4analysis.cxx b/PWGLF/TableProducer/lithium4analysis.cxx index 2080cca04ba..2b74de9d4dd 100644 --- a/PWGLF/TableProducer/lithium4analysis.cxx +++ b/PWGLF/TableProducer/lithium4analysis.cxx @@ -192,7 +192,7 @@ struct lithium4analysis { } template - void FillCandidateInfo(const T1& candidateHe3, const T2& candidatePr, bool mix) + bool FillCandidateInfo(const T1& candidateHe3, const T2& candidatePr, bool mix) { lithium4Candidate l4Cand; @@ -202,7 +202,7 @@ struct lithium4analysis { float invMass = RecoDecay::m(array{l4Cand.momHe3, l4Cand.momPr}, array{he3Mass, protonMass}); if (invMass < 3.74 || invMass > 3.85 || candidatePr.pt() > cfgCutMaxPrPT) { - return; + return false; } histos.fill(HIST("hHe3Pt"), l4Cand.recoPtHe3()); @@ -223,6 +223,7 @@ struct lithium4analysis { l4Cand.nTPCClustersHe3 = candidateHe3.tpcNClsFound(); l4Cand.nSigmaHe3 = computeNSigmaHe3(candidateHe3); l4Candidates.push_back(l4Cand); + return true; } Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; @@ -384,10 +385,13 @@ struct lithium4analysis { continue; } - FillCandidateInfo(track1, track2, false); + if (!FillCandidateInfo(track1, track2, false)) { + continue; + } auto& l4Candidate = l4Candidates.back(); l4Candidate.l4PtMC = mothertrack.pt(); - l4Candidate.l4MassMC = std::sqrt(mothertrack.e() * mothertrack.e() - mothertrack.p() * mothertrack.p()); + double eLit = mctrackHe3.e() + mctrackPr.e(); + l4Candidate.l4MassMC = std::sqrt(eLit*eLit - mothertrack.p() * mothertrack.p()); filledMothers.push_back(mothertrack.globalIndex()); } } @@ -412,18 +416,21 @@ struct lithium4analysis { auto kDaughters = mcParticle.daughters_as(); auto daughtHe3 = false; auto daughtPr = false; + double eLit = 0; for (auto kCurrentDaughter : kDaughters) { if (std::abs(kCurrentDaughter.pdgCode()) == he3PDG) { daughtHe3 = true; + eLit += kCurrentDaughter.e(); } else if (std::abs(kCurrentDaughter.pdgCode()) == protonPDG) { daughtPr = true; + eLit += kCurrentDaughter.e(); } } if (daughtHe3 && daughtPr) { lithium4Candidate l4Candidate; int sign = mcParticle.pdgCode() > 0 ? 1 : -1; l4Candidate.l4PtMC = mcParticle.pt() * sign; - l4Candidate.l4MassMC = std::sqrt(mcParticle.e() * mcParticle.e() - mcParticle.p() * mcParticle.p()); + l4Candidate.l4MassMC = std::sqrt(eLit*eLit - mcParticle.p() * mcParticle.p()); l4Candidates.push_back(l4Candidate); } } From bb880b7ea3fb3053c1a202aeb9245e20e2a4d7eb Mon Sep 17 00:00:00 2001 From: fmazzasc Date: Tue, 12 Sep 2023 16:47:20 +0200 Subject: [PATCH 3/5] Fix EM --- PWGLF/TableProducer/lithium4analysis.cxx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/PWGLF/TableProducer/lithium4analysis.cxx b/PWGLF/TableProducer/lithium4analysis.cxx index 2b74de9d4dd..6d0a31d5f4f 100644 --- a/PWGLF/TableProducer/lithium4analysis.cxx +++ b/PWGLF/TableProducer/lithium4analysis.cxx @@ -238,7 +238,7 @@ struct lithium4analysis { Preslice perColMC = aod::track::collisionId; // binning for EM background - ConfigurableAxis axisVertex{"axisVertex", {20, -10, 10}, "vertex axis for bin"}; + ConfigurableAxis axisVertex{"axisVertex", {30, -10, 10}, "vertex axis for bin"}; using BinningType = ColumnBinningPolicy; BinningType binningOnPositions{{axisVertex}, true}; SameKindPair pair{binningOnPositions, cfgNoMixedEvents, -1, &cache}; @@ -292,10 +292,9 @@ struct lithium4analysis { } PROCESS_SWITCH(lithium4analysis, processSameEvent, "Process Same event", false); - void processMixedEvent(soa::Join const& collisions, TrackCandidates const& tracks) + void processMixedEvent(EventCandidates& collisions, TrackCandidates const& tracks) { l4Candidates.clear(); - for (auto& [c1, tracks1, c2, tracks2] : pair) { if (!c1.sel8()) { continue; @@ -391,7 +390,7 @@ struct lithium4analysis { auto& l4Candidate = l4Candidates.back(); l4Candidate.l4PtMC = mothertrack.pt(); double eLit = mctrackHe3.e() + mctrackPr.e(); - l4Candidate.l4MassMC = std::sqrt(eLit*eLit - mothertrack.p() * mothertrack.p()); + l4Candidate.l4MassMC = std::sqrt(eLit * eLit - mothertrack.p() * mothertrack.p()); filledMothers.push_back(mothertrack.globalIndex()); } } @@ -430,7 +429,7 @@ struct lithium4analysis { lithium4Candidate l4Candidate; int sign = mcParticle.pdgCode() > 0 ? 1 : -1; l4Candidate.l4PtMC = mcParticle.pt() * sign; - l4Candidate.l4MassMC = std::sqrt(eLit*eLit - mcParticle.p() * mcParticle.p()); + l4Candidate.l4MassMC = std::sqrt(eLit * eLit - mcParticle.p() * mcParticle.p()); l4Candidates.push_back(l4Candidate); } } From c04fa23eee9821aa6158434bc425cf9be7c0cb11 Mon Sep 17 00:00:00 2001 From: fmazzasc Date: Wed, 13 Sep 2023 11:41:29 +0200 Subject: [PATCH 4/5] Adding TOF pid response --- PWGLF/DataModel/LFLithium4Tables.h | 9 +++ PWGLF/TableProducer/lithium4analysis.cxx | 86 +++++++++++++++++++++--- 2 files changed, 86 insertions(+), 9 deletions(-) diff --git a/PWGLF/DataModel/LFLithium4Tables.h b/PWGLF/DataModel/LFLithium4Tables.h index b5bcf4abe5e..d0b6995daa7 100644 --- a/PWGLF/DataModel/LFLithium4Tables.h +++ b/PWGLF/DataModel/LFLithium4Tables.h @@ -43,6 +43,9 @@ DECLARE_SOA_COLUMN(He3SignalTPC, he3SignalTPC, float); DECLARE_SOA_COLUMN(He3InnerParamTPC, he3InnerParamTPC, float); DECLARE_SOA_COLUMN(He3NClsTPC, he3NClsTPC, uint8_t); DECLARE_SOA_COLUMN(He3NSigmaTPC, he3NSigmaTPC, float); +DECLARE_SOA_COLUMN(PrNSigmaTPC, prNSigmaTOF, float); +DECLARE_SOA_COLUMN(He3MassTOF, he3MassTOF, float); +DECLARE_SOA_COLUMN(PrMassTOF, prMassTOF, float); DECLARE_SOA_COLUMN(IsBkgLS, isBkgLS, bool); DECLARE_SOA_COLUMN(IsBkgEM, isBkgEM, bool); @@ -68,6 +71,9 @@ DECLARE_SOA_TABLE(Lithium4Table, "AOD", "LITHIUM4TABLE", Lithium4TablesNS::He3InnerParamTPC, Lithium4TablesNS::He3NClsTPC, Lithium4TablesNS::He3NSigmaTPC, + Lithium4TablesNS::PrNSigmaTPC, + Lithium4TablesNS::He3MassTOF, + Lithium4TablesNS::PrMassTOF, Lithium4TablesNS::IsBkgLS, Lithium4TablesNS::IsBkgEM) DECLARE_SOA_TABLE(Lithium4TableMC, "AOD", "LITHIUM4TABLEMC", @@ -86,6 +92,9 @@ DECLARE_SOA_TABLE(Lithium4TableMC, "AOD", "LITHIUM4TABLEMC", Lithium4TablesNS::He3InnerParamTPC, Lithium4TablesNS::He3NClsTPC, Lithium4TablesNS::He3NSigmaTPC, + Lithium4TablesNS::PrNSigmaTPC, + Lithium4TablesNS::He3MassTOF, + Lithium4TablesNS::PrMassTOF, Lithium4TablesNS::IsBkgLS, Lithium4TablesNS::IsBkgEM, Lithium4TablesNS::SignedPtMC, diff --git a/PWGLF/TableProducer/lithium4analysis.cxx b/PWGLF/TableProducer/lithium4analysis.cxx index 6d0a31d5f4f..aacf7eaf58e 100644 --- a/PWGLF/TableProducer/lithium4analysis.cxx +++ b/PWGLF/TableProducer/lithium4analysis.cxx @@ -26,6 +26,9 @@ #include #include +#include "Common/Core/PID/PIDTOF.h" +#include "Common/TableProducer/PID/pidTOFBase.h" + #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" @@ -55,7 +58,6 @@ 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"}; -static const std::vector particleNames{"He3"}; constexpr float he3Mass = o2::constants::physics::MassHelium3; constexpr float protonMass = o2::constants::physics::MassProton; @@ -78,6 +80,10 @@ struct lithium4Candidate { std::array momPr; float nSigmaHe3 = -10; + float nSigmaPr = -10; + float massTOFHe3 = -10; + float massTOFPr = -10; + float he3DCAXY = -10; float he3DCAZ = -10; float protonDCAXY = -10; @@ -118,7 +124,7 @@ struct lithium4analysis { // bethe bloch parameters std::array mBBparamsHe; - Configurable> cfgBetheBlochParams{"cfgBetheBlochParams", {betheBlochDefault[0], 1, 6, particleNames, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for He3"}; + Configurable> cfgBetheBlochParams{"cfgBetheBlochParams", {betheBlochDefault[0], 1, 6, {"He3"}, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for He3"}; // MC Configurable isMC{"isMC", false, "Run MC"}; void init(o2::framework::InitContext&) @@ -192,7 +198,7 @@ struct lithium4analysis { } template - bool FillCandidateInfo(const T1& candidateHe3, const T2& candidatePr, bool mix) + bool FillCandidateInfo(const T1& candidateHe3, const T2& candidatePr, bool mix, bool isMC = false) { lithium4Candidate l4Cand; @@ -222,6 +228,8 @@ struct lithium4analysis { l4Cand.momHe3TPC = candidateHe3.tpcInnerParam(); l4Cand.nTPCClustersHe3 = candidateHe3.tpcNClsFound(); l4Cand.nSigmaHe3 = computeNSigmaHe3(candidateHe3); + l4Cand.nSigmaPr = candidatePr.tpcNSigmaPr(); + l4Candidates.push_back(l4Cand); return true; } @@ -231,8 +239,10 @@ struct lithium4analysis { Filter DCAcutFilter = (nabs(aod::track::dcaXY) < cfgCutDCAxy) && (nabs(aod::track::dcaZ) < cfgCutDCAz); using EventCandidates = soa::Filtered>; - using TrackCandidates = soa::Filtered>; - using TrackCandidatesMC = soa::Filtered>; + using TrackCandidates = soa::Filtered>; + using TrackCandidatesMC = soa::Filtered>; + o2::pid::tof::Beta responseBeta; + o2::pid::tof::Beta responseBetaMC; Preslice perCol = aod::track::collisionId; Preslice perColMC = aod::track::collisionId; @@ -277,7 +287,21 @@ struct lithium4analysis { continue; } - FillCandidateInfo(track1, track2, false); + if (!FillCandidateInfo(track1, track2, false)) { + continue; + } + // fill TOF info outside to avoide responseBeta crash + auto& cand = l4Candidates.back(); + if (track1.hasTOF()) { + float beta = responseBeta.GetBeta(track1); + beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked + cand.massTOFHe3 = track1.tpcInnerParam() * 2 * std::sqrt(1.f / (beta * beta) - 1.f); + } + if (track2.hasTOF()) { + float beta = responseBeta.GetBeta(track2); + beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked + cand.massTOFPr = track2.tpcInnerParam() * std::sqrt(1.f / (beta * beta) - 1.f); + } } } } @@ -287,6 +311,7 @@ struct lithium4analysis { l4Cand.recoPtPr(), l4Cand.recoEtaPr(), l4Cand.recoPhiPr(), l4Cand.he3DCAXY, l4Cand.he3DCAZ, l4Cand.protonDCAXY, l4Cand.protonDCAZ, l4Cand.tpcSignalHe3, l4Cand.momHe3TPC, l4Cand.nTPCClustersHe3, l4Cand.nSigmaHe3, + l4Cand.nSigmaPr, l4Cand.massTOFHe3, l4Cand.massTOFPr, l4Cand.isBkgUS, l4Cand.isBkgEM); } } @@ -310,8 +335,35 @@ struct lithium4analysis { if (!selectionTrack(t2)) { continue; } - if ((selectionPIDHe3(t1) && selectionPIDProton(t2)) || (selectionPIDHe3(t2) && selectionPIDProton(t1))) { - FillCandidateInfo(t1, t2, true); + + TrackCandidates::iterator he3Cand, protonCand; + bool passPID = false; + if (selectionPIDHe3(t1) && selectionPIDProton(t2)) { + he3Cand = t1, protonCand = t2; + passPID = true; + }; + if (selectionPIDHe3(t2) && selectionPIDProton(t1)) { + he3Cand = t2, protonCand = t1; + passPID = true; + }; + if (!passPID) { + continue; + } + + if (!FillCandidateInfo(he3Cand, protonCand, false)) { + continue; + } + // fill TOF info outside to avoide responseBeta crash + auto& cand = l4Candidates.back(); + if (he3Cand.hasTOF()) { + float beta = responseBeta.GetBeta(he3Cand); + beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked + cand.massTOFHe3 = he3Cand.tpcInnerParam() * 2 * std::sqrt(1.f / (beta * beta) - 1.f); + } + if (protonCand.hasTOF()) { + float beta = responseBeta.GetBeta(protonCand); + beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked + cand.massTOFPr = protonCand.tpcInnerParam() * std::sqrt(1.f / (beta * beta) - 1.f); } } } @@ -321,6 +373,7 @@ struct lithium4analysis { l4Cand.recoPtPr(), l4Cand.recoEtaPr(), l4Cand.recoPhiPr(), l4Cand.he3DCAXY, l4Cand.he3DCAZ, l4Cand.protonDCAXY, l4Cand.protonDCAZ, l4Cand.tpcSignalHe3, l4Cand.momHe3TPC, l4Cand.nTPCClustersHe3, l4Cand.nSigmaHe3, + l4Cand.nSigmaPr, l4Cand.massTOFHe3, l4Cand.massTOFPr, l4Cand.isBkgUS, l4Cand.isBkgEM); } } @@ -384,9 +437,23 @@ struct lithium4analysis { continue; } - if (!FillCandidateInfo(track1, track2, false)) { + if (!FillCandidateInfo(track1, track2, false, true)) { continue; } + + // fill TOF info outside to avoide responseBeta crash + auto& cand = l4Candidates.back(); + if (track1.hasTOF()) { + float beta = responseBetaMC.GetBeta(track1); + beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked + cand.massTOFHe3 = track1.tpcInnerParam() * 2 * std::sqrt(1.f / (beta * beta) - 1.f); + } + if (track2.hasTOF()) { + float beta = responseBetaMC.GetBeta(track2); + beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked + cand.massTOFPr = track2.tpcInnerParam() * std::sqrt(1.f / (beta * beta) - 1.f); + } + auto& l4Candidate = l4Candidates.back(); l4Candidate.l4PtMC = mothertrack.pt(); double eLit = mctrackHe3.e() + mctrackPr.e(); @@ -439,6 +506,7 @@ struct lithium4analysis { l4Cand.recoPtPr(), l4Cand.recoEtaPr(), l4Cand.recoPhiPr(), l4Cand.he3DCAXY, l4Cand.he3DCAZ, l4Cand.protonDCAXY, l4Cand.protonDCAZ, l4Cand.tpcSignalHe3, l4Cand.momHe3TPC, l4Cand.nTPCClustersHe3, l4Cand.nSigmaHe3, + l4Cand.nSigmaPr, l4Cand.massTOFHe3, l4Cand.massTOFPr, l4Cand.isBkgUS, l4Cand.isBkgEM, l4Cand.l4PtMC, l4Cand.l4MassMC); } From 4abe533e713264a92731177ca7c9fef62ae442f9 Mon Sep 17 00:00:00 2001 From: fmazzasc Date: Wed, 13 Sep 2023 11:47:09 +0200 Subject: [PATCH 5/5] Fix megalinter --- PWGLF/TableProducer/lithium4analysis.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGLF/TableProducer/lithium4analysis.cxx b/PWGLF/TableProducer/lithium4analysis.cxx index aacf7eaf58e..d97a61bcf4d 100644 --- a/PWGLF/TableProducer/lithium4analysis.cxx +++ b/PWGLF/TableProducer/lithium4analysis.cxx @@ -341,11 +341,11 @@ struct lithium4analysis { if (selectionPIDHe3(t1) && selectionPIDProton(t2)) { he3Cand = t1, protonCand = t2; passPID = true; - }; + } if (selectionPIDHe3(t2) && selectionPIDProton(t1)) { he3Cand = t2, protonCand = t1; passPID = true; - }; + } if (!passPID) { continue; }