Skip to content

Commit

Permalink
Merge pull request #32671 from smuzaffar/heppdt-3.04.01
Browse files Browse the repository at this point in the history
Revert #25298; memory leak fix for HepPDT::HeavyIonUnknownID
  • Loading branch information
cmsbuild committed Jan 18, 2021
2 parents 86a858d + d3375cf commit 1bab18c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
1 change: 0 additions & 1 deletion SimGeneral/HepPDTESSource/BuildFile.xml
@@ -1,4 +1,3 @@
<use name="SimGeneral/HepPDTRecord"/>
<use name="tbb"/>
<use name="heppdt"/>
<flags EDM_PLUGIN="1"/>
23 changes: 1 addition & 22 deletions SimGeneral/HepPDTESSource/src/HepPDTESSource.cc
@@ -1,26 +1,5 @@
#include "HepPDT/HeavyIonUnknownID.hh"
#include "SimGeneral/HepPDTESSource/interface/HepPDTESSource.h"
#include "tbb/concurrent_vector.h"

namespace {

class CachingHeavyIonUnknownID : public HepPDT::ProcessUnknownID {
HepPDT::ParticleData *processUnknownID(HepPDT::ParticleID id, const HepPDT::ParticleDataTable &table) final {
// HeavyIonUnknownID constructs a new particle but does not delete it
// we need to do that ourselves
std::unique_ptr<HepPDT::ParticleData> p{wrapped_.processUnknownID(id, table)};
auto *pPtr = p.get();
if (p) {
particles_.emplace_back(std::move(p));
}
return pPtr;
}

HepPDT::HeavyIonUnknownID wrapped_;
tbb::concurrent_vector<std::unique_ptr<HepPDT::ParticleData>> particles_;
};

} // namespace

HepPDTESSource::HepPDTESSource(const edm::ParameterSet &cfg)
: pdtFileName(cfg.getParameter<edm::FileInPath>("pdtFileName")) {
Expand All @@ -32,7 +11,7 @@ HepPDTESSource::~HepPDTESSource() {}

HepPDTESSource::ReturnType HepPDTESSource::produce(const PDTRecord &iRecord) {
using namespace edm::es;
auto pdt = std::make_unique<PDT>("PDG table", new CachingHeavyIonUnknownID);
auto pdt = std::make_unique<PDT>("PDG table", new HepPDT::HeavyIonUnknownID);
std::ifstream pdtFile(pdtFileName.fullPath().c_str());
if (!pdtFile)
throw cms::Exception("FileNotFound", "can't open pdt file") << "cannot open " << pdtFileName.fullPath();
Expand Down

0 comments on commit 1bab18c

Please sign in to comment.