Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 29 additions & 51 deletions PWGEM/Dilepton/Tasks/taggingHFE.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#include <array>
#include <cmath>
#include <cstdint>
#include <iostream>

Check failure on line 57 in PWGEM/Dilepton/Tasks/taggingHFE.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[include-iostream]

Do not include iostream. Use O2 logging instead.
#include <random>
#include <string>
#include <string_view>
Expand Down Expand Up @@ -99,7 +99,7 @@
Configurable<bool> skipGRPOquery{"skipGRPOquery", true, "skip grpo query"};
Configurable<float> d_bz_input{"d_bz_input", -999, "bz field in kG, -999 is automatic"};
Configurable<int> cfgPdgLepton{"cfgPdgLepton", 11, "pdg code of desired lepton: 11 or 13"};
Configurable<float> cfgDownSamplingHc{"cfgDownSamplingHc", 1.1, "down sampling for charm hadrons"}; // there are enough hc, but not jpsi or hb.
Configurable<float> cfgDownSampling{"cfgDownSampling", 1.1, "down sampling for wrongly found SV"};
Configurable<bool> useTOFNSigmaDeltaBC{"useTOFNSigmaDeltaBC", true, "Flag to shift delta BC for TOF n sigma (only with TTCA)"};

struct : ConfigurableGroup {
Expand Down Expand Up @@ -1028,12 +1028,6 @@
fRegistry.fill(HIST("Electron/hTPCdEdx"), track.tpcInnerParam(), track.mcTunedTPCSignal());
fRegistry.fill(HIST("Electron/hTOFbeta"), track.p(), mapTOFBetaReassociated[std::make_pair(collision.globalIndex(), track.globalIndex())]);

auto mcMother = mcParticle.template mothers_as<aod::McParticles>()[0];
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);
if (is_e_from_hc && dist01(engine) > cfgDownSamplingHc) { // random sampling hc, if necessary
continue;
}

if (track.sign() > 0) { // positron
positronIds.emplace_back(trackId.trackId());
} else { // electron
Expand Down Expand Up @@ -1159,11 +1153,11 @@
bool isMotherFromB = IsFromBeauty(mcMother, mcParticles) > -1;
auto mcCollision = mcpos.template mcCollision_as<aod::McCollisions>();

bool is_e_from_dy = std::abs(mcMother.pdgCode()) == 23; // virtual photon is Z in simulation.

Check failure on line 1156 in PWGEM/Dilepton/Tasks/taggingHFE.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
bool is_e_from_jpsi = std::abs(mcMother.pdgCode()) == 443;
bool is_e_from_prompt_jpsi = std::abs(mcMother.pdgCode()) == 443 && !isMotherFromB && std::abs(mcMother.pdgCode()) != 100443;

Check failure on line 1157 in PWGEM/Dilepton/Tasks/taggingHFE.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
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);

Check failure on line 1158 in PWGEM/Dilepton/Tasks/taggingHFE.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
bool is_e_from_hb = (std::abs(mcMother.pdgCode()) == 511 || std::abs(mcMother.pdgCode()) == 521 || std::abs(mcMother.pdgCode()) == 531 || std::abs(mcMother.pdgCode()) == 541 || std::abs(mcMother.pdgCode()) == 5122 || std::abs(mcMother.pdgCode()) == 5132 || std::abs(mcMother.pdgCode()) == 5232 || std::abs(mcMother.pdgCode()) == 5332) && isSemiLeptonic(mcMother, mcParticles, -cfgPdgLepton, cfgPdgLepton + 1);

