Skip to content

Commit

Permalink
Remove WatchRuns restriction on HectorProducer
Browse files Browse the repository at this point in the history
The module did nothing on Run transitions so should not restrict
the framework's behavior.
Also fixed a memory leak.
  • Loading branch information
Dr15Jones committed Nov 3, 2022
1 parent 0995d7f commit 7826336
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
7 changes: 2 additions & 5 deletions SimTransport/HectorProducer/interface/HectorProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,14 @@ class Hector;
namespace HepMC {
class GenEvent;
}
class HectorProducer : public edm::one::EDProducer<edm::one::SharedResources, edm::one::WatchRuns> {
class HectorProducer : public edm::one::EDProducer<edm::one::SharedResources> {
public:
explicit HectorProducer(edm::ParameterSet const &p);
~HectorProducer() override;
void beginRun(const edm::Run &r, const edm::EventSetup &c) override;
void endRun(const edm::Run &r, const edm::EventSetup &c) override;
void produce(edm::Event &e, const edm::EventSetup &c) override;

private:
HepMC::GenEvent *evt_;
Hector *m_Hector;
std::unique_ptr<Hector> m_Hector;

edm::ESGetToken<HepPDT::ParticleDataTable, PDTRecord> tok_pdt_;
edm::EDGetTokenT<edm::HepMCProduct> m_HepMC;
Expand Down
21 changes: 9 additions & 12 deletions SimTransport/HectorProducer/src/HectorProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ HectorProducer::HectorProducer(edm::ParameterSet const &p)
produces<edm::HepMCProduct>();
produces<edm::LHCTransportLinkContainer>();

m_Hector = new Hector(p, tok_pdt_, m_verbosity, m_FP420Transport, m_ZDCTransport);
usesResource("Hector");
m_Hector = std::make_unique<Hector>(p, tok_pdt_, m_verbosity, m_FP420Transport, m_ZDCTransport);

edm::Service<edm::RandomNumberGenerator> rng;
if (!rng.isAvailable()) {
Expand All @@ -57,10 +58,6 @@ HectorProducer::HectorProducer(edm::ParameterSet const &p)

HectorProducer::~HectorProducer() {}

void HectorProducer::beginRun(const edm::Run &r, const edm::EventSetup &c) {}

void HectorProducer::endRun(const edm::Run &r, const edm::EventSetup &c) {}

void HectorProducer::produce(edm::Event &iEvent, const edm::EventSetup &es) {
edm::Service<edm::RandomNumberGenerator> rng;
CLHEP::HepRandomEngine *engine = &rng->getEngine(iEvent.streamID());
Expand All @@ -85,30 +82,30 @@ void HectorProducer::produce(edm::Event &iEvent, const edm::EventSetup &es) {
throw cms::Exception("LogicError") << "HectorTrasported HepMCProduce already exists\n";
}

evt_ = new HepMC::GenEvent(*HepMCEvt->GetEvent());
auto evt = new HepMC::GenEvent(*HepMCEvt->GetEvent());
m_Hector->clearApertureFlags();
if (m_FP420Transport) {
m_Hector->clear();
m_Hector->add(evt_, es);
m_Hector->add(evt, es);
m_Hector->filterFP420(rootEngine);
}
if (m_ZDCTransport) {
m_Hector->clear();
m_Hector->add(evt_, es);
m_Hector->add(evt, es);
m_Hector->filterZDC(rootEngine);

m_Hector->clear();
m_Hector->add(evt_, es);
m_Hector->add(evt, es);
m_Hector->filterD1(rootEngine);
}
evt_ = m_Hector->addPartToHepMC(evt_);
evt = m_Hector->addPartToHepMC(evt);
if (m_verbosity)
evt_->print();
evt->print();

edm::LogVerbatim("SimTransportHectorProducer") << "new HepMC product ";

unique_ptr<edm::HepMCProduct> NewProduct(new edm::HepMCProduct());
NewProduct->addHepMCData(evt_);
NewProduct->addHepMCData(evt);

iEvent.put(std::move(NewProduct));

Expand Down

0 comments on commit 7826336

Please sign in to comment.