Skip to content

Commit 7e07d1f

Browse files
authored
[PWGEM/Dilepton] update taggingHFE for LS eh pairs (#16154)
1 parent 293ff20 commit 7e07d1f

1 file changed

Lines changed: 143 additions & 9 deletions

File tree

PWGEM/Dilepton/Tasks/taggingHFE.cxx

Lines changed: 143 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ struct taggingHFE {
9999
Configurable<bool> skipGRPOquery{"skipGRPOquery", true, "skip grpo query"};
100100
Configurable<float> d_bz_input{"d_bz_input", -999, "bz field in kG, -999 is automatic"};
101101
Configurable<int> cfgPdgLepton{"cfgPdgLepton", 11, "pdg code of desired lepton: 11 or 13"};
102-
Configurable<float> cfgDownSampling{"cfgDownSampling", 1.1, "down sampling for fake matches"};
102+
Configurable<float> cfgDownSamplingHc{"cfgDownSamplingHc", 1.1, "down sampling for charm hadrons"}; // there are enough hc, but not jpsi or hb.
103103
Configurable<bool> useTOFNSigmaDeltaBC{"useTOFNSigmaDeltaBC", true, "Flag to shift delta BC for TOF n sigma (only with TTCA)"};
104104

105105
struct : ConfigurableGroup {
@@ -970,10 +970,6 @@ struct taggingHFE {
970970
continue;
971971
}
972972

973-
if (dist01(engine) > cfgDownSampling) { // random sampling, if necessary
974-
continue;
975-
}
976-
977973
fillEventHistograms(collision);
978974
fRegistry.fill(HIST("Event/hCollisionCounter"), 1);
979975
mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()});
@@ -1016,6 +1012,13 @@ struct taggingHFE {
10161012
fRegistry.fill(HIST("Electron/hs"), trackParCov.getPt(), trackParCov.getEta(), RecoDecay::constrainAngle(trackParCov.getPhi(), 0, 1U));
10171013
fRegistry.fill(HIST("Electron/hTPCdEdx"), track.tpcInnerParam(), track.mcTunedTPCSignal());
10181014
fRegistry.fill(HIST("Electron/hTOFbeta"), track.p(), mapTOFBetaReassociated[std::make_pair(collision.globalIndex(), track.globalIndex())]);
1015+
1016+
auto mcMother = mcParticle.template mothers_as<aod::McParticles>()[0];
1017+
bool is_e_from_hc = (std::abs(mcMother.pdgCode()) == 411 || std::abs(mcMother.pdgCode()) == 421 || std::abs(mcMother.pdgCode()) == 431 || std::abs(mcMother.pdgCode()) == 4122 || std::abs(mcMother.pdgCode()) == 4132 || std::abs(mcMother.pdgCode()) == 4232 || std::abs(mcMother.pdgCode()) == 4332) && isSemiLeptonic(mcMother, mcParticles, -cfgPdgLepton, cfgPdgLepton + 1);
1018+
if (is_e_from_hc && dist01(engine) > cfgDownSamplingHc) { // random sampling hc, if necessary
1019+
continue;
1020+
}
1021+
10191022
if (track.sign() > 0) { // positron
10201023
positronIds.emplace_back(trackId.trackId());
10211024
} else { // electron
@@ -1182,7 +1185,7 @@ struct taggingHFE {
11821185
auto mcMother_of_kaon = mckaon.template mothers_first_as<aod::McParticles>();
11831186
if (mcMother_of_kaon.pdgCode() == -323 || mcMother_of_kaon.pdgCode() == -313 || mcMother_of_kaon.pdgCode() == 333) { // accept short-lived resonances such as phi->KK, K*(892)->Kpi for D+ -> anti-K*0(892) e+ nu_e -> (K- pi+) e+ nu_e and Ds+ -> phi e+ nu_e
11841187
int commonMotherId = FindCommonMotherFrom2ProngsWithoutPDG(mcpos, mcMother_of_kaon);
1185-
if (commonMotherId > 0 && std::abs(mcParticles.rawIteratorAt(commonMotherId).pdgCode()) != 2212) {
1188+
if (commonMotherId > 0) {
11861189
foundCommonMother = true;
11871190
// LOGF(info, "eK: e+ and K*(892) or phi is found. mother is %d", mcParticles.rawIteratorAt(commonMotherId).pdgCode());
11881191
}
@@ -1220,6 +1223,71 @@ struct taggingHFE {
12201223

12211224
} // end of kaon loop
12221225

1226+
for (const auto& kaonId : kaonPlusIds) {
1227+
auto kaon = tracks.rawIteratorAt(kaonId);
1228+
mDcaInfoCov.set(999, 999, 999, 999, 999);
1229+
auto trackParCov = getTrackParCov(kaon);
1230+
trackParCov.setPID(kaon.pidForTracking());
1231+
o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, trackParCov, 2.f, matCorr, &mDcaInfoCov);
1232+
float dcaXY_kaon = mDcaInfoCov.getY();
1233+
float dcaZ_kaon = mDcaInfoCov.getZ();
1234+
1235+
if (positronId == kaonId) {
1236+
continue;
1237+
}
1238+
1239+
auto eKpair = o2::aod::pwgem::dilepton::utils::makePairLeptonTrack(fitter_eK, collision, pos, kaon, o2::track::PID::Electron, kaon.pidForTracking());
1240+
if (!eKpair.isOK) {
1241+
continue;
1242+
}
1243+
if (!(lKPairCut.cfg_min_mass < eKpair.mass && eKpair.mass < lKPairCut.cfg_max_mass) || eKpair.cospa < lKPairCut.cfg_min_cospa || lKPairCut.cfg_max_lxyz < eKpair.lxyz || lKPairCut.cfg_max_dca2legs < eKpair.dca2legs) {
1244+
continue;
1245+
}
1246+
1247+
auto mckaon = kaon.template mcParticle_as<aod::McParticles>();
1248+
bool foundCommonMother = FindCommonMotherFrom2ProngsWithoutPDG(mcpos, mckaon) > 0;
1249+
if (mckaon.has_mothers() && !foundCommonMother) {
1250+
auto mcMother_of_kaon = mckaon.template mothers_first_as<aod::McParticles>();
1251+
if (mcMother_of_kaon.pdgCode() == -323 || mcMother_of_kaon.pdgCode() == -313 || mcMother_of_kaon.pdgCode() == 333) { // accept short-lived resonances such as phi->KK, K*(892)->Kpi for D+ -> anti-K*0(892) e+ nu_e -> (K- pi+) e+ nu_e and Ds+ -> phi e+ nu_e
1252+
int commonMotherId = FindCommonMotherFrom2ProngsWithoutPDG(mcpos, mcMother_of_kaon);
1253+
if (commonMotherId > 0) {
1254+
foundCommonMother = true;
1255+
// LOGF(info, "eK: e- and K*(892) or phi is found. mother is %d", mcParticles.rawIteratorAt(commonMotherId).pdgCode());
1256+
}
1257+
}
1258+
}
1259+
1260+
if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_jpsi) && !foundCommonMother) || ((is_e_from_dy || is_e_from_jpsi) && foundCommonMother && std::abs(mckaon.pdgCode()) == cfgPdgLepton))) {
1261+
// I want 3 types.
1262+
// 1. truely found HF->eh (SV should found by eh, and truely found.) For signal sample in ML.
1263+
// 2. mistakenly found DY->eh (SV should not be found by eh, but found.) For bkg sample in ML.
1264+
// 3. truely found DY->ee with misidentified ee. (SV may be found at the same position of PV.) For bkg sample in ML.
1265+
continue;
1266+
}
1267+
1268+
// if (std::abs(mckaon.pdgCode()) == 11) {
1269+
// LOGF(info, "mcMother.pdgCode() = %d, mckaon.pdgCode() = %d, foundCommonMother = %d", mcMother.pdgCode(), mckaon.pdgCode(), foundCommonMother);
1270+
// for (int d = mcMother.daughtersIds()[0]; d <= mcMother.daughtersIds()[1]; ++d) {
1271+
// auto daughter = mcParticles.rawIteratorAt(d);
1272+
// LOGF(info, "daughter.pdgCode() = %d", daughter.pdgCode());
1273+
// }
1274+
// }
1275+
1276+
float tofNSigmaPi = mapTOFNsigmaPiReassociated[std::make_pair(collision.globalIndex(), kaon.globalIndex())];
1277+
float tofNSigmaKa = mapTOFNsigmaKaReassociated[std::make_pair(collision.globalIndex(), kaon.globalIndex())];
1278+
1279+
emmllhpair(leptonTable.lastIndex(),
1280+
trackParCov.getQ2Pt(), trackParCov.getEta(), dcaXY_kaon, dcaZ_kaon, trackParCov.getSigmaY2(), trackParCov.getSigmaZY(), trackParCov.getSigmaZ2(),
1281+
kaon.tpcNSigmaPi(), tofNSigmaPi,
1282+
kaon.tpcNSigmaKa(), tofNSigmaKa,
1283+
eKpair.mass, eKpair.dca2legs, eKpair.cospa, eKpair.cospaXY,
1284+
eKpair.lxyz, eKpair.lxyzErr,
1285+
eKpair.lxy, eKpair.lxyErr,
1286+
eKpair.lz, eKpair.lzErr,
1287+
mckaon.pdgCode(), foundCommonMother);
1288+
1289+
} // end of kaon loop
1290+
12231291
// D+ -> e+ K0S nu_e
12241292
for (const auto& k0Id : k0Ids) {
12251293
auto v0 = v0s.rawIteratorAt(k0Id);
@@ -1271,7 +1339,7 @@ struct taggingHFE {
12711339
auto mcMother_of_k0s = mcK0S.template mothers_first_as<aod::McParticles>();
12721340
if (mcMother_of_k0s.pdgCode() == -323 || mcMother_of_k0s.pdgCode() == -313 || mcMother_of_k0s.pdgCode() == 333) { // accept short-lived resonances such as phi->KK, K*(892)->Kpi for D+ -> anti-K*0(892) e+ nu_e -> (K- pi+) e+ nu_e and Ds+ -> phi e+ nu_e
12731341
int commonMotherId = FindCommonMotherFrom2ProngsWithoutPDG(mcpos, mcMother_of_k0s);
1274-
if (commonMotherId > 0 && std::abs(mcParticles.rawIteratorAt(commonMotherId).pdgCode()) != 2212) { // proton decay is implemented. reject it.
1342+
if (commonMotherId > 0) {
12751343
foundCommonMother = true;
12761344
// LOGF(info, "eK0S: e+ and K*(892) or phi is found. mother is %d", mcParticles.rawIteratorAt(commonMotherId).pdgCode());
12771345
}
@@ -1514,6 +1582,72 @@ struct taggingHFE {
15141582
leptonParCov.getQ2Pt(), leptonParCov.getEta(), dcaXY_lepton, dcaZ_lepton, leptonParCov.getSigmaY2(), leptonParCov.getSigmaZY(), leptonParCov.getSigmaZ2(),
15151583
isMotherFromB, mcMother.pdgCode());
15161584

1585+
for (const auto& kaonId : kaonMinusIds) {
1586+
auto kaon = tracks.rawIteratorAt(kaonId);
1587+
mDcaInfoCov.set(999, 999, 999, 999, 999);
1588+
auto trackParCov = getTrackParCov(kaon);
1589+
trackParCov.setPID(kaon.pidForTracking());
1590+
o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, trackParCov, 2.f, matCorr, &mDcaInfoCov);
1591+
float dcaXY_kaon = mDcaInfoCov.getY();
1592+
float dcaZ_kaon = mDcaInfoCov.getZ();
1593+
1594+
if (electronId == kaonId) {
1595+
continue;
1596+
}
1597+
1598+
auto eKpair = o2::aod::pwgem::dilepton::utils::makePairLeptonTrack(fitter_eK, collision, ele, kaon, o2::track::PID::Electron, kaon.pidForTracking());
1599+
if (!eKpair.isOK) {
1600+
continue;
1601+
}
1602+
1603+
if (!(lKPairCut.cfg_min_mass < eKpair.mass && eKpair.mass < lKPairCut.cfg_max_mass) || eKpair.cospa < lKPairCut.cfg_min_cospa || lKPairCut.cfg_max_lxyz < eKpair.lxyz || lKPairCut.cfg_max_dca2legs < eKpair.dca2legs) {
1604+
continue;
1605+
}
1606+
1607+
auto mckaon = kaon.template mcParticle_as<aod::McParticles>();
1608+
bool foundCommonMother = FindCommonMotherFrom2ProngsWithoutPDG(mcele, mckaon) > 0;
1609+
if (mckaon.has_mothers() && !foundCommonMother) {
1610+
auto mcMother_of_kaon = mckaon.template mothers_first_as<aod::McParticles>();
1611+
if (mcMother_of_kaon.pdgCode() == 323 || mcMother_of_kaon.pdgCode() == 313 || mcMother_of_kaon.pdgCode() == 333) { // accept short-lived resonances such as phi->KK, K*(892)->Kpi for D+ -> anti-K*0(892) e+ nu_e -> (K- pi+) e+ nu_e and Ds+ -> phi e+ nu_e
1612+
int commonMotherId = FindCommonMotherFrom2ProngsWithoutPDG(mcele, mcMother_of_kaon);
1613+
if (commonMotherId > 0) {
1614+
foundCommonMother = true;
1615+
// LOGF(info, "eK: e+ and K*(892) or phi is found. mother is %d", mcParticles.rawIteratorAt(commonMotherId).pdgCode());
1616+
}
1617+
}
1618+
}
1619+
1620+
if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_jpsi) && !foundCommonMother) || ((is_e_from_dy || is_e_from_jpsi) && foundCommonMother && std::abs(mckaon.pdgCode()) == cfgPdgLepton))) {
1621+
// I want 3 types.
1622+
// 1. truely found HF->eh (SV should found by eh, and truely found.) For signal sample in ML.
1623+
// 2. mistakenly found DY->eh (SV should not be found by eh, but found.) For bkg sample in ML.
1624+
// 3. truely found DY->ee with misidentified ee. (SV may be found at the same position of PV.) For bkg sample in ML.
1625+
continue;
1626+
}
1627+
1628+
// if (std::abs(mckaon.pdgCode()) == 11) {
1629+
// LOGF(info, "mcMother.pdgCode() = %d, mckaon.pdgCode() = %d, foundCommonMother = %d", mcMother.pdgCode(), mckaon.pdgCode(), foundCommonMother);
1630+
// for (int d = mcMother.daughtersIds()[0]; d <= mcMother.daughtersIds()[1]; ++d) {
1631+
// auto daughter = mcParticles.rawIteratorAt(d);
1632+
// LOGF(info, "daughter.pdgCode() = %d", daughter.pdgCode());
1633+
// }
1634+
// }
1635+
1636+
float tofNSigmaPi = mapTOFNsigmaPiReassociated[std::make_pair(collision.globalIndex(), kaon.globalIndex())];
1637+
float tofNSigmaKa = mapTOFNsigmaKaReassociated[std::make_pair(collision.globalIndex(), kaon.globalIndex())];
1638+
1639+
emmllhpair(leptonTable.lastIndex(),
1640+
trackParCov.getQ2Pt(), trackParCov.getEta(), dcaXY_kaon, dcaZ_kaon, trackParCov.getSigmaY2(), trackParCov.getSigmaZY(), trackParCov.getSigmaZ2(),
1641+
kaon.tpcNSigmaPi(), tofNSigmaPi,
1642+
kaon.tpcNSigmaKa(), tofNSigmaKa,
1643+
eKpair.mass, eKpair.dca2legs, eKpair.cospa, eKpair.cospaXY,
1644+
eKpair.lxyz, eKpair.lxyzErr,
1645+
eKpair.lxy, eKpair.lxyErr,
1646+
eKpair.lz, eKpair.lzErr,
1647+
mckaon.pdgCode(), foundCommonMother);
1648+
1649+
} // end of kaon loop
1650+
15171651
// D0bar -> e- anti-nu_e K+, br = 0.03538, ctau = 123.01 um, m = 1864 MeV/c2
15181652
for (const auto& kaonId : kaonPlusIds) {
15191653
auto kaon = tracks.rawIteratorAt(kaonId);
@@ -1542,7 +1676,7 @@ struct taggingHFE {
15421676
auto mcMother_of_kaon = mckaon.template mothers_first_as<aod::McParticles>();
15431677
if (mcMother_of_kaon.pdgCode() == 323 || mcMother_of_kaon.pdgCode() == 313 || mcMother_of_kaon.pdgCode() == 333) { // accept short-lived resonances such as phi->KK, K*(892)->Kpi for D+ -> anti-K*0(892) e+ nu_e -> (K- pi+) e+ nu_e and Ds+ -> phi e+ nu_e
15441678
int commonMotherId = FindCommonMotherFrom2ProngsWithoutPDG(mcele, mcMother_of_kaon);
1545-
if (commonMotherId > 0 && std::abs(mcParticles.rawIteratorAt(commonMotherId).pdgCode()) != 2212) {
1679+
if (commonMotherId > 0) {
15461680
foundCommonMother = true;
15471681
// LOGF(info, "eK: e- and K*(892) or phi is found. mother is %d", mcParticles.rawIteratorAt(commonMotherId).pdgCode());
15481682
}
@@ -1630,7 +1764,7 @@ struct taggingHFE {
16301764
auto mcMother_of_k0s = mcK0S.template mothers_first_as<aod::McParticles>();
16311765
if (mcMother_of_k0s.pdgCode() == 323 || mcMother_of_k0s.pdgCode() == 313 || mcMother_of_k0s.pdgCode() == 333) { // accept short-lived resonances such as phi->KK, K*(892)->Kpi for D+ -> anti-K*0(892) e+ nu_e -> (K- pi+) e+ nu_e and Ds+ -> phi e+ nu_e
16321766
int commonMotherId = FindCommonMotherFrom2ProngsWithoutPDG(mcele, mcMother_of_k0s);
1633-
if (commonMotherId > 0 && std::abs(mcParticles.rawIteratorAt(commonMotherId).pdgCode()) != 2212) { // proton decay is implemented. reject it.
1767+
if (commonMotherId > 0) {
16341768
foundCommonMother = true;
16351769
// LOGF(info, "eK0S: e- and K*(892) or phi is found. mother is %d", mcParticles.rawIteratorAt(commonMotherId).pdgCode());
16361770
}

0 commit comments

Comments
 (0)