Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GenParticles2HepMCConverter Consumes migration #10311

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,5 +1,5 @@
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
Expand All @@ -25,20 +25,20 @@

using namespace std;

class GenParticles2HepMCConverter : public edm::EDProducer
class GenParticles2HepMCConverter : public edm::stream::EDProducer<>
{
public:
explicit GenParticles2HepMCConverter(const edm::ParameterSet& pset);
~GenParticles2HepMCConverter() {};

void beginRun(edm::Run& run, const edm::EventSetup& eventSetup);
void produce(edm::Event& event, const edm::EventSetup& eventSetup);
//void beginRun(const edm::Run& run, const edm::EventSetup& eventSetup) override;
void produce(edm::Event& event, const edm::EventSetup& eventSetup) override;

private:
// edm::InputTag lheEventLabel_;
edm::InputTag genParticlesLabel_;
// edm::InputTag genRunInfoLabel_;
edm::InputTag genEventInfoLabel_;
// edm::InputTag lheEventToken_;
edm::EDGetTokenT<reco::CandidateView> genParticlesToken_;
// edm::InputTag genRunInfoToken_;
edm::EDGetTokenT<GenEventInfoProduct> genEventInfoToken_;
edm::ESHandle<ParticleDataTable> pTable_;

private:
Expand All @@ -58,36 +58,36 @@ class GenParticles2HepMCConverter : public edm::EDProducer

GenParticles2HepMCConverter::GenParticles2HepMCConverter(const edm::ParameterSet& pset)
{
// lheEventLabel_ = pset.getParameter<edm::InputTag>("lheEvent");
genParticlesLabel_ = pset.getParameter<edm::InputTag>("genParticles");
//genRunInfoLabel_ = pset.getParameter<edm::InputTag>("genRunInfo");
genEventInfoLabel_ = pset.getParameter<edm::InputTag>("genEventInfo");
// lheEventToken_ = pset.getParameter<edm::InputTag>("lheEvent");
genParticlesToken_ = consumes<reco::CandidateView>(pset.getParameter<edm::InputTag>("genParticles"));
//genRunInfoToken_ = pset.getParameter<edm::InputTag>("genRunInfo");
genEventInfoToken_ = consumes<GenEventInfoProduct>(pset.getParameter<edm::InputTag>("genEventInfo"));

produces<edm::HepMCProduct>();
}

void GenParticles2HepMCConverter::beginRun(edm::Run& run, const edm::EventSetup& eventSetup)
{
//void GenParticles2HepMCConverter::beginRun(edm::Run& run, const edm::EventSetup& eventSetup)
//{
//edm::Handle<GenRunInfoProduct> genRunInfoHandle;
//event.getByLabel(genRunInfoLabel_, genRunInfoHandle);
//event.getByToken(genRunInfoToken_, genRunInfoHandle);
// const double xsecIn = genRunInfoHandle->internalXSec().value();
// const double xsecInErr = genRunInfoHandle->internalXSec().error();
// const double xsecLO = genRunInfoHandle->externalXSecLO().value();
// const double xsecLOErr = genRunInfoHandle->externalXSecLO().error();
// const double xsecNLO = genRunInfoHandle->externalXSecNLO().value();
// const double xsecNLOErr = genRunInfoHandle->externalXSecNLO().error();
}
//}

void GenParticles2HepMCConverter::produce(edm::Event& event, const edm::EventSetup& eventSetup)
{
// edm::Handle<LHEEventProduct> lheEventHandle;
// event.getByLabel(lheEventLabel_, lheEventHandle);
// event.getByToken(lheEventToken_, lheEventHandle);

edm::Handle<reco::CandidateView> genParticlesHandle;
event.getByLabel(genParticlesLabel_, genParticlesHandle);
event.getByToken(genParticlesToken_, genParticlesHandle);

edm::Handle<GenEventInfoProduct> genEventInfoHandle;
event.getByLabel(genEventInfoLabel_, genEventInfoHandle);
event.getByToken(genEventInfoToken_, genEventInfoHandle);

eventSetup.getData(pTable_);

Expand Down