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
33 changes: 16 additions & 17 deletions PWGJE/Tasks/gammaJetTreeProducer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@
/// \return true if particle is a prompt photon, false otherwise
bool isPromptPhoton(const auto& particle)
{
if (particle.pdgCode() == PDG_t::kGamma && particle.isPhysicalPrimary() && std::abs(particle.getGenStatusCode()) < 90) {

Check failure on line 480 in PWGJE/Tasks/gammaJetTreeProducer.cxx

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;
}
return false;
Expand All @@ -488,10 +488,10 @@
bool isDirectPromptPhoton(const auto& particle)
{
// check if particle isa prompt photon
if (particle.pdgCode() == PDG_t::kGamma && particle.isPhysicalPrimary() && std::abs(particle.getGenStatusCode()) < 90) {

Check failure on line 491 in PWGJE/Tasks/gammaJetTreeProducer.cxx

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.
// find the top carbon copy
auto topCopy = iTopCopy(particle);
if (topCopy.pdgCode() == PDG_t::kGamma && std::abs(topCopy.getGenStatusCode()) < 40) { // < 40 is particle directly produced in hard scattering

Check failure on line 494 in PWGJE/Tasks/gammaJetTreeProducer.cxx

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;
}
}
Expand All @@ -502,10 +502,10 @@
/// \return true if particle is a fragmentation photon, false otherwise
bool isFragmentationPhoton(const auto& particle)
{
if (particle.pdgCode() == PDG_t::kGamma && particle.isPhysicalPrimary() && std::abs(particle.getGenStatusCode()) < 90) {

Check failure on line 505 in PWGJE/Tasks/gammaJetTreeProducer.cxx

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.
// find the top carbon copy
auto topCopy = iTopCopy(particle);
if (topCopy.pdgCode() == PDG_t::kGamma && std::abs(topCopy.getGenStatusCode()) >= 40) { // frag photon

Check failure on line 508 in PWGJE/Tasks/gammaJetTreeProducer.cxx

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;
}
}
Expand All @@ -516,7 +516,7 @@
/// \return true if particle is a decay photon, false otherwise
bool isDecayPhoton(const auto& particle)
{
if (particle.pdgCode() == PDG_t::kGamma && particle.isPhysicalPrimary() && std::abs(particle.getGenStatusCode()) >= 90) {

Check failure on line 519 in PWGJE/Tasks/gammaJetTreeProducer.cxx

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;
}
return false;
Expand All @@ -527,7 +527,7 @@
template <typename T>
bool isDecayPhotonPi0(const T& particle)
{
if (particle.pdgCode() == PDG_t::kGamma && particle.isPhysicalPrimary() && std::abs(particle.getGenStatusCode()) >= 90) {

Check failure on line 530 in PWGJE/Tasks/gammaJetTreeProducer.cxx

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 if it has mothers that are pi0s
const auto& mothers = particle.template mothers_as<aod::JMcParticles>();
for (const auto& mother : mothers) {
Expand All @@ -544,11 +544,11 @@
template <typename T>
bool isDecayPhotonEta(const T& particle)
{
if (particle.pdgCode() == PDG_t::kGamma && particle.isPhysicalPrimary() && std::abs(particle.getGenStatusCode()) >= 90) {

Check failure on line 547 in PWGJE/Tasks/gammaJetTreeProducer.cxx

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 if it has mothers that are etas
const auto& mothers = particle.template mothers_as<aod::JMcParticles>();
for (const auto& mother : mothers) {
if (mother.pdgCode() == 221) {

Check failure on line 551 in PWGJE/Tasks/gammaJetTreeProducer.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.
return true;
}
}
Expand All @@ -565,7 +565,7 @@
// check if you find a pi0 mother or a eta mother
const auto& mothers = particle.template mothers_as<aod::JMcParticles>();
for (const auto& mother : mothers) {
if (mother.pdgCode() == PDG_t::kPi0 || mother.pdgCode() == 221) {

Check failure on line 568 in PWGJE/Tasks/gammaJetTreeProducer.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.
return false;
}
}
Expand Down Expand Up @@ -644,26 +644,23 @@
/// \param particle The particle to start from
/// \return Vector of daughter particle IDs
template <typename T>
std::vector<int> getDaughtersInChain(const T& particle, int depth = 0)
void getDaughtersInChain(const T& particle, std::vector<int>& daughters, int depth = 0)
{
std::vector<int> daughters;
// Limit recursion depth to avoid infinite loops
if (depth > kMaxRecursionDepth) { // 100 generations should be more than enough
return daughters;
return;
}
T currentParticle = particle;
while (currentParticle.has_daughters()) {
const auto& daughtersIDs = currentParticle.template daughters_as<aod::JMcParticles>();
for (const auto& daughter : daughtersIDs) {
daughters.push_back(daughter.globalIndex());
}
currentParticle = daughtersIDs.iteratorAt(0);
depth++;
if (depth > kMaxRecursionDepth) {
break;
}

if (!particle.has_daughters()) {
return;
}

const auto& daughterParticles = particle.template daughters_as<aod::JMcParticles>();
for (const auto& daughter : daughterParticles) {
daughters.push_back(daughter.globalIndex());
getDaughtersInChain(daughter, daughters, depth + 1);
}
return daughters;
return;
}
/// \brief Finds the first physical primary particle in the decay chain (upwards)
/// \param particle The particle to start from
Expand Down Expand Up @@ -728,8 +725,10 @@
const auto& daughter2 = daughtersMother.iteratorAt(1);
if (daughter1.pdgCode() == PDG_t::kGamma && daughter2.pdgCode() == PDG_t::kGamma) {
// get the full stack of particles that these daughters create
auto fullDecayChain1 = getDaughtersInChain(daughter1);
auto fullDecayChain2 = getDaughtersInChain(daughter2);
std::vector<int> fullDecayChain1;
std::vector<int> fullDecayChain2;
getDaughtersInChain(daughter1, fullDecayChain1);
getDaughtersInChain(daughter2, fullDecayChain2);
bool photon1Found = false;
bool photon2Found = false;

Expand Down
Loading