Skip to content

Commit

Permalink
Merge pull request #30284 from JamminJones/fixGeneratorInterfaceHiGen…
Browse files Browse the repository at this point in the history
…Common

added esConsumes to modules in GeneratorInterface/HiGenCommon
  • Loading branch information
cmsbuild committed Jun 19, 2020
2 parents d1039ad + 62ad60d commit 25064b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 6 additions & 2 deletions GeneratorInterface/HiGenCommon/plugins/GenHIEventProducer.cc
Expand Up @@ -28,6 +28,7 @@ Description: <one line class summary>

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Utilities/interface/ESGetToken.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"
Expand All @@ -54,6 +55,7 @@ class GenHIEventProducer : public edm::EDProducer {
void produce(edm::Event&, const edm::EventSetup&) override;
edm::EDGetTokenT<CrossingFrame<edm::HepMCProduct> > hepmcSrc_;
edm::ESHandle<ParticleDataTable> pdt;
edm::ESGetToken<ParticleDataTable, edm::DefaultRecord> pdtToken_;

double ptCut_;
bool doParticleInfo_;
Expand All @@ -73,6 +75,7 @@ class GenHIEventProducer : public edm::EDProducer {
GenHIEventProducer::GenHIEventProducer(const edm::ParameterSet& iConfig) {
produces<edm::GenHIEvent>();
hepmcSrc_ = consumes<CrossingFrame<edm::HepMCProduct> >(iConfig.getParameter<edm::InputTag>("src"));
pdtToken_ = esConsumes<ParticleDataTable, edm::DefaultRecord>();
doParticleInfo_ = iConfig.getUntrackedParameter<bool>("doParticleInfo", false);
if (doParticleInfo_) {
ptCut_ = iConfig.getParameter<double>("ptCut");
Expand All @@ -92,8 +95,9 @@ GenHIEventProducer::~GenHIEventProducer() {
void GenHIEventProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
using namespace edm;

if (!(pdt.isValid()))
iSetup.getData(pdt);
if (!(pdt.isValid())) {
pdt = iSetup.getHandle(pdtToken_);
}

double b = -1;
int npart = -1;
Expand Down
Expand Up @@ -26,6 +26,7 @@
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
Expand All @@ -44,7 +45,7 @@ class HighMultiplicityGenFilter : public edm::EDFilter {
void endJob() override;

// ----------member data ---------------------------
edm::ESHandle<ParticleDataTable> pdt;
edm::ESGetToken<ParticleDataTable, edm::DefaultRecord> pdtToken_;
edm::EDGetTokenT<edm::HepMCProduct> hepmcSrc;
double etaMax;
double ptMin;
Expand All @@ -64,7 +65,8 @@ class HighMultiplicityGenFilter : public edm::EDFilter {
// constructors and destructor
//
HighMultiplicityGenFilter::HighMultiplicityGenFilter(const edm::ParameterSet& iConfig)
: hepmcSrc(consumes<edm::HepMCProduct>(iConfig.getParameter<edm::InputTag>("generatorSmeared"))),
: pdtToken_(esConsumes<ParticleDataTable, edm::DefaultRecord>()),
hepmcSrc(consumes<edm::HepMCProduct>(iConfig.getParameter<edm::InputTag>("generatorSmeared"))),
etaMax(iConfig.getUntrackedParameter<double>("etaMax")),
ptMin(iConfig.getUntrackedParameter<double>("ptMin")),
nMin(iConfig.getUntrackedParameter<int>("nMin")) {
Expand All @@ -86,8 +88,7 @@ bool HighMultiplicityGenFilter::filter(edm::Event& iEvent, const edm::EventSetup
bool accepted = false;
edm::Handle<edm::HepMCProduct> evt;
iEvent.getByToken(hepmcSrc, evt);

iSetup.getData(pdt);
edm::ESHandle<ParticleDataTable> pdt = iSetup.getHandle(pdtToken_);

const HepMC::GenEvent* myGenEvent = evt->GetEvent();

Expand Down

0 comments on commit 25064b4

Please sign in to comment.