From 4e134e6db6bd94216fb1532a4d09247ea08f701f Mon Sep 17 00:00:00 2001 From: akshaya <99753263+AkshayaVijay@users.noreply.github.com> Date: Fri, 7 Aug 2026 14:37:49 -0500 Subject: [PATCH 01/26] Update CalorimeterClusterRecoCoG.cc --- .../calorimetry/CalorimeterClusterRecoCoG.cc | 83 +++++++++++++++---- 1 file changed, 69 insertions(+), 14 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc index b95476fae3..2771567141 100644 --- a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc +++ b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc @@ -266,21 +266,76 @@ void CalorimeterClusterRecoCoG::associate( } edm4hep::MCParticle -CalorimeterClusterRecoCoG::get_primary(const edm4hep::CaloHitContribution& contrib) { - // get contributing particle - const auto contributor = contrib.getParticle(); - - // walk back through parents to find primary - // - TODO finalize primary selection. This - // can be improved!! - edm4hep::MCParticle primary = contributor; - while (primary.parents_size() > 0) { - if (primary.getGeneratorStatus() != 0) { - break; +CalorimeterClusterRecoCoG::get_primary( + const edm4hep::CaloHitContribution& contrib) const +{ + edm4hep::MCParticle current = contrib.getParticle(); + if (!current.isAvailable()) + { + return current; } - primary = primary.getParents(0); - } - return primary; + + const edm4hep::MCParticle original = current; + const auto originalID = original.getObjectID(); + std::vector chain; + chain.push_back(current); + while (current.getGeneratorStatus() == 0 && + current.parents_size() > 0) + { + const auto parent = current.getParents(0); + + if (!parent.isAvailable()) + { + break; + } + + current = parent; + chain.push_back(current); + } + + const auto is_prompt_decay_particle = + [this](const edm4hep::MCParticle& particle) + { + return std::ranges::find( + m_cfg.promptDecayPDGs, + std::abs(particle.getPDG()) + ) != m_cfg.promptDecayPDGs.end(); + }; + for (std::size_t index = 0; + index < chain.size(); + ++index) + { + const auto& particle = chain[index]; + + if (!particle.isAvailable()) + { + continue; + } + + const auto particleID = particle.getObjectID(); + } + for (auto iterator = chain.rbegin(); + iterator != chain.rend(); + ++iterator) + { + if (!iterator->isAvailable()) + { + continue; + } + + const auto particleID = iterator->getObjectID(); + const bool isPrompt = + is_prompt_decay_particle(*iterator); + + if (isPrompt) + { + continue; + } + + return *iterator; + } + + return original; } } // namespace eicrecon From be7da4c8a717ccb5ba900e30edd02985f1e61ed0 Mon Sep 17 00:00:00 2001 From: akshaya <99753263+AkshayaVijay@users.noreply.github.com> Date: Fri, 7 Aug 2026 14:38:47 -0500 Subject: [PATCH 02/26] Update CalorimeterClusterRecoCoGConfig.h --- src/algorithms/calorimetry/CalorimeterClusterRecoCoGConfig.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/algorithms/calorimetry/CalorimeterClusterRecoCoGConfig.h b/src/algorithms/calorimetry/CalorimeterClusterRecoCoGConfig.h index df38aca48c..8368c6e631 100644 --- a/src/algorithms/calorimetry/CalorimeterClusterRecoCoGConfig.h +++ b/src/algorithms/calorimetry/CalorimeterClusterRecoCoGConfig.h @@ -27,6 +27,7 @@ struct CalorimeterClusterRecoCoGConfig { // the eta of the contributing hits. This is useful to avoid edge effects // for endcaps. bool enableEtaBounds = false; + std::vector promptDecayPDGs{111, 221, 331, 310, 3122}; }; } // namespace eicrecon From 5b23aca80f66c70b6555e7ded3391d8ab0b81837 Mon Sep 17 00:00:00 2001 From: akshaya <99753263+AkshayaVijay@users.noreply.github.com> Date: Fri, 7 Aug 2026 14:40:12 -0500 Subject: [PATCH 03/26] Update SimCalorimeterHitProcessor.cc --- .../calorimetry/SimCalorimeterHitProcessor.cc | 39 +++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc index d0ccbe4d52..ae7bf04e6c 100644 --- a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc +++ b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc @@ -52,18 +52,43 @@ template <> struct hash> { namespace { // Lookup primary MCParticle @TODO this should be a shared utility function in the edm4xxx // libraries -edm4hep::MCParticle lookup_primary(const edm4hep::CaloHitContribution& contrib) { - const auto contributor = contrib.getParticle(); +edm4hep::MCParticle lookup_primary(const edm4hep::CaloHitContribution& contrib,const std::vector& promptDecayPDGs) { + edm4hep::MCParticle current = contrib.getParticle(); - edm4hep::MCParticle primary = contributor; - while (primary.parents_size() > 0) { - if (primary.getGeneratorStatus() != 0) { + if (!current.isAvailable()) { + return current; + } + + const edm4hep::MCParticle original = current; + std::vector chain{current}; + while (current.getGeneratorStatus() == 0 && current.parents_size() > 0) + { + const auto parent = current.getParents(0); + if (!parent.isAvailable()) { break; } - primary = primary.getParents(0); + current = parent; + chain.push_back(current); } - return primary; + const auto is_prompt = [&promptDecayPDGs](const edm4hep::MCParticle& particle) + { + return std::ranges::find(promptDecayPDGs,std::abs(particle.getPDG())) != promptDecayPDGs.end(); + }; + for (auto iterator = chain.rbegin(); + iterator != chain.rend(); + ++iterator) + { + if (!iterator->isAvailable()) { + continue; + } + if (is_prompt(*iterator)) { + continue; + } + return *iterator; + } + return original; } + class HitContributionAccumulator { private: float m_energy{0}; From 077c58b99976ffe8e23f230f8661959ae099c3c5 Mon Sep 17 00:00:00 2001 From: akshaya <99753263+AkshayaVijay@users.noreply.github.com> Date: Fri, 7 Aug 2026 14:40:43 -0500 Subject: [PATCH 04/26] Update SimCalorimeterHitProcessorConfig.h --- src/algorithms/calorimetry/SimCalorimeterHitProcessorConfig.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/algorithms/calorimetry/SimCalorimeterHitProcessorConfig.h b/src/algorithms/calorimetry/SimCalorimeterHitProcessorConfig.h index 58f79bbd61..db8d117e74 100644 --- a/src/algorithms/calorimetry/SimCalorimeterHitProcessorConfig.h +++ b/src/algorithms/calorimetry/SimCalorimeterHitProcessorConfig.h @@ -30,6 +30,7 @@ struct SimCalorimeterHitProcessorConfig { double fixedTimeDelay{}; // time window for grouping contributions double timeWindow{100 * edm4eic::unit::ns}; + std::vector promptDecayPDGs{111,221,331,310,3122}; }; } // namespace eicrecon From 0ebf286ddd703ff9b73ea165417478acae624f47 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 7 Aug 2026 19:49:08 +0000 Subject: [PATCH 05/26] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../calorimetry/CalorimeterClusterRecoCoG.cc | 106 +++++++----------- .../calorimetry/SimCalorimeterHitProcessor.cc | 16 +-- .../SimCalorimeterHitProcessorConfig.h | 2 +- 3 files changed, 50 insertions(+), 74 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc index 2771567141..f18d2ae8e0 100644 --- a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc +++ b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc @@ -266,76 +266,56 @@ void CalorimeterClusterRecoCoG::associate( } edm4hep::MCParticle -CalorimeterClusterRecoCoG::get_primary( - const edm4hep::CaloHitContribution& contrib) const -{ - edm4hep::MCParticle current = contrib.getParticle(); - if (!current.isAvailable()) - { - return current; +CalorimeterClusterRecoCoG::get_primary(const edm4hep::CaloHitContribution& contrib) const { + edm4hep::MCParticle current = contrib.getParticle(); + if (!current.isAvailable()) { + return current; + } + + const edm4hep::MCParticle original = current; + const auto originalID = original.getObjectID(); + std::vector chain; + chain.push_back(current); + while (current.getGeneratorStatus() == 0 && current.parents_size() > 0) { + const auto parent = current.getParents(0); + + if (!parent.isAvailable()) { + break; } - const edm4hep::MCParticle original = current; - const auto originalID = original.getObjectID(); - std::vector chain; + current = parent; chain.push_back(current); - while (current.getGeneratorStatus() == 0 && - current.parents_size() > 0) - { - const auto parent = current.getParents(0); - - if (!parent.isAvailable()) - { - break; - } - - current = parent; - chain.push_back(current); + } + + const auto is_prompt_decay_particle = [this](const edm4hep::MCParticle& particle) { + return std::ranges::find(m_cfg.promptDecayPDGs, std::abs(particle.getPDG())) != + m_cfg.promptDecayPDGs.end(); + }; + for (std::size_t index = 0; index < chain.size(); ++index) { + const auto& particle = chain[index]; + + if (!particle.isAvailable()) { + continue; } - const auto is_prompt_decay_particle = - [this](const edm4hep::MCParticle& particle) - { - return std::ranges::find( - m_cfg.promptDecayPDGs, - std::abs(particle.getPDG()) - ) != m_cfg.promptDecayPDGs.end(); - }; - for (std::size_t index = 0; - index < chain.size(); - ++index) - { - const auto& particle = chain[index]; - - if (!particle.isAvailable()) - { - continue; - } - - const auto particleID = particle.getObjectID(); + const auto particleID = particle.getObjectID(); + } + for (auto iterator = chain.rbegin(); iterator != chain.rend(); ++iterator) { + if (!iterator->isAvailable()) { + continue; } - for (auto iterator = chain.rbegin(); - iterator != chain.rend(); - ++iterator) - { - if (!iterator->isAvailable()) - { - continue; - } - - const auto particleID = iterator->getObjectID(); - const bool isPrompt = - is_prompt_decay_particle(*iterator); - - if (isPrompt) - { - continue; - } - - return *iterator; + + const auto particleID = iterator->getObjectID(); + const bool isPrompt = is_prompt_decay_particle(*iterator); + + if (isPrompt) { + continue; } - - return original; + + return *iterator; + } + + return original; } } // namespace eicrecon diff --git a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc index ae7bf04e6c..4317f93554 100644 --- a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc +++ b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc @@ -52,7 +52,8 @@ template <> struct hash> { namespace { // Lookup primary MCParticle @TODO this should be a shared utility function in the edm4xxx // libraries -edm4hep::MCParticle lookup_primary(const edm4hep::CaloHitContribution& contrib,const std::vector& promptDecayPDGs) { +edm4hep::MCParticle lookup_primary(const edm4hep::CaloHitContribution& contrib, + const std::vector& promptDecayPDGs) { edm4hep::MCParticle current = contrib.getParticle(); if (!current.isAvailable()) { @@ -61,8 +62,7 @@ edm4hep::MCParticle lookup_primary(const edm4hep::CaloHitContribution& contrib,c const edm4hep::MCParticle original = current; std::vector chain{current}; - while (current.getGeneratorStatus() == 0 && current.parents_size() > 0) - { + while (current.getGeneratorStatus() == 0 && current.parents_size() > 0) { const auto parent = current.getParents(0); if (!parent.isAvailable()) { break; @@ -70,14 +70,10 @@ edm4hep::MCParticle lookup_primary(const edm4hep::CaloHitContribution& contrib,c current = parent; chain.push_back(current); } - const auto is_prompt = [&promptDecayPDGs](const edm4hep::MCParticle& particle) - { - return std::ranges::find(promptDecayPDGs,std::abs(particle.getPDG())) != promptDecayPDGs.end(); + const auto is_prompt = [&promptDecayPDGs](const edm4hep::MCParticle& particle) { + return std::ranges::find(promptDecayPDGs, std::abs(particle.getPDG())) != promptDecayPDGs.end(); }; - for (auto iterator = chain.rbegin(); - iterator != chain.rend(); - ++iterator) - { + for (auto iterator = chain.rbegin(); iterator != chain.rend(); ++iterator) { if (!iterator->isAvailable()) { continue; } diff --git a/src/algorithms/calorimetry/SimCalorimeterHitProcessorConfig.h b/src/algorithms/calorimetry/SimCalorimeterHitProcessorConfig.h index db8d117e74..49489ec331 100644 --- a/src/algorithms/calorimetry/SimCalorimeterHitProcessorConfig.h +++ b/src/algorithms/calorimetry/SimCalorimeterHitProcessorConfig.h @@ -30,7 +30,7 @@ struct SimCalorimeterHitProcessorConfig { double fixedTimeDelay{}; // time window for grouping contributions double timeWindow{100 * edm4eic::unit::ns}; - std::vector promptDecayPDGs{111,221,331,310,3122}; + std::vector promptDecayPDGs{111, 221, 331, 310, 3122}; }; } // namespace eicrecon From 64339efb11260e309e1674e45ae8a310d9d40c2e Mon Sep 17 00:00:00 2001 From: akshaya <99753263+AkshayaVijay@users.noreply.github.com> Date: Fri, 7 Aug 2026 14:57:36 -0500 Subject: [PATCH 06/26] Update CalorimeterClusterRecoCoG.h --- src/algorithms/calorimetry/CalorimeterClusterRecoCoG.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.h b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.h index e86afa695a..82216c7cb2 100644 --- a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.h +++ b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.h @@ -88,7 +88,7 @@ class CalorimeterClusterRecoCoG : public CalorimeterClusterRecoCoGAlgorithm, const podio::LinkNavigator& link_nav, edm4eic::MCRecoClusterParticleLinkCollection* links, edm4eic::MCRecoClusterParticleAssociationCollection* assocs) const; - static edm4hep::MCParticle get_primary(const edm4hep::CaloHitContribution& contrib); + edm4hep::MCParticle get_primary(const edm4hep::CaloHitContribution& contrib) const; }; } // namespace eicrecon From db042567e49d054368ead412b95dc4a98a25507c Mon Sep 17 00:00:00 2001 From: akshaya <99753263+AkshayaVijay@users.noreply.github.com> Date: Fri, 7 Aug 2026 15:09:23 -0500 Subject: [PATCH 07/26] Update SimCalorimeterHitProcessor.cc --- src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc index 4317f93554..c09a601d43 100644 --- a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc +++ b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc @@ -196,7 +196,7 @@ void SimCalorimeterHitProcessor::process(const SimCalorimeterHitProcessor::Input m_attenuationReferencePosition ? get_attenuation(ih.getPosition().z) : 1.; // Use primary particle (traced back through parents) to group contributions for (const auto& contrib : ih.getContributions()) { - edm4hep::MCParticle primary = lookup_primary(contrib); + edm4hep::MCParticle primary = lookup_primary(contrib, m_cfg.promptDecayPDGs); const double propagationTime = m_attenuationReferencePosition ? std::abs(m_attenuationReferencePosition.value() - ih.getPosition().z) * From 0b291957513d7b81e40e5eb08ec1c9413e2cabb5 Mon Sep 17 00:00:00 2001 From: akshaya <99753263+AkshayaVijay@users.noreply.github.com> Date: Fri, 7 Aug 2026 15:18:26 -0500 Subject: [PATCH 08/26] Update CalorimeterClusterRecoCoG.cc --- src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc index f18d2ae8e0..dec9498eb7 100644 --- a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc +++ b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc @@ -273,7 +273,6 @@ CalorimeterClusterRecoCoG::get_primary(const edm4hep::CaloHitContribution& contr } const edm4hep::MCParticle original = current; - const auto originalID = original.getObjectID(); std::vector chain; chain.push_back(current); while (current.getGeneratorStatus() == 0 && current.parents_size() > 0) { @@ -296,16 +295,12 @@ CalorimeterClusterRecoCoG::get_primary(const edm4hep::CaloHitContribution& contr if (!particle.isAvailable()) { continue; - } - - const auto particleID = particle.getObjectID(); + } } for (auto iterator = chain.rbegin(); iterator != chain.rend(); ++iterator) { if (!iterator->isAvailable()) { continue; } - - const auto particleID = iterator->getObjectID(); const bool isPrompt = is_prompt_decay_particle(*iterator); if (isPrompt) { From 8e5ba9b70115c7c520ab2c739fc7b57c8a6229e3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 7 Aug 2026 20:18:37 +0000 Subject: [PATCH 09/26] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc index dec9498eb7..a6268d1433 100644 --- a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc +++ b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc @@ -295,13 +295,13 @@ CalorimeterClusterRecoCoG::get_primary(const edm4hep::CaloHitContribution& contr if (!particle.isAvailable()) { continue; - } + } } for (auto iterator = chain.rbegin(); iterator != chain.rend(); ++iterator) { if (!iterator->isAvailable()) { continue; } - const bool isPrompt = is_prompt_decay_particle(*iterator); + const bool isPrompt = is_prompt_decay_particle(*iterator); if (isPrompt) { continue; From b27efd14fc73959f03276318311366e841489b0a Mon Sep 17 00:00:00 2001 From: epic-capybara <139920704+epic-capybara@users.noreply.github.com> Date: Sat, 8 Aug 2026 11:22:28 -0400 Subject: [PATCH 10/26] Redefined get_primary function to return first stable particle (fix: iwyu) (#2845) This PR applies the include-what-you-use fixes as suggested by https://github.com/eic/EICrecon/actions/runs/31215306595. Please merge this PR into the branch `CalorimeterClusterReco_get_Primary` to resolve failures in PR #2844. Auto-generated by [create-pull-request][1] [1]: https://github.com/peter-evans/create-pull-request Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc | 2 ++ src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc index a6268d1433..cbc3980b08 100644 --- a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc +++ b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc @@ -21,12 +21,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include diff --git a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc index c09a601d43..e6eb644561 100644 --- a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc +++ b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc @@ -15,11 +15,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include From fa58028fa50e3482170eac825cf9e71dfd4b708d Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Sat, 8 Aug 2026 11:42:01 -0500 Subject: [PATCH 11/26] fix: clang-tidy: modernize-deprecated-headers Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc | 2 +- src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc index cbc3980b08..d7a7b8d39c 100644 --- a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc +++ b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc index e6eb644561..f2d7e4c48d 100644 --- a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc +++ b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include From 78d2681a2b06dba2a0981bfe3828be2088111d73 Mon Sep 17 00:00:00 2001 From: akshaya <99753263+AkshayaVijay@users.noreply.github.com> Date: Sat, 8 Aug 2026 20:49:30 -0500 Subject: [PATCH 12/26] Update CalorimeterClusterRecoCoG.cc --- src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc index d7a7b8d39c..aa6f504331 100644 --- a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc +++ b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc @@ -292,13 +292,7 @@ CalorimeterClusterRecoCoG::get_primary(const edm4hep::CaloHitContribution& contr return std::ranges::find(m_cfg.promptDecayPDGs, std::abs(particle.getPDG())) != m_cfg.promptDecayPDGs.end(); }; - for (std::size_t index = 0; index < chain.size(); ++index) { - const auto& particle = chain[index]; - - if (!particle.isAvailable()) { - continue; - } - } + for (auto iterator = chain.rbegin(); iterator != chain.rend(); ++iterator) { if (!iterator->isAvailable()) { continue; From 03933946ad3fd18eb6dafa10d756e399a386c04a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 9 Aug 2026 01:49:48 +0000 Subject: [PATCH 13/26] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc index aa6f504331..c4a9e05d96 100644 --- a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc +++ b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc @@ -292,7 +292,7 @@ CalorimeterClusterRecoCoG::get_primary(const edm4hep::CaloHitContribution& contr return std::ranges::find(m_cfg.promptDecayPDGs, std::abs(particle.getPDG())) != m_cfg.promptDecayPDGs.end(); }; - + for (auto iterator = chain.rbegin(); iterator != chain.rend(); ++iterator) { if (!iterator->isAvailable()) { continue; From 328b479c49b10daeb7be2235f810359a880310b7 Mon Sep 17 00:00:00 2001 From: akshaya <99753263+AkshayaVijay@users.noreply.github.com> Date: Sat, 8 Aug 2026 21:00:25 -0500 Subject: [PATCH 14/26] Update SimCalorimeterHitProcessor.cc --- src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc index f2d7e4c48d..def620c90c 100644 --- a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc +++ b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc @@ -15,22 +15,22 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include #include #include #include #include +#include #include "algorithms/calorimetry/SimCalorimeterHitProcessorConfig.h" + using namespace dd4hep; // Define necessary hash functions From 51c83a56479b8888b0480e3dc5073c05b1b84392 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 9 Aug 2026 02:00:36 +0000 Subject: [PATCH 15/26] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc index def620c90c..734a8242cc 100644 --- a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc +++ b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc @@ -30,7 +30,6 @@ #include "algorithms/calorimetry/SimCalorimeterHitProcessorConfig.h" - using namespace dd4hep; // Define necessary hash functions From 94b3cc293d25d16e7c0eca5209aba8188f9b6979 Mon Sep 17 00:00:00 2001 From: epic-capybara <139920704+epic-capybara@users.noreply.github.com> Date: Sun, 9 Aug 2026 10:41:59 -0400 Subject: [PATCH 16/26] Redefined get_primary function to return first stable particle (fix: iwyu) (#2848) This PR applies the include-what-you-use fixes as suggested by https://github.com/eic/EICrecon/actions/runs/31289445857. Please merge this PR into the branch `CalorimeterClusterReco_get_Primary` to resolve failures in PR #2844. Auto-generated by [create-pull-request][1] [1]: https://github.com/peter-evans/create-pull-request Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc index 734a8242cc..e6eb644561 100644 --- a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc +++ b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc @@ -15,18 +15,19 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include #include #include #include -#include #include "algorithms/calorimetry/SimCalorimeterHitProcessorConfig.h" From e86967d8f8b21b7b1a7163da3f2bf6dc5eebdeef Mon Sep 17 00:00:00 2001 From: akshaya <99753263+AkshayaVijay@users.noreply.github.com> Date: Mon, 10 Aug 2026 09:07:32 -0500 Subject: [PATCH 17/26] Update ImagingClusterReco.cc --- .../calorimetry/ImagingClusterReco.cc | 48 ++++++++++++++----- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/src/algorithms/calorimetry/ImagingClusterReco.cc b/src/algorithms/calorimetry/ImagingClusterReco.cc index 1a6fa4bf51..20123d8f0a 100644 --- a/src/algorithms/calorimetry/ImagingClusterReco.cc +++ b/src/algorithms/calorimetry/ImagingClusterReco.cc @@ -29,6 +29,7 @@ #include #include #include +#include #include "algorithms/calorimetry/ClusterTypes.h" #include "algorithms/calorimetry/ImagingClusterReco.h" @@ -328,21 +329,42 @@ void ImagingClusterReco::associate_mc_particles( } edm4hep::MCParticle -ImagingClusterReco::get_primary(const edm4hep::CaloHitContribution& contrib) const { - // get contributing particle - const auto contributor = contrib.getParticle(); - - // walk back through parents to find primary - // - TODO finalize primary selection. This - // can be improved!! - edm4hep::MCParticle primary = contributor; - while (primary.parents_size() > 0) { - if (primary.getGeneratorStatus() != 0) { +CalorimeterClusterRecoCoG::get_primary(const edm4hep::CaloHitContribution& contrib) const { + edm4hep::MCParticle current = contrib.getParticle(); + if (!current.isAvailable()) { + return current; + } + + const edm4hep::MCParticle original = current; + std::vector chain; + chain.push_back(current); + while (current.getGeneratorStatus() == 0 && current.parents_size() > 0) { + const auto parent = current.getParents(0); + + if (!parent.isAvailable()) { break; } - primary = primary.getParents(0); + + current = parent; + chain.push_back(current); + } + + const auto is_prompt_decay_particle = [this](const edm4hep::MCParticle& particle) { + return std::ranges::find(m_cfg.promptDecayPDGs, std::abs(particle.getPDG())) != + m_cfg.promptDecayPDGs.end(); + }; + + for (auto iterator = chain.rbegin(); iterator != chain.rend(); ++iterator) { + if (!iterator->isAvailable()) { + continue; + } + const bool isPrompt = is_prompt_decay_particle(*iterator); + + if (isPrompt) { + continue; + } + + return *iterator; } - return primary; -} } // namespace eicrecon From d1167fdb93fb2aa852e82005805266486d9c2cc0 Mon Sep 17 00:00:00 2001 From: akshaya <99753263+AkshayaVijay@users.noreply.github.com> Date: Mon, 10 Aug 2026 09:08:57 -0500 Subject: [PATCH 18/26] Update ImagingClusterRecoConfig.h --- src/algorithms/calorimetry/ImagingClusterRecoConfig.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/algorithms/calorimetry/ImagingClusterRecoConfig.h b/src/algorithms/calorimetry/ImagingClusterRecoConfig.h index 9ed22791f6..525aa18e1c 100644 --- a/src/algorithms/calorimetry/ImagingClusterRecoConfig.h +++ b/src/algorithms/calorimetry/ImagingClusterRecoConfig.h @@ -8,6 +8,7 @@ namespace eicrecon { struct ImagingClusterRecoConfig { int trackStopLayer = 9; + std::vector promptDecayPDGs{111, 221, 331, 310, 3122}; }; } // namespace eicrecon From b0b57d5617305b56dd3bcc5030c120b81634aa48 Mon Sep 17 00:00:00 2001 From: akshaya <99753263+AkshayaVijay@users.noreply.github.com> Date: Mon, 10 Aug 2026 09:17:34 -0500 Subject: [PATCH 19/26] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/algorithms/calorimetry/ImagingClusterReco.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/ImagingClusterReco.cc b/src/algorithms/calorimetry/ImagingClusterReco.cc index 20123d8f0a..7f90e01c7b 100644 --- a/src/algorithms/calorimetry/ImagingClusterReco.cc +++ b/src/algorithms/calorimetry/ImagingClusterReco.cc @@ -329,7 +329,7 @@ void ImagingClusterReco::associate_mc_particles( } edm4hep::MCParticle -CalorimeterClusterRecoCoG::get_primary(const edm4hep::CaloHitContribution& contrib) const { +ImagingClusterReco::get_primary(const edm4hep::CaloHitContribution& contrib) const { edm4hep::MCParticle current = contrib.getParticle(); if (!current.isAvailable()) { return current; From 18bedc500a4d071f2d6858e311fb9ba0d6dfb7db Mon Sep 17 00:00:00 2001 From: akshaya <99753263+AkshayaVijay@users.noreply.github.com> Date: Mon, 10 Aug 2026 09:18:59 -0500 Subject: [PATCH 20/26] Update ImagingClusterRecoConfig.h --- src/algorithms/calorimetry/ImagingClusterRecoConfig.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/algorithms/calorimetry/ImagingClusterRecoConfig.h b/src/algorithms/calorimetry/ImagingClusterRecoConfig.h index 525aa18e1c..4fb0353aa6 100644 --- a/src/algorithms/calorimetry/ImagingClusterRecoConfig.h +++ b/src/algorithms/calorimetry/ImagingClusterRecoConfig.h @@ -2,6 +2,7 @@ // Copyright (C) 2022 Chao Peng, Sylvester Joosten, Whitney Armstrong #pragma once +#include namespace eicrecon { From fcd211e192f8758eed0365f8908b685411aefc49 Mon Sep 17 00:00:00 2001 From: akshaya <99753263+AkshayaVijay@users.noreply.github.com> Date: Mon, 10 Aug 2026 09:42:49 -0500 Subject: [PATCH 21/26] Update ImagingClusterReco.cc --- src/algorithms/calorimetry/ImagingClusterReco.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/algorithms/calorimetry/ImagingClusterReco.cc b/src/algorithms/calorimetry/ImagingClusterReco.cc index 7f90e01c7b..0523fe15c2 100644 --- a/src/algorithms/calorimetry/ImagingClusterReco.cc +++ b/src/algorithms/calorimetry/ImagingClusterReco.cc @@ -366,5 +366,7 @@ ImagingClusterReco::get_primary(const edm4hep::CaloHitContribution& contrib) con return *iterator; } +return original; +} } // namespace eicrecon From 81c6c04aecc562451dc03159011ed83264043484 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 10 Aug 2026 14:43:03 +0000 Subject: [PATCH 22/26] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/ImagingClusterReco.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/ImagingClusterReco.cc b/src/algorithms/calorimetry/ImagingClusterReco.cc index 0523fe15c2..142f2fa8d7 100644 --- a/src/algorithms/calorimetry/ImagingClusterReco.cc +++ b/src/algorithms/calorimetry/ImagingClusterReco.cc @@ -366,7 +366,7 @@ ImagingClusterReco::get_primary(const edm4hep::CaloHitContribution& contrib) con return *iterator; } -return original; + return original; } } // namespace eicrecon From d80bb451dd2d8eef9dff7ce31e49c7483acdc32f Mon Sep 17 00:00:00 2001 From: epic-capybara <139920704+epic-capybara@users.noreply.github.com> Date: Mon, 10 Aug 2026 11:00:33 -0400 Subject: [PATCH 23/26] Redefined get_primary function to return first stable particle (fix: iwyu) (#2851) This PR applies the include-what-you-use fixes as suggested by https://github.com/eic/EICrecon/actions/runs/31399679224. Please merge this PR into the branch `CalorimeterClusterReco_get_Primary` to resolve failures in PR #2844. Auto-generated by [create-pull-request][1] [1]: https://github.com/peter-evans/create-pull-request Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/algorithms/calorimetry/ImagingClusterReco.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/algorithms/calorimetry/ImagingClusterReco.cc b/src/algorithms/calorimetry/ImagingClusterReco.cc index 142f2fa8d7..cc92c05294 100644 --- a/src/algorithms/calorimetry/ImagingClusterReco.cc +++ b/src/algorithms/calorimetry/ImagingClusterReco.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include // IWYU pragma: keep #include @@ -28,6 +29,7 @@ #include #include #include +#include #include #include From 77d7bb64d07b499cf831464067935a367b204368 Mon Sep 17 00:00:00 2001 From: akshaya <99753263+AkshayaVijay@users.noreply.github.com> Date: Mon, 10 Aug 2026 10:09:27 -0500 Subject: [PATCH 24/26] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc index e6eb644561..7d809cf06a 100644 --- a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc +++ b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc @@ -15,13 +15,13 @@ #include #include #include -#include +#include #include #include +#include #include #include #include -#include #include #include #include From 40db4f3eec8828065fc35a2dc9665187e4e2bc42 Mon Sep 17 00:00:00 2001 From: akshaya <99753263+AkshayaVijay@users.noreply.github.com> Date: Mon, 10 Aug 2026 10:23:36 -0500 Subject: [PATCH 25/26] Update src/algorithms/calorimetry/ImagingClusterReco.cc Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/algorithms/calorimetry/ImagingClusterReco.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/ImagingClusterReco.cc b/src/algorithms/calorimetry/ImagingClusterReco.cc index cc92c05294..d256dcb84a 100644 --- a/src/algorithms/calorimetry/ImagingClusterReco.cc +++ b/src/algorithms/calorimetry/ImagingClusterReco.cc @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include // IWYU pragma: keep #include From c228abb8f84206202edaad4a127eaa2c1e4bcdbf Mon Sep 17 00:00:00 2001 From: epic-capybara <139920704+epic-capybara@users.noreply.github.com> Date: Mon, 10 Aug 2026 11:38:11 -0400 Subject: [PATCH 26/26] Redefined get_primary function to return first stable particle (fix: iwyu) (#2852) This PR applies the include-what-you-use fixes as suggested by https://github.com/eic/EICrecon/actions/runs/31403341190. Please merge this PR into the branch `CalorimeterClusterReco_get_Primary` to resolve failures in PR #2844. Auto-generated by [create-pull-request][1] [1]: https://github.com/peter-evans/create-pull-request Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc index 7d809cf06a..f8dc0118f0 100644 --- a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc +++ b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc @@ -15,13 +15,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include #include