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

Use esConsumes in RandomXiThetaGunProducer #35995

Merged
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h
Expand Up @@ -10,6 +10,9 @@

#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"

#include "HepPDT/ParticleDataTable.hh"
#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"

#include "CLHEP/Random/RandFlat.h"
#include "CLHEP/Random/RandGauss.h"

Expand All @@ -27,6 +30,8 @@ namespace edm {
void produce(Event&, const EventSetup&) override;
void generateParticle(double z_sign, double mass, unsigned int barcode, HepMC::GenVertex* vtx) const;

edm::ESGetToken<HepPDT::ParticleDataTable, edm::DefaultRecord> tableToken_;

unsigned int verbosity_;
unsigned int particleId_;

Expand Down
11 changes: 4 additions & 7 deletions IOMC/ParticleGuns/src/RandomXiThetaGunProducer.cc
Expand Up @@ -13,16 +13,14 @@
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Utilities/interface/RandomNumberGenerator.h"

#include "HepPDT/ParticleDataTable.hh"
#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"

using namespace edm;
using namespace std;

//----------------------------------------------------------------------------------------------------

RandomXiThetaGunProducer::RandomXiThetaGunProducer(const edm::ParameterSet &iConfig)
: verbosity_(iConfig.getUntrackedParameter<unsigned int>("verbosity", 0)),
: tableToken_(esConsumes()),
verbosity_(iConfig.getUntrackedParameter<unsigned int>("verbosity", 0)),
particleId_(iConfig.getParameter<unsigned int>("particleId")),
energy_(iConfig.getParameter<double>("energy")),
xi_min_(iConfig.getParameter<double>("xi_min")),
Expand All @@ -44,8 +42,7 @@ void RandomXiThetaGunProducer::produce(edm::Event &e, const edm::EventSetup &es)
edm::Service<edm::RandomNumberGenerator> rng;
engine_ = &rng->getEngine(e.streamID());

ESHandle<HepPDT::ParticleDataTable> pdgTable;
es.getData(pdgTable);
auto const &pdgTable = es.getData(tableToken_);

// prepare HepMC event
HepMC::GenEvent *fEvt = new HepMC::GenEvent();
Expand All @@ -54,7 +51,7 @@ void RandomXiThetaGunProducer::produce(edm::Event &e, const edm::EventSetup &es)
HepMC::GenVertex *vtx = new HepMC::GenVertex(HepMC::FourVector(0., 0., 0., 0.));
fEvt->add_vertex(vtx);

const HepPDT::ParticleData *pData = pdgTable->particle(HepPDT::ParticleID(particleId_));
const HepPDT::ParticleData *pData = pdgTable.particle(HepPDT::ParticleID(particleId_));
double mass = pData->mass().value();

// generate particles
Expand Down