diff --git a/PWGLF/DataModel/LFKinkDecayTables.h b/PWGLF/DataModel/LFKinkDecayTables.h index c636358e20b..aedab773b5e 100644 --- a/PWGLF/DataModel/LFKinkDecayTables.h +++ b/PWGLF/DataModel/LFKinkDecayTables.h @@ -229,6 +229,54 @@ DECLARE_SOA_COLUMN(PhotonPosTpcChi2NCl, photonPosTpcChi2NCl, float); DECLARE_SOA_COLUMN(PhotonNegTpcChi2NCl, photonNegTpcChi2NCl, float); //! TPC chi2 per cluster of the photon's negative daughter DECLARE_SOA_COLUMN(MlScore, mlScore, float); //! BDT score of the candidate (signal probability), -1 if not computed +// unbound tables (no index columns) +DECLARE_SOA_COLUMN(CollisionIndex, collisionIndex, int); //! Collision index in the timeframe +DECLARE_SOA_COLUMN(RunNumber, runNumber, int); //! Run number + +// KFParticle proton-photon vertex (-999 if not computed or failed) +DECLARE_SOA_COLUMN(KfChi2Ndf, kfChi2Ndf, float); //! chi2/NDF of the KFParticle proton-photon vertex +DECLARE_SOA_COLUMN(KfDevProtonGamma, kfDevProtonGamma, float); //! Proton-photon distance in units of its uncertainty (KFParticle) +DECLARE_SOA_COLUMN(KfDcaProtonGamma, kfDcaProtonGamma, float); //! Proton-photon distance (KFParticle, cm) +DECLARE_SOA_COLUMN(KfPhotonChi2Ndf, kfPhotonChi2Ndf, float); //! chi2/NDF of the KFParticle photon (e+e-) vertex +DECLARE_SOA_COLUMN(KfSigmaXYDecVtx, kfSigmaXYDecVtx, float); //! Transverse uncertainty of the KFParticle vertex, sqrt(Cxx + Cyy) (cm) +DECLARE_SOA_COLUMN(KfSigmaZDecVtx, kfSigmaZDecVtx, float); //! Longitudinal uncertainty of the KFParticle vertex, sqrt(Czz) (cm) +DECLARE_SOA_COLUMN(SigmaFlightDirT, sigmaFlightDirT, float); //! Flight-direction uncertainty in the xy plane (rad), -999 if not positive definite +DECLARE_SOA_COLUMN(SigmaFlightDirL, sigmaFlightDirL, float); //! Flight-direction uncertainty perpendicular to it (rad), -999 if not positive definite +DECLARE_SOA_COLUMN(SigmaMassSigmaPlus, sigmaMassSigmaPlus, float); //! Mass uncertainty from the flight-direction uncertainties (GeV/c^2) + +// primary vertex +DECLARE_SOA_COLUMN(PvX, pvX, float); //! Primary vertex (x direction, cm) +DECLARE_SOA_COLUMN(PvY, pvY, float); //! Primary vertex (y direction, cm) +DECLARE_SOA_COLUMN(PvZ, pvZ, float); //! Primary vertex (z direction, cm) + +// momentum correction (-999 if not computed), the mass columns stay uncorrected +DECLARE_SOA_COLUMN(PxSigmaPlusCorr, pxSigmaPlusCorr, float); //! Corrected Sigma+ momentum (x direction, GeV/c) +DECLARE_SOA_COLUMN(PySigmaPlusCorr, pySigmaPlusCorr, float); //! Corrected Sigma+ momentum (y direction, GeV/c) +DECLARE_SOA_COLUMN(PzSigmaPlusCorr, pzSigmaPlusCorr, float); //! Corrected Sigma+ momentum (z direction, GeV/c) +DECLARE_SOA_COLUMN(MassSigmaPlusCorr, massSigmaPlusCorr, float); //! Mass with the corrected flight direction (GeV/c^2) +DECLARE_SOA_COLUMN(FlightDirCorrAngle, flightDirCorrAngle, float); //! Angle between the corrected and the used flight direction (rad) +// flight direction used for the missing photon +DECLARE_SOA_COLUMN(FlightDirTheta, flightDirTheta, float); //! Polar angle of the used flight direction (rad) +DECLARE_SOA_COLUMN(FlightDirPhi, flightDirPhi, float); //! Azimuth of the used flight direction (rad) + +// further proton and photon variables +DECLARE_SOA_COLUMN(ProtonTpcChi2NCl, protonTpcChi2NCl, float); //! TPC chi2 per cluster of the proton track +DECLARE_SOA_COLUMN(ProtonItsChi2NCl, protonItsChi2NCl, float); //! ITS chi2 per cluster of the proton track +DECLARE_SOA_COLUMN(PhotonConvX, photonConvX, float); //! Photon conversion point (x direction, cm) +DECLARE_SOA_COLUMN(PhotonConvY, photonConvY, float); //! Photon conversion point (y direction, cm) +DECLARE_SOA_COLUMN(PhotonConvZ, photonConvZ, float); //! Photon conversion point (z direction, cm) +DECLARE_SOA_COLUMN(PhotonDcaToPV, photonDcaToPV, float); //! 3D distance of the photon's flight line to the PV (cm) +DECLARE_SOA_COLUMN(PhotonOpeningAngleVtx, photonOpeningAngleVtx, float); //! e+e- opening angle at the conversion point (rad) +DECLARE_SOA_COLUMN(PhotonDeltaTheta, photonDeltaTheta, float); //! theta(e+) - theta(e-) of the daughter tracks (rad) +DECLARE_SOA_COLUMN(PhotonDauMaxAbsEta, photonDauMaxAbsEta, float); //! Larger |eta| of the two photon daughter tracks +DECLARE_SOA_COLUMN(PhotonPosPt, photonPosPt, float); //! pT of the photon's positive daughter track (GeV/c) +DECLARE_SOA_COLUMN(PhotonNegPt, photonNegPt, float); //! pT of the photon's negative daughter track (GeV/c) +// track identities (plain integers) +DECLARE_SOA_COLUMN(ProtonTrackIndex, protonTrackIndex, int); //! Global index of the proton track +DECLARE_SOA_COLUMN(PhotonPosTrackIndex, photonPosTrackIndex, int); //! Global index of the photon's positive daughter track +DECLARE_SOA_COLUMN(PhotonNegTrackIndex, photonNegTrackIndex, int); //! Global index of the photon's negative daughter track +// proton PID for other species (TOF: -999 without TOF) + // MC columns DECLARE_SOA_COLUMN(CollisionIdCheck, collisionIdCheck, bool); //! True if the proton's collision ID matches the reconstructed collision ID @@ -236,20 +284,25 @@ DECLARE_SOA_COLUMN(IsSignal, isSignal, bool); //! True if the DECLARE_SOA_COLUMN(IsProtonFromSigma, isProtonFromSigma, bool); //! True if the proton is the daughter of a true Sigma+ -> p pi0 DECLARE_SOA_COLUMN(IsPhotonFromSigma, isPhotonFromSigma, bool); //! True if the photon is from the pi0 of a true Sigma+ -> p pi0 -DECLARE_SOA_COLUMN(XDecVtxMC, xDecVtxMC, float); //! MC-truth Sigma+ decay vertex (x direction) -DECLARE_SOA_COLUMN(YDecVtxMC, yDecVtxMC, float); //! MC-truth Sigma+ decay vertex (y direction) -DECLARE_SOA_COLUMN(ZDecVtxMC, zDecVtxMC, float); //! MC-truth Sigma+ decay vertex (z direction) -DECLARE_SOA_COLUMN(DecayRadiusMC, decayRadiusMC, float); //! MC-truth Sigma+ decay radius -DECLARE_SOA_COLUMN(MassMC, massMC, float); //! MC-truth invariant mass of the Sigma+ mother -DECLARE_SOA_COLUMN(PxSigmaPlusMC, pxSigmaPlusMC, float); //! MC-truth Sigma+ mother Px -DECLARE_SOA_COLUMN(PySigmaPlusMC, pySigmaPlusMC, float); //! MC-truth Sigma+ mother Py -DECLARE_SOA_COLUMN(PzSigmaPlusMC, pzSigmaPlusMC, float); //! MC-truth Sigma+ mother Pz -DECLARE_SOA_COLUMN(PxProtonMC, pxProtonMC, float); //! MC-truth proton Px -DECLARE_SOA_COLUMN(PyProtonMC, pyProtonMC, float); //! MC-truth proton Py -DECLARE_SOA_COLUMN(PzProtonMC, pzProtonMC, float); //! MC-truth proton Pz -DECLARE_SOA_COLUMN(PxGammaMC, pxGammaMC, float); //! MC-truth momentum of the measured photon (Px) -DECLARE_SOA_COLUMN(PyGammaMC, pyGammaMC, float); //! MC-truth momentum of the measured photon (Py) -DECLARE_SOA_COLUMN(PzGammaMC, pzGammaMC, float); //! MC-truth momentum of the measured photon (Pz) +DECLARE_SOA_COLUMN(XDecVtxMC, xDecVtxMC, float); //! MC-truth Sigma+ decay vertex (x direction) +DECLARE_SOA_COLUMN(YDecVtxMC, yDecVtxMC, float); //! MC-truth Sigma+ decay vertex (y direction) +DECLARE_SOA_COLUMN(ZDecVtxMC, zDecVtxMC, float); //! MC-truth Sigma+ decay vertex (z direction) +DECLARE_SOA_COLUMN(DecayRadiusMC, decayRadiusMC, float); //! MC-truth Sigma+ decay radius +DECLARE_SOA_COLUMN(MassMC, massMC, float); //! MC-truth invariant mass of the Sigma+ mother +DECLARE_SOA_COLUMN(McParticleIndex, mcParticleIndex, int); //! MC particle of the true Sigma+ (plain integer, not an index column), -1 otherwise +DECLARE_SOA_COLUMN(ProtonPdgMC, protonPdgMC, int); //! PDG code of the MC particle of the proton track (0 if none) +DECLARE_SOA_COLUMN(ProtonMotherPdgMC, protonMotherPdgMC, int); //! PDG code of the first mother of that MC particle (0 if none) +DECLARE_SOA_COLUMN(PhotonPdgMC, photonPdgMC, int); //! PDG code of the first mother of the positive photon daughter (22 for a conversion, 0 if none) +DECLARE_SOA_COLUMN(PhotonMotherPdgMC, photonMotherPdgMC, int); //! PDG code of the first mother of that particle (0 if none) +DECLARE_SOA_COLUMN(PxSigmaPlusMC, pxSigmaPlusMC, float); //! MC-truth Sigma+ mother Px +DECLARE_SOA_COLUMN(PySigmaPlusMC, pySigmaPlusMC, float); //! MC-truth Sigma+ mother Py +DECLARE_SOA_COLUMN(PzSigmaPlusMC, pzSigmaPlusMC, float); //! MC-truth Sigma+ mother Pz +DECLARE_SOA_COLUMN(PxProtonMC, pxProtonMC, float); //! MC-truth proton Px +DECLARE_SOA_COLUMN(PyProtonMC, pyProtonMC, float); //! MC-truth proton Py +DECLARE_SOA_COLUMN(PzProtonMC, pzProtonMC, float); //! MC-truth proton Pz +DECLARE_SOA_COLUMN(PxGammaMC, pxGammaMC, float); //! MC-truth momentum of the measured photon (Px) +DECLARE_SOA_COLUMN(PyGammaMC, pyGammaMC, float); //! MC-truth momentum of the measured photon (Py) +DECLARE_SOA_COLUMN(PzGammaMC, pzGammaMC, float); //! MC-truth momentum of the measured photon (Pz) // DYNAMIC COLUMNS @@ -306,6 +359,7 @@ DECLARE_SOA_TABLE(SigmaPlusCands, "AOD", "SIGMAPLUSCANDS", sigmapluscand::PhotonPosDcaXY, sigmapluscand::PhotonPosDcaZ, sigmapluscand::PhotonNegDcaXY, sigmapluscand::PhotonNegDcaZ, sigmapluscand::PhotonPosTpcNClsFindable, sigmapluscand::PhotonNegTpcNClsFindable, sigmapluscand::PhotonPosTpcChi2NCl, sigmapluscand::PhotonNegTpcChi2NCl, sigmapluscand::MlScore, + sigmapluscand::PxSigmaPlusCorr, sigmapluscand::PySigmaPlusCorr, sigmapluscand::PzSigmaPlusCorr, // dynamic columns sigmapluscand::Radius, @@ -336,6 +390,7 @@ DECLARE_SOA_TABLE(SigmaPlusCandsMC, "AOD", "SIGMAPLUSMC", sigmapluscand::PhotonPosDcaXY, sigmapluscand::PhotonPosDcaZ, sigmapluscand::PhotonNegDcaXY, sigmapluscand::PhotonNegDcaZ, sigmapluscand::PhotonPosTpcNClsFindable, sigmapluscand::PhotonNegTpcNClsFindable, sigmapluscand::PhotonPosTpcChi2NCl, sigmapluscand::PhotonNegTpcChi2NCl, sigmapluscand::MlScore, + sigmapluscand::PxSigmaPlusCorr, sigmapluscand::PySigmaPlusCorr, sigmapluscand::PzSigmaPlusCorr, sigmapluscand::CollisionIdCheck, sigmapluscand::IsSignal, sigmapluscand::IsProtonFromSigma, sigmapluscand::IsPhotonFromSigma, sigmapluscand::XDecVtxMC, sigmapluscand::YDecVtxMC, sigmapluscand::ZDecVtxMC, @@ -412,6 +467,96 @@ DECLARE_SOA_TABLE(SlimSigmaPlusCandsMC, "AOD", "SLIMSIGMAPLUSMC", sigmapluscand::PtSigmaPlusMC, sigmapluscand::YSigmaPlusMC); +// unbound candidate tables: no index columns, readable without the parent tables +DECLARE_SOA_TABLE(SigmaPlusCandsUnbound, "AOD", "UBSIGMAPLUS", + sigmapluscand::CollisionIndex, sigmapluscand::RunNumber, + sigmapluscand::XDecVtx, sigmapluscand::YDecVtx, sigmapluscand::ZDecVtx, sigmapluscand::FlightDistance, + sigmapluscand::DcaProtonGamma, + sigmapluscand::PxProton, sigmapluscand::PyProton, sigmapluscand::PzProton, + sigmapluscand::PxGamma1, sigmapluscand::PyGamma1, sigmapluscand::PzGamma1, + sigmapluscand::PxGamma2, sigmapluscand::PyGamma2, sigmapluscand::PzGamma2, + sigmapluscand::NSigmaTPCProton, sigmapluscand::NSigmaTOFProton, + sigmapluscand::NSigmaTPCElPos, sigmapluscand::NSigmaTPCElNeg, + sigmapluscand::PhotonMass, sigmapluscand::PhotonAlpha, sigmapluscand::PhotonQt, sigmapluscand::PhotonConvRadius, + sigmapluscand::PhotonOpeningAngle, sigmapluscand::PhotonPointingAngle, + sigmapluscand::RootCenter, sigmapluscand::AntiSigmaPointingAngle, sigmapluscand::CandDcaToPV, sigmapluscand::FlightDirTilt, + sigmapluscand::ProtonSign, + sigmapluscand::ProtonItsNCls, sigmapluscand::ProtonTpcNCls, sigmapluscand::ProtonDcaXY, sigmapluscand::ProtonDcaZ, + sigmapluscand::PhotonPosItsNCls, sigmapluscand::PhotonPosTpcNCls, sigmapluscand::PhotonNegItsNCls, sigmapluscand::PhotonNegTpcNCls, + sigmapluscand::PhotonDcaDau, sigmapluscand::PhotonCosPAToPV, sigmapluscand::PhotonDcaXYToPV, sigmapluscand::PhotonDcaZToPV, sigmapluscand::PhotonPsiPair, + sigmapluscand::PhotonPosDcaXY, sigmapluscand::PhotonPosDcaZ, sigmapluscand::PhotonNegDcaXY, sigmapluscand::PhotonNegDcaZ, + sigmapluscand::PhotonPosTpcNClsFindable, sigmapluscand::PhotonNegTpcNClsFindable, sigmapluscand::PhotonPosTpcChi2NCl, sigmapluscand::PhotonNegTpcChi2NCl, + sigmapluscand::MlScore, + sigmapluscand::KfChi2Ndf, sigmapluscand::KfDevProtonGamma, sigmapluscand::KfDcaProtonGamma, sigmapluscand::KfPhotonChi2Ndf, + sigmapluscand::KfSigmaXYDecVtx, sigmapluscand::KfSigmaZDecVtx, + sigmapluscand::SigmaFlightDirT, sigmapluscand::SigmaFlightDirL, sigmapluscand::SigmaMassSigmaPlus, + sigmapluscand::PvX, sigmapluscand::PvY, sigmapluscand::PvZ, + sigmapluscand::PxSigmaPlusCorr, sigmapluscand::PySigmaPlusCorr, sigmapluscand::PzSigmaPlusCorr, sigmapluscand::MassSigmaPlusCorr, sigmapluscand::FlightDirCorrAngle, + sigmapluscand::FlightDirTheta, sigmapluscand::FlightDirPhi, + sigmapluscand::ProtonTpcChi2NCl, sigmapluscand::ProtonItsChi2NCl, + sigmapluscand::PhotonConvX, sigmapluscand::PhotonConvY, sigmapluscand::PhotonConvZ, sigmapluscand::PhotonDcaToPV, + sigmapluscand::PhotonOpeningAngleVtx, sigmapluscand::PhotonDeltaTheta, sigmapluscand::PhotonDauMaxAbsEta, + sigmapluscand::PhotonPosPt, sigmapluscand::PhotonNegPt, + sigmapluscand::ProtonTrackIndex, sigmapluscand::PhotonPosTrackIndex, sigmapluscand::PhotonNegTrackIndex, + + // dynamic columns + sigmapluscand::Radius, + sigmapluscand::PxSigmaPlus, + sigmapluscand::PySigmaPlus, + sigmapluscand::PzSigmaPlus, + sigmapluscand::PtSigmaPlus, + sigmapluscand::MassSigmaPlus); + +DECLARE_SOA_TABLE(SigmaPlusCandsUnboundMC, "AOD", "UBSIGMAPLUSMC", + sigmapluscand::CollisionIndex, sigmapluscand::RunNumber, + sigmapluscand::XDecVtx, sigmapluscand::YDecVtx, sigmapluscand::ZDecVtx, sigmapluscand::FlightDistance, + sigmapluscand::DcaProtonGamma, + sigmapluscand::PxProton, sigmapluscand::PyProton, sigmapluscand::PzProton, + sigmapluscand::PxGamma1, sigmapluscand::PyGamma1, sigmapluscand::PzGamma1, + sigmapluscand::PxGamma2, sigmapluscand::PyGamma2, sigmapluscand::PzGamma2, + sigmapluscand::NSigmaTPCProton, sigmapluscand::NSigmaTOFProton, + sigmapluscand::NSigmaTPCElPos, sigmapluscand::NSigmaTPCElNeg, + sigmapluscand::PhotonMass, sigmapluscand::PhotonAlpha, sigmapluscand::PhotonQt, sigmapluscand::PhotonConvRadius, + sigmapluscand::PhotonOpeningAngle, sigmapluscand::PhotonPointingAngle, + sigmapluscand::RootCenter, sigmapluscand::AntiSigmaPointingAngle, sigmapluscand::CandDcaToPV, sigmapluscand::FlightDirTilt, + sigmapluscand::ProtonSign, + sigmapluscand::ProtonItsNCls, sigmapluscand::ProtonTpcNCls, sigmapluscand::ProtonDcaXY, sigmapluscand::ProtonDcaZ, + sigmapluscand::PhotonPosItsNCls, sigmapluscand::PhotonPosTpcNCls, sigmapluscand::PhotonNegItsNCls, sigmapluscand::PhotonNegTpcNCls, + sigmapluscand::PhotonDcaDau, sigmapluscand::PhotonCosPAToPV, sigmapluscand::PhotonDcaXYToPV, sigmapluscand::PhotonDcaZToPV, sigmapluscand::PhotonPsiPair, + sigmapluscand::PhotonPosDcaXY, sigmapluscand::PhotonPosDcaZ, sigmapluscand::PhotonNegDcaXY, sigmapluscand::PhotonNegDcaZ, + sigmapluscand::PhotonPosTpcNClsFindable, sigmapluscand::PhotonNegTpcNClsFindable, sigmapluscand::PhotonPosTpcChi2NCl, sigmapluscand::PhotonNegTpcChi2NCl, + sigmapluscand::MlScore, + sigmapluscand::KfChi2Ndf, sigmapluscand::KfDevProtonGamma, sigmapluscand::KfDcaProtonGamma, sigmapluscand::KfPhotonChi2Ndf, + sigmapluscand::KfSigmaXYDecVtx, sigmapluscand::KfSigmaZDecVtx, + sigmapluscand::SigmaFlightDirT, sigmapluscand::SigmaFlightDirL, sigmapluscand::SigmaMassSigmaPlus, + sigmapluscand::PvX, sigmapluscand::PvY, sigmapluscand::PvZ, + sigmapluscand::PxSigmaPlusCorr, sigmapluscand::PySigmaPlusCorr, sigmapluscand::PzSigmaPlusCorr, sigmapluscand::MassSigmaPlusCorr, sigmapluscand::FlightDirCorrAngle, + sigmapluscand::FlightDirTheta, sigmapluscand::FlightDirPhi, + sigmapluscand::ProtonTpcChi2NCl, sigmapluscand::ProtonItsChi2NCl, + sigmapluscand::PhotonConvX, sigmapluscand::PhotonConvY, sigmapluscand::PhotonConvZ, sigmapluscand::PhotonDcaToPV, + sigmapluscand::PhotonOpeningAngleVtx, sigmapluscand::PhotonDeltaTheta, sigmapluscand::PhotonDauMaxAbsEta, + sigmapluscand::PhotonPosPt, sigmapluscand::PhotonNegPt, + sigmapluscand::ProtonTrackIndex, sigmapluscand::PhotonPosTrackIndex, sigmapluscand::PhotonNegTrackIndex, + sigmapluscand::McParticleIndex, + sigmapluscand::CollisionIdCheck, + sigmapluscand::IsSignal, sigmapluscand::IsProtonFromSigma, sigmapluscand::IsPhotonFromSigma, + sigmapluscand::ProtonPdgMC, sigmapluscand::ProtonMotherPdgMC, sigmapluscand::PhotonPdgMC, sigmapluscand::PhotonMotherPdgMC, + sigmapluscand::XDecVtxMC, sigmapluscand::YDecVtxMC, sigmapluscand::ZDecVtxMC, + sigmapluscand::PxProtonMC, sigmapluscand::PyProtonMC, sigmapluscand::PzProtonMC, + sigmapluscand::PxGammaMC, sigmapluscand::PyGammaMC, sigmapluscand::PzGammaMC, + sigmapluscand::PxSigmaPlusMC, sigmapluscand::PySigmaPlusMC, sigmapluscand::PzSigmaPlusMC, + sigmapluscand::DecayRadiusMC, sigmapluscand::MassMC, + + // dynamic columns + sigmapluscand::Radius, + sigmapluscand::PxSigmaPlus, + sigmapluscand::PySigmaPlus, + sigmapluscand::PzSigmaPlus, + sigmapluscand::PtSigmaPlus, + sigmapluscand::MassSigmaPlus, + sigmapluscand::PtSigmaPlusMC, + sigmapluscand::YSigmaPlusMC); + } // namespace o2::aod #endif // PWGLF_DATAMODEL_LFKINKDECAYTABLES_H_ diff --git a/PWGLF/TableProducer/Strangeness/CMakeLists.txt b/PWGLF/TableProducer/Strangeness/CMakeLists.txt index 765c16cd21f..309523de55e 100644 --- a/PWGLF/TableProducer/Strangeness/CMakeLists.txt +++ b/PWGLF/TableProducer/Strangeness/CMakeLists.txt @@ -95,7 +95,7 @@ o2physics_add_dpl_workflow(sigmaminus-task # o2-linter: disable=name/o2-workflow o2physics_add_dpl_workflow(sigmaplusbuilder SOURCES sigmaplusbuilder.cxx REUSE_FROM LfStrangenessPCH - PUBLIC_LINK_LIBRARIES O2::DCAFitter O2Physics::AnalysisCore O2Physics::MLCore + PUBLIC_LINK_LIBRARIES O2::DCAFitter O2Physics::AnalysisCore O2Physics::MLCore KFParticle::KFParticle COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(strange-tree-creator diff --git a/PWGLF/TableProducer/Strangeness/sigmaplusbuilder.cxx b/PWGLF/TableProducer/Strangeness/sigmaplusbuilder.cxx index 90722327000..a516c10c659 100644 --- a/PWGLF/TableProducer/Strangeness/sigmaplusbuilder.cxx +++ b/PWGLF/TableProducer/Strangeness/sigmaplusbuilder.cxx @@ -26,6 +26,7 @@ #include "Common/DataModel/PIDResponseTOF.h" #include "Common/DataModel/PIDResponseTPC.h" #include "Common/DataModel/TrackSelectionTables.h" +#include "Tools/KFparticle/KFUtilities.h" #include "Tools/ML/MlResponse.h" #include @@ -58,6 +59,9 @@ #include #include +#include +#include + #include #include #include @@ -66,6 +70,7 @@ #include #include #include +#include #include #include #include @@ -86,23 +91,23 @@ struct Sigmaplusbuilder { Configurable cutZVertex{"cutZVertex", 10.0f, "Accepted z-vertex range (cm)"}; // photon (PCM) selection - Configurable photonMaxMass{"photonMaxMass", 0.05, "Max photon mass (GeV/c^2)"}; - Configurable photonMinRapidity{"photonMinRapidity", -1.0, "Min photon rapidity"}; - Configurable photonMaxRapidity{"photonMaxRapidity", 1.0, "Max photon rapidity"}; - Configurable photonDauEtaMin{"photonDauEtaMin", -1.0, "Min eta of photon daughter tracks"}; - Configurable photonDauEtaMax{"photonDauEtaMax", 1.0, "Max eta of photon daughter tracks"}; - Configurable photonMinRadius{"photonMinRadius", 3.0, "Min photon conversion radius (cm)"}; - Configurable photonMaxRadius{"photonMaxRadius", 115., "Max photon conversion radius (cm)"}; + Configurable photonMaxMass{"photonMaxMass", 0.08, "Max photon mass (GeV/c^2)"}; + Configurable photonMinRapidity{"photonMinRapidity", -2.0, "Min photon rapidity"}; + Configurable photonMaxRapidity{"photonMaxRapidity", 2.0, "Max photon rapidity"}; + Configurable photonDauEtaMin{"photonDauEtaMin", -1.2, "Min eta of photon daughter tracks"}; + Configurable photonDauEtaMax{"photonDauEtaMax", 1.2, "Max eta of photon daughter tracks"}; + Configurable photonMinRadius{"photonMinRadius", 1.0, "Min photon conversion radius (cm)"}; + Configurable photonMaxRadius{"photonMaxRadius", 250., "Max photon conversion radius (cm)"}; Configurable photonMinV0cospa{"photonMinV0cospa", 0.9, "Min photon cosine of pointing angle to the PV"}; Configurable photonMaxDCAV0Dau{"photonMaxDCAV0Dau", 1.5, "Max DCA between photon daughters (cm)"}; Configurable photonMaxOpeningAngle{"photonMaxOpeningAngle", 0.4, "Max opening angle between the photon's e+/e- daughter momenta (rad)"}; Configurable photonMaxDeltaTheta{"photonMaxDeltaTheta", 0.15, "Max |theta_pos - theta_neg| of the photon's daughter tracks (rad)"}; - Configurable photonMaxQt{"photonMaxQt", 0.05, "Max Armenteros qT for photons (GeV/c)"}; - Configurable photonMaxAlpha{"photonMaxAlpha", 0.95, "Max |Armenteros alpha| for photons"}; + Configurable photonMaxQt{"photonMaxQt", 0.04, "Max Armenteros qT for photons (GeV/c)"}; + Configurable photonMaxAlpha{"photonMaxAlpha", 1.1, "Max |Armenteros alpha| for photons"}; Configurable photonDauMinTPCNSigmaEl{"photonDauMinTPCNSigmaEl", -3., "Min TPC nSigma_el of the photon daughters"}; Configurable photonDauMaxTPCNSigmaEl{"photonDauMaxTPCNSigmaEl", 3., "Max TPC nSigma_el of the photon daughters"}; - Configurable photonDauMaxPt{"photonDauMaxPt", 0.5, "Max pT of the photon daughters (GeV/c)"}; - Configurable photonDauMinTpcNCls{"photonDauMinTpcNCls", 30, "Min number of found TPC clusters for the photon daughter tracks"}; + Configurable photonDauMaxPt{"photonDauMaxPt", 100., "Max pT of the photon daughters (GeV/c)"}; + Configurable photonDauMinTpcNCls{"photonDauMinTpcNCls", 20, "Min number of found TPC clusters for the photon daughter tracks"}; // photon daughters paired by this task instead of taken from V0Datas (V0Datas assumes photons from primary vertex) Configurable photonSkipAmbiTracks{"photonSkipAmbiTracks", false, "Skip ambiguous tracks when pairing photon daughters"}; @@ -113,36 +118,43 @@ struct Sigmaplusbuilder { Configurable photonPrefitMaxDca{"photonPrefitMaxDca", 3., "Max daughter DCA (cm) of the fit without material correction (photonPrefitWithoutMatCorr)"}; // proton selection - Configurable protonMinPt{"protonMinPt", 0.4, "Minimum proton pT (GeV/c)"}; - Configurable protonMaxEta{"protonMaxEta", 0.9, "Maximum |eta| for proton track"}; - Configurable protonMinTpcNCls{"protonMinTpcNCls", 80, "Min number of found TPC clusters for the proton track"}; + Configurable protonMinPt{"protonMinPt", 0.0, "Minimum proton pT (GeV/c)"}; + Configurable protonMaxPt{"protonMaxPt", 15.0, "Maximum proton pT (GeV/c)"}; + Configurable protonMaxEta{"protonMaxEta", 1.0, "Maximum |eta| for proton track"}; + Configurable protonMinTpcNCls{"protonMinTpcNCls", 40, "Min number of found TPC clusters for the proton track"}; Configurable protonMaxTPCNSigma{"protonMaxTPCNSigma", 4, "Max |TPC nSigma_pr| for proton"}; - Configurable protonMaxTOFNSigma{"protonMaxTOFNSigma", 4, "Max |TOF nSigma_pr| for proton, if TOF available"}; - Configurable protonPtMinRequireTOF{"protonPtMinRequireTOF", 0.75, "Above this pT, require TOF PID for proton"}; + Configurable protonMaxTOFNSigma{"protonMaxTOFNSigma", 6, "Max |TOF nSigma_pr| for proton, if TOF available"}; + Configurable protonPtMinRequireTOF{"protonPtMinRequireTOF", 0.9, "Above this momentum, require TOF PID for proton"}; + Configurable protonTofUseTpcMomentum{"protonTofUseTpcMomentum", true, "Use the TPC inner-wall momentum instead of pT for protonPtMinRequireTOF"}; Configurable protonRequireTofHit{"protonRequireTofHit", false, "Above protonPtMinRequireTOF, reject a proton with no TOF hit at all"}; Configurable protonMinDcaToPV{"protonMinDcaToPV", 0.005, "Min DCAxy of the proton track to the PV (cm)"}; Configurable protonMaxDcaToPV{"protonMaxDcaToPV", 5.0, "Max DCAxy of the proton track to the PV (cm)"}; - Configurable protonMaxDcaZToPV{"protonMaxDcaZToPV", 0.3, "Max |DCAz| of the proton track to the PV (cm)"}; + Configurable protonMaxDcaZToPV{"protonMaxDcaZToPV", 2., "Max |DCAz| of the proton track to the PV (cm), also applied to recomputed DCAs"}; + Configurable protonKeepMissingDca{"protonKeepMissingDca", true, "Proton tracks not propagated to the PV (DCA = 999) pass the DCAxy cuts"}; // proton-photon candidate selection Configurable candVertexProtonWeight{"candVertexProtonWeight", 1.0, "Sigma+ vertex between the proton's (1) and the photon's (0) point of closest approach"}; - Configurable candMaxDcaProtonGamma{"candMaxDcaProtonGamma", 1.5, "Max DCA between proton and photon at the fitted vertex (cm)"}; - Configurable candMaxDcaToPV{"candMaxDcaToPV", 20., "Max DCA of the candidate's total (reconstructed) momentum line to the PV (cm)"}; + Configurable candMaxDcaProtonGamma{"candMaxDcaProtonGamma", 5.0, "Max DCA between proton and photon at the fitted vertex (cm)"}; + Configurable candMaxDcaToPV{"candMaxDcaToPV", 1000., "Max DCA of the candidate's total (reconstructed) momentum line to the PV (cm)"}; Configurable candRejectNegRootCenter{"candRejectNegRootCenter", true, "Reject candidates with rootCenter<0"}; - Configurable candMaxRootCenter{"candMaxRootCenter", 15, "Max rootCenter=-coefB/(2*coefA) (GeV/c)"}; - Configurable candMinAntiSigmaPointingAngle{"candMinAntiSigmaPointingAngle", 0.0, "Min AntiSigmaPointingAngle (rad)"}; - Configurable candMaxAntiSigmaPointingAngle{"candMaxAntiSigmaPointingAngle", 10., "Max AntiSigmaPointingAngle (rad)"}; + Configurable candMaxRootCenter{"candMaxRootCenter", 1000, "Max rootCenter=-coefB/(2*coefA) (GeV/c)"}; + Configurable candMinAntiSigmaPointingAngle{"candMinAntiSigmaPointingAngle", 0.005, "Min AntiSigmaPointingAngle (rad)"}; + Configurable candMaxAntiSigmaPointingAngle{"candMaxAntiSigmaPointingAngle", 0.6, "Max AntiSigmaPointingAngle (rad)"}; Configurable candMaxSigmaMass{"candMaxSigmaMass", 1.35, "Max reconstructed Sigma+ candidate mass (GeV/c^2)"}; Configurable candMaxRapidity{"candMaxRapidity", 0.9, "Max |rapidity| of the reconstructed Sigma+ candidate"}; - Configurable candMinRadius{"candMinRadius", 1.0, "Min candidate decay radius (cm)"}; - Configurable candMaxRadius{"candMaxRadius", 100., "Max candidate decay radius (cm)"}; - Configurable candMinFlightDistance{"candMinFlightDistance", 0.0, "Min 3D distance from PV to candidate decay vertex (cm)"}; - Configurable candMaxFlightDistance{"candMaxFlightDistance", 250.0, "Max 3D distance from PV to candidate decay vertex (cm)"}; + Configurable candMinRadius{"candMinRadius", 0.0, "Min candidate decay radius (cm)"}; + Configurable candMaxRadius{"candMaxRadius", 250., "Max candidate decay radius (cm)"}; + Configurable candMinFlightDistance{"candMinFlightDistance", 0.5, "Min 3D distance from PV to candidate decay vertex (cm)"}; + Configurable candMaxFlightDistance{"candMaxFlightDistance", 60.0, "Max 3D distance from PV to candidate decay vertex (cm)"}; Configurable candMaxPhotonOpeningAngle{"candMaxPhotonOpeningAngle", 3.15, "Max photon opening angle (rad), recomputed from the daughters' track momenta"}; - Configurable candMaxPhotonPointingAngle{"candMaxPhotonPointingAngle", 0.5, "Max angle between the photon momentum and the decay-vertex-to-conversion-point line (rad)"}; + Configurable candMaxPhotonPointingAngle{"candMaxPhotonPointingAngle", 3.15, "Max angle between the photon momentum and the decay-vertex-to-conversion-point line (rad)"}; Configurable candMaxPhotonDcaToPV{"candMaxPhotonDcaToPV", 250.0, "Max DCA of the photon's flight line to the PV (cm)"}; - Configurable candMaxPhotonDcaZToPV{"candMaxPhotonDcaZToPV", 2.0, "Max |DCAz| of the photon's flight line to the PV at its transverse DCA (cm), applied to the photon before the pairing with the proton"}; - Configurable candDeduplicatePhotons{"candDeduplicatePhotons", true, "Per timeframe, write only the candidate with the smallest DCA to PV among candidates sharing the same photon"}; + Configurable candMaxPhotonDcaZToPV{"candMaxPhotonDcaZToPV", 8., "Max |DCAz| of the photon's flight line to the PV at its transverse DCA (cm), applied to the photon before the pairing with the proton"}; + // candidates sharing tracks + struct : ConfigurableGroup { + Configurable candDeduplicatePhotons{"candDeduplicatePhotons", false, "Per timeframe, keep only the candidate with the smallest DCA to PV per photon"}; + Configurable candDeduplicateProtons{"candDeduplicateProtons", true, "Per collision, keep only the candidate with the smallest KF chi2/NDF per proton"}; + } dedupOpts; // flight direction options struct : ConfigurableGroup { @@ -151,15 +163,40 @@ struct Sigmaplusbuilder { Configurable candMaxTilt{"candMaxTilt", 0.05, "Max tilt of the flight direction searched for a real root (rad)"}; Configurable candTiltStep{"candTiltStep", 0.005, "Tilt step between the rings of tried flight directions (rad)"}; Configurable candTiltNAzimuth{"candTiltNAzimuth", 36, "Flight directions tried per ring"}; - Configurable candFlightDirAtSv{"candFlightDirAtSv", false, "Use the tangent of the Sigma+ track at the decay vertex as flight direction (otherwise the PV->SV chord)"}; - Configurable protonRecomputeMissingDca{"protonRecomputeMissingDca", false, "Compute the DCA to the PV of proton tracks that the track propagation did not propagate (DCA = 999)"}; + Configurable candFlightDirAtSv{"candFlightDirAtSv", true, "Use the tangent of the Sigma+ track at the decay vertex as flight direction (otherwise the PV->SV chord)"}; + Configurable protonRecomputeMissingDca{"protonRecomputeMissingDca", true, "Compute the DCA to the PV of proton tracks that the track propagation did not propagate (DCA = 999)"}; } flightDirOpts; + // KFParticle proton-photon vertex + struct : ConfigurableGroup { + Configurable kfCompute{"kfCompute", true, "Fit the proton-photon vertex with KFParticle"}; + Configurable kfUseVertex{"kfUseVertex", true, "Use the KFParticle vertex as decay vertex (candidates with a failed fit are rejected)"}; + Configurable candMaxKfDcaProtonGamma{"candMaxKfDcaProtonGamma", 2.0, "Max KFParticle proton-photon distance (cm), with kfUseVertex"}; + } kfOpts; + + // momentum correction: random variations of the flight direction, the one giving the mass closest to the Sigma+ mass is kept + struct : ConfigurableGroup { + Configurable momCorr{"momCorr", true, "Compute the corrected Sigma+ momentum"}; + Configurable momCorrMaxShift{"momCorrMaxShift", 2.0, "Max shift of the decay vertex along the proton in units of its uncertainty"}; + Configurable momCorrNShiftSteps{"momCorrNShiftSteps", 80, "Shift steps per side along the proton"}; + Configurable momCorrPhotonDirRes{"momCorrPhotonDirRes", 0.009, "Photon direction uncertainty for the shift uncertainty (rad)"}; + Configurable momCorrConvPointRes{"momCorrConvPointRes", 0.2, "Conversion point uncertainty for the shift uncertainty (cm)"}; + Configurable momCorrMassTolerance{"momCorrMassTolerance", 0.001, "Max distance to the Sigma+ mass to stop the shift search (GeV/c2)"}; + Configurable momCorrNDraws{"momCorrNDraws", 100, "Number of random flight-direction variations without a solution along the proton"}; + Configurable momCorrMaxNSigma{"momCorrMaxNSigma", 2.0, "Max variation per axis in units of its width"}; + Configurable momCorrMaxAngle{"momCorrMaxAngle", 0.02, "Max variation per axis (rad)"}; + // width sqrt((a/d)^2 + b^2) vs flight distance d (MC resolution), used where the KF uncertainty is not usable + Configurable momCorrFallbackA{"momCorrFallbackA", 0.0326, "Fallback width: a (rad cm)"}; + Configurable momCorrFallbackBT{"momCorrFallbackBT", 0.0129, "Fallback width: b (rad), transverse axis"}; + Configurable momCorrFallbackBL{"momCorrFallbackBL", 0.0098, "Fallback width: b (rad), other axis"}; + } momCorrOpts; + // MC Configurable cutRapMotherMC{"cutRapMotherMC", 1.0f, "Rapidity cut for generated mother Sigma+ in MC"}; Configurable cutPtGenMC{"cutPtGenMC", 0.5f, "Minimum pT for generated Sigma+ in MC"}; Configurable fillSlimTables{"fillSlimTables", false, "write the slim candidate tables instead of the full ones"}; + Configurable fillUnboundTables{"fillUnboundTables", false, "write the unbound candidate tables (no index columns) instead of the full/slim ones"}; // BDT score (MlScore column) of every written candidate, inputs in the order of the training (see computeMlScore) Configurable applyMl{"applyMl", false, "Compute the BDT score of every written candidate (otherwise MlScore = -1)"}; @@ -176,6 +213,8 @@ struct Sigmaplusbuilder { Produces sigmaPlusCandsMC; Produces slimSigmaPlusCands; Produces slimSigmaPlusCandsMC; + Produces sigmaPlusCandsUnbound; + Produces sigmaPlusCandsUnboundMC; Service ccdb{}; o2::vertexing::DCAFitterN<2> fitter; @@ -184,6 +223,8 @@ struct Sigmaplusbuilder { o2::base::MatLayerCylSet* mLut = nullptr; o2::aod::common::TPCVDriftManager mVDriftMgr; o2::analysis::MlResponse mlResponse; + static constexpr unsigned int MomCorrSeed = 20261127u; + std::mt19937 mMomCorrRng{MomCorrSeed}; // momentum correction // daughter pairing (electrons and positrons with the range of collisions each is compatible with) svPoolCreator svPhotonPoolCreator{PDG_t::kElectron, PDG_t::kPositron}; @@ -244,8 +285,37 @@ struct Sigmaplusbuilder { float posDcaZ = 0.f; float negDcaXY = 0.f; float negDcaZ = 0.f; + int runNumber = 0; + // KFParticle vertex (-999 if not computed or failed) + float kfChi2Ndf = -999.f; + float kfDevProtonGamma = -999.f; + float kfDcaProtonGamma = -999.f; + float kfPhotonChi2Ndf = -999.f; + float kfSigmaXYDecVtx = -999.f; + float kfSigmaZDecVtx = -999.f; + float sigmaFlightDirT = -999.f; + float sigmaFlightDirL = -999.f; + float sigmaMass = -999.f; + std::array pv{-999.f, -999.f, -999.f}; + std::array pSigmaCorr{-999.f, -999.f, -999.f}; + float massCorr = -999.f; + float flightDirCorrAngle = -999.f; + std::array flightDir{-999.f, -999.f, -999.f}; + float protonTpcChi2NCl = -999.f; + float protonItsChi2NCl = -999.f; + std::array photonConv{-999.f, -999.f, -999.f}; + float photonDcaToPV = -999.f; + float photonOpeningAngleVtx = -999.f; + float photonDeltaTheta = -999.f; + float photonDauMaxAbsEta = -999.f; + float photonPosPt = -999.f; + float photonNegPt = -999.f; // MC bool collisionIdCheck = false; + int protonPdgMC = 0; + int protonMotherPdgMC = 0; + int photonPdgMC = 0; + int photonMotherPdgMC = 0; bool protonIsSignal = false; bool photonIsSignal = false; std::array decVtxMC{}; @@ -390,7 +460,6 @@ struct Sigmaplusbuilder { histos.add("Candidate/Inclusive/hPhotonOpeningAngle", "hPhotonOpeningAngle", kTH1F, {axisPhotonOpeningAngle}); histos.add("Candidate/Inclusive/hPhotonPointingAngle", "hPhotonPointingAngle", kTH1F, {axisPhotonOpeningAngle}); histos.add("Candidate/Inclusive/hPhotonDcaToPV", "hPhotonDcaToPV", kTH1F, {axisCandPhotonDcaToPV}); - const bool doMc = doprocessMc || doprocessMcCustomVertexer; if (doMc || doprocessFindable) { histos.addClone("Photon/Inclusive/", "Photon/True/"); @@ -454,6 +523,10 @@ struct Sigmaplusbuilder { float cosPAToPV = 0.f; TTrack negTrack; TTrack posTrack; + // e+/e- legs with covariance, for the KFParticle photon + o2::track::TrackParCov posLeg; + o2::track::TrackParCov negLeg; + float openingAngleVtx = -999.f; // at the conversion point }; // longitudinal distance of the photon's flight line to the PV at its transverse DCA (cm) @@ -619,7 +692,11 @@ struct Sigmaplusbuilder { fillPhotonHist(HIST("h2ArmenterosPodolanski"), isSignal, alpha, qtarm); fillPhotonHist(HIST("h2ConvPointXY"), isSignal, secVtx[0], secVtx[1]); - photons.push_back({secVtx[0], secVtx[1], secVtx[2], pGamma[0], pGamma[1], pGamma[2], mGamma, alpha, qtarm, radius, v0.dcaV0daughters(), cosPA, negTrack, posTrack}); + auto posLeg = getTrackParCov(posTrack); + auto negLeg = getTrackParCov(negTrack); + posLeg.setPID(o2::track::PID::Electron); + negLeg.setPID(o2::track::PID::Electron); + photons.push_back({secVtx[0], secVtx[1], secVtx[2], pGamma[0], pGamma[1], pGamma[2], mGamma, alpha, qtarm, radius, v0.dcaV0daughters(), cosPA, negTrack, posTrack, posLeg, negLeg, photonOpeningAngle}); } return photons; @@ -770,7 +847,9 @@ struct Sigmaplusbuilder { std::array secVtx{}; std::array pPos{}; std::array pNeg{}; - float posTrackZ = 0.f; // z of the positive daughter at the fit, after moving it to the collision's time + float posTrackZ = 0.f; // z of the positive daughter at the fit, after moving it to the collision's time + o2::track::TrackParCov posAtVtx; // daughters at the photon vertex + o2::track::TrackParCov negAtVtx; }; // moves a track with only a TPC time to the time of the collision @@ -825,6 +904,8 @@ struct Sigmaplusbuilder { fitter.getTrack(0).getPxPyPzGlo(fit.pPos); fitter.getTrack(1).getPxPyPzGlo(fit.pNeg); fit.posTrackZ = posTrackParCov.getZ(); + fit.posAtVtx = fitter.getTrack(0); + fit.negAtVtx = fitter.getTrack(1); return true; } @@ -952,7 +1033,10 @@ struct Sigmaplusbuilder { continue; } fit = *referenceFit; - fit.secVtx[2] += posTrackParCov.getZ() - referenceFit->posTrackZ; + float shiftZ = posTrackParCov.getZ() - referenceFit->posTrackZ; + fit.secVtx[2] += shiftZ; + fit.posAtVtx.setZ(fit.posAtVtx.getZ() + shiftZ); + fit.negAtVtx.setZ(fit.negAtVtx.getZ() + shiftZ); } else { auto posTrackParCov = getTrackParCov(posTrack); auto negTrackParCov = getTrackParCov(negTrack); @@ -1007,6 +1091,9 @@ struct Sigmaplusbuilder { passStep(10); float qtarm = v0Qt(fit.pPos[0], fit.pPos[1], fit.pPos[2], fit.pNeg[0], fit.pNeg[1], fit.pNeg[2]); + if (!std::isfinite(qtarm)) { + qtarm = 0.f; // collinear legs (rounding) + } float alpha = v0Alpha(fit.pPos[0], fit.pPos[1], fit.pPos[2], fit.pNeg[0], fit.pNeg[1], fit.pNeg[2]); if (qtarm > photonMaxQt) { continue; @@ -1031,7 +1118,7 @@ struct Sigmaplusbuilder { fillPhotonHist(HIST("h2ConvPointXY"), isSignal, fit.secVtx[0], fit.secVtx[1]); nCopies++; - photonsByCollision[collIdx].push_back({fit.secVtx[0], fit.secVtx[1], fit.secVtx[2], pGamma[0], pGamma[1], pGamma[2], mGamma, alpha, qtarm, radius, fit.dca, cosPA, negTrack, posTrack}); + photonsByCollision[collIdx].push_back({fit.secVtx[0], fit.secVtx[1], fit.secVtx[2], pGamma[0], pGamma[1], pGamma[2], mGamma, alpha, qtarm, radius, fit.dca, cosPA, negTrack, posTrack, fit.posAtVtx, fit.negAtVtx, photonOpeningAngle}); } if (anyFitOk) { @@ -1091,7 +1178,7 @@ struct Sigmaplusbuilder { }; fillProtonStep(0); - if (track.pt() < protonMinPt) { + if (track.pt() < protonMinPt || track.pt() > protonMaxPt) { return false; } fillProtonStep(1); @@ -1112,7 +1199,7 @@ struct Sigmaplusbuilder { } fillProtonStep(4); - if (track.pt() > protonPtMinRequireTOF) { + if ((protonTofUseTpcMomentum ? track.tpcInnerParam() : track.pt()) > protonPtMinRequireTOF) { if (track.hasTOF()) { if (std::abs(track.tofNSigmaPr()) > protonMaxTOFNSigma) { return false; @@ -1125,7 +1212,12 @@ struct Sigmaplusbuilder { dca = protonDcaToPv(track, pv); fillProtonHist(HIST("h2DcaToPVVsPt"), isSignal, track.pt(), std::abs(dca[0])); - if (std::abs(dca[0]) < protonMinDcaToPV || std::abs(dca[0]) > protonMaxDcaToPV || std::abs(dca[1]) > protonMaxDcaZToPV) { + constexpr float NotPropagatedDca = 900.f; + const bool missingDca = std::abs(track.dcaXY()) > NotPropagatedDca; + if (!(protonKeepMissingDca && missingDca) && (std::abs(dca[0]) < protonMinDcaToPV || std::abs(dca[0]) > protonMaxDcaToPV)) { + return false; + } + if (std::abs(dca[0]) < NotPropagatedDca && std::abs(dca[1]) > protonMaxDcaZToPV) { return false; } fillProtonStep(6); @@ -1270,9 +1362,101 @@ struct Sigmaplusbuilder { return sigmaMothers.front().globalIndex(); } + // KFParticle proton-photon vertex: photon from its e+e- legs, then KFParticle(proton, photon) + struct KfVertex { + bool ok = false; + float chi2Ndf = -999.f; + float devProtonGamma = -999.f; + float dcaProtonGamma = -999.f; + float photonChi2Ndf = -999.f; + std::array vtx{-999.f, -999.f, -999.f}; + std::array cov{}; // xx, xy, yy, xz, yz, zz + }; + + template + KfVertex fitKfVertex(const o2::track::TrackParCov& protonTrackParCov, int protonSign, const PhotonCand& photon) + { + KfVertex kf; + auto isFinite = [](float v) { return std::isfinite(v); }; + auto posTrack = photon.posTrack; + auto negTrack = photon.negTrack; + + KFPTrack kfpPos = createKFPTrackFromTrackParCov(photon.posLeg, 1, posTrack.tpcNClsFound(), posTrack.tpcChi2NCl()); + KFPTrack kfpNeg = createKFPTrackFromTrackParCov(photon.negLeg, -1, negTrack.tpcNClsFound(), negTrack.tpcChi2NCl()); + KFParticle kfPos(kfpPos, PDG_t::kPositron); + KFParticle kfNeg(kfpNeg, PDG_t::kElectron); + std::array photonDaughters{&kfPos, &kfNeg}; + KFParticle kfPhoton; + constexpr int KfConstructWithDaughterMass = 2; + kfPhoton.SetConstructMethod(KfConstructWithDaughterMass); + try { + kfPhoton.Construct(photonDaughters.data(), 2); + } catch (...) { + return kf; + } + if (kfPhoton.GetNDF() <= 0 || !isFinite(kfPhoton.GetChi2()) || !isFinite(kfPhoton.GetX()) || !isFinite(kfPhoton.GetPx())) { + return kf; + } + kf.photonChi2Ndf = kfPhoton.GetChi2() / kfPhoton.GetNDF(); + + o2::track::TrackParCov protonPar = protonTrackParCov; + protonPar.setPID(o2::track::PID::Proton); + KFParticle kfProton = createKFParticleFromTrackParCov(protonPar, protonSign, o2::constants::physics::MassProton); + KFParticle kfSigma; + try { + kfSigma = KFParticle(kfProton, kfPhoton); + kfSigma.TransportToDecayVertex(); + } catch (...) { + return kf; + } + if (kfSigma.GetNDF() <= 0 || !isFinite(kfSigma.GetChi2()) || !isFinite(kfSigma.GetX()) || !isFinite(kfSigma.GetY()) || !isFinite(kfSigma.GetZ())) { + return kf; + } + for (size_t i = 0; i < kf.cov.size(); ++i) { + kf.cov[i] = kfSigma.GetCovariance(i); + } + auto isPositive = [](float v) { return v > 0.f; }; // false also for NaN + if (!isPositive(kf.cov[0]) || !isPositive(kf.cov[2]) || !isPositive(kf.cov[5])) { + return kf; + } + kf.chi2Ndf = kfSigma.GetChi2() / kfSigma.GetNDF(); + kf.devProtonGamma = kfProton.GetDeviationFromParticle(kfPhoton); + kf.dcaProtonGamma = kfProton.GetDistanceFromParticle(kfPhoton); + kf.vtx = {kfSigma.GetX(), kfSigma.GetY(), kfSigma.GetZ()}; + kf.ok = true; + return kf; + } + + // uncertainties (rad) of the PV->SV direction, transverse in the xy plane (T) and perpendicular to it (L) + static std::array flightDirUncertainty(const std::array& flightVec, const std::array& svCov, const std::array& pvCov) + { + float length = std::sqrt(dot3(flightVec, flightVec)); + if (length <= 0.f) { + return {-999.f, -999.f}; + } + std::array c{}; + for (size_t i = 0; i < c.size(); ++i) { + c[i] = svCov[i] + pvCov[i]; + } + auto variance = [&](const std::array& u) { + return static_cast(c[0]) * u[0] * u[0] + static_cast(c[2]) * u[1] * u[1] + static_cast(c[5]) * u[2] * u[2] + + 2. * (static_cast(c[1]) * u[0] * u[1] + static_cast(c[3]) * u[0] * u[2] + static_cast(c[4]) * u[1] * u[2]); + }; + std::array n = normalize3(flightVec); + float nT = std::hypot(n[0], n[1]); + std::array uT = nT > 0.f ? std::array{-n[1] / nT, n[0] / nT, 0.f} : std::array{1.f, 0.f, 0.f}; + std::array uL = cross3(n, uT); + // -999 where the covariance is not positive definite + auto sigma = [&](const std::array& u) { + double v = variance(u); + return v > 0. ? static_cast(std::sqrt(v) / length) : -999.f; + }; + return {sigma(uT), sigma(uL)}; + } + // Build a Sigma+ -> p pi0 candidate from a proton track and a PCM photon template - void buildSigmaPlusCandidate(const TTrack& protonTrack, const std::array& protonDca, const PhotonCand& photon, int collisionIndex, const std::array& pv) + void buildSigmaPlusCandidate(const TTrack& protonTrack, const std::array& protonDca, const PhotonCand& photon, int collisionIndex, const std::array& pv, const std::array& pvCov) { auto posTrack = photon.posTrack; auto negTrack = photon.negTrack; @@ -1289,9 +1473,28 @@ struct Sigmaplusbuilder { float decayRadiusMC = -999.f; float massMC = -999.f; int matchedSigmaId = -1; + int protonPdgMC = 0; + int protonMotherPdgMC = 0; + int photonPdgMC = 0; + int photonMotherPdgMC = 0; if constexpr (IsMC) { + if (posTrack.has_mcParticle()) { + auto const& posMothers = posTrack.template mcParticle_as().template mothers_as(); + if (!posMothers.empty()) { + photonPdgMC = posMothers.front().pdgCode(); + auto const& photonMothers = posMothers.front().template mothers_as(); + if (!photonMothers.empty()) { + photonMotherPdgMC = photonMothers.front().pdgCode(); + } + } + } if (protonTrack.has_mcParticle()) { auto mcProton = protonTrack.template mcParticle_as(); + protonPdgMC = mcProton.pdgCode(); + auto const& protonMothers = mcProton.template mothers_as(); + if (!protonMothers.empty()) { + protonMotherPdgMC = protonMothers.front().pdgCode(); + } auto protonCollision = protonTrack.template collision_as(); if (protonCollision.has_mcCollision()) { @@ -1371,10 +1574,30 @@ struct Sigmaplusbuilder { } fillCandStep(3); // DCA(p,gamma) - // decay vertex between the proton's and the photon's point of closest approach (relative weight given by candVertexProtonWeight) + // KFParticle vertex: here if used as decay vertex, otherwise only for candidates passing all cuts + KfVertex kf; + bool kfDone = false; + auto runKf = [&]() { + if (!kfDone) { + kf = fitKfVertex(protonTrackParCov, protonTrack.sign(), photon); + kfDone = true; + } + }; + if (kfOpts.kfCompute && kfOpts.kfUseVertex) { + runKf(); + if (!kf.ok || kf.dcaProtonGamma > kfOpts.candMaxKfDcaProtonGamma) { + return; + } + } + + // decay vertex: KFParticle vertex, or between the proton's and the photon's point of closest approach std::array secVtx{}; - for (size_t i = 0; i < secVtx.size(); ++i) { - secVtx[i] = candVertexProtonWeight * protonAtPca[i] + (1.f - candVertexProtonWeight) * photonAtPca[i]; + if (kfDone && kf.ok) { + secVtx = kf.vtx; + } else { + for (size_t i = 0; i < secVtx.size(); ++i) { + secVtx[i] = candVertexProtonWeight * protonAtPca[i] + (1.f - candVertexProtonWeight) * photonAtPca[i]; + } } float radius = std::hypot(secVtx[0], secVtx[1]); fillCandHist(HIST("hRadius"), isSignal, radius); @@ -1398,18 +1621,20 @@ struct Sigmaplusbuilder { fitter.getTrack(0).getPxPyPzGlo(pProton); fitter.getTrack(1).getPxPyPzGlo(pGamma1); - // Sigma+ direction at the decay vertex: PV->SV chord rotated by half the bending angle - if (flightDirOpts.candFlightDirAtSv && std::abs(mBz) > 0.f) { - float ptEstimate = std::hypot(pProton[0] + pGamma1[0], pProton[1] + pGamma1[1]); - float rhoSigma = ptEstimate * 1000.f / (0.2998f * std::abs(mBz)); // cm, Bz in kG - float sinHalfBend = rhoSigma > 0.f ? std::hypot(flightVec[0], flightVec[1]) / (2.f * rhoSigma) : 1.f; - if (sinHalfBend < 1.f) { - float rot = -static_cast(protonTrack.sign()) * (mBz < 0.f ? -1.f : 1.f) * std::asin(sinHalfBend); - nHatOrig = normalize3({flightVec[0] * std::cos(rot) - flightVec[1] * std::sin(rot), - flightVec[0] * std::sin(rot) + flightVec[1] * std::cos(rot), - flightVec[2]}); + // Sigma+ direction at the decay vertex: PV->vertex chord rotated by half the bending angle + const float ptEstimate = std::hypot(pProton[0] + pGamma1[0], pProton[1] + pGamma1[1]); + auto directionAtVertex = [&](const std::array& chord) { + if (flightDirOpts.candFlightDirAtSv && std::abs(mBz) > 0.f) { + float rhoSigma = ptEstimate * 1000.f / (0.2998f * std::abs(mBz)); // cm, Bz in kG + float sinHalfBend = rhoSigma > 0.f ? std::hypot(chord[0], chord[1]) / (2.f * rhoSigma) : 1.f; + if (sinHalfBend < 1.f) { + float rot = -static_cast(protonTrack.sign()) * (mBz < 0.f ? -1.f : 1.f) * std::asin(sinHalfBend); + return normalize3({chord[0] * std::cos(rot) - chord[1] * std::sin(rot), chord[0] * std::sin(rot) + chord[1] * std::cos(rot), chord[2]}); + } } - } + return normalize3(chord); + }; + nHatOrig = directionAtVertex(flightVec); float e1 = std::sqrt(dot3(pGamma1, pGamma1)); float massPi0 = o2::constants::physics::MassPionNeutral; @@ -1526,7 +1751,8 @@ struct Sigmaplusbuilder { if (!haveCandidate) { return; } - fillCandStep(7); // valid root + fillCandStep(7); // valid root + const std::array nHatCand = nHat; // flight direction after the tilt search std::array pSigma{pProton[0] + pGamma1[0] + bestMomGamma2[0], pProton[1] + pGamma1[1] + bestMomGamma2[1], pProton[2] + pGamma1[2] + bestMomGamma2[2]}; float ptSigma = std::hypot(pSigma[0], pSigma[1]); @@ -1622,6 +1848,143 @@ struct Sigmaplusbuilder { fillCandStep(13); // photon DCA to PV float psiPair = photonPsiPair(posTrack, negTrack, photon.radius); + // root closest to the Sigma+ mass for a flight direction: mass (-1 without a real root) and missing-photon momentum + auto closestSolution = [&](const std::array& dir) { + std::pair> closest{-1.f, {}}; + float disc = solveForFlightDir(dir); + if (disc < 0.f) { + return closest; + } + for (const float& pGamma2Long : {(-coefB + std::sqrt(disc)) / (2.f * coefA), (-coefB - std::sqrt(disc)) / (2.f * coefA)}) { + std::array pGamma2{eIn[0] * pGamma2In + eOut[0] * pGamma2Out + nHat[0] * pGamma2Long, + eIn[1] * pGamma2In + eOut[1] * pGamma2Out + nHat[1] * pGamma2Long, + eIn[2] * pGamma2In + eOut[2] * pGamma2Out + nHat[2] * pGamma2Long}; + float eTotal = std::sqrt(dot3(pProton, pProton) + o2::constants::physics::MassProton * o2::constants::physics::MassProton) + e1 + std::sqrt(tPerp2 + pGamma2Long * pGamma2Long); + std::array pTotal{pProton[0] + pGamma1[0] + pGamma2[0], pProton[1] + pGamma1[1] + pGamma2[1], pProton[2] + pGamma1[2] + pGamma2[2]}; + float mass2 = eTotal * eTotal - dot3(pTotal, pTotal); + if (mass2 >= 0.f && (closest.first < 0.f || std::abs(std::sqrt(mass2) - o2::constants::physics::MassSigmaPlus) < std::abs(closest.first - o2::constants::physics::MassSigmaPlus))) { + closest = {std::sqrt(mass2), pGamma2}; + } + } + return closest; + }; + // axes transverse to the flight direction: in the xy plane (T) and perpendicular to it (L) + float nHatCandT = std::hypot(nHatCand[0], nHatCand[1]); + const std::array axisT = nHatCandT > 0.f ? std::array{-nHatCand[1] / nHatCandT, nHatCand[0] / nHatCandT, 0.f} : std::array{1.f, 0.f, 0.f}; + const std::array axisL = cross3(nHatCand, axisT); + auto tiltedDirection = [&](const std::array& angles) { + return normalize3({nHatCand[0] + angles[0] * axisT[0] + angles[1] * axisL[0], nHatCand[1] + angles[0] * axisT[1] + angles[1] * axisL[1], nHatCand[2] + angles[0] * axisT[2] + angles[1] * axisL[2]}); + }; + + // flight-direction widths (KF uncertainty, else the fallback) and the per-candidate mass uncertainty + std::array sigmaFlightDir{-999.f, -999.f}; + float sigmaMass = -999.f; + const float flightDist3D = std::sqrt(dot3(flightVec, flightVec)); + auto fallbackWidth = [&](float b) { return flightDist3D > 0.f ? std::hypot(momCorrOpts.momCorrFallbackA / flightDist3D, b) : b; }; + std::array widthFlightDir{fallbackWidth(momCorrOpts.momCorrFallbackBT), fallbackWidth(momCorrOpts.momCorrFallbackBL)}; + if (kfOpts.kfCompute) { + runKf(); + if (kf.ok) { + sigmaFlightDir = flightDirUncertainty(flightVec, kf.cov, pvCov); + for (size_t iAxis = 0; iAxis < widthFlightDir.size(); ++iAxis) { + if (sigmaFlightDir[iAxis] > 0.f) { + widthFlightDir[iAxis] = sigmaFlightDir[iAxis]; + } + } + } + } + // half the mass change when tilting by +-1 width along each axis (one-sided if one side has no root) + float variance = 0.f; + int nAxes = 0; + for (size_t iAxis = 0; iAxis < widthFlightDir.size(); ++iAxis) { + std::array massShifted{}; + for (size_t side = 0; side < massShifted.size(); ++side) { + std::array angles{0.f, 0.f}; + angles[iAxis] = (side == 0 ? 1.f : -1.f) * widthFlightDir[iAxis]; + massShifted[side] = closestSolution(tiltedDirection(angles)).first; + } + float deltaMass = -1.f; + if (massShifted[0] >= 0.f && massShifted[1] >= 0.f) { + deltaMass = 0.5f * std::abs(massShifted[0] - massShifted[1]); + } else if (massShifted[0] >= 0.f || massShifted[1] >= 0.f) { + deltaMass = std::abs(std::max(massShifted[0], massShifted[1]) - bestMass); + } + if (deltaMass >= 0.f) { + variance += deltaMass * deltaMass; + nAxes++; + } + } + if (nAxes > 0) { + sigmaMass = std::sqrt(variance); + } + + // momentum correction: the decay vertex is moved along the proton direction, in steps of increasing distance in units of + // its uncertainty (photon line uncertainty over the sine of the proton-photon angle), and the first position reaching the + // Sigma+ mass is taken, else the one closest to it. Without any solution on the line the flight direction is varied randomly. + std::array pSigmaCorr{-999.f, -999.f, -999.f}; + float massCorr = -999.f; + float flightDirCorrAngle = -999.f; + if (momCorrOpts.momCorr) { + constexpr float MinSinProtonPhoton = 0.05f; + const std::array protonDir = normalize3(pProton); + const float cosProtonPhoton = dot3(protonDir, normalize3(pGamma1)); + const float sinProtonPhoton = std::sqrt(std::max(0.f, 1.f - cosProtonPhoton * cosProtonPhoton)); + const std::array vtxToConv{photon.x - secVtx[0], photon.y - secVtx[1], photon.z - secVtx[2]}; + const float shiftWidth = std::hypot(momCorrOpts.momCorrPhotonDirRes * std::sqrt(dot3(vtxToConv, vtxToConv)), momCorrOpts.momCorrConvPointRes) / + std::max(sinProtonPhoton, MinSinProtonPhoton); + const int nSteps = momCorrOpts.momCorrNShiftSteps; + float lineMass = -1.f; + std::array lineMomGamma2{}; + std::array lineDir{}; + bool reached = false; + for (int iStep = 0; iStep <= nSteps && !reached; ++iStep) { + for (const float side : {1.f, -1.f}) { + if (reached || (iStep == 0 && side < 0.f)) { + continue; + } + float shift = side * momCorrOpts.momCorrMaxShift * shiftWidth * iStep / std::max(nSteps, 1); + std::array dir = directionAtVertex({flightVec[0] + shift * protonDir[0], flightVec[1] + shift * protonDir[1], flightVec[2] + shift * protonDir[2]}); + auto [mass, momGamma2] = closestSolution(dir); + if (mass >= 0.f && (lineMass < 0.f || std::abs(mass - o2::constants::physics::MassSigmaPlus) < std::abs(lineMass - o2::constants::physics::MassSigmaPlus))) { + lineMass = mass; + lineMomGamma2 = momGamma2; + lineDir = dir; + reached = std::abs(mass - o2::constants::physics::MassSigmaPlus) < momCorrOpts.momCorrMassTolerance; + } + } + } + if (lineMass >= 0.f) { + pSigmaCorr = {pProton[0] + pGamma1[0] + lineMomGamma2[0], pProton[1] + pGamma1[1] + lineMomGamma2[1], pProton[2] + pGamma1[2] + lineMomGamma2[2]}; + massCorr = lineMass; + flightDirCorrAngle = std::acos(std::clamp(dot3(lineDir, nHatCand), -1.f, 1.f)); + } + } + if (momCorrOpts.momCorr && massCorr < 0.f) { + std::normal_distribution gaus(0.f, 1.f); + float corrMass = bestMass; + std::array corrMomGamma2 = bestMomGamma2; + std::array corrAngles{0.f, 0.f}; + for (int iDraw = 0; iDraw < momCorrOpts.momCorrNDraws; ++iDraw) { + std::array angles{widthFlightDir[0] * gaus(mMomCorrRng), widthFlightDir[1] * gaus(mMomCorrRng)}; + bool keep = true; + for (size_t iAxis = 0; iAxis < angles.size(); ++iAxis) { + keep = keep && std::abs(angles[iAxis]) <= std::min(momCorrOpts.momCorrMaxAngle.value, momCorrOpts.momCorrMaxNSigma * widthFlightDir[iAxis]); + } + if (!keep) { + continue; + } + auto [mass, momGamma2] = closestSolution(tiltedDirection(angles)); + if (mass >= 0.f && std::abs(mass - o2::constants::physics::MassSigmaPlus) < std::abs(corrMass - o2::constants::physics::MassSigmaPlus)) { + corrMass = mass; + corrMomGamma2 = momGamma2; + corrAngles = angles; + } + } + pSigmaCorr = {pProton[0] + pGamma1[0] + corrMomGamma2[0], pProton[1] + pGamma1[1] + corrMomGamma2[1], pProton[2] + pGamma1[2] + corrMomGamma2[2]}; + massCorr = corrMass; + flightDirCorrAngle = std::hypot(corrAngles[0], corrAngles[1]); + } + SigmaPlusCandidate cand; cand.photonId = photonId(posTrack.globalIndex(), negTrack.globalIndex()); cand.collisionId = collisionIndex; @@ -1674,6 +2037,36 @@ struct Sigmaplusbuilder { cand.posDcaZ = posTrack.dcaZ(); cand.negDcaXY = negTrack.dcaXY(); cand.negDcaZ = negTrack.dcaZ(); + cand.runNumber = mRunNumber; + if (kf.ok) { + cand.kfChi2Ndf = kf.chi2Ndf; + cand.kfDevProtonGamma = kf.devProtonGamma; + cand.kfDcaProtonGamma = kf.dcaProtonGamma; + cand.kfSigmaXYDecVtx = std::sqrt(kf.cov[0] + kf.cov[2]); + cand.kfSigmaZDecVtx = std::sqrt(kf.cov[5]); + } + cand.kfPhotonChi2Ndf = kf.photonChi2Ndf; + cand.sigmaFlightDirT = sigmaFlightDir[0]; + cand.sigmaFlightDirL = sigmaFlightDir[1]; + cand.sigmaMass = sigmaMass; + cand.pv = pv; + cand.pSigmaCorr = pSigmaCorr; + cand.massCorr = massCorr; + cand.flightDirCorrAngle = flightDirCorrAngle; + cand.flightDir = nHatCand; + cand.protonTpcChi2NCl = protonTrack.tpcChi2NCl(); + cand.protonItsChi2NCl = protonTrack.itsChi2NCl(); + cand.photonConv = {photon.x, photon.y, photon.z}; + cand.photonDcaToPV = photonDcaToPV; + cand.photonOpeningAngleVtx = photon.openingAngleVtx; + cand.photonDeltaTheta = 2.f * std::atan(std::exp(-posTrack.eta())) - 2.f * std::atan(std::exp(-negTrack.eta())); + cand.photonDauMaxAbsEta = std::max(std::abs(posTrack.eta()), std::abs(negTrack.eta())); + cand.photonPosPt = posTrack.pt(); + cand.photonNegPt = negTrack.pt(); + cand.protonPdgMC = protonPdgMC; + cand.protonMotherPdgMC = protonMotherPdgMC; + cand.photonPdgMC = photonPdgMC; + cand.photonMotherPdgMC = photonMotherPdgMC; cand.collisionIdCheck = collisionIdCheck; cand.protonIsSignal = protonIsSignal; cand.photonIsSignal = photonIsSignal; @@ -1696,10 +2089,90 @@ struct Sigmaplusbuilder { return mlResponse.getModelOutput(inputs, 0)[1]; } + // unbound tables: no index columns + template + void fillUnboundTable(const SigmaPlusCandidate& cand, float mlScore) + { + if constexpr (IsMC) { + sigmaPlusCandsUnboundMC(cand.collisionId, cand.runNumber, + cand.decVtx[0], cand.decVtx[1], cand.decVtx[2], + cand.flightDistance, cand.dcaProtonGamma, + cand.pProton[0], cand.pProton[1], cand.pProton[2], + cand.pGamma1[0], cand.pGamma1[1], cand.pGamma1[2], + cand.pGamma2[0], cand.pGamma2[1], cand.pGamma2[2], + cand.protonTpcNSigma, cand.protonTofNSigma, + cand.posTpcNSigmaEl, cand.negTpcNSigmaEl, + cand.photonMass, cand.photonAlpha, cand.photonQt, cand.photonRadius, + cand.photonOpeningAngle, cand.photonPointingAngle, + cand.rootCenter, cand.antiSigmaPointingAngle, cand.dcaToPV, cand.tiltAngle, + cand.protonSign, + cand.protonItsNCls, cand.protonTpcNCls, cand.protonDcaXY, cand.protonDcaZ, + cand.posItsNCls, cand.posTpcNCls, cand.negItsNCls, cand.negTpcNCls, + cand.photonDcaDau, cand.photonCosPAToPV, cand.photonDcaXYToPV, cand.photonDcaZToPV, cand.photonPsiPair, + cand.posDcaXY, cand.posDcaZ, cand.negDcaXY, cand.negDcaZ, + cand.posTpcNClsFindable, cand.negTpcNClsFindable, cand.posTpcChi2NCl, cand.negTpcChi2NCl, + mlScore, + cand.kfChi2Ndf, cand.kfDevProtonGamma, cand.kfDcaProtonGamma, cand.kfPhotonChi2Ndf, + cand.kfSigmaXYDecVtx, cand.kfSigmaZDecVtx, + cand.sigmaFlightDirT, cand.sigmaFlightDirL, cand.sigmaMass, + cand.pv[0], cand.pv[1], cand.pv[2], + cand.pSigmaCorr[0], cand.pSigmaCorr[1], cand.pSigmaCorr[2], cand.massCorr, cand.flightDirCorrAngle, + std::acos(std::clamp(cand.flightDir[2], -1.f, 1.f)), std::atan2(cand.flightDir[1], cand.flightDir[0]), + cand.protonTpcChi2NCl, cand.protonItsChi2NCl, + cand.photonConv[0], cand.photonConv[1], cand.photonConv[2], cand.photonDcaToPV, + cand.photonOpeningAngleVtx, cand.photonDeltaTheta, cand.photonDauMaxAbsEta, + cand.photonPosPt, cand.photonNegPt, + cand.protonTrackId, cand.photonPosTrackId, cand.photonNegTrackId, + cand.matchedSigmaId, + cand.collisionIdCheck, + cand.isSignal, cand.protonIsSignal, cand.photonIsSignal, + cand.protonPdgMC, cand.protonMotherPdgMC, cand.photonPdgMC, cand.photonMotherPdgMC, + cand.decVtxMC[0], cand.decVtxMC[1], cand.decVtxMC[2], + cand.pProtonMC[0], cand.pProtonMC[1], cand.pProtonMC[2], + cand.pGammaMC[0], cand.pGammaMC[1], cand.pGammaMC[2], + cand.pSigmaPlusMC[0], cand.pSigmaPlusMC[1], cand.pSigmaPlusMC[2], + cand.decayRadiusMC, cand.massMC); + } else { + sigmaPlusCandsUnbound(cand.collisionId, cand.runNumber, + cand.decVtx[0], cand.decVtx[1], cand.decVtx[2], + cand.flightDistance, cand.dcaProtonGamma, + cand.pProton[0], cand.pProton[1], cand.pProton[2], + cand.pGamma1[0], cand.pGamma1[1], cand.pGamma1[2], + cand.pGamma2[0], cand.pGamma2[1], cand.pGamma2[2], + cand.protonTpcNSigma, cand.protonTofNSigma, + cand.posTpcNSigmaEl, cand.negTpcNSigmaEl, + cand.photonMass, cand.photonAlpha, cand.photonQt, cand.photonRadius, + cand.photonOpeningAngle, cand.photonPointingAngle, + cand.rootCenter, cand.antiSigmaPointingAngle, cand.dcaToPV, cand.tiltAngle, + cand.protonSign, + cand.protonItsNCls, cand.protonTpcNCls, cand.protonDcaXY, cand.protonDcaZ, + cand.posItsNCls, cand.posTpcNCls, cand.negItsNCls, cand.negTpcNCls, + cand.photonDcaDau, cand.photonCosPAToPV, cand.photonDcaXYToPV, cand.photonDcaZToPV, cand.photonPsiPair, + cand.posDcaXY, cand.posDcaZ, cand.negDcaXY, cand.negDcaZ, + cand.posTpcNClsFindable, cand.negTpcNClsFindable, cand.posTpcChi2NCl, cand.negTpcChi2NCl, + mlScore, + cand.kfChi2Ndf, cand.kfDevProtonGamma, cand.kfDcaProtonGamma, cand.kfPhotonChi2Ndf, + cand.kfSigmaXYDecVtx, cand.kfSigmaZDecVtx, + cand.sigmaFlightDirT, cand.sigmaFlightDirL, cand.sigmaMass, + cand.pv[0], cand.pv[1], cand.pv[2], + cand.pSigmaCorr[0], cand.pSigmaCorr[1], cand.pSigmaCorr[2], cand.massCorr, cand.flightDirCorrAngle, + std::acos(std::clamp(cand.flightDir[2], -1.f, 1.f)), std::atan2(cand.flightDir[1], cand.flightDir[0]), + cand.protonTpcChi2NCl, cand.protonItsChi2NCl, + cand.photonConv[0], cand.photonConv[1], cand.photonConv[2], cand.photonDcaToPV, + cand.photonOpeningAngleVtx, cand.photonDeltaTheta, cand.photonDauMaxAbsEta, + cand.photonPosPt, cand.photonNegPt, + cand.protonTrackId, cand.photonPosTrackId, cand.photonNegTrackId); + } + } + template void fillCandidateTables(const SigmaPlusCandidate& cand) { const float mlScore = applyMl ? computeMlScore(cand) : -1.f; + if (fillUnboundTables) { + fillUnboundTable(cand, mlScore); + return; + } if constexpr (IsMC) { if (fillSlimTables) { slimSigmaPlusCandsMC(cand.collisionId, cand.protonTrackId, cand.photonPosTrackId, cand.photonNegTrackId, @@ -1743,6 +2216,7 @@ struct Sigmaplusbuilder { cand.posDcaXY, cand.posDcaZ, cand.negDcaXY, cand.negDcaZ, cand.posTpcNClsFindable, cand.negTpcNClsFindable, cand.posTpcChi2NCl, cand.negTpcChi2NCl, mlScore, + cand.pSigmaCorr[0], cand.pSigmaCorr[1], cand.pSigmaCorr[2], cand.collisionIdCheck, cand.isSignal, cand.protonIsSignal, cand.photonIsSignal, cand.decVtxMC[0], cand.decVtxMC[1], cand.decVtxMC[2], @@ -1786,11 +2260,12 @@ struct Sigmaplusbuilder { cand.photonDcaDau, cand.photonCosPAToPV, cand.photonDcaXYToPV, cand.photonDcaZToPV, cand.photonPsiPair, cand.posDcaXY, cand.posDcaZ, cand.negDcaXY, cand.negDcaZ, cand.posTpcNClsFindable, cand.negTpcNClsFindable, cand.posTpcChi2NCl, cand.negTpcChi2NCl, - mlScore); + mlScore, + cand.pSigmaCorr[0], cand.pSigmaCorr[1], cand.pSigmaCorr[2]); } } - // The same photon can be in candidates of several collisions + // The same photon can be in candidates of several collisions, the same proton in several candidates of one collision template void deduplicateAndWriteCandidates() { @@ -1798,10 +2273,10 @@ struct Sigmaplusbuilder { for (int iCand = 0; iCand < static_cast(mCandidatesOfTimeframe.size()); ++iCand) { candsByPhoton[mCandidatesOfTimeframe[iCand].photonId].push_back(iCand); } - std::vector keep(mCandidatesOfTimeframe.size(), !candDeduplicatePhotons); + std::vector keep(mCandidatesOfTimeframe.size(), !dedupOpts.candDeduplicatePhotons); for (const auto& [photon, cands] : candsByPhoton) { histos.fill(HIST("Candidate/Inclusive/hCandidatesPerPhoton"), cands.size()); - if (candDeduplicatePhotons) { + if (dedupOpts.candDeduplicatePhotons) { int best = cands[0]; for (const int& iCand : cands) { if (mCandidatesOfTimeframe[iCand].dcaToPV < mCandidatesOfTimeframe[best].dcaToPV) { @@ -1812,6 +2287,31 @@ struct Sigmaplusbuilder { } } + // one candidate per proton and collision: smallest KF chi2/NDF (negative chi2 last), then smallest proton-photon DCA + if (dedupOpts.candDeduplicateProtons) { + std::unordered_map> candsByProton; + for (int iCand = 0; iCand < static_cast(mCandidatesOfTimeframe.size()); ++iCand) { + if (keep[iCand]) { + const auto& cand = mCandidatesOfTimeframe[iCand]; + candsByProton[(static_cast(static_cast(cand.collisionId)) << 32) | static_cast(cand.protonTrackId)].push_back(iCand); + } + } + auto rank = [&](int iCand) { + const auto& cand = mCandidatesOfTimeframe[iCand]; + return std::make_pair(cand.kfChi2Ndf >= 0.f ? cand.kfChi2Ndf : std::numeric_limits::max(), cand.dcaProtonGamma); + }; + for (const auto& [proton, cands] : candsByProton) { + int best = cands[0]; + for (const int& iCand : cands) { + keep[iCand] = false; + if (rank(iCand) < rank(best)) { + best = iCand; + } + } + keep[best] = true; + } + } + for (int iCand = 0; iCand < static_cast(mCandidatesOfTimeframe.size()); ++iCand) { if (!keep[iCand]) { continue; @@ -1843,6 +2343,7 @@ struct Sigmaplusbuilder { o2::base::Propagator::initFieldFromGRP(grpmag); mBz = grpmag->getNominalL3Field(); fitter.setBz(mBz); + KFParticle::SetField(mBz); if (!mLut) { mLut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(lutPath)); } @@ -1915,6 +2416,48 @@ struct Sigmaplusbuilder { float genDecayRadiusMC = std::hypot(genDecVtx[0] - mcPart.vx(), genDecVtx[1] - mcPart.vy()); float genMassMC = std::sqrt(mcPart.e() * mcPart.e() - mcPart.p() * mcPart.p()); + if (fillUnboundTables) { + sigmaPlusCandsUnboundMC(-1, mRunNumber, + -999.f, -999.f, -999.f, + -999.f, -999.f, + -999.f, -999.f, -999.f, + -999.f, -999.f, -999.f, + -999.f, -999.f, -999.f, + -999.f, -999.f, + -999.f, -999.f, + -999.f, -999.f, -999.f, -999.f, + -999.f, -999.f, + -999.f, -999.f, -999.f, -999.f, + 0, + 0, -999, -999.f, -999.f, + 0, -999, 0, -999, + -999.f, -999.f, -999.f, -999.f, -999.f, + -999.f, -999.f, -999.f, -999.f, + 0, 0, -999.f, -999.f, + -1.f, + -999.f, -999.f, -999.f, -999.f, + -999.f, -999.f, + -999.f, -999.f, -999.f, + -999.f, -999.f, -999.f, + -999.f, -999.f, -999.f, -999.f, -999.f, + -999.f, -999.f, + -999.f, -999.f, + -999.f, -999.f, -999.f, -999.f, + -999.f, -999.f, -999.f, + -999.f, -999.f, + -1, -1, -1, + static_cast(mcPart.globalIndex()), + false, + false, false, false, + 0, 0, 0, 0, + genDecVtx[0], genDecVtx[1], genDecVtx[2], + genMomProton[0], genMomProton[1], genMomProton[2], + -999.f, -999.f, -999.f, + mcPart.px(), mcPart.py(), mcPart.pz(), + genDecayRadiusMC, genMassMC); + continue; + } + if (fillSlimTables) { slimSigmaPlusCandsMC(-1, -1, -1, -1, mcPart.globalIndex(), @@ -1958,6 +2501,7 @@ struct Sigmaplusbuilder { -999.f, -999.f, -999.f, -999.f, 0, 0, -999.f, -999.f, -1.f, + -999.f, -999.f, -999.f, false, false, false, false, genDecVtx[0], genDecVtx[1], genDecVtx[2], @@ -1992,6 +2536,7 @@ struct Sigmaplusbuilder { initCCDB(collision.template bc_as()); histos.fill(HIST("hVertexZ"), collision.posZ()); std::array pv{collision.posX(), collision.posY(), collision.posZ()}; + std::array pvCov{collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()}; auto tracksThisCollision = [&]() { if constexpr (IsMC) { @@ -2026,7 +2571,7 @@ struct Sigmaplusbuilder { for (const auto& photon : acceptedPhotons) { for (size_t iProton = 0; iProton < acceptedProtons.size(); ++iProton) { - buildSigmaPlusCandidate(acceptedProtons[iProton], acceptedProtonDcas[iProton], photon, collision.globalIndex(), pv); + buildSigmaPlusCandidate(acceptedProtons[iProton], acceptedProtonDcas[iProton], photon, collision.globalIndex(), pv, pvCov); } } }