From 5720f82e0b2d2b1400d5b5b1e13ede5a57c0dc83 Mon Sep 17 00:00:00 2001 From: ddobrigk Date: Tue, 4 Nov 2025 16:05:26 +0100 Subject: [PATCH 1/2] [PWGLF] StraTOF: Addition of hasTOF functionality --- PWGLF/DataModel/LFStrangenessPIDTables.h | 60 +++++++++++++++++++ .../Strangeness/strangenesstofpid.cxx | 30 ++++++---- 2 files changed, 80 insertions(+), 10 deletions(-) diff --git a/PWGLF/DataModel/LFStrangenessPIDTables.h b/PWGLF/DataModel/LFStrangenessPIDTables.h index b157097a605..d5cd42dd60a 100644 --- a/PWGLF/DataModel/LFStrangenessPIDTables.h +++ b/PWGLF/DataModel/LFStrangenessPIDTables.h @@ -9,8 +9,16 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +//********************************************************************** // Defines TOF PID tables for strangeness. // Entries calculated per candidate, tables are joinable with v0/cascdata tables. +//********************************************************************** + +//********************************************************************** +// Nota bene: when using, do not check track.hasTOF! That conditional may not match +// the calculation of strangeness TOF, which requires e.g. a successful calculation +// of the collision time for the reassociated collision +//********************************************************************** #ifndef PWGLF_DATAMODEL_LFSTRANGENESSPIDTABLES_H_ #define PWGLF_DATAMODEL_LFSTRANGENESSPIDTABLES_H_ @@ -203,6 +211,25 @@ DECLARE_SOA_COLUMN(TOFNSigmaALaPi, tofNSigmaALaPi, float); //! positive DECLARE_SOA_COLUMN(TOFNSigmaK0PiPlus, tofNSigmaK0PiPlus, float); //! positive track NSigma from pion <- k0short expectation DECLARE_SOA_COLUMN(TOFNSigmaK0PiMinus, tofNSigmaK0PiMinus, float); //! negative track NSigma from pion <- k0short expectation +// dynamics to replace hasTOF (note: that condition does not match track hasTOF!) +// note: only single hypothesis check necessary; other hypotheses will always be valid +DECLARE_SOA_DYNAMIC_COLUMN(PositiveHasTOF, positiveHasTOF, //! positive daughter TOF calculation valid + [](float TOFNSigmaLaPr) -> bool { + bool returnStatus = true; + if(std::abs(TOFNSigmaLaPr - kNoTOFValue) < kEpsilon){ + returnStatus = false; + } + return returnStatus; + }); +DECLARE_SOA_DYNAMIC_COLUMN(NegativeHasTOF, negativeHasTOF, //! negative daughter TOF calculation valid + [](float TOFNSigmaALaPr) -> bool { + bool returnStatus = true; + if(std::abs(TOFNSigmaALaPr - kNoTOFValue) < kEpsilon){ + returnStatus = false; + } + return returnStatus; + }); + // dynamics based on n-sigmas with use-only-if-tof-present logic DECLARE_SOA_DYNAMIC_COLUMN(TofLambdaCompatibility, tofLambdaCompatibility, //! compatibility with being lambda, checked only if TOF present. Argument: number of sigmas [](float tofNSigmaLaPr, float tofNSigmaLaPi, float nsigma) -> float { @@ -284,6 +311,8 @@ DECLARE_SOA_TABLE(V0TOFNSigmas, "AOD", "V0TOFNSIGMA", // processed NSigma table v0data::TOFNSigmaLaPr, v0data::TOFNSigmaLaPi, v0data::TOFNSigmaALaPr, v0data::TOFNSigmaALaPi, v0data::TOFNSigmaK0PiPlus, v0data::TOFNSigmaK0PiMinus, + v0data::PositiveHasTOF, + v0data::NegativeHasTOF, v0data::TofLambdaCompatibility, v0data::TofAntiLambdaCompatibility, v0data::TofK0ShortCompatibility); @@ -325,6 +354,34 @@ DECLARE_SOA_COLUMN(TOFNSigmaOmLaPi, tofNSigmaOmLaPi, float); //! meson track NSi DECLARE_SOA_COLUMN(TOFNSigmaOmLaPr, tofNSigmaOmLaPr, float); //! baryon track NSigma from proton <- lambda <- om expectation DECLARE_SOA_COLUMN(TOFNSigmaOmKa, tofNSigmaOmKa, float); //! bachelor track NSigma from kaon <- om expectation +// dynamics to replace hasTOF (note: that condition does not match track hasTOF!) +// note: only single hypothesis check necessary; other hypotheses will always be valid +DECLARE_SOA_DYNAMIC_COLUMN(PositiveHasTOF, positiveHasTOF, //! positive daughter TOF calculation valid + [](float PosTOFDeltaTXiPr) -> bool { + bool returnStatus = true; + if(std::abs(PosTOFDeltaTXiPr - kNoTOFValue) < kEpsilon){ + returnStatus = false; + } + return returnStatus; + }); +DECLARE_SOA_DYNAMIC_COLUMN(NegativeHasTOF, negativeHasTOF, //! positive daughter TOF calculation valid + [](float NegTOFDeltaTXiPr) -> bool { + bool returnStatus = true; + if(std::abs(NegTOFDeltaTXiPr - kNoTOFValue) < kEpsilon){ + returnStatus = false; + } + return returnStatus; + }); +DECLARE_SOA_DYNAMIC_COLUMN(BachelorHasTOF, bachelorHasTOF, //! bachelor daughter TOF calculation valid + [](float BachTOFDeltaTXiPi) -> bool { + bool returnStatus = true; + if(std::abs(BachTOFDeltaTXiPi - kNoTOFValue) < kEpsilon){ + returnStatus = false; + } + return returnStatus; + }); + + // dynamics based on n-sigmas with use-only-if-tof-present logic DECLARE_SOA_DYNAMIC_COLUMN(TofXiCompatibility, tofXiCompatibility, //! compatibility with being lambda, checked only if TOF present. Argument: number of sigmas [](float tofNSigmaXiLaPr, float tofNSigmaXiLaPi, float tofNSigmaXiPi, float nsigma) -> float { @@ -376,6 +433,9 @@ DECLARE_SOA_TABLE(CascTOFPIDs, "AOD", "CASCTOFPID", // processed information for DECLARE_SOA_TABLE(CascTOFNSigmas, "AOD", "CascTOFNSigmas", // Nsigmas for cascades cascdata::TOFNSigmaXiLaPi, cascdata::TOFNSigmaXiLaPr, cascdata::TOFNSigmaXiPi, cascdata::TOFNSigmaOmLaPi, cascdata::TOFNSigmaOmLaPr, cascdata::TOFNSigmaOmKa, + cascdata::PositiveHasTOF, + cascdata::NegativeHasTOF, + cascdata::BachelorHasTOF, cascdata::TofXiCompatibility, cascdata::TofOmegaCompatibility); } // namespace o2::aod diff --git a/PWGLF/TableProducer/Strangeness/strangenesstofpid.cxx b/PWGLF/TableProducer/Strangeness/strangenesstofpid.cxx index b02ef7b584a..3fe70d9db6c 100644 --- a/PWGLF/TableProducer/Strangeness/strangenesstofpid.cxx +++ b/PWGLF/TableProducer/Strangeness/strangenesstofpid.cxx @@ -804,7 +804,7 @@ struct strangenesstofpid { float velocityPositivePr, velocityPositivePi, lengthPositive; velocityPositivePr = velocityPositivePi = lengthPositive = o2::aod::v0data::kNoTOFValue; - if (pTof.hasTOF && pTof.hasITS && pTof.tofEvTime > -1e+5 && pValidTOF) { + if (pTof.hasTOF && pTof.tofEvTime > -1e+5 && pValidTOF) { // method 0: legacy standalone without use of primary particle TOF if (calculationMethod.value == 0) { velocityPositivePr = velocity(posTrack.getP(), o2::constants::physics::MassProton); @@ -823,7 +823,9 @@ struct strangenesstofpid { const o2::math_utils::Point3D trackVertex{trackCollision.posX(), trackCollision.posY(), trackCollision.posZ()}; o2::track::TrackLTIntegral ltIntegral; bool successPropag = o2::base::Propagator::Instance()->propagateToDCA(trackVertex, posTrack, d_bz, 2.f, o2::base::Propagator::MatCorrType::USEMatCorrNONE, nullptr, <Integral); - histos.fill(HIST("hPropagationBookkeeping"), kPropagPosV0, static_cast(successPropag)); + if(doQA){ + histos.fill(HIST("hPropagationBookkeeping"), kPropagPosV0, static_cast(successPropag)); + } if (successPropag) { lengthPositive = pTof.length - ltIntegral.getL(); v0tof.timePositivePr = o2::framework::pid::tof::MassToExpTime(pTof.tofExpMom, lengthPositive, o2::constants::physics::MassProton * o2::constants::physics::MassProton); @@ -880,7 +882,7 @@ struct strangenesstofpid { } float velocityNegativePr, velocityNegativePi, lengthNegative; velocityNegativePr = velocityNegativePi = lengthNegative = o2::aod::v0data::kNoTOFValue; - if (nTof.hasTOF && nTof.hasITS && nTof.tofEvTime > -1e+5 && nValidTOF) { + if (nTof.hasTOF && nTof.tofEvTime > -1e+5 && nValidTOF) { // method 0: legacy standalone without use of primary particle TOF if (calculationMethod.value == 0) { velocityNegativePr = velocity(negTrack.getP(), o2::constants::physics::MassProton); @@ -899,7 +901,9 @@ struct strangenesstofpid { const o2::math_utils::Point3D trackVertex{trackCollision.posX(), trackCollision.posY(), trackCollision.posZ()}; o2::track::TrackLTIntegral ltIntegral; bool successPropag = o2::base::Propagator::Instance()->propagateToDCA(trackVertex, negTrack, d_bz, 2.f, o2::base::Propagator::MatCorrType::USEMatCorrNONE, nullptr, <Integral); - histos.fill(HIST("hPropagationBookkeeping"), kPropagNegV0, static_cast(successPropag)); + if(doQA){ + histos.fill(HIST("hPropagationBookkeeping"), kPropagNegV0, static_cast(successPropag)); + } if (successPropag) { lengthNegative = nTof.length - ltIntegral.getL(); v0tof.timeNegativePr = o2::framework::pid::tof::MassToExpTime(nTof.tofExpMom, lengthNegative, o2::constants::physics::MassProton * o2::constants::physics::MassProton); @@ -1072,7 +1076,7 @@ struct strangenesstofpid { //_____________________________________________________________________________________________ // Actual calculation - if (pTof.hasTOF && pTof.hasITS && pTof.tofEvTime > -1e+5 && pValidTOF) { + if (pTof.hasTOF && pTof.tofEvTime > -1e+5 && pValidTOF) { float velocityPositivePr, velocityPositivePi, lengthPositive; velocityPositivePr = velocityPositivePi = lengthPositive = o2::aod::v0data::kNoTOFValue; if (calculationMethod.value == 0) { @@ -1092,7 +1096,9 @@ struct strangenesstofpid { const o2::math_utils::Point3D trackVertex{trackCollision.posX(), trackCollision.posY(), trackCollision.posZ()}; o2::track::TrackLTIntegral ltIntegral; bool successPropag = o2::base::Propagator::Instance()->propagateToDCA(trackVertex, posTrack, d_bz, 2.f, o2::base::Propagator::MatCorrType::USEMatCorrNONE, nullptr, <Integral); - histos.fill(HIST("hPropagationBookkeeping"), kPropagPosCasc, static_cast(successPropag)); + if(doQA){ + histos.fill(HIST("hPropagationBookkeeping"), kPropagPosCasc, static_cast(successPropag)); + } if (successPropag) { lengthPositive = pTof.length - ltIntegral.getL(); casctof.posFlightPr = o2::framework::pid::tof::MassToExpTime(pTof.tofExpMom, pTof.length - ltIntegral.getL(), o2::constants::physics::MassProton * o2::constants::physics::MassProton); @@ -1161,7 +1167,7 @@ struct strangenesstofpid { } } // end positive - if (nTof.hasTOF && nTof.hasITS && nTof.tofEvTime > -1e+5 && nValidTOF) { + if (nTof.hasTOF && nTof.tofEvTime > -1e+5 && nValidTOF) { float velocityNegativePr, velocityNegativePi, lengthNegative; velocityNegativePr = velocityNegativePi = lengthNegative = o2::aod::v0data::kNoTOFValue; // method 0: legacy standalone without use of primary particle TOF @@ -1182,7 +1188,9 @@ struct strangenesstofpid { const o2::math_utils::Point3D trackVertex{trackCollision.posX(), trackCollision.posY(), trackCollision.posZ()}; o2::track::TrackLTIntegral ltIntegral; bool successPropag = o2::base::Propagator::Instance()->propagateToDCA(trackVertex, negTrack, d_bz, 2.f, o2::base::Propagator::MatCorrType::USEMatCorrNONE, nullptr, <Integral); - histos.fill(HIST("hPropagationBookkeeping"), kPropagNegCasc, static_cast(successPropag)); + if(doQA){ + histos.fill(HIST("hPropagationBookkeeping"), kPropagNegCasc, static_cast(successPropag)); + } if (successPropag) { lengthNegative = nTof.length - ltIntegral.getL(); casctof.negFlightPr = o2::framework::pid::tof::MassToExpTime(nTof.tofExpMom, nTof.length - ltIntegral.getL(), o2::constants::physics::MassProton * o2::constants::physics::MassProton); @@ -1251,7 +1259,7 @@ struct strangenesstofpid { } } // end negative - if (bTof.hasTOF && bTof.hasITS && bTof.tofEvTime > -1e+5 && bValidTOF) { + if (bTof.hasTOF && bTof.tofEvTime > -1e+5 && bValidTOF) { float velocityBachelorKa, velocityBachelorPi, lengthBachelor; velocityBachelorKa = velocityBachelorPi = lengthBachelor = o2::aod::v0data::kNoTOFValue; // method 0: legacy standalone without use of primary particle TOF @@ -1272,7 +1280,9 @@ struct strangenesstofpid { const o2::math_utils::Point3D trackVertex{trackCollision.posX(), trackCollision.posY(), trackCollision.posZ()}; o2::track::TrackLTIntegral ltIntegral; bool successPropag = o2::base::Propagator::Instance()->propagateToDCA(trackVertex, bachTrack, d_bz, 2.f, o2::base::Propagator::MatCorrType::USEMatCorrNONE, nullptr, <Integral); - histos.fill(HIST("hPropagationBookkeeping"), kPropagBachCasc, static_cast(successPropag)); + if(doQA){ + histos.fill(HIST("hPropagationBookkeeping"), kPropagBachCasc, static_cast(successPropag)); + } if (successPropag) { lengthBachelor = bTof.length - ltIntegral.getL(); casctof.bachFlightPi = o2::framework::pid::tof::MassToExpTime(bTof.tofExpMom, bTof.length - ltIntegral.getL(), o2::constants::physics::MassPionCharged * o2::constants::physics::MassPionCharged); From f893a0ae7739ff351ee29b12b828d373881c1b9e Mon Sep 17 00:00:00 2001 From: ALICE Builder Date: Tue, 4 Nov 2025 16:13:41 +0100 Subject: [PATCH 2/2] Please consider the following formatting changes (#493) --- PWGLF/DataModel/LFStrangenessPIDTables.h | 65 +++++++++---------- .../Strangeness/strangenesstofpid.cxx | 10 +-- 2 files changed, 37 insertions(+), 38 deletions(-) diff --git a/PWGLF/DataModel/LFStrangenessPIDTables.h b/PWGLF/DataModel/LFStrangenessPIDTables.h index d5cd42dd60a..c815ece9653 100644 --- a/PWGLF/DataModel/LFStrangenessPIDTables.h +++ b/PWGLF/DataModel/LFStrangenessPIDTables.h @@ -15,8 +15,8 @@ //********************************************************************** //********************************************************************** -// Nota bene: when using, do not check track.hasTOF! That conditional may not match -// the calculation of strangeness TOF, which requires e.g. a successful calculation +// Nota bene: when using, do not check track.hasTOF! That conditional may not match +// the calculation of strangeness TOF, which requires e.g. a successful calculation // of the collision time for the reassociated collision //********************************************************************** @@ -213,21 +213,21 @@ DECLARE_SOA_COLUMN(TOFNSigmaK0PiMinus, tofNSigmaK0PiMinus, float); //! negative // dynamics to replace hasTOF (note: that condition does not match track hasTOF!) // note: only single hypothesis check necessary; other hypotheses will always be valid -DECLARE_SOA_DYNAMIC_COLUMN(PositiveHasTOF, positiveHasTOF, //! positive daughter TOF calculation valid +DECLARE_SOA_DYNAMIC_COLUMN(PositiveHasTOF, positiveHasTOF, //! positive daughter TOF calculation valid [](float TOFNSigmaLaPr) -> bool { - bool returnStatus = true; - if(std::abs(TOFNSigmaLaPr - kNoTOFValue) < kEpsilon){ - returnStatus = false; - } - return returnStatus; + bool returnStatus = true; + if (std::abs(TOFNSigmaLaPr - kNoTOFValue) < kEpsilon) { + returnStatus = false; + } + return returnStatus; }); -DECLARE_SOA_DYNAMIC_COLUMN(NegativeHasTOF, negativeHasTOF, //! negative daughter TOF calculation valid +DECLARE_SOA_DYNAMIC_COLUMN(NegativeHasTOF, negativeHasTOF, //! negative daughter TOF calculation valid [](float TOFNSigmaALaPr) -> bool { - bool returnStatus = true; - if(std::abs(TOFNSigmaALaPr - kNoTOFValue) < kEpsilon){ - returnStatus = false; - } - return returnStatus; + bool returnStatus = true; + if (std::abs(TOFNSigmaALaPr - kNoTOFValue) < kEpsilon) { + returnStatus = false; + } + return returnStatus; }); // dynamics based on n-sigmas with use-only-if-tof-present logic @@ -356,31 +356,30 @@ DECLARE_SOA_COLUMN(TOFNSigmaOmKa, tofNSigmaOmKa, float); //! bachelor track // dynamics to replace hasTOF (note: that condition does not match track hasTOF!) // note: only single hypothesis check necessary; other hypotheses will always be valid -DECLARE_SOA_DYNAMIC_COLUMN(PositiveHasTOF, positiveHasTOF, //! positive daughter TOF calculation valid +DECLARE_SOA_DYNAMIC_COLUMN(PositiveHasTOF, positiveHasTOF, //! positive daughter TOF calculation valid [](float PosTOFDeltaTXiPr) -> bool { - bool returnStatus = true; - if(std::abs(PosTOFDeltaTXiPr - kNoTOFValue) < kEpsilon){ - returnStatus = false; - } - return returnStatus; + bool returnStatus = true; + if (std::abs(PosTOFDeltaTXiPr - kNoTOFValue) < kEpsilon) { + returnStatus = false; + } + return returnStatus; }); -DECLARE_SOA_DYNAMIC_COLUMN(NegativeHasTOF, negativeHasTOF, //! positive daughter TOF calculation valid +DECLARE_SOA_DYNAMIC_COLUMN(NegativeHasTOF, negativeHasTOF, //! positive daughter TOF calculation valid [](float NegTOFDeltaTXiPr) -> bool { - bool returnStatus = true; - if(std::abs(NegTOFDeltaTXiPr - kNoTOFValue) < kEpsilon){ - returnStatus = false; - } - return returnStatus; + bool returnStatus = true; + if (std::abs(NegTOFDeltaTXiPr - kNoTOFValue) < kEpsilon) { + returnStatus = false; + } + return returnStatus; }); -DECLARE_SOA_DYNAMIC_COLUMN(BachelorHasTOF, bachelorHasTOF, //! bachelor daughter TOF calculation valid +DECLARE_SOA_DYNAMIC_COLUMN(BachelorHasTOF, bachelorHasTOF, //! bachelor daughter TOF calculation valid [](float BachTOFDeltaTXiPi) -> bool { - bool returnStatus = true; - if(std::abs(BachTOFDeltaTXiPi - kNoTOFValue) < kEpsilon){ - returnStatus = false; - } - return returnStatus; + bool returnStatus = true; + if (std::abs(BachTOFDeltaTXiPi - kNoTOFValue) < kEpsilon) { + returnStatus = false; + } + return returnStatus; }); - // dynamics based on n-sigmas with use-only-if-tof-present logic DECLARE_SOA_DYNAMIC_COLUMN(TofXiCompatibility, tofXiCompatibility, //! compatibility with being lambda, checked only if TOF present. Argument: number of sigmas diff --git a/PWGLF/TableProducer/Strangeness/strangenesstofpid.cxx b/PWGLF/TableProducer/Strangeness/strangenesstofpid.cxx index 3fe70d9db6c..5b343b7cab5 100644 --- a/PWGLF/TableProducer/Strangeness/strangenesstofpid.cxx +++ b/PWGLF/TableProducer/Strangeness/strangenesstofpid.cxx @@ -823,7 +823,7 @@ struct strangenesstofpid { const o2::math_utils::Point3D trackVertex{trackCollision.posX(), trackCollision.posY(), trackCollision.posZ()}; o2::track::TrackLTIntegral ltIntegral; bool successPropag = o2::base::Propagator::Instance()->propagateToDCA(trackVertex, posTrack, d_bz, 2.f, o2::base::Propagator::MatCorrType::USEMatCorrNONE, nullptr, <Integral); - if(doQA){ + if (doQA) { histos.fill(HIST("hPropagationBookkeeping"), kPropagPosV0, static_cast(successPropag)); } if (successPropag) { @@ -901,7 +901,7 @@ struct strangenesstofpid { const o2::math_utils::Point3D trackVertex{trackCollision.posX(), trackCollision.posY(), trackCollision.posZ()}; o2::track::TrackLTIntegral ltIntegral; bool successPropag = o2::base::Propagator::Instance()->propagateToDCA(trackVertex, negTrack, d_bz, 2.f, o2::base::Propagator::MatCorrType::USEMatCorrNONE, nullptr, <Integral); - if(doQA){ + if (doQA) { histos.fill(HIST("hPropagationBookkeeping"), kPropagNegV0, static_cast(successPropag)); } if (successPropag) { @@ -1096,7 +1096,7 @@ struct strangenesstofpid { const o2::math_utils::Point3D trackVertex{trackCollision.posX(), trackCollision.posY(), trackCollision.posZ()}; o2::track::TrackLTIntegral ltIntegral; bool successPropag = o2::base::Propagator::Instance()->propagateToDCA(trackVertex, posTrack, d_bz, 2.f, o2::base::Propagator::MatCorrType::USEMatCorrNONE, nullptr, <Integral); - if(doQA){ + if (doQA) { histos.fill(HIST("hPropagationBookkeeping"), kPropagPosCasc, static_cast(successPropag)); } if (successPropag) { @@ -1188,7 +1188,7 @@ struct strangenesstofpid { const o2::math_utils::Point3D trackVertex{trackCollision.posX(), trackCollision.posY(), trackCollision.posZ()}; o2::track::TrackLTIntegral ltIntegral; bool successPropag = o2::base::Propagator::Instance()->propagateToDCA(trackVertex, negTrack, d_bz, 2.f, o2::base::Propagator::MatCorrType::USEMatCorrNONE, nullptr, <Integral); - if(doQA){ + if (doQA) { histos.fill(HIST("hPropagationBookkeeping"), kPropagNegCasc, static_cast(successPropag)); } if (successPropag) { @@ -1280,7 +1280,7 @@ struct strangenesstofpid { const o2::math_utils::Point3D trackVertex{trackCollision.posX(), trackCollision.posY(), trackCollision.posZ()}; o2::track::TrackLTIntegral ltIntegral; bool successPropag = o2::base::Propagator::Instance()->propagateToDCA(trackVertex, bachTrack, d_bz, 2.f, o2::base::Propagator::MatCorrType::USEMatCorrNONE, nullptr, <Integral); - if(doQA){ + if (doQA) { histos.fill(HIST("hPropagationBookkeeping"), kPropagBachCasc, static_cast(successPropag)); } if (successPropag) {