From 540c5c59d68684360832ca96a2a2280255408688 Mon Sep 17 00:00:00 2001 From: Daiki Sekihata Date: Sat, 25 Apr 2026 14:28:49 +0200 Subject: [PATCH] [PWGEM/Dilepton] update taggingHFE.cxx --- PWGEM/Dilepton/DataModel/lmeeMLTables.h | 34 ++++++++++++ PWGEM/Dilepton/Tasks/taggingHFE.cxx | 73 ++++++++++++++++++++----- 2 files changed, 93 insertions(+), 14 deletions(-) diff --git a/PWGEM/Dilepton/DataModel/lmeeMLTables.h b/PWGEM/Dilepton/DataModel/lmeeMLTables.h index 4bb0032c934..d2f750ac2fc 100644 --- a/PWGEM/Dilepton/DataModel/lmeeMLTables.h +++ b/PWGEM/Dilepton/DataModel/lmeeMLTables.h @@ -192,6 +192,40 @@ DECLARE_SOA_TABLE(EMFwdTrackErrsForML, "AOD", "EMFWDTRKERRML", //! Joinable with // iterators using EMFwdTrackErrForML = EMFwdTrackErrsForML::iterator; +// for SemiCharmTag at midrapidity, only electrons +namespace emmllhpair +{ +DECLARE_SOA_COLUMN(Signed1PtL, signed1PtL, float); //! signed1Pt of lepton +DECLARE_SOA_COLUMN(EtaL, etaL, float); //! eta of lepton +DECLARE_SOA_COLUMN(DcaL, dcaL, float); //! dca of lepton +DECLARE_SOA_COLUMN(DcaLSigma, dcaLsigma, float); //! dca of lepton + +DECLARE_SOA_COLUMN(Signed1PtH, signed1PtH, float); //! signed1Pt of hadron +DECLARE_SOA_COLUMN(EtaH, etaH, float); //! eta of hadron +DECLARE_SOA_COLUMN(DcaH, dcaH, float); //! dca of hadron +DECLARE_SOA_COLUMN(DcaHSigma, dcaHsigma, float); //! dca resolution of hadron +DECLARE_SOA_COLUMN(NSigmaKa, nSigmaKa, float); //! PID n sigma with respect to charged Kaon + +DECLARE_SOA_COLUMN(Mass, mass, float); //! invariant mass of LH assuming kaon +DECLARE_SOA_COLUMN(DcaLH, dcalh, float); //! DCA between lepton and hadron +DECLARE_SOA_COLUMN(CosPA, cospa, float); //! flight direction of LH pair +DECLARE_SOA_COLUMN(Lxyz, lxyz, float); //! decay length of LH pair +DECLARE_SOA_COLUMN(LxyzSigma, lxyzSigma, float); //! decay length resolution of LH pair + +DECLARE_SOA_COLUMN(PdgCodeH, pdgCodeH, int); //! pdg code of associated hadron +DECLARE_SOA_COLUMN(PdgCodeHFH, pdgCodeHFH, int); //! pdg code of HF hadron +} // namespace emmllhpair + +DECLARE_SOA_TABLE(EMMLLHPairs, "AOD", "EMMLLHPAIR", //! + o2::soa::Index<>, collision::NumContrib, evsel::NumTracksInTimeRange, evsel::SumAmpFT0CInTimeRange, + emmllhpair::Signed1PtL, emmllhpair::EtaL, emmllhpair::DcaL, emmllhpair::DcaLSigma, + emmllhpair::Signed1PtH, emmllhpair::EtaH, emmllhpair::DcaH, emmllhpair::DcaHSigma, emmllhpair::NSigmaKa, + emmllhpair::Mass, emmllhpair::DcaLH, emmllhpair::CosPA, emmllhpair::Lxyz, emmllhpair::LxyzSigma, + emmllhpair::PdgCodeH, emmllhpair::PdgCodeHFH); + +// iterators +using EMMLLHPair = EMMLLHPairs::iterator; + } // namespace o2::aod #endif // PWGEM_DILEPTON_DATAMODEL_LMEEMLTABLES_H_ diff --git a/PWGEM/Dilepton/Tasks/taggingHFE.cxx b/PWGEM/Dilepton/Tasks/taggingHFE.cxx index 0b5df3eddc7..a07ed257816 100644 --- a/PWGEM/Dilepton/Tasks/taggingHFE.cxx +++ b/PWGEM/Dilepton/Tasks/taggingHFE.cxx @@ -13,6 +13,7 @@ /// \brief a task to study tagging e from charm hadron decays in MC /// \author daiki.sekihata@cern.ch +#include "PWGEM/Dilepton/DataModel/lmeeMLTables.h" #include "PWGEM/Dilepton/Utils/MCUtilities.h" #include "PWGEM/Dilepton/Utils/SemiCharmTag.h" #include "PWGLF/DataModel/LFStrangenessTables.h" @@ -82,15 +83,7 @@ struct taggingHFE { using MyV0s = soa::Join; using MyCascades = soa::Join; - struct EBPair { // electron-baryon pair - float mass{-999.f}; - float dca2legs{-999.f}; - float cospa{-999.f}; - float lxy{-999.f}; - float lz{-999.f}; - float ptepv{-999.f}; - float dca3dinsigma{-999.f}; - }; + Produces emmllhpair; // Configurables Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; @@ -124,8 +117,8 @@ struct taggingHFE { std::string prefix = "electronCut"; Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.4, "min pT for single track"}; Configurable cfg_max_pt_track{"cfg_max_pt_track", 1e+10, "max pT for single track"}; - Configurable cfg_min_eta_track{"cfg_min_eta_track", -0.5, "min eta for single track"}; - Configurable cfg_max_eta_track{"cfg_max_eta_track", +0.5, "max eta for single track"}; + Configurable cfg_min_eta_track{"cfg_min_eta_track", -0.8, "min eta for single track"}; + Configurable cfg_max_eta_track{"cfg_max_eta_track", +0.8, "max eta for single track"}; Configurable cfg_min_cr2findable_ratio_tpc{"cfg_min_cr2findable_ratio_tpc", 0.8, "min. TPC Ncr/Nf ratio"}; Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 0.7, "max fraction of shared clusters in TPC"}; Configurable cfg_min_ncrossedrows_tpc{"cfg_min_ncrossedrows_tpc", 80, "min ncrossed rows"}; @@ -658,9 +651,9 @@ struct taggingHFE { return false; } - if (!isKaon(track)) { - return false; - } + // if (!isKaon(track)) { + // return false; + // } return true; } @@ -905,6 +898,20 @@ struct taggingHFE { } } + template + float combinedNSigmaKa(TTrack const& track) + { + if (track.hasTOF()) { + if (track.tpcNSigmaKa() > 0.f) { + return std::sqrt((std::pow(track.tpcNSigmaKa(), 2) + std::pow(track.tofNSigmaKa(), 2)) / 2.); + } else { + return -1 * std::sqrt((std::pow(track.tpcNSigmaKa(), 2) + std::pow(track.tofNSigmaKa(), 2)) / 2.); + } + } else { + return track.tpcNSigmaKa(); + } + } + template bool isSemiLeptonic(TMCParticle const& mcParticle, TMCParticles const& mcParticles, const int pdgLepton, const int pdgNeutrino, const int pdgStrHad) { @@ -1123,7 +1130,10 @@ struct taggingHFE { o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, leptonParCov, 2.f, matCorr, &mDcaInfoCov); float dcaXY_lepton = mDcaInfoCov.getY(); float dcaZ_lepton = mDcaInfoCov.getZ(); + float dca3D_lepton = std::hypot(dcaXY_lepton, dcaZ_lepton); float dca3DinSigma_lepton = dca3DinSigmaOTF(dcaXY_lepton, dcaZ_lepton, leptonParCov.getSigmaY2(), leptonParCov.getSigmaZ2(), leptonParCov.getSigmaZY()); + float sigma3D_lepton = dca3D_lepton / dca3DinSigma_lepton; + const auto& mcpos = pos.template mcParticle_as(); // D0 -> e+ nu_e K-, br = 0.03538, ctau = 123.01 um, m = 1864 MeV/c2 @@ -1135,7 +1145,9 @@ struct taggingHFE { o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, trackParCov, 2.f, matCorr, &mDcaInfoCov); float dcaXY_kaon = mDcaInfoCov.getY(); float dcaZ_kaon = mDcaInfoCov.getZ(); + float dca3D_kaon = std::hypot(dcaXY_kaon, dcaZ_kaon); float dca3DinSigma_kaon = dca3DinSigmaOTF(dcaXY_kaon, dcaZ_kaon, trackParCov.getSigmaY2(), trackParCov.getSigmaZ2(), trackParCov.getSigmaZY()); + float sigma3D_kaon = dca3D_kaon / dca3DinSigma_kaon; if (positronId == kaonId) { continue; @@ -1162,6 +1174,20 @@ struct taggingHFE { // const auto& mcD0 = mcParticles.rawIteratorAt(mcD0Id); fRegistry.fill(HIST("MC/eKfromDpm/hs"), leptonParCov.getPt(), dca3DinSigma_lepton, trackParCov.getPt(), dca3DinSigma_kaon, eKpair.mass, eKpair.lxyz / eKpair.lxyzErr, eKpair.cospa, eKpair.dca2legs); } + + int mcMotherId = FindCommonMotherFrom2ProngsWithoutPDG(mcpos, mckaon); + int pdgCodeMother = 0; + if (mcMotherId > -1) { + auto mcMother = mcParticles.rawIteratorAt(mcMotherId); + pdgCodeMother = mcMother.pdgCode(); + } else { + pdgCodeMother = 0; + } + emmllhpair(collision.numContrib(), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange(), + leptonParCov.getQ2Pt(), leptonParCov.getEta(), dca3D_lepton, sigma3D_lepton, + trackParCov.getQ2Pt(), trackParCov.getEta(), dca3D_kaon, sigma3D_kaon, combinedNSigmaKa(kaon), + eKpair.mass, eKpair.dca2legs, eKpair.cospa, eKpair.lxyz, eKpair.lxyzErr, mckaon.pdgCode(), pdgCodeMother); + } // end of kaon loop // D+ -> e+ K0S nu_e @@ -1300,7 +1326,10 @@ struct taggingHFE { o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, leptonParCov, 2.f, matCorr, &mDcaInfoCov); float dcaXY_lepton = mDcaInfoCov.getY(); float dcaZ_lepton = mDcaInfoCov.getZ(); + float dca3D_lepton = std::hypot(dcaXY_lepton, dcaZ_lepton); float dca3DinSigma_lepton = dca3DinSigmaOTF(dcaXY_lepton, dcaZ_lepton, leptonParCov.getSigmaY2(), leptonParCov.getSigmaZ2(), leptonParCov.getSigmaZY()); + float sigma3D_lepton = dca3D_lepton / dca3DinSigma_lepton; + const auto& mcele = ele.template mcParticle_as(); // D0bar -> e- anti-nu_e K+, br = 0.03538, ctau = 123.01 um, m = 1864 MeV/c2 @@ -1312,7 +1341,9 @@ struct taggingHFE { o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, trackParCov, 2.f, matCorr, &mDcaInfoCov); float dcaXY_kaon = mDcaInfoCov.getY(); float dcaZ_kaon = mDcaInfoCov.getZ(); + float dca3D_kaon = std::hypot(dcaXY_kaon, dcaZ_kaon); float dca3DinSigma_kaon = dca3DinSigmaOTF(dcaXY_kaon, dcaZ_kaon, trackParCov.getSigmaY2(), trackParCov.getSigmaZ2(), trackParCov.getSigmaZY()); + float sigma3D_kaon = dca3D_kaon / dca3DinSigma_kaon; if (electronId == kaonId) { continue; @@ -1337,6 +1368,20 @@ struct taggingHFE { // const auto& mcD0 = mcParticles.rawIteratorAt(mcD0Id); fRegistry.fill(HIST("MC/eKfromDpm/hs"), leptonParCov.getPt(), dca3DinSigma_lepton, trackParCov.getPt(), dca3DinSigma_kaon, eKpair.mass, eKpair.lxyz / eKpair.lxyzErr, eKpair.cospa, eKpair.dca2legs); } + + int mcMotherId = FindCommonMotherFrom2ProngsWithoutPDG(mcele, mckaon); + int pdgCodeMother = 0; + if (mcMotherId > -1) { + auto mcMother = mcParticles.rawIteratorAt(mcMotherId); + pdgCodeMother = mcMother.pdgCode(); + } else { + pdgCodeMother = 0; + } + emmllhpair(collision.numContrib(), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange(), + leptonParCov.getQ2Pt(), leptonParCov.getEta(), dca3D_lepton, sigma3D_lepton, + trackParCov.getQ2Pt(), trackParCov.getEta(), dca3D_kaon, sigma3D_kaon, combinedNSigmaKa(kaon), + eKpair.mass, eKpair.dca2legs, eKpair.cospa, eKpair.lxyz, eKpair.lxyzErr, mckaon.pdgCode(), pdgCodeMother); + } // end of kaon loop // D- -> e0 anti-K0S anti-nu_e