Check failure on line 1159 in PWGEM/Dilepton/Tasks/taggingHFE.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
if (!(is_e_from_dy || is_e_from_jpsi || is_e_from_hc || is_e_from_hb)) {
if (!(is_e_from_dy || is_e_from_prompt_jpsi || is_e_from_hc || is_e_from_hb)) {
continue;
}

Expand Down Expand Up @@ -1199,7 +1193,7 @@
bool foundCommonMother = FindCommonMotherFrom2ProngsWithoutPDG(mcpos, mckaon) > 0;
if (mckaon.has_mothers() && !foundCommonMother) {
auto mcMother_of_kaon = mckaon.template mothers_first_as<aod::McParticles>();
if (mcMother_of_kaon.pdgCode() == -323 || mcMother_of_kaon.pdgCode() == -313 || mcMother_of_kaon.pdgCode() == 333 || mcMother_of_kaon.pdgCode() == -413) { // 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

Check failure on line 1196 in PWGEM/Dilepton/Tasks/taggingHFE.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
int commonMotherId = FindCommonMotherFrom2ProngsWithoutPDG(mcpos, mcMother_of_kaon);
if (commonMotherId > 0) {
foundCommonMother = true;
Expand All @@ -1208,21 +1202,17 @@
}
}

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))) {
if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_prompt_jpsi) && !foundCommonMother) || ((is_e_from_dy || is_e_from_prompt_jpsi) && foundCommonMother && std::abs(mckaon.pdgCode()) == cfgPdgLepton))) {
// I want 3 types.
// 1. truely found HF->eh (SV should found by eh, and truely found.) For signal sample in ML.
// 2. mistakenly found DY->eh (SV should not be found by eh, but found.) For bkg sample in ML.
// 3. truely found DY->ee with misidentified ee. (SV may be found at the same position of PV.) For bkg sample in ML.
continue;
}

// if (std::abs(mckaon.pdgCode()) == 11) {
// LOGF(info, "mcMother.pdgCode() = %d, mckaon.pdgCode() = %d, foundCommonMother = %d", mcMother.pdgCode(), mckaon.pdgCode(), foundCommonMother);
// for (int d = mcMother.daughtersIds()[0]; d <= mcMother.daughtersIds()[1]; ++d) {
// auto daughter = mcParticles.rawIteratorAt(d);
// LOGF(info, "daughter.pdgCode() = %d", daughter.pdgCode());
// }
// }
if (!foundCommonMother && dist01(engine) > cfgDownSampling) { // random sampling, if necessary
continue;
}

float tofNSigmaPi = mapTOFNsigmaPiReassociated[std::make_pair(collision.globalIndex(), kaon.globalIndex())];
float tofNSigmaKa = mapTOFNsigmaKaReassociated[std::make_pair(collision.globalIndex(), kaon.globalIndex())];
Expand Down Expand Up @@ -1267,7 +1257,7 @@
bool foundCommonMother = FindCommonMotherFrom2ProngsWithoutPDG(mcpos, mckaon) > 0;
if (mckaon.has_mothers() && !foundCommonMother) {
auto mcMother_of_kaon = mckaon.template mothers_first_as<aod::McParticles>();
if (mcMother_of_kaon.pdgCode() == -323 || mcMother_of_kaon.pdgCode() == -313 || mcMother_of_kaon.pdgCode() == 333 || mcMother_of_kaon.pdgCode() == -413) { // 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

Check failure on line 1260 in PWGEM/Dilepton/Tasks/taggingHFE.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
int commonMotherId = FindCommonMotherFrom2ProngsWithoutPDG(mcpos, mcMother_of_kaon);
if (commonMotherId > 0) {
foundCommonMother = true;
Expand All @@ -1276,21 +1266,17 @@
}
}

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))) {
if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_prompt_jpsi) && !foundCommonMother) || ((is_e_from_dy || is_e_from_prompt_jpsi) && foundCommonMother && std::abs(mckaon.pdgCode()) == cfgPdgLepton))) {
// I want 3 types.
// 1. truely found HF->eh (SV should found by eh, and truely found.) For signal sample in ML.
// 2. mistakenly found DY->eh (SV should not be found by eh, but found.) For bkg sample in ML.
// 3. truely found DY->ee with misidentified ee. (SV may be found at the same position of PV.) For bkg sample in ML.
continue;
}

// if (std::abs(mckaon.pdgCode()) == 11) {
// LOGF(info, "mcMother.pdgCode() = %d, mckaon.pdgCode() = %d, foundCommonMother = %d", mcMother.pdgCode(), mckaon.pdgCode(), foundCommonMother);
// for (int d = mcMother.daughtersIds()[0]; d <= mcMother.daughtersIds()[1]; ++d) {
// auto daughter = mcParticles.rawIteratorAt(d);
// LOGF(info, "daughter.pdgCode() = %d", daughter.pdgCode());
// }
// }
if (!foundCommonMother && dist01(engine) > cfgDownSampling) { // random sampling, if necessary
continue;
}

