diff --git a/PWGHF/DataModel/CandidateReconstructionTables.h b/PWGHF/DataModel/CandidateReconstructionTables.h index 009735144a7..71679159b1c 100644 --- a/PWGHF/DataModel/CandidateReconstructionTables.h +++ b/PWGHF/DataModel/CandidateReconstructionTables.h @@ -35,6 +35,7 @@ #include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/Utils/utilsPid.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" namespace o2::aod { @@ -484,7 +485,7 @@ DECLARE_SOA_COLUMN(ErrorImpactParameterZ2, errorImpactParameterZ2, float); DECLARE_SOA_DYNAMIC_COLUMN(ImpactParameterZNormalised2, impactParameterZNormalised2, //! [](float dca, float err) -> float { return dca / err; }); /// prong PID nsigma -DECLARE_SOA_COLUMN(NProngsContributorsPV, nProngsContributorsPV, uint8_t); //! number of prongs contributing to the primary-vertex reconstruction +DECLARE_SOA_COLUMN(IndicesProngsContributorsPV, indicesProngsContributorsPV, uint8_t); //! indices of prongs contributing to the primary-vertex reconstruction encoded in binary form DECLARE_SOA_COLUMN(NSigTpcPi0, nSigTpcPi0, float); //! TPC nSigma for pion hypothesis - prong 0 DECLARE_SOA_COLUMN(NSigTpcPi1, nSigTpcPi1, float); //! TPC nSigma for pion hypothesis - prong 1 DECLARE_SOA_COLUMN(NSigTpcPi2, nSigTpcPi2, float); //! TPC nSigma for pion hypothesis - prong 2 @@ -503,6 +504,7 @@ DECLARE_SOA_COLUMN(NSigTofKa2, nSigTofKa2, float); //! T DECLARE_SOA_COLUMN(NSigTofPr0, nSigTofPr0, float); //! TOF nSigma for proton hypothesis - prong 0 DECLARE_SOA_COLUMN(NSigTofPr1, nSigTofPr1, float); //! TOF nSigma for proton hypothesis - prong 1 DECLARE_SOA_COLUMN(NSigTofPr2, nSigTofPr2, float); //! TOF nSigma for proton hypothesis - prong 2 +DECLARE_SOA_DYNAMIC_COLUMN(NProngsContributorsPV, nProngsContributorsPV, [](uint8_t indicesProngsContributorsPV) -> uint8_t {return hf_trkcandsel::countOnesInBinary(indicesProngsContributorsPV); }); DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaPi0, tpcTofNSigmaPi0, //! Combined NSigma separation with the TPC & TOF detectors for pion - prong 0 [](float tpcNSigmaPi0, float tofNSigmaPi0) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPi0, tofNSigmaPi0); }); DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaPi1, tpcTofNSigmaPi1, //! Combined NSigma separation with the TPC & TOF detectors for pion - prong 1 @@ -664,7 +666,7 @@ DECLARE_SOA_TABLE(HfCand2ProngBase, "AOD", "HFCAND2PBASE", //! hf_cand::ErrorImpactParameter0, hf_cand::ErrorImpactParameter1, hf_cand::ImpactParameterZ0, hf_cand::ImpactParameterZ1, hf_cand::ErrorImpactParameterZ0, hf_cand::ErrorImpactParameterZ1, - hf_track_index::Prong0Id, hf_track_index::Prong1Id, hf_cand::NProngsContributorsPV, + hf_track_index::Prong0Id, hf_track_index::Prong1Id, hf_cand::IndicesProngsContributorsPV, hf_track_index::HFflag, /* dynamic columns */ hf_cand_2prong::M, @@ -672,6 +674,7 @@ DECLARE_SOA_TABLE(HfCand2ProngBase, "AOD", "HFCAND2PBASE", //! hf_cand_2prong::ImpactParameterProduct, hf_cand_2prong::CosThetaStar, hf_cand_2prong::ImpactParameterProngSqSum, + hf_cand::NProngsContributorsPV, /* dynamic columns that use candidate momentum components */ hf_cand::Pt, hf_cand::Pt2, @@ -970,12 +973,13 @@ DECLARE_SOA_TABLE(HfCand3ProngBase, "AOD", "HFCAND3PBASE", //! hf_cand::ErrorImpactParameter0, hf_cand::ErrorImpactParameter1, hf_cand::ErrorImpactParameter2, hf_cand::ImpactParameterZ0, hf_cand::ImpactParameterZ1, hf_cand::ImpactParameterZ2, hf_cand::ErrorImpactParameterZ0, hf_cand::ErrorImpactParameterZ1, hf_cand::ErrorImpactParameterZ2, - hf_track_index::Prong0Id, hf_track_index::Prong1Id, hf_track_index::Prong2Id, hf_cand::NProngsContributorsPV, + hf_track_index::Prong0Id, hf_track_index::Prong1Id, hf_track_index::Prong2Id, hf_cand::IndicesProngsContributorsPV, hf_track_index::HFflag, /* dynamic columns */ hf_cand_3prong::M, hf_cand_3prong::M2, hf_cand_3prong::ImpactParameterProngSqSum, + hf_cand::NProngsContributorsPV, /* prong 2 */ hf_cand::ImpactParameterNormalised2, hf_cand::PtProng2, diff --git a/PWGHF/DataModel/DerivedTables.h b/PWGHF/DataModel/DerivedTables.h index 179695e2787..9b804322ad7 100644 --- a/PWGHF/DataModel/DerivedTables.h +++ b/PWGHF/DataModel/DerivedTables.h @@ -564,7 +564,7 @@ DECLARE_SOA_TABLE_STAGED(HfBplusMcs, "HFBPMC", //! Table with MC candidate info // normalised: DecayLengthNormalised, DecayLengthXYNormalised, ImpactParameterNormalised0 DECLARE_SOA_TABLE_STAGED(HfLcPars, "HFLCPAR", //! Table with candidate properties used for selection hf_cand::Chi2PCA, - hf_cand::NProngsContributorsPV, + hf_cand::IndicesProngsContributorsPV, hf_cand_par::Cpa, hf_cand_par::CpaXY, hf_cand_par::DecayLength, diff --git a/PWGHF/TableProducer/candidateCreator2Prong.cxx b/PWGHF/TableProducer/candidateCreator2Prong.cxx index 8b464257ce6..241410bb083 100644 --- a/PWGHF/TableProducer/candidateCreator2Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator2Prong.cxx @@ -281,12 +281,12 @@ struct HfCandidateCreator2Prong { auto errorDecayLengthXY = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, 0.) + getRotatedCovMatrixXX(covMatrixPCA, phi, 0.)); auto indexCollision = collision.globalIndex(); - uint8_t nProngsContributorsPV = 0; + uint8_t indicesProngsContributorsPV = 0; if (indexCollision == track0.collisionId() && track0.isPVContributor()) { - nProngsContributorsPV += 1; + indicesProngsContributorsPV += 1; } if (indexCollision == track1.collisionId() && track1.isPVContributor()) { - nProngsContributorsPV += 1; + indicesProngsContributorsPV += 2; } // fill candidate table rows @@ -301,7 +301,7 @@ struct HfCandidateCreator2Prong { std::sqrt(impactParameter0.getSigmaY2()), std::sqrt(impactParameter1.getSigmaY2()), impactParameter0.getZ(), impactParameter1.getZ(), std::sqrt(impactParameter0.getSigmaZ2()), std::sqrt(impactParameter1.getSigmaZ2()), - rowTrackIndexProng2.prong0Id(), rowTrackIndexProng2.prong1Id(), nProngsContributorsPV, + rowTrackIndexProng2.prong0Id(), rowTrackIndexProng2.prong1Id(), indicesProngsContributorsPV, rowTrackIndexProng2.hfflag()); // fill candidate prong PID rows @@ -432,12 +432,12 @@ struct HfCandidateCreator2Prong { } auto indexCollision = collision.globalIndex(); - uint8_t nProngsContributorsPV = 0; + uint8_t indicesProngsContributorsPV = 0; if (indexCollision == track0.collisionId() && track0.isPVContributor()) { - nProngsContributorsPV += 1; + indicesProngsContributorsPV += 1; } if (indexCollision == track1.collisionId() && track1.isPVContributor()) { - nProngsContributorsPV += 1; + indicesProngsContributorsPV += 2; } // fill candidate table rows @@ -452,7 +452,7 @@ struct HfCandidateCreator2Prong { errImpactParameter0XY, errImpactParameter1XY, 0.f, 0.f, 0.f, 0.f, - rowTrackIndexProng2.prong0Id(), rowTrackIndexProng2.prong1Id(), nProngsContributorsPV, + rowTrackIndexProng2.prong0Id(), rowTrackIndexProng2.prong1Id(), indicesProngsContributorsPV, rowTrackIndexProng2.hfflag()); // fill candidate prong PID rows diff --git a/PWGHF/TableProducer/candidateCreator3Prong.cxx b/PWGHF/TableProducer/candidateCreator3Prong.cxx index e7c464efa72..56ec18ba576 100644 --- a/PWGHF/TableProducer/candidateCreator3Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator3Prong.cxx @@ -275,15 +275,15 @@ struct HfCandidateCreator3Prong { auto errorDecayLengthXY = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, 0.) + getRotatedCovMatrixXX(covMatrixPCA, phi, 0.)); auto indexCollision = collision.globalIndex(); - uint8_t nProngsContributorsPV = 0; + uint8_t indicesProngsContributorsPV = 0; if (indexCollision == track0.collisionId() && track0.isPVContributor()) { - nProngsContributorsPV += 1; + indicesProngsContributorsPV += 1; } if (indexCollision == track1.collisionId() && track1.isPVContributor()) { - nProngsContributorsPV += 1; + indicesProngsContributorsPV += 2; } if (indexCollision == track2.collisionId() && track2.isPVContributor()) { - nProngsContributorsPV += 1; + indicesProngsContributorsPV += 4; } // fill candidate table rows @@ -299,7 +299,7 @@ struct HfCandidateCreator3Prong { std::sqrt(impactParameter0.getSigmaY2()), std::sqrt(impactParameter1.getSigmaY2()), std::sqrt(impactParameter2.getSigmaY2()), impactParameter0.getZ(), impactParameter1.getZ(), impactParameter2.getZ(), std::sqrt(impactParameter0.getSigmaZ2()), std::sqrt(impactParameter1.getSigmaZ2()), std::sqrt(impactParameter2.getSigmaZ2()), - rowTrackIndexProng3.prong0Id(), rowTrackIndexProng3.prong1Id(), rowTrackIndexProng3.prong2Id(), nProngsContributorsPV, + rowTrackIndexProng3.prong0Id(), rowTrackIndexProng3.prong1Id(), rowTrackIndexProng3.prong2Id(), indicesProngsContributorsPV, rowTrackIndexProng3.hfflag()); // fill histograms diff --git a/PWGHF/TableProducer/derivedDataCreatorLcToPKPi.cxx b/PWGHF/TableProducer/derivedDataCreatorLcToPKPi.cxx index 6353241bc38..eda22feae72 100644 --- a/PWGHF/TableProducer/derivedDataCreatorLcToPKPi.cxx +++ b/PWGHF/TableProducer/derivedDataCreatorLcToPKPi.cxx @@ -191,7 +191,7 @@ struct HfDerivedDataCreatorLcToPKPi { if (fillCandidatePar) { rowCandidatePar( candidate.chi2PCA(), - candidate.nProngsContributorsPV(), + candidate.indicesProngsContributorsPV(), candidate.cpa(), candidate.cpaXY(), candidate.decayLength(), diff --git a/PWGHF/TableProducer/treeCreatorLcToPKPi.cxx b/PWGHF/TableProducer/treeCreatorLcToPKPi.cxx index f0c1c1503c2..d83655fde6c 100644 --- a/PWGHF/TableProducer/treeCreatorLcToPKPi.cxx +++ b/PWGHF/TableProducer/treeCreatorLcToPKPi.cxx @@ -100,7 +100,7 @@ DECLARE_SOA_TABLE(HfCandLcLites, "AOD", "HFCANDLCLITE", collision::PosX, collision::PosY, collision::PosZ, - hf_cand::NProngsContributorsPV, + hf_cand::IndicesProngsContributorsPV, // hf_cand::ErrorDecayLength, // hf_cand::ErrorDecayLengthXY, hf_cand::Chi2PCA, @@ -158,7 +158,7 @@ DECLARE_SOA_TABLE(HfCandLcFulls, "AOD", "HFCANDLCFULL", collision::PosX, collision::PosY, collision::PosZ, - hf_cand::NProngsContributorsPV, + hf_cand::IndicesProngsContributorsPV, hf_cand::XSecondaryVertex, hf_cand::YSecondaryVertex, hf_cand::ZSecondaryVertex, @@ -356,7 +356,7 @@ struct HfTreeCreatorLcToPKPi { candidate.posX(), candidate.posY(), candidate.posZ(), - candidate.nProngsContributorsPV(), + candidate.indicesProngsContributorsPV(), // candidate.errorDecayLength(), // candidate.errorDecayLengthXY(), candidate.chi2PCA(), @@ -418,7 +418,7 @@ struct HfTreeCreatorLcToPKPi { candidate.posX(), candidate.posY(), candidate.posZ(), - candidate.nProngsContributorsPV(), + candidate.indicesProngsContributorsPV(), candidate.xSecondaryVertex(), candidate.ySecondaryVertex(), candidate.zSecondaryVertex(), @@ -613,7 +613,7 @@ struct HfTreeCreatorLcToPKPi { candidate.posX(), candidate.posY(), candidate.posZ(), - candidate.nProngsContributorsPV(), + candidate.indicesProngsContributorsPV(), // candidate.errorDecayLength(), // candidate.errorDecayLengthXY(), candidate.chi2PCA(), @@ -675,7 +675,7 @@ struct HfTreeCreatorLcToPKPi { candidate.posX(), candidate.posY(), candidate.posZ(), - candidate.nProngsContributorsPV(), + candidate.indicesProngsContributorsPV(), candidate.xSecondaryVertex(), candidate.ySecondaryVertex(), candidate.zSecondaryVertex(), diff --git a/PWGHF/Utils/utilsTrkCandHf.h b/PWGHF/Utils/utilsTrkCandHf.h index 073e416236d..b67a455d6ce 100644 --- a/PWGHF/Utils/utilsTrkCandHf.h +++ b/PWGHF/Utils/utilsTrkCandHf.h @@ -41,6 +41,21 @@ void setLabelHistoCands(Histo& hCandidates) hCandidates->GetXaxis()->SetBinLabel(SVFitting::Fail + 1, "Run-time error in secondary vertexing"); } +int countOnesInBinary(uint8_t num) { + int count = 0; + + // Loop through all bits of the number (8 bits for uint8_t) + while (num > 0) { + // Increment count if the last bit is 1 + count += num & 1; + + // Right shift the number by 1 to check the next bit + num >>= 1; + } + + return count; +} + } // namespace o2::hf_trkcandsel #endif // PWGHF_UTILS_UTILSTRKCANDHF_H_ diff --git a/PWGJE/Core/JetHFUtilities.h b/PWGJE/Core/JetHFUtilities.h index 1334d8ad6f6..0e74c459595 100644 --- a/PWGJE/Core/JetHFUtilities.h +++ b/PWGJE/Core/JetHFUtilities.h @@ -563,7 +563,7 @@ void fillLcCandidateTable(T const& candidate, U& LcParTable, V& LcParETable, M& LcParTable( candidate.chi2PCA(), - candidate.nProngsContributorsPV(), + candidate.indicesProngsContributorsPV(), candidate.cpa(), candidate.cpaXY(), candidate.decayLength(),