From d41873522df7f972a91023de4f0902543411ff5d Mon Sep 17 00:00:00 2001 From: Francois Drielsma Date: Wed, 8 Nov 2023 17:20:54 -0800 Subject: [PATCH] Store gen_id in the TruthParticle object when it's provided in the larcv.Particle one --- analysis/classes/TruthParticle.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/analysis/classes/TruthParticle.py b/analysis/classes/TruthParticle.py index aa2557b6..ba58f948 100644 --- a/analysis/classes/TruthParticle.py +++ b/analysis/classes/TruthParticle.py @@ -114,6 +114,10 @@ def register_larcv_particle(self, particle): for k in scalar_keys: val = getattr(particle, k)() setattr(self, k, val) + + # TODO: Move this to main list once this is in every LArCV file + if hasattr(particle, 'gen_id'): + setattr(self, 'gen_id', particle.gen_id()) # Exception for particle_id self.truth_id = particle.id() @@ -178,6 +182,10 @@ def load_larcv_attributes(self, particle_dict): attr = attr.decode() setattr(self, attr_name, attr) + # TODO: Move this to main list once this is in every LArCV file + if 'gen_id' in particle_dict: + setattr(self, 'gen_id', particle_dict['gen_id']) + def merge(self, particle): ''' Merge another particle object into this one