float tofNSigmaPi = mapTOFNsigmaPiReassociated[std::make_pair(collision.globalIndex(), kaon.globalIndex())];
float tofNSigmaKa = mapTOFNsigmaKaReassociated[std::make_pair(collision.globalIndex(), kaon.globalIndex())];
Expand Down Expand Up @@ -1347,18 +1333,18 @@
int pdgCodeV0 = 0;
bool foundCommonMother = false;
if (mcK0SId > 0) { // true K0S
pdgCodeV0 = 310;

Check failure on line 1336 in PWGEM/Dilepton/Tasks/taggingHFE.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
auto mcK0S = mcParticles.rawIteratorAt(mcK0SId);
auto mcK0 = mcK0S.template mothers_first_as<aod::McParticles>(); // mother of K0S is K0 in simulation.
// LOGF(info, "mcK0S.pdgCode() = %d, mcK0.pdgCode() = %d", mcK0S.pdgCode(), mcK0.pdgCode());
if (std::abs(mcK0.pdgCode()) == 311) {

Check failure on line 1340 in PWGEM/Dilepton/Tasks/taggingHFE.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
mcK0S = mcK0;
}
foundCommonMother = FindCommonMotherFrom2ProngsWithoutPDG(mcpos, mcK0S) > 0;

if (mcK0S.has_mothers() && !foundCommonMother) {
auto mcMother_of_k0s = mcK0S.template mothers_first_as<aod::McParticles>();
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

Check failure on line 1347 in PWGEM/Dilepton/Tasks/taggingHFE.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
int commonMotherId = FindCommonMotherFrom2ProngsWithoutPDG(mcpos, mcMother_of_k0s);
if (commonMotherId > 0) {
foundCommonMother = true;
Expand All @@ -1367,7 +1353,7 @@
}
}

if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_jpsi) && !foundCommonMother))) {
if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_prompt_jpsi) && !foundCommonMother))) {
continue;
}

Expand Down Expand Up @@ -1427,7 +1413,7 @@
foundCommonMother = FindCommonMotherFrom2ProngsWithoutPDG(mcpos, mcLambda) > 0;
}

if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_jpsi) && !foundCommonMother))) {
if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_prompt_jpsi) && !foundCommonMother))) {
continue;
}

Expand Down Expand Up @@ -1492,7 +1478,7 @@
}
}

if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_jpsi) && !foundCommonMother))) {
if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_prompt_jpsi) && !foundCommonMother))) {
continue;
}

Expand Down Expand Up @@ -1557,7 +1543,7 @@
}
}

if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_jpsi) && !foundCommonMother))) {
if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_prompt_jpsi) && !foundCommonMother))) {
continue;
}

Expand Down Expand Up @@ -1591,10 +1577,10 @@
auto mcCollision = mcele.template mcCollision_as<aod::McCollisions>();

bool is_e_from_dy = std::abs(mcMother.pdgCode()) == 23; // virtual photon is Z in simulation.
bool is_e_from_jpsi = std::abs(mcMother.pdgCode()) == 443;
bool is_e_from_prompt_jpsi = std::abs(mcMother.pdgCode()) == 443 && !isMotherFromB && std::abs(mcMother.pdgCode()) != 100443;
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);
bool is_e_from_hb = (std::abs(mcMother.pdgCode()) == 511 || std::abs(mcMother.pdgCode()) == 521 || std::abs(mcMother.pdgCode()) == 531 || std::abs(mcMother.pdgCode()) == 541 || std::abs(mcMother.pdgCode()) == 5122 || std::abs(mcMother.pdgCode()) == 5132 || std::abs(mcMother.pdgCode()) == 5232 || std::abs(mcMother.pdgCode()) == 5332) && isSemiLeptonic(mcMother, mcParticles, cfgPdgLepton, -cfgPdgLepton - 1);
if (!(is_e_from_dy || is_e_from_jpsi || is_e_from_hc || is_e_from_hb)) {
if (!(is_e_from_dy || is_e_from_prompt_jpsi || is_e_from_hc || is_e_from_hb)) {
continue;
}

Expand Down Expand Up @@ -1638,21 +1624,17 @@
}
}

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))) {
if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_prompt_jpsi) && !foundCommonMother) || ((is_e_from_dy || is_e_from_prompt_jpsi) && foundCommonMother && std::abs(mckaon.pdgCode()) == cfgPdgLepton))) {
// I want 3 types.
// 1. truely found HF->eh (SV should found by eh, and truely found.) For signal sample in ML.
// 2. mistakenly found DY->eh (SV should not be found by eh, but found.) For bkg sample in ML.
// 3. truely found DY->ee with misidentified ee. (SV may be found at the same position of PV.) For bkg sample in ML.
continue;
}

