From 6b824ce53b7225338f33b9b0c3df7d5fdc754e82 Mon Sep 17 00:00:00 2001 From: fchinu Date: Tue, 3 Dec 2024 14:42:25 +0100 Subject: [PATCH 1/3] Add variables and selections to pid studies task --- PWGHF/Tasks/pidStudies.cxx | 111 +++++++++++++++++++++++++++++++------ 1 file changed, 93 insertions(+), 18 deletions(-) diff --git a/PWGHF/Tasks/pidStudies.cxx b/PWGHF/Tasks/pidStudies.cxx index 6b72dc01378..55463ca04b7 100644 --- a/PWGHF/Tasks/pidStudies.cxx +++ b/PWGHF/Tasks/pidStudies.cxx @@ -49,8 +49,12 @@ DECLARE_SOA_COLUMN(MassAntiLambda, massAntiLambda, float); //! Candidate mass DECLARE_SOA_COLUMN(Pt, pt, float); //! Transverse momentum of the candidate (GeV/c) DECLARE_SOA_COLUMN(PtPos, ptPos, float); //! Transverse momentum of positive track (GeV/c) DECLARE_SOA_COLUMN(PtNeg, ptNeg, float); //! Transverse momentum of negative track (GeV/c) +DECLARE_SOA_COLUMN(TPCInnerParPos, tpcInnerParPos, float); //! Momentum of positive track at inner wall of TPC (GeV/c) +DECLARE_SOA_COLUMN(TPCInnerParNeg, tpcInnerParNeg, float); //! Momentum of negative track at inner wall of TPC (GeV/c) DECLARE_SOA_COLUMN(Radius, radius, float); //! Radius DECLARE_SOA_COLUMN(Cpa, cpa, float); //! Cosine of pointing angle +DECLARE_SOA_COLUMN(DCAV0Daughters, dcaV0Daughters, float); //! DCA between V0 daughters +DECLARE_SOA_COLUMN(DCAV0ToPV, dcaV0ToPv, float); //! DCA V0 to PV DECLARE_SOA_COLUMN(NSigmaTpcPosPi, nSigmaTpcPosPi, float); //! nSigmaTPC of positive track with pion hypothesis DECLARE_SOA_COLUMN(NSigmaTpcNegPi, nSigmaTpcNegPi, float); //! nSigmaTPC of negative track with pion hypothesis DECLARE_SOA_COLUMN(NSigmaTpcPosPr, nSigmaTpcPosPr, float); //! nSigmaTPC of positive track with proton hypothesis @@ -66,6 +70,8 @@ DECLARE_SOA_COLUMN(QtArm, qtArm, float); //! Armenteros Qt DECLARE_SOA_COLUMN(MassOmega, massOmega, float); //! Candidate mass DECLARE_SOA_COLUMN(MassXi, massXi, float); //! Candidate mass DECLARE_SOA_COLUMN(BachPt, bachPt, float); //! Transverse momentum of the bachelor (GeV/c) +DECLARE_SOA_COLUMN(TPCInnerParBach, tpcInnerParBach, float); //! Transverse momentum of the bachelor (GeV/c) +DECLARE_SOA_COLUMN(MLambda, mLambda, float); //! Daughter lambda mass (GeV/c^2) DECLARE_SOA_COLUMN(V0cosPA, v0cosPA, float); //! V0 CPA DECLARE_SOA_COLUMN(CascCosPA, casccosPA, float); //! Cascade CPA DECLARE_SOA_COLUMN(DCAV0daughters, dcaV0daughters, float); //! DCA of V0 daughters @@ -88,8 +94,12 @@ DECLARE_SOA_TABLE(PidV0s, "AOD", "PIDV0S", //! Table with PID information pid_studies::Pt, pid_studies::PtPos, pid_studies::PtNeg, + pid_studies::TPCInnerParPos, + pid_studies::TPCInnerParNeg, pid_studies::Radius, pid_studies::Cpa, + pid_studies::DCAV0Daughters, + pid_studies::DCAV0ToPV, pid_studies::NSigmaTpcPosPi, pid_studies::NSigmaTpcNegPi, pid_studies::NSigmaTpcPosPr, @@ -110,6 +120,8 @@ DECLARE_SOA_TABLE(PidCascades, "AOD", "PIDCASCADES", //! Table with PID informat pid_studies::MassOmega, pid_studies::Pt, pid_studies::BachPt, + pid_studies::TPCInnerParBach, + pid_studies::MLambda, pid_studies::V0cosPA, pid_studies::MassXi, pid_studies::CascCosPA, @@ -134,6 +146,8 @@ struct HfPidStudies { Configurable massLambdaMax{"massLambdaMax", 1.3, "Maximum mass for lambda"}; Configurable massOmegaMin{"massOmegaMin", 1.5, "Minimum mass for omega"}; Configurable massOmegaMax{"massOmegaMax", 1.8, "Maximum mass for omega"}; + Configurable qtArmenterosMinForK0{"qtArmenterosMinForK0", 0.12, "Minimum Armenteros' qt for K0"}; + Configurable qtArmenterosMaxForLambda{"qtArmenterosMaxForLambda", 0.12, "Minimum Armenteros' qt for (anti)Lambda"}; Configurable downSampleBkgFactor{"downSampleBkgFactor", 1., "Fraction of candidates to keep"}; Configurable ptMaxForDownSample{"ptMaxForDownSample", 10., "Maximum pt for the application of the downsampling factor"}; @@ -144,6 +158,13 @@ struct HfPidStudies { using V0sMcRec = soa::Join; using CascsMcRec = soa::Join; + void init(InitContext&) + { + if ((doprocessV0Mc && doprocessV0Data) || (doprocessCascMc && doprocessCascData)) { + LOGP(fatal, "Both data and MC process functions were enabled! Please check your configuration!"); + } + } + template void fillTree(Cand const& candidate, const int flag) { @@ -163,8 +184,12 @@ struct HfPidStudies { candidate.pt(), posTrack.pt(), negTrack.pt(), + posTrack.tpcInnerParam(), + negTrack.tpcInnerParam(), candidate.v0radius(), candidate.v0cosPA(), + candidate.dcaV0daughters(), + candidate.dcav0topv(), posTrack.tofNSigmaPi(), negTrack.tofNSigmaPi(), posTrack.tofNSigmaPr(), @@ -186,6 +211,8 @@ struct HfPidStudies { candidate.mOmega(), candidate.pt(), candidate.bachelorpt(), + bachTrack.tpcInnerParam(), + candidate.mLambda(), candidate.v0cosPA(coll.posX(), coll.posY(), coll.posZ()), candidate.mXi(), candidate.casccosPA(coll.posX(), coll.posY(), coll.posZ()), @@ -242,25 +269,78 @@ struct HfPidStudies { return aod::pid_studies::Particle::NotMatched; } - void processMc(V0sMcRec const& V0s, + template + bool isSelectedV0AsK0s(const V0Cand& v0) + { + if (v0.mK0Short() < massK0Min || v0.mK0Short() > massK0Max) { + return false; + } + if (v0.qtarm() < qtArmenterosMinForK0) { + return false; + } + return true; + } + + template + bool isSelectedV0AsLambda(const V0Cand& v0) + { + if ((v0.mLambda() < massLambdaMin || v0.mLambda() > massLambdaMax) && + (v0.mAntiLambda() < massLambdaMin || v0.mAntiLambda() > massLambdaMax)) { + return false; + } + if (v0.qtarm() > qtArmenterosMaxForLambda) { + return false; + } + return true; + } + + template + bool isSelectedCascAsOmega(const CascCand& casc) + { + if (casc.mOmega() < massOmegaMin || casc.mOmega() > massOmegaMax) { + return false; + } + if (casc.mLambda() < massLambdaMin || casc.mLambda() > massLambdaMax) { + return false; + } + return true; + } + + void processV0Mc(V0sMcRec const& V0s, aod::V0MCCores const&, - CascsMcRec const& cascades, - aod::CascMCCores const&, CollSels const&, PidTracks const&) { for (const auto& v0 : V0s) { - if ((v0.mK0Short() > massK0Min && v0.mK0Short() < massK0Max) || - (v0.mLambda() > massLambdaMin && v0.mLambda() < massLambdaMax) || - (v0.mAntiLambda() > massLambdaMin && v0.mAntiLambda() < massLambdaMax)) { + if (isSelectedV0AsK0s(v0) || isSelectedV0AsLambda(v0)) { int matched = isMatched(v0); if (matched != aod::pid_studies::Particle::NotMatched) { fillTree(v0, matched); } } } + } + PROCESS_SWITCH(HfPidStudies, processV0Mc, "Process MC", true); + + void processV0Data(aod::V0Datas const& V0s, + CollSels const&, + PidTracks const&) + { + for (const auto& v0 : V0s) { + if (isSelectedV0AsK0s(v0) || isSelectedV0AsLambda(v0)) { + fillTree(v0, aod::pid_studies::Particle::NotMatched); + } + } + } + PROCESS_SWITCH(HfPidStudies, processV0Data, "Process data", false); + + void processCascMc(CascsMcRec const& cascades, + aod::CascMCCores const&, + CollSels const&, + PidTracks const&) + { for (const auto& casc : cascades) { - if (casc.mOmega() > massOmegaMin && casc.mOmega() < massOmegaMax && casc.mLambda() > massLambdaMin && casc.mLambda() < massLambdaMax) { + if (isSelectedCascAsOmega(casc)) { int matched = isMatched(casc); if (matched != aod::pid_studies::Particle::NotMatched) { fillTree(casc, matched); @@ -268,24 +348,19 @@ struct HfPidStudies { } } } - PROCESS_SWITCH(HfPidStudies, processMc, "Process MC", true); + PROCESS_SWITCH(HfPidStudies, processCascMc, "Process MC", true); - void processData(aod::V0Datas const& V0s, aod::CascDatas const& cascades, CollSels const&, PidTracks const&) + void processCascData(aod::CascDatas const& cascades, + CollSels const&, + PidTracks const&) { - for (const auto& v0 : V0s) { - if ((v0.mK0Short() > massK0Min && v0.mK0Short() < massK0Max) || - (v0.mLambda() > massLambdaMin && v0.mLambda() < massLambdaMax) || - (v0.mAntiLambda() > massLambdaMin && v0.mAntiLambda() < massLambdaMax)) { - fillTree(v0, aod::pid_studies::Particle::NotMatched); - } - } for (const auto& casc : cascades) { - if (casc.mOmega() > massOmegaMin && casc.mOmega() < massOmegaMax && casc.mLambda() > massLambdaMin && casc.mLambda() < massLambdaMax) { + if (isSelectedCascAsOmega(casc)) { fillTree(casc, aod::pid_studies::Particle::NotMatched); } } } - PROCESS_SWITCH(HfPidStudies, processData, "Process data", false); + PROCESS_SWITCH(HfPidStudies, processCascData, "Process data", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) From b362ad3be29e0a59f537aa374a7926685fb411fe Mon Sep 17 00:00:00 2001 From: fchinu Date: Wed, 4 Dec 2024 09:21:57 +0100 Subject: [PATCH 2/3] Fix format & linter --- PWGHF/Tasks/CMakeLists.txt | 10 ++-- .../{pidStudies.cxx => taskPidStudies.cxx} | 52 +++++++++---------- 2 files changed, 31 insertions(+), 31 deletions(-) rename PWGHF/Tasks/{pidStudies.cxx => taskPidStudies.cxx} (91%) diff --git a/PWGHF/Tasks/CMakeLists.txt b/PWGHF/Tasks/CMakeLists.txt index 888961a70de..9a46eeba773 100644 --- a/PWGHF/Tasks/CMakeLists.txt +++ b/PWGHF/Tasks/CMakeLists.txt @@ -44,12 +44,12 @@ o2physics_add_dpl_workflow(task-multiplicity-estimator-correlation PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(task-pid-studies + SOURCES taskPidStudies.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + # o2physics_add_dpl_workflow(task-sel-optimisation # SOURCES taskSelOptimisation.cxx # PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore # COMPONENT_NAME Analysis) - -o2physics_add_dpl_workflow(pid-studies - SOURCES pidStudies.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore - COMPONENT_NAME Analysis) diff --git a/PWGHF/Tasks/pidStudies.cxx b/PWGHF/Tasks/taskPidStudies.cxx similarity index 91% rename from PWGHF/Tasks/pidStudies.cxx rename to PWGHF/Tasks/taskPidStudies.cxx index 55463ca04b7..ca658f92aef 100644 --- a/PWGHF/Tasks/pidStudies.cxx +++ b/PWGHF/Tasks/taskPidStudies.cxx @@ -9,7 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file pidStudies.cxx +/// \file taskPidStudies.cxx /// \brief task for studies of PID performance /// /// \author Fabrizio Chinu , Università and INFN Torino @@ -49,12 +49,12 @@ DECLARE_SOA_COLUMN(MassAntiLambda, massAntiLambda, float); //! Candidate mass DECLARE_SOA_COLUMN(Pt, pt, float); //! Transverse momentum of the candidate (GeV/c) DECLARE_SOA_COLUMN(PtPos, ptPos, float); //! Transverse momentum of positive track (GeV/c) DECLARE_SOA_COLUMN(PtNeg, ptNeg, float); //! Transverse momentum of negative track (GeV/c) -DECLARE_SOA_COLUMN(TPCInnerParPos, tpcInnerParPos, float); //! Momentum of positive track at inner wall of TPC (GeV/c) -DECLARE_SOA_COLUMN(TPCInnerParNeg, tpcInnerParNeg, float); //! Momentum of negative track at inner wall of TPC (GeV/c) +DECLARE_SOA_COLUMN(TpcInnerParPos, tpcInnerParPos, float); //! Momentum of positive track at inner wall of TPC (GeV/c) +DECLARE_SOA_COLUMN(TpcInnerParNeg, tpcInnerParNeg, float); //! Momentum of negative track at inner wall of TPC (GeV/c) DECLARE_SOA_COLUMN(Radius, radius, float); //! Radius DECLARE_SOA_COLUMN(Cpa, cpa, float); //! Cosine of pointing angle -DECLARE_SOA_COLUMN(DCAV0Daughters, dcaV0Daughters, float); //! DCA between V0 daughters -DECLARE_SOA_COLUMN(DCAV0ToPV, dcaV0ToPv, float); //! DCA V0 to PV +DECLARE_SOA_COLUMN(DcaV0Daughters, dcaV0Daughters, float); //! DCA between V0 daughters +DECLARE_SOA_COLUMN(DcaV0ToPv, dcaV0ToPv, float); //! DCA V0 to PV DECLARE_SOA_COLUMN(NSigmaTpcPosPi, nSigmaTpcPosPi, float); //! nSigmaTPC of positive track with pion hypothesis DECLARE_SOA_COLUMN(NSigmaTpcNegPi, nSigmaTpcNegPi, float); //! nSigmaTPC of negative track with pion hypothesis DECLARE_SOA_COLUMN(NSigmaTpcPosPr, nSigmaTpcPosPr, float); //! nSigmaTPC of positive track with proton hypothesis @@ -70,12 +70,12 @@ DECLARE_SOA_COLUMN(QtArm, qtArm, float); //! Armenteros Qt DECLARE_SOA_COLUMN(MassOmega, massOmega, float); //! Candidate mass DECLARE_SOA_COLUMN(MassXi, massXi, float); //! Candidate mass DECLARE_SOA_COLUMN(BachPt, bachPt, float); //! Transverse momentum of the bachelor (GeV/c) -DECLARE_SOA_COLUMN(TPCInnerParBach, tpcInnerParBach, float); //! Transverse momentum of the bachelor (GeV/c) +DECLARE_SOA_COLUMN(TpcInnerParBach, tpcInnerParBach, float); //! Transverse momentum of the bachelor (GeV/c) DECLARE_SOA_COLUMN(MLambda, mLambda, float); //! Daughter lambda mass (GeV/c^2) DECLARE_SOA_COLUMN(V0cosPA, v0cosPA, float); //! V0 CPA -DECLARE_SOA_COLUMN(CascCosPA, casccosPA, float); //! Cascade CPA -DECLARE_SOA_COLUMN(DCAV0daughters, dcaV0daughters, float); //! DCA of V0 daughters -DECLARE_SOA_COLUMN(DCAv0topv, dcav0topv, float); //! V0 DCA to PV +DECLARE_SOA_COLUMN(CascCosPa, cascCosPa, float); //! Cascade CPA +DECLARE_SOA_COLUMN(DcaV0daughters, dcaV0daughters, float); //! DCA of V0 daughters +DECLARE_SOA_COLUMN(Dcav0topv, dcav0topv, float); //! V0 DCA to PV DECLARE_SOA_COLUMN(NSigmaTpcBachKa, nSigmaTpcBachKa, float); //! nSigmaTPC of bachelor with kaon hypothesis DECLARE_SOA_COLUMN(NSigmaTofBachKa, nSigmaTofBachKa, float); //! nSigmaTOF of bachelor with kaon hypothesis @@ -94,12 +94,12 @@ DECLARE_SOA_TABLE(PidV0s, "AOD", "PIDV0S", //! Table with PID information pid_studies::Pt, pid_studies::PtPos, pid_studies::PtNeg, - pid_studies::TPCInnerParPos, - pid_studies::TPCInnerParNeg, + pid_studies::TpcInnerParPos, + pid_studies::TpcInnerParNeg, pid_studies::Radius, pid_studies::Cpa, - pid_studies::DCAV0Daughters, - pid_studies::DCAV0ToPV, + pid_studies::DcaV0Daughters, + pid_studies::DcaV0ToPv, pid_studies::NSigmaTpcPosPi, pid_studies::NSigmaTpcNegPi, pid_studies::NSigmaTpcPosPr, @@ -120,13 +120,13 @@ DECLARE_SOA_TABLE(PidCascades, "AOD", "PIDCASCADES", //! Table with PID informat pid_studies::MassOmega, pid_studies::Pt, pid_studies::BachPt, - pid_studies::TPCInnerParBach, + pid_studies::TpcInnerParBach, pid_studies::MLambda, pid_studies::V0cosPA, pid_studies::MassXi, - pid_studies::CascCosPA, - pid_studies::DCAV0daughters, - pid_studies::DCAv0topv, + pid_studies::CascCosPa, + pid_studies::DcaV0daughters, + pid_studies::Dcav0topv, pid_studies::NSigmaTpcBachKa, pid_studies::NSigmaTofBachKa, pid_studies::OccupancyFt0c, @@ -136,7 +136,7 @@ DECLARE_SOA_TABLE(PidCascades, "AOD", "PIDCASCADES", //! Table with PID informat pid_studies::CandFlag); } // namespace o2::aod -struct HfPidStudies { +struct HfTaskPidStudies { Produces pidV0; Produces pidCascade; @@ -307,9 +307,9 @@ struct HfPidStudies { } void processV0Mc(V0sMcRec const& V0s, - aod::V0MCCores const&, - CollSels const&, - PidTracks const&) + aod::V0MCCores const&, + CollSels const&, + PidTracks const&) { for (const auto& v0 : V0s) { if (isSelectedV0AsK0s(v0) || isSelectedV0AsLambda(v0)) { @@ -320,7 +320,7 @@ struct HfPidStudies { } } } - PROCESS_SWITCH(HfPidStudies, processV0Mc, "Process MC", true); + PROCESS_SWITCH(HfTaskPidStudies, processV0Mc, "Process MC", true); void processV0Data(aod::V0Datas const& V0s, CollSels const&, @@ -332,7 +332,7 @@ struct HfPidStudies { } } } - PROCESS_SWITCH(HfPidStudies, processV0Data, "Process data", false); + PROCESS_SWITCH(HfTaskPidStudies, processV0Data, "Process data", false); void processCascMc(CascsMcRec const& cascades, aod::CascMCCores const&, @@ -348,7 +348,7 @@ struct HfPidStudies { } } } - PROCESS_SWITCH(HfPidStudies, processCascMc, "Process MC", true); + PROCESS_SWITCH(HfTaskPidStudies, processCascMc, "Process MC", true); void processCascData(aod::CascDatas const& cascades, CollSels const&, @@ -360,10 +360,10 @@ struct HfPidStudies { } } } - PROCESS_SWITCH(HfPidStudies, processCascData, "Process data", false); + PROCESS_SWITCH(HfTaskPidStudies, processCascData, "Process data", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc)}; + return WorkflowSpec{adaptAnalysisTask(cfgc)}; } From 690bcca3a438eda6ec4e25053083d83a679a4067 Mon Sep 17 00:00:00 2001 From: fchinu Date: Wed, 4 Dec 2024 10:29:15 +0100 Subject: [PATCH 3/3] Implement Vit's comment --- PWGHF/Tasks/taskPidStudies.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/PWGHF/Tasks/taskPidStudies.cxx b/PWGHF/Tasks/taskPidStudies.cxx index ca658f92aef..8516963bafc 100644 --- a/PWGHF/Tasks/taskPidStudies.cxx +++ b/PWGHF/Tasks/taskPidStudies.cxx @@ -74,8 +74,6 @@ DECLARE_SOA_COLUMN(TpcInnerParBach, tpcInnerParBach, float); //! Transverse mome DECLARE_SOA_COLUMN(MLambda, mLambda, float); //! Daughter lambda mass (GeV/c^2) DECLARE_SOA_COLUMN(V0cosPA, v0cosPA, float); //! V0 CPA DECLARE_SOA_COLUMN(CascCosPa, cascCosPa, float); //! Cascade CPA -DECLARE_SOA_COLUMN(DcaV0daughters, dcaV0daughters, float); //! DCA of V0 daughters -DECLARE_SOA_COLUMN(Dcav0topv, dcav0topv, float); //! V0 DCA to PV DECLARE_SOA_COLUMN(NSigmaTpcBachKa, nSigmaTpcBachKa, float); //! nSigmaTPC of bachelor with kaon hypothesis DECLARE_SOA_COLUMN(NSigmaTofBachKa, nSigmaTofBachKa, float); //! nSigmaTOF of bachelor with kaon hypothesis @@ -125,8 +123,8 @@ DECLARE_SOA_TABLE(PidCascades, "AOD", "PIDCASCADES", //! Table with PID informat pid_studies::V0cosPA, pid_studies::MassXi, pid_studies::CascCosPa, - pid_studies::DcaV0daughters, - pid_studies::Dcav0topv, + pid_studies::DcaV0Daughters, + pid_studies::DcaV0ToPv, pid_studies::NSigmaTpcBachKa, pid_studies::NSigmaTofBachKa, pid_studies::OccupancyFt0c,