diff --git a/PWGHF/TableProducer/candidateCreator3Prong.cxx b/PWGHF/TableProducer/candidateCreator3Prong.cxx index bb03518d889..4a2483b58c4 100644 --- a/PWGHF/TableProducer/candidateCreator3Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator3Prong.cxx @@ -111,10 +111,10 @@ struct HfCandidateCreator3Prong { Configurable propagateToPCA{"propagateToPCA", true, "create tracks version propagated to PCA"}; Configurable useAbsDCA{"useAbsDCA", false, "Minimise abs. distance rather than chi2"}; Configurable useWeightedFinalPCA{"useWeightedFinalPCA", false, "Recalculate vertex position using track covariances, effective only if useAbsDCA is true"}; - Configurable maxR{"maxR", 200., "reject PCA's above this radius"}; - Configurable maxDZIni{"maxDZIni", 4., "reject (if>0) PCA candidate if tracks DZ exceeds threshold"}; - Configurable minParamChange{"minParamChange", 1.e-3, "stop iterations if largest change of any X is smaller than this"}; - Configurable minRelChi2Change{"minRelChi2Change", 0.9, "stop iterations is chi2/chi2old > this"}; + Configurable maxR{"maxR", 200., "reject PCA's above this radius"}; + Configurable maxDZIni{"maxDZIni", 4., "reject (if>0) PCA candidate if tracks DZ exceeds threshold"}; + Configurable minParamChange{"minParamChange", 1.e-3, "stop iterations if largest change of any X is smaller than this"}; + Configurable minRelChi2Change{"minRelChi2Change", 0.9, "stop iterations is chi2/chi2old > this"}; Configurable fillHistograms{"fillHistograms", true, "do validation plots"}; // magnetic field setting from CCDB Configurable isRun2{"isRun2", false, "enable Run 2 or Run 3 GRP objects for magnetic field"}; @@ -138,7 +138,7 @@ struct HfCandidateCreator3Prong { int runNumber{0}; double bz{0.}; - const float toMicrometers = 10000.; // from cm to µm + constexpr static float CentiToMicro{10000.f}; // from cm to µm constexpr static float UndefValueFloat{-999.f}; using FilteredHf3Prongs = soa::Filtered; @@ -307,7 +307,7 @@ struct HfCandidateCreator3Prong { // df.setBz(bz); /// put it outside the 'if'! Otherwise we have a difference wrt bz Configurable (< 1 permille) in Run2 conv. data // df.print(); } - df.setBz(bz); + df.setBz(static_cast(bz)); // reconstruct the 3-prong secondary vertex hCandidates->Fill(SVFitting::BeforeFit); @@ -371,15 +371,15 @@ struct HfCandidateCreator3Prong { trackParVar0.propagateToDCA(primaryVertex, bz, &impactParameter0); trackParVar1.propagateToDCA(primaryVertex, bz, &impactParameter1); trackParVar2.propagateToDCA(primaryVertex, bz, &impactParameter2); - registry.fill(HIST("hDcaXYProngs"), track0.pt(), impactParameter0.getY() * toMicrometers); - registry.fill(HIST("hDcaXYProngs"), track1.pt(), impactParameter1.getY() * toMicrometers); - registry.fill(HIST("hDcaXYProngs"), track2.pt(), impactParameter2.getY() * toMicrometers); - registry.fill(HIST("hDcaZProngs"), track0.pt(), impactParameter0.getZ() * toMicrometers); - registry.fill(HIST("hDcaZProngs"), track1.pt(), impactParameter1.getZ() * toMicrometers); - registry.fill(HIST("hDcaZProngs"), track2.pt(), impactParameter2.getZ() * toMicrometers); + registry.fill(HIST("hDcaXYProngs"), track0.pt(), impactParameter0.getY() * CentiToMicro); + registry.fill(HIST("hDcaXYProngs"), track1.pt(), impactParameter1.getY() * CentiToMicro); + registry.fill(HIST("hDcaXYProngs"), track2.pt(), impactParameter2.getY() * CentiToMicro); + registry.fill(HIST("hDcaZProngs"), track0.pt(), impactParameter0.getZ() * CentiToMicro); + registry.fill(HIST("hDcaZProngs"), track1.pt(), impactParameter1.getZ() * CentiToMicro); + registry.fill(HIST("hDcaZProngs"), track2.pt(), impactParameter2.getZ() * CentiToMicro); // get uncertainty of the decay length - double phi, theta; + double phi{}, theta{}; getPointDirection(std::array{primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}, secondaryVertex, phi, theta); auto errorDecayLength = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, theta) + getRotatedCovMatrixXX(covMatrixPCA, phi, theta)); auto errorDecayLengthXY = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, 0.) + getRotatedCovMatrixXX(covMatrixPCA, phi, 0.)); @@ -481,7 +481,7 @@ struct HfCandidateCreator3Prong { } float covMatrixPV[6]; - KFParticle::SetField(bz); + KFParticle::SetField(static_cast(bz)); KFPVertex kfpVertex = createKFPVertexFromCollision(collision); if constexpr (DoPvRefit) { @@ -513,22 +513,22 @@ struct HfCandidateCreator3Prong { float impactParameter0XY = 0., errImpactParameter0XY = 0., impactParameter1XY = 0., errImpactParameter1XY = 0., impactParameter2XY = 0., errImpactParameter2XY = 0.; if (!kfFirstProton.GetDistanceFromVertexXY(kfpV, impactParameter0XY, errImpactParameter0XY)) { - registry.fill(HIST("hDcaXYProngs"), track0.pt(), impactParameter0XY * toMicrometers); - registry.fill(HIST("hDcaZProngs"), track0.pt(), std::sqrt(kfFirstProton.GetDistanceFromVertex(kfpV) * kfFirstProton.GetDistanceFromVertex(kfpV) - impactParameter0XY * impactParameter0XY) * toMicrometers); + registry.fill(HIST("hDcaXYProngs"), track0.pt(), impactParameter0XY * CentiToMicro); + registry.fill(HIST("hDcaZProngs"), track0.pt(), std::sqrt(kfFirstProton.GetDistanceFromVertex(kfpV) * kfFirstProton.GetDistanceFromVertex(kfpV) - impactParameter0XY * impactParameter0XY) * CentiToMicro); } else { registry.fill(HIST("hDcaXYProngs"), track0.pt(), UndefValueFloat); registry.fill(HIST("hDcaZProngs"), track0.pt(), UndefValueFloat); } if (!kfSecondKaon.GetDistanceFromVertexXY(kfpV, impactParameter1XY, errImpactParameter1XY)) { - registry.fill(HIST("hDcaXYProngs"), track1.pt(), impactParameter1XY * toMicrometers); - registry.fill(HIST("hDcaZProngs"), track1.pt(), std::sqrt(kfSecondKaon.GetDistanceFromVertex(kfpV) * kfSecondKaon.GetDistanceFromVertex(kfpV) - impactParameter1XY * impactParameter1XY) * toMicrometers); + registry.fill(HIST("hDcaXYProngs"), track1.pt(), impactParameter1XY * CentiToMicro); + registry.fill(HIST("hDcaZProngs"), track1.pt(), std::sqrt(kfSecondKaon.GetDistanceFromVertex(kfpV) * kfSecondKaon.GetDistanceFromVertex(kfpV) - impactParameter1XY * impactParameter1XY) * CentiToMicro); } else { registry.fill(HIST("hDcaXYProngs"), track1.pt(), UndefValueFloat); registry.fill(HIST("hDcaZProngs"), track1.pt(), UndefValueFloat); } if (!kfThirdProton.GetDistanceFromVertexXY(kfpV, impactParameter2XY, errImpactParameter2XY)) { - registry.fill(HIST("hDcaXYProngs"), track2.pt(), impactParameter2XY * toMicrometers); - registry.fill(HIST("hDcaZProngs"), track2.pt(), std::sqrt(kfThirdProton.GetDistanceFromVertex(kfpV) * kfThirdProton.GetDistanceFromVertex(kfpV) - impactParameter2XY * impactParameter2XY) * toMicrometers); + registry.fill(HIST("hDcaXYProngs"), track2.pt(), impactParameter2XY * CentiToMicro); + registry.fill(HIST("hDcaZProngs"), track2.pt(), std::sqrt(kfThirdProton.GetDistanceFromVertex(kfpV) * kfThirdProton.GetDistanceFromVertex(kfpV) - impactParameter2XY * impactParameter2XY) * CentiToMicro); } else { registry.fill(HIST("hDcaXYProngs"), track2.pt(), UndefValueFloat); registry.fill(HIST("hDcaZProngs"), track2.pt(), UndefValueFloat); @@ -604,14 +604,14 @@ struct HfCandidateCreator3Prong { const float massPiK = kfPairPiK.GetMass(); if (applyInvMassConstraint) { // constraints applied after minv getters - to preserve unbiased values of minv - kfCandPKPi.SetNonlinearMassConstraint(createLc ? MassLambdaCPlus : MassXiCPlus); - kfCandPiKP.SetNonlinearMassConstraint(createLc ? MassLambdaCPlus : MassXiCPlus); + kfCandPKPi.SetNonlinearMassConstraint(createLc ? static_cast(MassLambdaCPlus) : static_cast(MassXiCPlus)); + kfCandPiKP.SetNonlinearMassConstraint(createLc ? static_cast(MassLambdaCPlus) : static_cast(MassXiCPlus)); kfCandPiKPi.SetNonlinearMassConstraint(MassDPlus); kfCandKKPi.SetNonlinearMassConstraint(MassDS); kfCandPiKK.SetNonlinearMassConstraint(MassDS); } - const float chi2geo = kfCandPKPi.Chi2() / kfCandPKPi.NDF(); + const float chi2geo = kfCandPKPi.Chi2() / static_cast(kfCandPKPi.NDF()); const std::pair ldl = kfCalculateLdL(kfCandPKPi, kfpV); std::array pProng0 = kfCalculateProngMomentumInSecondaryVertex(kfFirstProton, kfCandPiKP); @@ -624,7 +624,7 @@ struct HfCandidateCreator3Prong { registry.fill(HIST("hCovSVZZ"), kfCandPKPi.Covariance(2, 2)); auto* covMatrixSV = kfCandPKPi.CovarianceMatrix(); - double phi, theta; + double phi{}, theta{}; getPointDirection(std::array{kfpV.GetX(), kfpV.GetY(), kfpV.GetZ()}, std::array{kfCandPKPi.GetX(), kfCandPKPi.GetY(), kfCandPKPi.GetZ()}, phi, theta); auto errorDecayLength = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, theta) + getRotatedCovMatrixXX(covMatrixSV, phi, theta)); auto errorDecayLengthXY = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, 0.) + getRotatedCovMatrixXX(covMatrixSV, phi, 0.)); @@ -647,7 +647,7 @@ struct HfCandidateCreator3Prong { kfpV.GetX(), kfpV.GetY(), kfpV.GetZ(), kfCandPKPi.GetX(), kfCandPKPi.GetY(), kfCandPKPi.GetZ(), errorDecayLength, errorDecayLengthXY, - kfCandPKPi.GetChi2() / kfCandPKPi.GetNDF(), + kfCandPKPi.GetChi2() / static_cast(kfCandPKPi.GetNDF()), pProng0.at(0), pProng0.at(1), pProng0.at(2), pProng1.at(0), pProng1.at(1), pProng1.at(2), pProng2.at(0), pProng2.at(1), pProng2.at(2), @@ -904,7 +904,7 @@ struct HfCandidateCreator3Prong { const auto bc = collision.template foundBC_as(); const auto ir = hfEvSel.getInteractionRate(bc, ccdb); // Hz /// monitor the satisfied event selections - hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy, ir); + hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy, static_cast(ir)); } /// end loop over collisions } @@ -923,7 +923,7 @@ struct HfCandidateCreator3Prong { const auto bc = collision.template foundBC_as(); const auto ir = hfEvSel.getInteractionRate(bc, ccdb); // Hz /// monitor the satisfied event selections - hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy, ir); + hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy, static_cast(ir)); } /// end loop over collisions } @@ -942,7 +942,7 @@ struct HfCandidateCreator3Prong { const auto bc = collision.template foundBC_as(); const auto ir = hfEvSel.getInteractionRate(bc, ccdb); // Hz /// monitor the satisfied event selections - hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy, ir); + hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy, static_cast(ir)); } /// end loop over collisions } @@ -966,7 +966,7 @@ struct HfCandidateCreator3Prong { const auto bc = collision.template foundBC_as(); const auto ir = hfEvSel.getInteractionRate(bc, ccdb); // Hz /// monitor the satisfied event selections - hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy, ir); + hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy, static_cast(ir)); } /// end loop over collisions } @@ -1132,7 +1132,7 @@ struct HfCandidateCreator3ProngExpressions { return; } if (indexRec > -1) { - flagChannelMain = sign * channelMain; + flagChannelMain = static_cast(sign * channelMain); /// swapping for D+, Ds->Kpipi; Lc, Xic->pKpi if (std::abs(flagChannelMain) == DecayChannelMain::DplusToPiKK || std::abs(flagChannelMain) == DecayChannelMain::DsToPiKK || std::abs(flagChannelMain) == DecayChannelMain::LcToPKPi || std::abs(flagChannelMain) == DecayChannelMain::XicToPKPi) { @@ -1185,7 +1185,7 @@ struct HfCandidateCreator3ProngExpressions { indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDPlus, arrPdgDaughtersDplusToPiKPi, true, &sign, 2); } if (indexRec > -1) { - flagChannelMain = sign * DecayChannelMain::DplusToPiKPi; + flagChannelMain = static_cast(sign * DecayChannelMain::DplusToPiKPi); } } @@ -1215,7 +1215,7 @@ struct HfCandidateCreator3ProngExpressions { } } if (indexRec > -1) { - flagChannelMain = sign * (isDplus ? DecayChannelMain::DplusToPiKK : DecayChannelMain::DsToPiKK); + flagChannelMain = sign * (isDplus ? static_cast(DecayChannelMain::DplusToPiKK) : static_cast(DecayChannelMain::DsToPiKK)); if (arrayDaughters[0].has_mcParticle()) { swapping = static_cast(std::abs(arrayDaughters[0].mcParticle().pdgCode()) == kPiPlus); } @@ -1243,7 +1243,7 @@ struct HfCandidateCreator3ProngExpressions { indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDStar, arrPdgDaughtersDstarToPiKPi, true, &sign, 2); } if (indexRec > -1) { - flagChannelMain = sign * DecayChannelMain::DstarToPiKPi; + flagChannelMain = static_cast(sign * DecayChannelMain::DstarToPiKPi); flagChannelResonant = 0; } } @@ -1261,7 +1261,7 @@ struct HfCandidateCreator3ProngExpressions { indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kLambdaCPlus, arrPdgDaughtersLcToPKPi, true, &sign, 2); } if (indexRec > -1) { - flagChannelMain = sign * DecayChannelMain::LcToPKPi; + flagChannelMain = static_cast(sign * DecayChannelMain::LcToPKPi); // Flagging the different Λc± → p± K∓ π± decay channels if (arrayDaughters[0].has_mcParticle()) { @@ -1297,7 +1297,7 @@ struct HfCandidateCreator3ProngExpressions { indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kXiCPlus, arrPdgDaughtersXicToPKPi, true, &sign, 2); } if (indexRec > -1) { - flagChannelMain = sign * DecayChannelMain::XicToPKPi; + flagChannelMain = static_cast(sign * DecayChannelMain::XicToPKPi); flagChannelResonant = 0; // TODO if (arrayDaughters[0].has_mcParticle()) { swapping = static_cast(std::abs(arrayDaughters[0].mcParticle().pdgCode()) == kPiPlus); @@ -1309,7 +1309,7 @@ struct HfCandidateCreator3ProngExpressions { // Check whether the particle is non-prompt (from a b quark). if (flagChannelMain != 0) { auto particle = mcParticles.rawIteratorAt(indexRec); - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); + origin = static_cast(RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers)); } if (origin == RecoDecay::OriginType::NonPrompt) { auto bHadMother = mcParticles.rawIteratorAt(idxBhadMothers[0]); diff --git a/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx b/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx index b4e2e3f0aa4..d820c4389d3 100644 --- a/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx +++ b/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -144,6 +145,7 @@ struct HfCandidateCreatorXic0Omegac0 { HfEventSelection hfEvSel; // event selection and monitoring o2::vertexing::DCAFitterN<2> df; // 2-prong vertex fitter to build the omegac/xic vertex Service ccdb; + Service pdgdb; o2::base::MatLayerCylSet* lut{}; o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; int runNumber{-1}; @@ -1124,7 +1126,7 @@ struct HfCandidateCreatorXic0Omegac0 { kfOmegac0Candidate.rapOmegac = kfOmegaC0.GetRapidity(); // KF cosThetaStar - kfOmegac0Candidate.cosThetaStarPiFromOmegac = cosThetaStarFromKF(0, 4332, 211, 3312, kfBachPionToOmegaC, kfOmegaToOmegaC); + kfOmegac0Candidate.cosThetaStarPiFromOmegac = cosThetaStarFromKF(0, 4332, 211, 3312, kfBachPionToOmegaC, kfOmegaToOmegaC, pdgdb); // KF ct kfOmegac0Candidate.ctV0 = kfV0.GetLifeTime(); @@ -1588,7 +1590,7 @@ struct HfCandidateCreatorXic0Omegac0 { kfXic0Candidate.rapXic = kfXiC0.GetRapidity(); // KF cosThetaStar - kfXic0Candidate.cosThetaStarPiFromXic = cosThetaStarFromKF(0, 4132, 211, 3312, kfCharmBachPionToXiC, kfXiToXiC); + kfXic0Candidate.cosThetaStarPiFromXic = cosThetaStarFromKF(0, 4132, 211, 3312, kfCharmBachPionToXiC, kfXiToXiC, pdgdb); // KF ct kfXic0Candidate.ctV0 = kfV0ToCasc.GetLifeTime(); @@ -1950,8 +1952,8 @@ struct HfCandidateCreatorXic0Omegac0 { float const ptOmega = kfOmega.GetPt(); // KF cosThetaStar - float const cosThetaStarKaFromOmegac = cosThetaStarFromKF(0, 4332, 321, 3334, kfKaFromCharmToOmegaKa, kfOmegaToOmegaKa); - float const cosThetaStarKaFromXic = cosThetaStarFromKF(0, 4132, 321, 3334, kfKaFromCharmToOmegaKa, kfOmegaToOmegaKa); + float const cosThetaStarKaFromOmegac = cosThetaStarFromKF(0, 4332, 321, 3334, kfKaFromCharmToOmegaKa, kfOmegaToOmegaKa, pdgdb); + float const cosThetaStarKaFromXic = cosThetaStarFromKF(0, 4132, 321, 3334, kfKaFromCharmToOmegaKa, kfOmegaToOmegaKa, pdgdb); // KF ct float const ctV0 = kfV0ToOmega.GetLifeTime(); diff --git a/PWGHF/TableProducer/candidateSelectorLc.cxx b/PWGHF/TableProducer/candidateSelectorLc.cxx index b372780c1f3..31a6730ab26 100644 --- a/PWGHF/TableProducer/candidateSelectorLc.cxx +++ b/PWGHF/TableProducer/candidateSelectorLc.cxx @@ -62,18 +62,18 @@ struct HfCandidateSelectorLc { Configurable ptCandMax{"ptCandMax", 36., "Upper bound of candidate pT"}; Configurable usePid{"usePid", true, "Bool to use or not the PID based on nSigma cut at filtering level"}; // TPC PID - Configurable ptPidTpcMin{"ptPidTpcMin", 0.1, "Lower bound of track pT for TPC PID"}; - Configurable ptPidTpcMax{"ptPidTpcMax", 1., "Upper bound of track pT for TPC PID"}; - Configurable nSigmaTpcMax{"nSigmaTpcMax", 3., "Nsigma cut on TPC only"}; - Configurable nSigmaTpcCombinedMax{"nSigmaTpcCombinedMax", 5., "Nsigma cut on TPC combined with TOF"}; + Configurable ptPidTpcMin{"ptPidTpcMin", 0.1, "Lower bound of track pT for TPC PID"}; + Configurable ptPidTpcMax{"ptPidTpcMax", 1., "Upper bound of track pT for TPC PID"}; + Configurable nSigmaTpcMax{"nSigmaTpcMax", 3., "Nsigma cut on TPC only"}; + Configurable nSigmaTpcCombinedMax{"nSigmaTpcCombinedMax", 5., "Nsigma cut on TPC combined with TOF"}; // TOF PID - Configurable ptPidTofMin{"ptPidTofMin", 0.5, "Lower bound of track pT for TOF PID"}; - Configurable ptPidTofMax{"ptPidTofMax", 2.5, "Upper bound of track pT for TOF PID"}; - Configurable nSigmaTofMax{"nSigmaTofMax", 3., "Nsigma cut on TOF only"}; - Configurable nSigmaTofCombinedMax{"nSigmaTofCombinedMax", 5., "Nsigma cut on TOF combined with TPC"}; + Configurable ptPidTofMin{"ptPidTofMin", 0.5, "Lower bound of track pT for TOF PID"}; + Configurable ptPidTofMax{"ptPidTofMax", 2.5, "Upper bound of track pT for TOF PID"}; + Configurable nSigmaTofMax{"nSigmaTofMax", 3., "Nsigma cut on TOF only"}; + Configurable nSigmaTofCombinedMax{"nSigmaTofCombinedMax", 5., "Nsigma cut on TOF combined with TPC"}; // Bayesian PID - Configurable ptPidBayesMin{"ptPidBayesMin", 0., "Lower bound of track pT for Bayesian PID"}; - Configurable ptPidBayesMax{"ptPidBayesMax", 100, "Upper bound of track pT for Bayesian PID"}; + Configurable ptPidBayesMin{"ptPidBayesMin", 0., "Lower bound of track pT for Bayesian PID"}; + Configurable ptPidBayesMax{"ptPidBayesMax", 100, "Upper bound of track pT for Bayesian PID"}; // Combined PID options Configurable usePidTpcAndTof{"usePidTpcAndTof", false, "Bool to decide how to combine TPC and TOF PID: true = both (if present, only one otherwise); false = one is enough"}; // TPC quality track cuts @@ -518,11 +518,11 @@ struct HfCandidateSelectorLc { if (usePid) { // track-level PID selection - TrackSelectorPID::Status pidTrackPos1Proton; - TrackSelectorPID::Status pidTrackPos2Proton; - TrackSelectorPID::Status pidTrackPos1Pion; - TrackSelectorPID::Status pidTrackPos2Pion; - TrackSelectorPID::Status pidTrackNegKaon; + TrackSelectorPID::Status pidTrackPos1Proton{}; + TrackSelectorPID::Status pidTrackPos2Proton{}; + TrackSelectorPID::Status pidTrackPos1Pion{}; + TrackSelectorPID::Status pidTrackPos2Pion{}; + TrackSelectorPID::Status pidTrackNegKaon{}; if (usePidTpcAndTof) { pidTrackPos1Proton = selectorProton.statusTpcAndTof(trackPos1, candidate.nSigTpcPr0(), candidate.nSigTofPr0()); pidTrackPos2Proton = selectorProton.statusTpcAndTof(trackPos2, candidate.nSigTpcPr2(), candidate.nSigTofPr2()); diff --git a/PWGHF/TableProducer/treeCreatorLcToPKPi.cxx b/PWGHF/TableProducer/treeCreatorLcToPKPi.cxx index 97264a2336a..7e83872624f 100644 --- a/PWGHF/TableProducer/treeCreatorLcToPKPi.cxx +++ b/PWGHF/TableProducer/treeCreatorLcToPKPi.cxx @@ -544,7 +544,7 @@ struct HfTreeCreatorLcToPKPi { /// \param candidatesSize size of the candidates table /// \param isMc boolean flag whether MC or data is processed template - void reserveTables(size_t candidatesSize, bool isMc) + void reserveTables(int64_t candidatesSize, bool isMc) { if constexpr (ReconstructionType == aod::hf_cand::VertexerType::DCAFitter) { if (fillCandidateLiteTable) { @@ -814,22 +814,22 @@ struct HfTreeCreatorLcToPKPi { int functionSelection, int sigbgstatus) { - float chi2primProton; - float chi2primPion; - float dcaProtonKaon; - float dcaPionKaon; - float chi2GeoProtonKaon; - float chi2GeoPionKaon; - float mass; - float valueTpcNSigmaPr; + float chi2primProton{}; + float chi2primPion{}; + float dcaProtonKaon{}; + float dcaPionKaon{}; + float chi2GeoProtonKaon{}; + float chi2GeoPionKaon{}; + float mass{}; + float valueTpcNSigmaPr{}; const float valueTpcNSigmaKa = candidate.nSigTpcKa1(); - float valueTpcNSigmaPi; - float valueTofNSigmaPr; + float valueTpcNSigmaPi{}; + float valueTofNSigmaPr{}; const float valueTofNSigmaKa = candidate.nSigTofKa1(); - float valueTofNSigmaPi; - float valueTpcTofNSigmaPr; + float valueTofNSigmaPi{}; + float valueTpcTofNSigmaPr{}; const float valueTpcTofNSigmaKa = candidate.tpcTofNSigmaKa1(); - float valueTpcTofNSigmaPi; + float valueTpcTofNSigmaPi{}; if (candFlag == 0) { chi2primProton = candidate.kfChi2PrimProng0(); chi2primPion = candidate.kfChi2PrimProng2(); @@ -875,16 +875,16 @@ struct HfTreeCreatorLcToPKPi { const float chi2Topo = candidate.kfChi2Topo(); const float decayLength = candidate.kfDecayLength(); const float dl = candidate.kfDecayLengthError(); - const float pt = std::sqrt(candidate.kfPx() * candidate.kfPx() + candidate.kfPy() * candidate.kfPy()); + const float pt = std::hypot(candidate.kfPx(), candidate.kfPy()); const float deltaPt = std::sqrt(candidate.kfPx() * candidate.kfPx() * candidate.kfErrorPx() * candidate.kfErrorPx() + candidate.kfPy() * candidate.kfPy() * candidate.kfErrorPy() * candidate.kfErrorPy()) / pt; - const float p = std::sqrt(pt * pt + candidate.kfPz() * candidate.kfPz()); + const float p = std::hypot(pt, candidate.kfPz()); const float deltaP = std::sqrt(pt * pt * deltaPt * deltaPt + candidate.kfPz() * candidate.kfPz() * candidate.kfErrorPz() * candidate.kfErrorPz()) / p; - const float lifetime = decayLength * MassLambdaCPlus / LightSpeedCm2PS / p; - const float deltaT = dl * MassLambdaCPlus / LightSpeedCm2PS / p; + const float lifetime = decayLength * static_cast(MassLambdaCPlus) / LightSpeedCm2PS / p; + const float deltaT = dl * static_cast(MassLambdaCPlus) / LightSpeedCm2PS / p; rowCandidateKF( svX, svY, svZ, svErrX, svErrY, svErrZ, pvErrX, pvErrY, pvErrZ, @@ -924,17 +924,17 @@ struct HfTreeCreatorLcToPKPi { fillEventProperties(collisions); - const size_t candidatesSize = candidates.size(); + const int64_t candidatesSize = static_cast(candidates.size()); reserveTables(candidatesSize, IsMc); int iCand{0}; for (const auto& candidate : candidates) { - auto candidateMlScore = candidateMlScores.rawIteratorAt(iCand); + const auto candidateMlScore = candidateMlScores.rawIteratorAt(iCand); ++iCand; - float ptProng0 = candidate.ptProng0(); - auto collision = candidate.template collision_as(); + const float ptProng0 = candidate.ptProng0(); + const auto collision = candidate.template collision_as(); auto fillTable = [&](int candFlag) { - double const pseudoRndm = ptProng0 * 1000. - static_cast(ptProng0 * 1000); + double const pseudoRndm = ptProng0 * 1000. - static_cast(static_cast(ptProng0 * 1000)); const int functionSelection = candFlag == 0 ? candidate.isSelLcToPKPi() : candidate.isSelLcToPiKP(); const int sigbgstatus = determineSignalBgStatus(candidate, candFlag); const bool isMcCandidateSignal = (sigbgstatus == Prompt) || (sigbgstatus == NonPrompt); @@ -954,7 +954,7 @@ struct HfTreeCreatorLcToPKPi { fillKFTable(candidate, collision, candFlag, functionSelection, sigbgstatus); } if (fillCandidateMcTable) { - float p, pt, svX, svY, svZ, pvX, pvY, pvZ, decayLength, lifetime; + float p{}, pt{}, svX{}, svY{}, svZ{}, pvX{}, pvY{}, pvZ{}, decayLength{}, lifetime{}; if (!isMcCandidateSignal) { p = UndefValueFloat; pt = UndefValueFloat; @@ -967,13 +967,13 @@ struct HfTreeCreatorLcToPKPi { decayLength = UndefValueFloat; lifetime = UndefValueFloat; } else { - auto mcParticleProng0 = candidate.template prong0_as>().template mcParticle_as>(); - auto indexMother = RecoDecay::getMother(particles, mcParticleProng0, o2::constants::physics::Pdg::kLambdaCPlus, true); - auto particleMother = particles.rawIteratorAt(indexMother); - auto mcCollision = particleMother.template mcCollision_as(); + const auto mcParticleProng0 = candidate.template prong0_as>().template mcParticle_as>(); + const auto indexMother = RecoDecay::getMother(particles, mcParticleProng0, o2::constants::physics::Pdg::kLambdaCPlus, true); + const auto particleMother = particles.rawIteratorAt(indexMother); + const auto mcCollision = particleMother.template mcCollision_as(); p = particleMother.p(); pt = particleMother.pt(); - const float p2m = p / MassLambdaCPlus; + const float p2m = p / static_cast(MassLambdaCPlus); const float gamma = std::sqrt(1 + p2m * p2m); // mother's particle Lorentz factor pvX = mcCollision.posX(); pvY = mcCollision.posY(); @@ -981,7 +981,7 @@ struct HfTreeCreatorLcToPKPi { svX = mcParticleProng0.vx(); svY = mcParticleProng0.vy(); svZ = mcParticleProng0.vz(); - decayLength = RecoDecay::distance(std::array{svX, svY, svZ}, std::array{pvX, pvY, pvZ}); + decayLength = static_cast(RecoDecay::distance(std::array{svX, svY, svZ}, std::array{pvX, pvY, pvZ})); lifetime = mcParticleProng0.vt() * NanoToPico / gamma; // from ns to ps * from lab time to proper time } rowCandidateMC( @@ -1000,10 +1000,10 @@ struct HfTreeCreatorLcToPKPi { rowCandidateFullParticles.reserve(particles.size()); for (const auto& particle : particles) { if (std::abs(particle.flagMcMatchGen()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { - auto mcDaughter0 = particle.template daughters_as>().begin(); - auto mcCollision = particle.template mcCollision_as(); - auto p = particle.p(); - const float p2m = p / MassLambdaCPlus; + const auto mcDaughter0 = particle.template daughters_as>().begin(); + const auto mcCollision = particle.template mcCollision_as(); + const auto p = particle.p(); + const float p2m = p / static_cast(MassLambdaCPlus); const float gamma = std::sqrt(1 + p2m * p2m); // mother's particle Lorentz factor const float pvX = mcCollision.posX(); const float pvY = mcCollision.posY(); @@ -1011,7 +1011,7 @@ struct HfTreeCreatorLcToPKPi { const float svX = mcDaughter0.vx(); const float svY = mcDaughter0.vy(); const float svZ = mcDaughter0.vz(); - const float l = RecoDecay::distance(std::array{svX, svY, svZ}, std::array{pvX, pvY, pvZ}); + const float l = static_cast(RecoDecay::distance(std::array{svX, svY, svZ}, std::array{pvX, pvY, pvZ})); const float t = mcDaughter0.vt() * NanoToPico / gamma; // from ns to ps * from lab time to proper time rowCandidateFullParticles( particle.pt(), @@ -1111,19 +1111,19 @@ struct HfTreeCreatorLcToPKPi { fillEventProperties(collisions); - const size_t candidatesSize = candidates.size(); + const size_t candidatesSize = static_cast(candidates.size()); reserveTables(candidatesSize, IsMc); // Filling candidate properties int iCand{0}; for (const auto& candidate : candidates) { - auto candidateMlScore = candidateMlScores.rawIteratorAt(iCand); + const auto candidateMlScore = candidateMlScores.rawIteratorAt(iCand); ++iCand; - float ptProng0 = candidate.ptProng0(); - auto collision = candidate.template collision_as(); + const float ptProng0 = candidate.ptProng0(); + const auto collision = candidate.template collision_as(); auto fillTable = [&](int candFlag) { - double const pseudoRndm = ptProng0 * 1000. - static_cast(ptProng0 * 1000); + double const pseudoRndm = ptProng0 * 1000. - static_cast(static_cast(ptProng0 * 1000)); const int functionSelection = candFlag == 0 ? candidate.isSelLcToPKPi() : candidate.isSelLcToPiKP(); if (functionSelection >= selectionFlagLc && (candidate.pt() > downSampleBkgPtMax || (pseudoRndm < downSampleBkgFactor && candidate.pt() < downSampleBkgPtMax))) { if (fillCandidateLiteTable) { diff --git a/Tools/KFparticle/KFUtilities.h b/Tools/KFparticle/KFUtilities.h index bec24fd7adc..b6c6e607a9b 100644 --- a/Tools/KFparticle/KFUtilities.h +++ b/Tools/KFparticle/KFUtilities.h @@ -19,19 +19,19 @@ #define TOOLS_KFPARTICLE_KFUTILITIES_H_ #ifndef HomogeneousField -#define HomogeneousField +#define HomogeneousField // o2-linter: disable=name/macro (required by KFParticle) #endif #include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" +#include #include +#include #include #include #include -#include // FIXME - #include #include #include @@ -43,6 +43,12 @@ #include #include +constexpr float ArbitrarySmallNumber{1e-8f}; +constexpr float ArbitraryHugeNumber{1e8f}; +constexpr float UndefLdLValue{9999.f}; +constexpr int NumberOfMomentumComponents{3}; +constexpr int NumberOfCovMatrixComponents{21}; + /// @brief Function to create a KFPVertex from the collision table in the AO2Ds. /// The Multiplicity table is required to set the number of real PV Contributors /// This function works only for Run 3 data. @@ -70,24 +76,20 @@ KFPTrack createKFPTrack(const o2::track::TrackParametrizationWithError& t int16_t tpcNClsFound, float tpcChi2NCl) { - std::array trkpos_par; - std::array trkmom_par; - std::array trk_cov; - trackparCov.getXYZGlo(trkpos_par); - trackparCov.getPxPyPzGlo(trkmom_par); - trackparCov.getCovXYZPxPyPzGlo(trk_cov); - float trkpar_KF[6] = {trkpos_par[0], trkpos_par[1], trkpos_par[2], - trkmom_par[0], trkmom_par[1], trkmom_par[2]}; - float trkcov_KF[21]; - for (int i = 0; i < 21; i++) { - trkcov_KF[i] = trk_cov[i]; - } + std::array trkPositionPar{}; + std::array trkMomentumPar{}; + std::array trkCovMatrix{}; + trackparCov.getXYZGlo(trkPositionPar); + trackparCov.getPxPyPzGlo(trkMomentumPar); + trackparCov.getCovXYZPxPyPzGlo(trkCovMatrix); + const float trkParKf[6] = {trkPositionPar[0], trkPositionPar[1], trkPositionPar[2], + trkMomentumPar[0], trkMomentumPar[1], trkMomentumPar[2]}; KFPTrack kfpTrack; - kfpTrack.SetParameters(trkpar_KF); - kfpTrack.SetCovarianceMatrix(trkcov_KF); + kfpTrack.SetParameters(trkParKf); + kfpTrack.SetCovarianceMatrix(trkCovMatrix.data()); kfpTrack.SetCharge(trackSign); kfpTrack.SetNDF(tpcNClsFound - 5); - kfpTrack.SetChi2(tpcNClsFound * tpcChi2NCl); + kfpTrack.SetChi2(static_cast(tpcNClsFound) * tpcChi2NCl); return kfpTrack; } @@ -130,12 +132,12 @@ KFParticle createKFParticleFromTrackParCov(const o2::track::TrackParametrization float xyzpxpypz[6]; trackparCov.getPxPyPzGlo(pxpypz); trackparCov.getXYZGlo(xyz); - for (int i{0}; i < 3; ++i) { + for (int i{0}; i < NumberOfMomentumComponents; ++i) { xyzpxpypz[i] = xyz[i]; xyzpxpypz[i + 3] = pxpypz[i]; } - std::array cv; + std::array cv{}; try { trackparCov.getCovXYZPxPyPzGlo(cv); } catch (std::runtime_error& e) { @@ -143,9 +145,9 @@ KFParticle createKFParticleFromTrackParCov(const o2::track::TrackParametrization } KFParticle kfPart; - float Mini, SigmaMini, M, SigmaM; - kfPart.GetMass(Mini, SigmaMini); - LOG(debug) << "Daughter KFParticle mass before creation: " << Mini << " +- " << SigmaMini; + float mInit{}, sigmaMInit{}, m{}, sigmaM{}; + kfPart.GetMass(mInit, sigmaMInit); + LOG(debug) << "Daughter KFParticle mass before creation: " << mInit << " +- " << sigmaMInit; try { kfPart.Create(xyzpxpypz, cv.data(), charge, mass); @@ -153,8 +155,8 @@ KFParticle createKFParticleFromTrackParCov(const o2::track::TrackParametrization LOG(debug) << "Failed to create KFParticle from daughter TrackParCov" << e.what(); } - kfPart.GetMass(M, SigmaM); - LOG(debug) << "Daughter KFParticle mass after creation: " << M << " +- " << SigmaM; + kfPart.GetMass(m, sigmaM); + LOG(debug) << "Daughter KFParticle mass after creation: " << m << " +- " << sigmaM; return kfPart; } @@ -165,8 +167,8 @@ KFParticle createKFParticleFromTrackParCov(const o2::track::TrackParametrization /// @return o2::track::TrackParametrizationWithError track o2::track::TrackParCov getTrackParCovFromKFP(const KFParticle& kfParticle, const o2::track::PID pid, const int sign) { - std::array xyz, pxpypz; - std::array cv; + std::array xyz{}, pxpypz{}; + std::array cv{}; // get parameters from kfParticle xyz[0] = kfParticle.GetX(); @@ -177,7 +179,7 @@ o2::track::TrackParCov getTrackParCovFromKFP(const KFParticle& kfParticle, const pxpypz[2] = kfParticle.GetPz(); // set covariance matrix elements (lower triangle) - for (int i = 0; i < 21; i++) { + for (int i = 0; i < NumberOfCovMatrixComponents; i++) { cv[i] = kfParticle.GetCovariance(i); } @@ -192,7 +194,7 @@ o2::track::TrackParCov getTrackParCovFromKFP(const KFParticle& kfParticle, const /// @return cpa float cpaFromKF(KFParticle kfp, KFParticle PV) { - float xVtxP, yVtxP, zVtxP, xVtxS, yVtxS, zVtxS, px, py, pz = 0.; + float xVtxP{}, yVtxP{}, zVtxP{}, xVtxS{}, yVtxS{}, zVtxS{}, px{}, py{}, pz{}; xVtxP = PV.GetX(); yVtxP = PV.GetY(); @@ -206,7 +208,7 @@ float cpaFromKF(KFParticle kfp, KFParticle PV) py = kfp.GetPy(); pz = kfp.GetPz(); - float cpa = RecoDecay::cpa(std::array{xVtxP, yVtxP, zVtxP}, std::array{xVtxS, yVtxS, zVtxS}, std::array{px, py, pz}); + const float cpa = static_cast(RecoDecay::cpa(std::array{xVtxP, yVtxP, zVtxP}, std::array{xVtxS, yVtxS, zVtxS}, std::array{px, py, pz})); return cpa; } @@ -216,7 +218,7 @@ float cpaFromKF(KFParticle kfp, KFParticle PV) /// @return cpa in xy float cpaXYFromKF(KFParticle kfp, KFParticle PV) { - float xVtxP, yVtxP, xVtxS, yVtxS, px, py = 0.; + float xVtxP{}, yVtxP{}, xVtxS{}, yVtxS{}, px{}, py{}; xVtxP = PV.GetX(); yVtxP = PV.GetY(); @@ -227,7 +229,7 @@ float cpaXYFromKF(KFParticle kfp, KFParticle PV) px = kfp.GetPx(); py = kfp.GetPy(); - float cpaXY = RecoDecay::cpaXY(std::array{xVtxP, yVtxP}, std::array{xVtxS, yVtxS}, std::array{px, py}); + const float cpaXY = static_cast(RecoDecay::cpaXY(std::array{xVtxP, yVtxP}, std::array{xVtxS, yVtxS}, std::array{px, py})); return cpaXY; } @@ -239,10 +241,11 @@ float cpaXYFromKF(KFParticle kfp, KFParticle PV) /// @param kfpvtx KFPartice mother /// @param kfpprong0 KFParticle Prong 0 /// @param kfpprong1 KFParticele Prong 1 +/// @param pdgdb Service PDG data base /// @return cos theta star -float cosThetaStarFromKF(int ip, int pdgvtx, int pdgprong0, int pdgprong1, KFParticle kfpprong0, KFParticle kfpprong1) +float cosThetaStarFromKF(int iProng, int pdgvtx, int pdgprong0, int pdgprong1, KFParticle kfpprong0, KFParticle kfpprong1, const o2::framework::Service& pdgdb) { - float px0, py0, pz0, px1, py1, pz1 = 0.; + float px0{}, py0{}, pz0{}, px1{}, py1{}, pz1{}; px0 = kfpprong0.GetPx(); py0 = kfpprong0.GetPy(); @@ -252,12 +255,11 @@ float cosThetaStarFromKF(int ip, int pdgvtx, int pdgprong0, int pdgprong1, KFPar py1 = kfpprong1.GetPy(); pz1 = kfpprong1.GetPz(); std::array m = {0., 0.}; - m[0] = TDatabasePDG::Instance()->GetParticle(pdgprong0)->Mass(); // FIXME: Get from the PDG service of the common header - m[1] = TDatabasePDG::Instance()->GetParticle(pdgprong1)->Mass(); // FIXME: Get from the PDG service of the common header - double mTot = TDatabasePDG::Instance()->GetParticle(pdgvtx)->Mass(); // FIXME: Get from the PDG service of the common header - int iProng = ip; + m[0] = pdgdb->Mass(pdgprong0); + m[1] = pdgdb->Mass(pdgprong1); + const double mTot = pdgdb->Mass(pdgvtx); - float cosThetastar = RecoDecay::cosThetaStar(std::array{std::array{px0, py0, pz0}, std::array{px1, py1, pz1}}, m, mTot, iProng); + const float cosThetastar = static_cast(RecoDecay::cosThetaStar(std::array{std::array{px0, py0, pz0}, std::array{px1, py1, pz1}}, m, mTot, iProng)); return cosThetastar; } @@ -269,7 +271,7 @@ float cosThetaStarFromKF(int ip, int pdgvtx, int pdgprong0, int pdgprong1, KFPar /// @return impact parameter float impParXYFromKF(KFParticle kfpParticle, KFParticle Vertex) { - float xVtxP, yVtxP, zVtxP, xVtxS, yVtxS, zVtxS, px, py, pz = 0.; + float xVtxP{}, yVtxP{}, zVtxP{}, xVtxS{}, yVtxS{}, zVtxS{}, px{}, py{}, pz{}; xVtxP = Vertex.GetX(); yVtxP = Vertex.GetY(); @@ -283,7 +285,7 @@ float impParXYFromKF(KFParticle kfpParticle, KFParticle Vertex) py = kfpParticle.GetPy(); pz = kfpParticle.GetPz(); - float impParXY = RecoDecay::impParXY(std::array{xVtxP, yVtxP, zVtxP}, std::array{xVtxS, yVtxS, zVtxS}, std::array{px, py, pz}); + const float impParXY = static_cast(RecoDecay::impParXY(std::array{xVtxP, yVtxP, zVtxP}, std::array{xVtxS, yVtxS, zVtxS}, std::array{px, py, pz})); return impParXY; } @@ -293,17 +295,17 @@ float impParXYFromKF(KFParticle kfpParticle, KFParticle Vertex) /// @return l/delta l float ldlFromKF(KFParticle kfpParticle, KFParticle PV) { - float dx_particle = PV.GetX() - kfpParticle.GetX(); - float dy_particle = PV.GetY() - kfpParticle.GetY(); - float dz_particle = PV.GetZ() - kfpParticle.GetZ(); - float l_particle = sqrt(dx_particle * dx_particle + dy_particle * dy_particle + dz_particle * dz_particle); - float dl_particle = (PV.GetCovariance(0) + kfpParticle.GetCovariance(0)) * dx_particle * dx_particle + (PV.GetCovariance(2) + kfpParticle.GetCovariance(2)) * dy_particle * dy_particle + (PV.GetCovariance(5) + kfpParticle.GetCovariance(5)) * dz_particle * dz_particle + 2 * ((PV.GetCovariance(1) + kfpParticle.GetCovariance(1)) * dx_particle * dy_particle + (PV.GetCovariance(3) + kfpParticle.GetCovariance(3)) * dx_particle * dz_particle + (PV.GetCovariance(4) + kfpParticle.GetCovariance(4)) * dy_particle * dz_particle); - if (fabs(l_particle) < 1.e-8f) - l_particle = 1.e-8f; - dl_particle = dl_particle < 0. ? 1.e8f : sqrt(dl_particle) / l_particle; - if (dl_particle == 0.) - return 9999.; - return l_particle / dl_particle; + const float dxParticle = PV.GetX() - kfpParticle.GetX(); + const float dyParticle = PV.GetY() - kfpParticle.GetY(); + const float dzParticle = PV.GetZ() - kfpParticle.GetZ(); + float lParticle = std::hypot(dxParticle, dyParticle, dzParticle); + float dlParticle = (PV.GetCovariance(0) + kfpParticle.GetCovariance(0)) * dxParticle * dxParticle + (PV.GetCovariance(2) + kfpParticle.GetCovariance(2)) * dyParticle * dyParticle + (PV.GetCovariance(5) + kfpParticle.GetCovariance(5)) * dzParticle * dzParticle + 2 * ((PV.GetCovariance(1) + kfpParticle.GetCovariance(1)) * dxParticle * dyParticle + (PV.GetCovariance(3) + kfpParticle.GetCovariance(3)) * dxParticle * dzParticle + (PV.GetCovariance(4) + kfpParticle.GetCovariance(4)) * dyParticle * dzParticle); + if (std::fabs(lParticle) < ArbitrarySmallNumber) + lParticle = ArbitrarySmallNumber; + dlParticle = dlParticle < 0.f ? ArbitraryHugeNumber : std::sqrt(dlParticle) / lParticle; + if (dlParticle == 0.) + return UndefLdLValue; + return lParticle / dlParticle; } /// @brief distance between production vertex and decay vertex normalised by the uncertainty in xy plane @@ -312,16 +314,16 @@ float ldlFromKF(KFParticle kfpParticle, KFParticle PV) /// @return l/delta l in xy plane float ldlXYFromKF(KFParticle kfpParticle, KFParticle PV) { - float dx_particle = PV.GetX() - kfpParticle.GetX(); - float dy_particle = PV.GetY() - kfpParticle.GetY(); - float l_particle = sqrt(dx_particle * dx_particle + dy_particle * dy_particle); - float dl_particle = (PV.GetCovariance(0) + kfpParticle.GetCovariance(0)) * dx_particle * dx_particle + (PV.GetCovariance(2) + kfpParticle.GetCovariance(2)) * dy_particle * dy_particle + 2 * ((PV.GetCovariance(1) + kfpParticle.GetCovariance(1)) * dx_particle * dy_particle); - if (fabs(l_particle) < 1.e-8f) - l_particle = 1.e-8f; - dl_particle = dl_particle < 0. ? 1.e8f : sqrt(dl_particle) / l_particle; - if (dl_particle == 0.) - return 9999.; - return l_particle / dl_particle; + const float dxParticle = PV.GetX() - kfpParticle.GetX(); + const float dyParticle = PV.GetY() - kfpParticle.GetY(); + float lParticle = std::hypot(dxParticle, dyParticle); + float dlParticle = (PV.GetCovariance(0) + kfpParticle.GetCovariance(0)) * dxParticle * dxParticle + (PV.GetCovariance(2) + kfpParticle.GetCovariance(2)) * dyParticle * dyParticle + 2 * ((PV.GetCovariance(1) + kfpParticle.GetCovariance(1)) * dxParticle * dyParticle); + if (std::fabs(lParticle) < ArbitrarySmallNumber) + lParticle = ArbitrarySmallNumber; + dlParticle = dlParticle < 0.f ? ArbitraryHugeNumber : std::sqrt(dlParticle) / lParticle; + if (dlParticle == 0.) + return UndefLdLValue; + return lParticle / dlParticle; } /// @brief squared distance between track and primary vertex normalised by its uncertainty evaluated in matrix form @@ -330,9 +332,9 @@ float ldlXYFromKF(KFParticle kfpParticle, KFParticle PV) /// @return chi2 to primary vertex float kfCalculateChi2ToPrimaryVertex(KFParticle track, const KFParticle& vtx) { - const float PvPoint[3] = {vtx.X(), vtx.Y(), vtx.Z()}; + const float pvPoint[3] = {vtx.X(), vtx.Y(), vtx.Z()}; - track.TransportToPoint(PvPoint); + track.TransportToPoint(pvPoint); return track.GetDeviationFromVertex(vtx); } @@ -342,9 +344,9 @@ float kfCalculateChi2ToPrimaryVertex(KFParticle track, const KFParticle& vtx) /// @return array with components of prong's momentum in the secondary (decay) vertex std::array kfCalculateProngMomentumInSecondaryVertex(KFParticle track, const KFParticle& vtx) { - const float SvPoint[3] = {vtx.X(), vtx.Y(), vtx.Z()}; + const float svPoint[3] = {vtx.X(), vtx.Y(), vtx.Z()}; - track.TransportToPoint(SvPoint); + track.TransportToPoint(svPoint); return {track.GetPx(), track.GetPy(), track.GetPz()}; } @@ -364,7 +366,7 @@ float kfCalculateDistanceBetweenParticles(KFParticle track1, KFParticle track2) const float dx = params1[0] - params2[0]; const float dy = params1[1] - params2[1]; const float dz = params1[2] - params2[2]; - return std::sqrt(dx * dx + dy * dy + dz * dz); + return std::hypot(dx, dy, dz); } /// @brief squared distance between two tracks normalised by its uncertainty evaluated in matrix form @@ -374,11 +376,11 @@ float kfCalculateDistanceBetweenParticles(KFParticle track1, KFParticle track2) float kfCalculateChi2geoBetweenParticles(KFParticle track1, KFParticle track2) { KFParticle kfPair; - const KFParticle* kfDaughters[3] = {&track1, &track2}; + const KFParticle* kfDaughters[2] = {&track1, &track2}; kfPair.SetConstructMethod(2); kfPair.Construct(kfDaughters, 2); - return kfPair.Chi2() / kfPair.NDF(); + return kfPair.Chi2() / static_cast(kfPair.NDF()); } /// @brief signed distance between primary and secondary vertex and its uncertainty, cm @@ -387,7 +389,7 @@ float kfCalculateChi2geoBetweenParticles(KFParticle track1, KFParticle track2) /// @return pair of l and delta l std::pair kfCalculateLdL(KFParticle candidate, const KFParticle& vtx) { - float l, dl; + float l{}, dl{}; candidate.SetProductionVertex(vtx); candidate.KFParticleBase::GetDecayLength(l, dl); @@ -400,7 +402,7 @@ std::pair kfCalculateLdL(KFParticle candidate, const KFParticle& v /// @return pair of impact parameter and its error std::pair kfCalculateImpactParameterZ(const KFParticle& candidate, const KFParticle& vtx) { - float distanceToVertexXY, errDistanceToVertexXY; + float distanceToVertexXY{}, errDistanceToVertexXY{}; candidate.GetDistanceFromVertexXY(vtx, distanceToVertexXY, errDistanceToVertexXY); const float distanceToVertex = candidate.GetDistanceFromVertex(vtx); const float chi2ToVertex = candidate.GetDeviationFromVertex(vtx); diff --git a/Tools/KFparticle/qaKFParticle.cxx b/Tools/KFparticle/qaKFParticle.cxx index c634d0837a4..0389d9b1fc3 100644 --- a/Tools/KFparticle/qaKFParticle.cxx +++ b/Tools/KFparticle/qaKFParticle.cxx @@ -15,30 +15,14 @@ /// \brief Task to test the performance of the KFParticle package /// +#ifndef HomogeneousField +#define HomogeneousField // o2-linter: disable=name/macro (required by KFParticle) +#endif + #include "Tools/KFparticle/qaKFParticle.h" #include "TableHelper.h" -#include - -#include -#include - -#include - -/// includes O2 -#include "DataFormatsParameters/GRPMagField.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DetectorsBase/GeometryManager.h" -#include "DetectorsBase/Propagator.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/DCA.h" -#include "ReconstructionDataFormats/Track.h" - -/// includes O2Physics #include "Common/Core/RecoDecay.h" #include "Common/Core/TrackSelection.h" #include "Common/Core/TrackSelectionDefaults.h" @@ -49,18 +33,30 @@ #include "Common/DataModel/TrackSelectionTables.h" #include "Tools/KFparticle/KFUtilities.h" -/// includes KFParticle -#include "KFPTrack.h" -#include "KFPVertex.h" -#include "KFParticle.h" -#include "KFParticleBase.h" -#include "KFVertex.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#ifndef HomogeneousField +#include +#include -#define HomogeneousField +#include +#include +#include +#include +#include -#endif +#include using namespace o2; using namespace o2::framework; @@ -76,6 +72,7 @@ struct qaKFParticle { Configurable ccdbPathGrp{"ccdbPathGrp", "GLO/GRP/GRP", "Path of the grp file (Run 2)"}; Configurable ccdbPathGrpMag{"ccdbPathGrpMag", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object (Run 3)"}; Service ccdb; + Service pdgdb; o2::base::MatLayerCylSet* lut; o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; int runNumber; @@ -335,22 +332,22 @@ struct qaKFParticle { bool isSelectedTracks(const T& track1, const T& track2) { /// DCA XY of the daughter tracks to the primaty vertex - if (fabs(track1.dcaXY()) > d_dcaXYTrackPV) { + if (std::fabs(track1.dcaXY()) > d_dcaXYTrackPV) { histos.fill(HIST("DZeroCandTopo/Selections"), 6.f); return false; } /// DCA XY of the daughter tracks to the primaty vertex - if (fabs(track2.dcaXY()) > d_dcaXYTrackPV) { + if (std::fabs(track2.dcaXY()) > d_dcaXYTrackPV) { histos.fill(HIST("DZeroCandTopo/Selections"), 6.f); return false; } /// DCA Z of the daughter tracks to the primaty vertex - if (fabs(track1.dcaZ()) > d_dcaZTrackPV) { + if (std::fabs(track1.dcaZ()) > d_dcaZTrackPV) { histos.fill(HIST("DZeroCandTopo/Selections"), 7.f); return false; } /// DCA Z of the daughter tracks to the primaty vertex - if (fabs(track2.dcaZ()) > d_dcaZTrackPV) { + if (std::fabs(track2.dcaZ()) > d_dcaZTrackPV) { histos.fill(HIST("DZeroCandTopo/Selections"), 7.f); return false; } @@ -462,15 +459,15 @@ struct qaKFParticle { { switch (particle) { case kPiPlus: { - if ((track.pt() <= ptPidTofMinPi) && track.hasTPC() && (abs(track.tpcNSigmaPi()) < nSigmaTpcMaxPi)) { + if ((track.pt() <= ptPidTofMinPi) && track.hasTPC() && (std::abs(track.tpcNSigmaPi()) < nSigmaTpcMaxPi)) { return true; - } else if ((track.pt() > ptPidTofMinPi) && track.hasTPC() && !track.hasTOF() && (abs(track.tpcNSigmaPi()) < nSigmaTpcMaxPi)) { + } else if ((track.pt() > ptPidTofMinPi) && track.hasTPC() && !track.hasTOF() && (std::abs(track.tpcNSigmaPi()) < nSigmaTpcMaxPi)) { return true; - } else if ((track.pt() > ptPidTofMinPi) && !track.hasTPC() && track.hasTOF() && (abs(track.tofNSigmaPi()) < nSigmaTofMaxPi)) { + } else if ((track.pt() > ptPidTofMinPi) && !track.hasTPC() && track.hasTOF() && (std::abs(track.tofNSigmaPi()) < nSigmaTofMaxPi)) { return true; } else if ((track.pt() > ptPidTofMinPi) && track.hasTPC() && track.hasTOF()) { - float CombinednSigma = 1. / sqrt(2) * sqrt((track.tpcNSigmaPi() * track.tpcNSigmaPi()) + (track.tofNSigmaPi() * track.tofNSigmaPi())); - if (abs(CombinednSigma) < nSigmaCombMaxPi) { + float CombinednSigma = 1. / std::sqrt(2) * std::sqrt((track.tpcNSigmaPi() * track.tpcNSigmaPi()) + (track.tofNSigmaPi() * track.tofNSigmaPi())); + if (std::abs(CombinednSigma) < nSigmaCombMaxPi) { return true; } else { return false; @@ -481,15 +478,15 @@ struct qaKFParticle { break; } case kKPlus: { - if ((track.pt() <= ptPidTofMinKa) && track.hasTPC() && (abs(track.tpcNSigmaKa()) < nSigmaTpcMaxKa)) { + if ((track.pt() <= ptPidTofMinKa) && track.hasTPC() && (std::abs(track.tpcNSigmaKa()) < nSigmaTpcMaxKa)) { return true; - } else if ((track.pt() > ptPidTofMinKa) && track.hasTPC() && !track.hasTOF() && (abs(track.tpcNSigmaKa()) < nSigmaTpcMaxKa)) { + } else if ((track.pt() > ptPidTofMinKa) && track.hasTPC() && !track.hasTOF() && (std::abs(track.tpcNSigmaKa()) < nSigmaTpcMaxKa)) { return true; - } else if ((track.pt() > ptPidTofMinKa) && !track.hasTPC() && track.hasTOF() && (abs(track.tofNSigmaKa()) < nSigmaTofMaxKa)) { + } else if ((track.pt() > ptPidTofMinKa) && !track.hasTPC() && track.hasTOF() && (std::abs(track.tofNSigmaKa()) < nSigmaTofMaxKa)) { return true; } else if ((track.pt() > ptPidTofMinKa) && track.hasTPC() && track.hasTOF()) { - float CombinednSigma = 1. / sqrt(2) * sqrt((track.tpcNSigmaKa() * track.tpcNSigmaKa()) + (track.tofNSigmaKa() * track.tofNSigmaKa())); - if (abs(CombinednSigma) < nSigmaCombMaxKa) { + float CombinednSigma = 1. / std::sqrt(2) * std::sqrt((track.tpcNSigmaKa() * track.tpcNSigmaKa()) + (track.tofNSigmaKa() * track.tofNSigmaKa())); + if (std::abs(CombinednSigma) < nSigmaCombMaxKa) { return true; } else { return false; @@ -598,7 +595,7 @@ struct qaKFParticle { float chi2geo = KFDZero.GetChi2() / KFDZero.GetNDF(); float normdecayLength = KFDZero_PV.GetDecayLength() / KFDZero_PV.GetErrDecayLength(); float chi2topo = KFDZero_PV.GetChi2() / KFDZero_PV.GetNDF(); - const double pseudoRndm = track1.pt() * 1000. - (int64_t)(track1.pt() * 1000); + const double pseudoRndm = track1.pt() * 1000. - static_cast((track1.pt() * 1000)); if (pseudoRndm < d_DwnSmplFact) { if (writeTree) { /// Filling the D0 tree @@ -800,7 +797,7 @@ struct qaKFParticle { continue; } /// Apply selection on geometrically reconstructed D0 - cosThetaStar = cosThetaStarFromKF(1, 421, 211, 321, KFPosPion, KFNegKaon); + cosThetaStar = cosThetaStarFromKF(1, 421, 211, 321, KFPosPion, KFNegKaon, pdgdb); if (!isSelectedDoGeo(KFDZero, KFPV, cosThetaStar)) { continue; } @@ -835,7 +832,7 @@ struct qaKFParticle { continue; } /// Apply selection on geometrically reconstructed D0 - cosThetaStar = cosThetaStarFromKF(0, 421, 321, 211, KFPosKaon, KFNegPion); + cosThetaStar = cosThetaStarFromKF(0, 421, 321, 211, KFPosKaon, KFNegPion, pdgdb); if (!isSelectedDoGeo(KFDZeroBar, KFPV, cosThetaStar)) { continue; } @@ -940,7 +937,7 @@ struct qaKFParticle { // KFPV = KFPVNew; // } // if (i > 1) { - // if (abs(matchedCollision.posZ() - collMC.posZ()) == min) { + // if (std::abs(matchedCollision.posZ() - collMC.posZ()) == min) { // kfpVertex = createKFPVertexFromCollision(matchedCollision); // KFParticle KFPVNew(kfpVertex); // KFPV = KFPVNew; @@ -1107,7 +1104,7 @@ struct qaKFParticle { continue; } /// Apply selection on geometrically reconstructed D0 - cosThetaStar = cosThetaStarFromKF(1, 421, 211, 321, KFPosPion, KFNegKaon); + cosThetaStar = cosThetaStarFromKF(1, 421, 211, 321, KFPosPion, KFNegKaon, pdgdb); if (!isSelectedDoGeo(KFDZero, KFPV, cosThetaStar)) { continue; } @@ -1147,7 +1144,7 @@ struct qaKFParticle { continue; } /// Apply selection on geometrically reconstructed D0 - cosThetaStar = cosThetaStarFromKF(0, 421, 321, 211, KFPosKaon, KFNegPion); + cosThetaStar = cosThetaStarFromKF(0, 421, 321, 211, KFPosKaon, KFNegPion, pdgdb); if (!isSelectedDoGeo(KFDZeroBar, KFPV, cosThetaStar)) { continue; }