// if (std::abs(mckaon.pdgCode()) == 11) {
// LOGF(info, "mcMother.pdgCode() = %d, mckaon.pdgCode() = %d, foundCommonMother = %d", mcMother.pdgCode(), mckaon.pdgCode(), foundCommonMother);
// for (int d = mcMother.daughtersIds()[0]; d <= mcMother.daughtersIds()[1]; ++d) {
// auto daughter = mcParticles.rawIteratorAt(d);
// LOGF(info, "daughter.pdgCode() = %d", daughter.pdgCode());
// }
// }
if (!foundCommonMother && dist01(engine) > cfgDownSampling) { // random sampling, if necessary
continue;
}

float tofNSigmaPi = mapTOFNsigmaPiReassociated[std::make_pair(collision.globalIndex(), kaon.globalIndex())];
float tofNSigmaKa = mapTOFNsigmaKaReassociated[std::make_pair(collision.globalIndex(), kaon.globalIndex())];
Expand Down Expand Up @@ -1707,21 +1689,17 @@
}
}

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))) {
if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_prompt_jpsi) && !foundCommonMother) || ((is_e_from_dy || is_e_from_prompt_jpsi) && foundCommonMother && std::abs(mckaon.pdgCode()) == cfgPdgLepton))) {
// I want 3 types.
// 1. truely found HF->eh (SV should found by eh, and truely found.) For signal sample in ML.
// 2. mistakenly found DY->eh (SV should not be found by eh, but found.) For bkg sample in ML.
// 3. truely found DY->ee with misidentified ee. (SV may be found at the same position of PV.) For bkg sample in ML.
continue;
}

// if (std::abs(mckaon.pdgCode()) == 11) {
// LOGF(info, "mcMother.pdgCode() = %d, mckaon.pdgCode() = %d, foundCommonMother = %d", mcMother.pdgCode(), mckaon.pdgCode(), foundCommonMother);
// for (int d = mcMother.daughtersIds()[0]; d <= mcMother.daughtersIds()[1]; ++d) {
// auto daughter = mcParticles.rawIteratorAt(d);
// LOGF(info, "daughter.pdgCode() = %d", daughter.pdgCode());
// }
// }
if (!foundCommonMother && dist01(engine) > cfgDownSampling) { // random sampling, if necessary
continue;
}

float tofNSigmaPi = mapTOFNsigmaPiReassociated[std::make_pair(collision.globalIndex(), kaon.globalIndex())];
float tofNSigmaKa = mapTOFNsigmaKaReassociated[std::make_pair(collision.globalIndex(), kaon.globalIndex())];
Expand Down Expand Up @@ -1797,7 +1775,7 @@
}
}

if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_jpsi) && !foundCommonMother))) {
if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_prompt_jpsi) && !foundCommonMother))) {
continue;
}

Expand Down Expand Up @@ -1857,7 +1835,7 @@
foundCommonMother = FindCommonMotherFrom2ProngsWithoutPDG(mcele, mcLambda) > 0;
}

if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_jpsi) && !foundCommonMother))) {
if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_prompt_jpsi) && !foundCommonMother))) {
continue;
}

Expand Down Expand Up @@ -1922,7 +1900,7 @@
}
}

if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_jpsi) && !foundCommonMother))) {
if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_prompt_jpsi) && !foundCommonMother))) {
continue;
}

Expand Down Expand Up @@ -1987,7 +1965,7 @@
}
}

if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_jpsi) && !foundCommonMother))) {
if (!(((is_e_from_hc || is_e_from_hb) && foundCommonMother) || ((is_e_from_dy || is_e_from_prompt_jpsi) && !foundCommonMother))) {
continue;
}

Expand Down
Loading