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
40 changes: 25 additions & 15 deletions PWGEM/Dilepton/Utils/MCUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
template <typename T>
bool isCharmonia(T const& track)
{
if (std::abs(track.pdgCode()) < 100) {

Check failure on line 77 in PWGEM/Dilepton/Utils/MCUtilities.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
return false;
}

Expand All @@ -82,7 +82,7 @@
int n = pdgStr.length();
int pdg3 = std::stoi(pdgStr.substr(n - 3, 3));

if (pdg3 == 441 || pdg3 == 443 || pdg3 == 445 || pdg3 == 447) {

Check failure on line 85 in PWGEM/Dilepton/Utils/MCUtilities.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.

Check failure on line 85 in PWGEM/Dilepton/Utils/MCUtilities.h

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.
return true;
} else {
return false;
Expand All @@ -96,7 +96,7 @@
return false;
}

if (400 < std::abs(track.pdgCode()) && std::abs(track.pdgCode()) < 500) {

Check failure on line 99 in PWGEM/Dilepton/Utils/MCUtilities.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
return true;
} else {
return false;
Expand All @@ -106,7 +106,7 @@
template <typename T>
bool isCharmBaryon(T const& track)
{
if (4000 < std::abs(track.pdgCode()) && std::abs(track.pdgCode()) < 5000) {

Check failure on line 109 in PWGEM/Dilepton/Utils/MCUtilities.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
return true;
} else {
return false;
Expand All @@ -124,7 +124,7 @@
int n = pdgStr.length();
int pdg3 = std::stoi(pdgStr.substr(n - 3, 3));

if (pdg3 == 551 || pdg3 == 553 || pdg3 == 555 || pdg3 == 557) {

Check failure on line 127 in PWGEM/Dilepton/Utils/MCUtilities.h

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.
return true;
} else {
return false;
Expand Down Expand Up @@ -417,6 +417,16 @@
return -999;
}
//_______________________________________________________________________
template <typename TMCParticle>
bool isFlavorOscillationB(TMCParticle const& mcParticle)
{
if ((std::abs(mcParticle.pdgCode()) == 511 || std::abs(mcParticle.pdgCode()) == 531) && mcParticle.getGenStatusCode() == 92) {

Check failure on line 423 in PWGEM/Dilepton/Utils/MCUtilities.h

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.
return true;
} else {
return false;
}
}
//_______________________________________________________________________
template <typename TMCParticle, typename TMCParticles>
bool findFlavorOscillationB(TMCParticle const& mcParticle, TMCParticles const& mcParticles)
{
Expand All @@ -430,7 +440,7 @@
while (motherid1 > -1) {
if (motherid1 < mcParticles.size()) { // protect against bad mother indices. why is this needed?
auto mp = mcParticles.iteratorAt(motherid1);
if ((std::abs(mp.pdgCode()) == 511 || std::abs(mp.pdgCode()) == 531) && mp.getGenStatusCode() == 92) {
if (isFlavorOscillationB(mp)) {
return true;
}

Expand Down Expand Up @@ -477,7 +487,7 @@

int counter = 0;
for (const auto& pdg : mothers_pdg) {
if (std::abs(pdg) <= 6 || std::abs(pdg) == 21 || (std::abs(pdg) == 2212 && counter == static_cast<int>(mothers_pdg.size() - 1)) || (std::abs(pdg) > 1e+9 && counter == static_cast<int>(mothers_pdg.size() - 1))) { // quarks or gluon or proton or ion beam

Check failure on line 490 in PWGEM/Dilepton/Utils/MCUtilities.h

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.
break;
}
counter++;
Expand Down Expand Up @@ -554,8 +564,8 @@

auto mpfh1 = mcparticles.iteratorAt(find1stHadron(p1, mcparticles));
auto mpfh2 = mcparticles.iteratorAt(find1stHadron(p2, mcparticles));
bool isFOFound1 = findFlavorOscillationB(p1, mcparticles);
bool isFOFound2 = findFlavorOscillationB(p2, mcparticles);
bool isFOat1stDecay1 = isFlavorOscillationB(mpfh1); // oscillation occured at 1st hb decay.
bool isFOat1stDecay2 = isFlavorOscillationB(mpfh2); // oscillation occured at 1st hb decay.

bool is_direct_from_b1 = isWeakDecayFromBeautyHadron(p1, mcparticles);
bool is_direct_from_b2 = isWeakDecayFromBeautyHadron(p2, mcparticles);
Expand All @@ -564,7 +574,7 @@
bool is_c_from_b1 = isWeakDecayFromCharmHadron(p1, mcparticles) && IsFromBeauty(p1, mcparticles) > 0;
bool is_c_from_b2 = isWeakDecayFromCharmHadron(p2, mcparticles) && IsFromBeauty(p2, mcparticles) > 0;

if (is_prompt_c1 && is_prompt_c2 && mpfh1.pdgCode() * mpfh2.pdgCode() < 0) { // charmed mesons never oscillate. only ULS
if (is_prompt_c1 && is_prompt_c2 && mpfh1.pdgCode() * mpfh2.pdgCode() < 0) { // charmed mesons never oscillate. Be careful with D(2007)*0 -> D0 e+ e-
mothers_id1.clear();
mothers_pdg1.clear();
mothers_id2.clear();
Expand All @@ -576,9 +586,9 @@
return static_cast<int>(EM_HFeeType::kCe_Ce); // cc->ee, decay type = 0
}

bool b2l_b2l_case0 = is_direct_from_b1 && is_direct_from_b2 && mpfh1.pdgCode() * mpfh2.pdgCode() < 0 && !isFOFound1 && !isFOFound2; // 0 oscillation: bbbar -> ll ULS
bool b2l_b2l_case1 = is_direct_from_b1 && is_direct_from_b2 && mpfh1.pdgCode() * mpfh2.pdgCode() > 0 && static_cast<bool>(isFOFound1 ^ isFOFound2); // 1 oscillation: bbbar -> ll LS
bool b2l_b2l_case2 = is_direct_from_b1 && is_direct_from_b2 && mpfh1.pdgCode() * mpfh2.pdgCode() < 0 && isFOFound1 && isFOFound2; // 2 oscillation: bbbar -> ll ULS
bool b2l_b2l_case0 = is_direct_from_b1 && is_direct_from_b2 && mpfh1.pdgCode() * mpfh2.pdgCode() < 0 && !isFOat1stDecay1 && !isFOat1stDecay2; // bbbar -> ll ULS
bool b2l_b2l_case1 = is_direct_from_b1 && is_direct_from_b2 && mpfh1.pdgCode() * mpfh2.pdgCode() > 0 && static_cast<bool>(isFOat1stDecay1 ^ isFOat1stDecay2); // bbbar -> ll LS
bool b2l_b2l_case2 = is_direct_from_b1 && is_direct_from_b2 && mpfh1.pdgCode() * mpfh2.pdgCode() < 0 && isFOat1stDecay1 && isFOat1stDecay2; // bbbar -> ll ULS

if (b2l_b2l_case0 || b2l_b2l_case1 || b2l_b2l_case2) {
mothers_id1.clear();
Expand All @@ -592,9 +602,9 @@
return static_cast<int>(EM_HFeeType::kBe_Be); // bb->ee, decay type = 2
}

bool b2c2l_b2c2l_case0 = is_c_from_b1 && is_c_from_b2 && mpfh1.pdgCode() * mpfh2.pdgCode() < 0 && !isFOFound1 && !isFOFound2; // 0 oscillation: bbbar -> ll ULS
bool b2c2l_b2c2l_case1 = is_c_from_b1 && is_c_from_b2 && mpfh1.pdgCode() * mpfh2.pdgCode() > 0 && static_cast<bool>(isFOFound1 ^ isFOFound2); // 1 oscillation: bbbar -> ll LS
bool b2c2l_b2c2l_case2 = is_c_from_b1 && is_c_from_b2 && mpfh1.pdgCode() * mpfh2.pdgCode() < 0 && isFOFound1 && isFOFound2; // 2 oscillation: bbbar -> ll ULS
bool b2c2l_b2c2l_case0 = is_c_from_b1 && is_c_from_b2 && mpfh1.pdgCode() * mpfh2.pdgCode() < 0 && !isFOat1stDecay1 && !isFOat1stDecay2; // bbbar -> ll ULS
bool b2c2l_b2c2l_case1 = is_c_from_b1 && is_c_from_b2 && mpfh1.pdgCode() * mpfh2.pdgCode() > 0 && static_cast<bool>(isFOat1stDecay1 ^ isFOat1stDecay2); // bbbar -> ll LS
bool b2c2l_b2c2l_case2 = is_c_from_b1 && is_c_from_b2 && mpfh1.pdgCode() * mpfh2.pdgCode() < 0 && isFOat1stDecay1 && isFOat1stDecay2; // bbbar -> ll ULS

if (b2c2l_b2c2l_case0 || b2c2l_b2c2l_case1 || b2c2l_b2c2l_case2) {
mothers_id1.clear();
Expand Down Expand Up @@ -625,15 +635,15 @@
mothers_pdg1.shrink_to_fit();
mothers_id2.shrink_to_fit();
mothers_pdg2.shrink_to_fit();
return static_cast<int>(EM_HFeeType::kBCe_Be_SameB); // b->c->e and b->e, decay type = 3. this should happen only in ULS.
return static_cast<int>(EM_HFeeType::kBCe_Be_SameB); // b->c->e and b->e, decay type = 3
}
}
} // end of motherid2
} // end of motherid1

bool b2c2l_b2l_diffb_case0 = mpfh1.pdgCode() * mpfh2.pdgCode() > 0 && !isFOFound1 && !isFOFound2; // 0 oscillation: bbbar -> ll LS
bool b2c2l_b2l_diffb_case1 = mpfh1.pdgCode() * mpfh2.pdgCode() < 0 && static_cast<bool>(isFOFound1 ^ isFOFound2); // 1 oscillation: bbbar -> ll ULS
bool b2c2l_b2l_diffb_case2 = mpfh1.pdgCode() * mpfh2.pdgCode() > 0 && isFOFound1 && isFOFound2; // 2 oscillation: bbbar -> ll LS
bool b2c2l_b2l_diffb_case0 = mpfh1.pdgCode() * mpfh2.pdgCode() < 0 && !isFOat1stDecay1 && !isFOat1stDecay2; // bbbar -> ll LS
bool b2c2l_b2l_diffb_case1 = mpfh1.pdgCode() * mpfh2.pdgCode() > 0 && static_cast<bool>(isFOat1stDecay1 ^ isFOat1stDecay2); // bbbar -> ll ULS
bool b2c2l_b2l_diffb_case2 = mpfh1.pdgCode() * mpfh2.pdgCode() < 0 && isFOat1stDecay1 && isFOat1stDecay2; // bbbar -> ll LS

if (b2c2l_b2l_diffb_case0 || b2c2l_b2l_diffb_case1 || b2c2l_b2l_diffb_case2) {
mothers_id1.clear();
Expand All @@ -644,7 +654,7 @@
mothers_pdg1.shrink_to_fit();
mothers_id2.shrink_to_fit();
mothers_pdg2.shrink_to_fit();
return static_cast<int>(EM_HFeeType::kBCe_Be_DiffB); // b->c->e and b->e, decay type = 4. this should happen only in LS.
return static_cast<int>(EM_HFeeType::kBCe_Be_DiffB); // b->c->e and b->e, decay type = 4
}
}

Expand Down Expand Up @@ -690,7 +700,7 @@
if (equal) { // we are searching for the quark
int quark_id = -1;
int next_mother_id = -1;
for (int i : allmothersids) {

Check failure on line 703 in PWGEM/Dilepton/Utils/MCUtilities.h

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
auto mother = mcParticles.iteratorAt(i);
int mpdg = mother.pdgCode();
// if (std::abs(mpdg) == pdg && mpdg * p.pdgCode() > 0) { // check for quark
Expand Down Expand Up @@ -719,7 +729,7 @@
return -1;
} else { // searching for first ancestor that is not quark anymore
int quark_id = -1;
for (int i : allmothersids) {

Check failure on line 732 in PWGEM/Dilepton/Utils/MCUtilities.h

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
auto mother = mcParticles.iteratorAt(i);
int mpdg = std::abs(mother.pdgCode());
if (mpdg == pdg && mother.pdgCode() == p.pdgCode()) { // found the quark
Expand Down
Loading