Skip to content

BTagging + ParticleJetTools: Avoid using raw pointers in ParticleToJetAssociator

In the SPOT tests job I came across this memory leak:

64,192 (11,424 direct, 52,768 indirect) bytes in 476 blocks are definitely lost in loss record 103,522 of 104,842
  at 0x4C2AAD2: operator new(unsigned long) (vg_replace_malloc.c:342)
  by 0xC019FFB9: std::vector<std::vector<xAOD::TrackParticle_v1 const*, std::allocator<xAOD::TrackParticle_v1 const*> >*, std::allocator<std::vector<xAOD::TrackParticle_v1 const*, std::allocator<xAOD::TrackParticle_v1 const*> >*> > Analysis::ParticleToJetAssociator::associateParticlesToJets<std::vector<xAOD::TrackParticle_v1 const*, std::allocator<xAOD::TrackParticle_v1 const*> >, DataVector<xAOD::TrackParticle_v1, DataVector<xAOD::IParticle, DataModel_detail::NoBase> > >(DataVector<xAOD::Jet_v1, DataVector<xAOD::IParticle, DataModel_detail::NoBase> > const*, DataVector<xAOD::TrackParticle_v1, DataVector<xAOD::IParticle, DataModel_detail::NoBase> > const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const (ParticleToJetAssociator.h:290)
  by 0xC0219B7E: Analysis::JetParticleAssociationAlg::execute() (JetParticleAssociationAlg.cxx:73)
  by 0x36114FD9: Gaudi::details::LegacyAlgorithmAdapter::execute(EventContext const&) const (Algorithm.h:48)
  by 0x301A0066: Gaudi::Algorithm::sysExecute(EventContext const&) (Algorithm.cpp:367)

I updated ParticleToJetAssociator to pass unique pointers instead of raw ones, so that the clients (there are not many) don't have to do explicit clean-up. The latter was already being done in BTagTrackAssociation but not in JetParticleAssociationAlg, hence the leak.

By the way, this issue came up in the master branch but looking at the code, the problematic part is in a block that refers to release 21. This makes me believe that maybe there is also a configuration issue, perhaps Release property of JetParticleAssociationAlg is not being set up properly. But that's independent of what's introduced here.

In any case, let me cc @cvarni and @guirriec. I'm sure the CI will tell if there is anything fishy w/ the updates.

Merge request reports

Loading