From b6a91fe44d3401e2145fdec0ac0310c724213789 Mon Sep 17 00:00:00 2001
From: John Chapman <John.Chapman@cern.ch>
Date: Wed, 5 Mar 2025 17:32:12 +0100
Subject: [PATCH] TruthParentDecoratorAlg: Hack to make it compile - untested
 needs fixing properly

---
 .../src/TruthParentDecoratorAlg.cxx                 | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleJetTools/src/TruthParentDecoratorAlg.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleJetTools/src/TruthParentDecoratorAlg.cxx
index bb987a5180a..29c0f27c679 100644
--- a/PhysicsAnalysis/AnalysisCommon/ParticleJetTools/src/TruthParentDecoratorAlg.cxx
+++ b/PhysicsAnalysis/AnalysisCommon/ParticleJetTools/src/TruthParentDecoratorAlg.cxx
@@ -1,6 +1,7 @@
 #include "TruthParentDecoratorAlg.h"
 
 #include "StoreGate/WriteDecorHandle.h"
+#include "TruthUtils/HepMCHelpers.h"
 
 #include <format>
 
@@ -368,8 +369,8 @@ StatusCode TruthParentDecoratorAlg::execute(const EventContext& cxt) const
   unsigned int n_parents = 0;
   for (const auto* p: psort) {
     unsigned int parent_index = n_parents++;
-    ATH_MSG_VERBOSE("pdgid: " << p->pdgId() << ", barcode: " << p->barcode());
-    for (auto& [cbar, histbars]: findAllDescendants(p->barcode(), barcodex)) {
+    ATH_MSG_VERBOSE("pdgid: " << p->pdgId() << ", barcode: " << HepMC::uniqueID(p));
+    for (auto& [cbar, histbars]: findAllDescendants(HepMC::uniqueID(p), barcodex)) {
       IPMap::mapped_type& barkids = ipmap.at(cbar);
       const xAOD::TruthParticle* child = selectChild(barkids);
       std::vector<std::pair<float, const J*>> drs;
@@ -509,8 +510,8 @@ void TruthParentDecoratorAlg::addTruthContainer(
 
   // insert a particle into the record, return the child set
   auto insert = [&barcodex, &ipmap](const xAOD::TruthParticle* p) -> auto& {
-    ipmap[p->barcode()].insert(p);
-    return barcodex[p->barcode()];
+    ipmap[HepMC::uniqueID(p)].insert(p);
+    return barcodex[HepMC::uniqueID(p)];
   };
 
   for (const xAOD::TruthParticle* p: container) {
@@ -532,7 +533,7 @@ void TruthParentDecoratorAlg::addTruthContainer(
           } else {
             auto problem = std::format(
               "null truth child [barcode={},pdg_id={},child={}of{}]",
-              p->barcode(), p->pdgId(), child_n, p->nChildren());
+              HepMC::uniqueID(p), p->pdgId(), child_n, p->nChildren());
             const auto& warn_missing = m_warn_missing_children_pdgids.value();
             if (warn_missing.contains(p->pdgId())) {
               m_missing_n_warned++;
@@ -543,7 +544,7 @@ void TruthParentDecoratorAlg::addTruthContainer(
           }
         } else if (cascadeWants(c)) {
           insert(c);
-          child_set.insert(c->barcode());
+          child_set.insert(HepMC::uniqueID(c));
         }
       };
     }
-- 
GitLab