diff --git a/PWGEM/Dilepton/DataModel/lmeeMLTables.h b/PWGEM/Dilepton/DataModel/lmeeMLTables.h index f7d01dbb839..b8f745d730c 100644 --- a/PWGEM/Dilepton/DataModel/lmeeMLTables.h +++ b/PWGEM/Dilepton/DataModel/lmeeMLTables.h @@ -346,22 +346,26 @@ using EMMLLCascPair = EMMLLCascPairs::iterator; namespace emmldilepton { -DECLARE_SOA_INDEX_COLUMN(EMMLEvent, emmlevent); //! index to event table -DECLARE_SOA_COLUMN(Signed1Pt1, signed1Pt1, float); //! q/pt of lepton1 at PV -DECLARE_SOA_COLUMN(Eta1, eta1, float); //! eta of lepton1 at PV -DECLARE_SOA_COLUMN(ImpParXY1, impParXY1, float); //! impact parameter for lepton1 in XY plane -DECLARE_SOA_COLUMN(ImpParZ1, impParZ1, float); //! impact parameter for lepton1 in Z plane -DECLARE_SOA_COLUMN(ImpParCYY1, impParCYY1, float); //! sigma of impact parameter for lepton1 in XY -DECLARE_SOA_COLUMN(ImpParCZY1, impParCZY1, float); //! sigma of impact parameter for lepton1, correlaion term -DECLARE_SOA_COLUMN(ImpParCZZ1, impParCZZ1, float); //! sigma of impact parameter for lepton1 in Z - -DECLARE_SOA_COLUMN(Signed1Pt2, signed1Pt2, float); //! q/pt of lepton2 at PV -DECLARE_SOA_COLUMN(Eta2, eta2, float); //! eta of lepton1 at PV -DECLARE_SOA_COLUMN(ImpParXY2, impParXY2, float); //! impact parameter for lepton2 in XY plane -DECLARE_SOA_COLUMN(ImpParZ2, impParZ2, float); //! impact parameter for lepton2 in Z plane -DECLARE_SOA_COLUMN(ImpParCYY2, impParCYY2, float); //! sigma of impact parameter for lepton2 in XY -DECLARE_SOA_COLUMN(ImpParCZY2, impParCZY2, float); //! sigma of impact parameter for lepton2, correlaion term -DECLARE_SOA_COLUMN(ImpParCZZ2, impParCZZ2, float); //! sigma of impact parameter for lepton2 in Z +DECLARE_SOA_INDEX_COLUMN(EMMLEvent, emmlevent); //! index to event table +DECLARE_SOA_COLUMN(Signed1Pt1, signed1Pt1, float); //! q/pt of lepton1 at PV +DECLARE_SOA_COLUMN(Eta1, eta1, float); //! eta of lepton1 at PV +DECLARE_SOA_COLUMN(ImpParXY1, impParXY1, float); //! impact parameter for lepton1 in XY plane +DECLARE_SOA_COLUMN(ImpParZ1, impParZ1, float); //! impact parameter for lepton1 in Z plane +DECLARE_SOA_COLUMN(ImpParCYY1, impParCYY1, float); //! sigma of impact parameter for lepton1 in XY +DECLARE_SOA_COLUMN(ImpParCZY1, impParCZY1, float); //! sigma of impact parameter for lepton1, correlaion term +DECLARE_SOA_COLUMN(ImpParCZZ1, impParCZZ1, float); //! sigma of impact parameter for lepton1 in Z +DECLARE_SOA_COLUMN(IsCorrectCollision1, isCorrectCollision1, bool); //! lepton1 is associated to correct collision. +DECLARE_SOA_COLUMN(PdgCodeMother1, pdgCodeMother1, int); //! pdg code of mother of lepton1 + +DECLARE_SOA_COLUMN(Signed1Pt2, signed1Pt2, float); //! q/pt of lepton2 at PV +DECLARE_SOA_COLUMN(Eta2, eta2, float); //! eta of lepton1 at PV +DECLARE_SOA_COLUMN(ImpParXY2, impParXY2, float); //! impact parameter for lepton2 in XY plane +DECLARE_SOA_COLUMN(ImpParZ2, impParZ2, float); //! impact parameter for lepton2 in Z plane +DECLARE_SOA_COLUMN(ImpParCYY2, impParCYY2, float); //! sigma of impact parameter for lepton2 in XY +DECLARE_SOA_COLUMN(ImpParCZY2, impParCZY2, float); //! sigma of impact parameter for lepton2, correlaion term +DECLARE_SOA_COLUMN(ImpParCZZ2, impParCZZ2, float); //! sigma of impact parameter for lepton2 in Z +DECLARE_SOA_COLUMN(IsCorrectCollision2, isCorrectCollision2, bool); //! lepton is associated to correct collision. +DECLARE_SOA_COLUMN(PdgCodeMother2, pdgCodeMother2, int); //! pdg code of mother of lepton1 DECLARE_SOA_COLUMN(Mass, mass, float); //! invariant mass of dilepton DECLARE_SOA_COLUMN(Pt, pt, float); //! dilepton pair pt @@ -384,14 +388,14 @@ DECLARE_SOA_COLUMN(PdgCodeCommonMother, pdgCodeCommonMother, int); //! pdg code DECLARE_SOA_TABLE(EMMLDielectronsAtSV, "AOD", "EMMLEESV", //! emmldilepton::EMMLEventId, - emmldilepton::Signed1Pt1, emmldilepton::Eta1, emmldilepton::ImpParXY1, emmldilepton::ImpParZ1, emmldilepton::ImpParCYY1, emmldilepton::ImpParCZY1, emmldilepton::ImpParCZZ1, - emmldilepton::Signed1Pt2, emmldilepton::Eta2, emmldilepton::ImpParXY2, emmldilepton::ImpParZ2, emmldilepton::ImpParCYY2, emmldilepton::ImpParCZY2, emmldilepton::ImpParCZZ2, + emmldilepton::Signed1Pt1, emmldilepton::Eta1, emmldilepton::ImpParXY1, emmldilepton::ImpParZ1, emmldilepton::ImpParCYY1, emmldilepton::ImpParCZY1, emmldilepton::ImpParCZZ1, emmldilepton::IsCorrectCollision1, emmldilepton::PdgCodeMother1, + emmldilepton::Signed1Pt2, emmldilepton::Eta2, emmldilepton::ImpParXY2, emmldilepton::ImpParZ2, emmldilepton::ImpParCYY2, emmldilepton::ImpParCZY2, emmldilepton::ImpParCZZ2, emmldilepton::IsCorrectCollision2, emmldilepton::PdgCodeMother2, emmldilepton::Mass, emmldilepton::Pt, emmldilepton::Rapidity, emmldilepton::Chi2PCA, emmldilepton::CPA, emmldilepton::CPAXY, emmldilepton::CPARZ, emmldilepton::Lxy, emmldilepton::Lz, emmldilepton::Lxyz, emmldilepton::LxyErr, emmldilepton::LzErr, emmldilepton::LxyzErr, - emmldilepton::DileptonType, emmldilepton::PdgCodeCommonMother); + emmldilepton::DileptonType); // iterators using EMMLDielectronAtSV = EMMLDielectronsAtSV::iterator; diff --git a/PWGEM/Dilepton/Tasks/studyDCAFitter.cxx b/PWGEM/Dilepton/Tasks/studyDCAFitter.cxx index e5c51d60b6b..9db1cffc033 100644 --- a/PWGEM/Dilepton/Tasks/studyDCAFitter.cxx +++ b/PWGEM/Dilepton/Tasks/studyDCAFitter.cxx @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -80,6 +81,7 @@ struct studyDCAFitter { Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; // Configurable mVtxPath{"mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"}; + Configurable cfgDownSampling{"cfgDownSampling", 1.1, "down sampling for wrongly found SV"}; struct : ConfigurableGroup { std::string prefix = "electronCut"; @@ -153,6 +155,10 @@ struct studyDCAFitter { mRunNumber = 0; d_bz = 0; + std::random_device seed_gen; + engine = std::mt19937(seed_gen()); + dist01 = std::uniform_real_distribution(0.0f, 1.0f); + addHistograms(); } @@ -167,6 +173,9 @@ struct studyDCAFitter { o2::dataformats::DCA mDcaInfoCov; o2::dataformats::VertexBase mVtx; + std::mt19937 engine; + std::uniform_real_distribution dist01; + template void initCCDB(TBC const& bc) { @@ -411,11 +420,11 @@ struct studyDCAFitter { auto t1mc = t1.template mcParticle_as(); auto t2mc = t2.template mcParticle_as(); - int mcCommonMotherid = FindCommonMother(t1mc, t2mc, mcParticles); + int mcCommonMotherId = FindCommonMother(t1mc, t2mc, mcParticles); int hfee_type = IsHF(t1mc, t2mc, mcParticles); - if (mcCommonMotherid > -1) { - auto cmp = mcParticles.rawIteratorAt(mcCommonMotherid); + if (mcCommonMotherId > -1) { + auto cmp = mcParticles.rawIteratorAt(mcCommonMotherId); switch (std::abs(cmp.pdgCode())) { case 23: if constexpr (signType == 0) { // ULS @@ -495,7 +504,6 @@ struct studyDCAFitter { fRegistry.fill(HIST("Pair/PV/b2c2e_b2e_diffb/lsmm/hs"), v12.M(), v12.Pt(), pair_dca); } break; - default: break; } // end of switch for HFee @@ -583,19 +591,22 @@ struct studyDCAFitter { float pteeAtSV = RecoDecay::sqrtSumOfSquares(pvecSum[0], pvecSum[1]); float yeeAtSV = RecoDecay::y(pvecSum, meeAtSV); - int pdgCodeCM = 0; - - auto t1mc = t1.template mcParticle_as(); - auto t2mc = t2.template mcParticle_as(); + auto t1mc = t1.template mcParticle_as(); // true lepton + auto t2mc = t2.template mcParticle_as(); // true lepton + bool isCorrectCollision1 = t1mc.mcCollisionId() == collision.mcCollisionId(); + bool isCorrectCollision2 = t2mc.mcCollisionId() == collision.mcCollisionId(); + int pdgCodeMother1 = 0; + int pdgCodeMother2 = 0; - int mcCommonMotherid = FindCommonMother(t1mc, t2mc, mcParticles); + int mcCommonMotherId = FindCommonMother(t1mc, t2mc, mcParticles); int hfee_type = IsHF(t1mc, t2mc, mcParticles); bool keepSignal = false; uint8_t dileptonType = 0; - if (mcCommonMotherid > -1) { - auto cmp = mcParticles.rawIteratorAt(mcCommonMotherid); - pdgCodeCM = cmp.pdgCode(); + if (mcCommonMotherId > -1) { + auto cmp = mcParticles.rawIteratorAt(mcCommonMotherId); + pdgCodeMother1 = cmp.pdgCode(); + pdgCodeMother2 = cmp.pdgCode(); switch (std::abs(cmp.pdgCode())) { case 23: keepSignal = true; @@ -678,6 +689,10 @@ struct studyDCAFitter { } // end of switch for LF } else if (hfee_type > -1) { keepSignal = true; + auto t1mcMother = t1mc.template mothers_first_as(); + auto t2mcMother = t2mc.template mothers_first_as(); + pdgCodeMother1 = t1mcMother.pdgCode(); + pdgCodeMother2 = t2mcMother.pdgCode(); switch (hfee_type) { case static_cast(EM_HFeeType::kCe_Ce): dileptonType = 3; @@ -765,18 +780,26 @@ struct studyDCAFitter { } else { keepSignal = true; dileptonType = 0; // bkg + auto t1mcMother = t1mc.template mothers_first_as(); + auto t2mcMother = t2mc.template mothers_first_as(); + pdgCodeMother1 = t1mcMother.pdgCode(); + pdgCodeMother2 = t2mcMother.pdgCode(); } if (keepSignal) { + if (dileptonType == 0 && dist01(engine) > cfgDownSampling) { // random sampling, if necessary + return; + } + dileptonTable(eventTable.lastIndex() + 1, - signed1Pt1, eta1, dcaXY1, dcaZ1, CYY1, CZY1, CZZ1, - signed1Pt2, eta2, dcaXY2, dcaZ2, CYY2, CZY2, CZZ2, + signed1Pt1, eta1, dcaXY1, dcaZ1, CYY1, CZY1, CZZ1, isCorrectCollision1, pdgCodeMother1, + signed1Pt2, eta2, dcaXY2, dcaZ2, CYY2, CZY2, CZZ2, isCorrectCollision2, pdgCodeMother2, meeAtSV, pteeAtSV, yeeAtSV, chi2PCA, cpa, cpaXY, cpaRZ, lxy, lz, lxyz, lxyErr, lzErr, lxyzErr, - dileptonType, pdgCodeCM); + dileptonType); } } @@ -825,6 +848,11 @@ struct studyDCAFitter { if (std::abs(mctrack.pdgCode()) != 11) { continue; } + + auto mcMother = mctrack.template mothers_first_as(); + if (std::abs(mcMother.pdgCode()) > 1e+9) { + continue; + } if (!(mctrack.isPhysicalPrimary() || mctrack.producedByGenerator())) { continue; }