Skip to content

Commit

Permalink
Use esConsumes in RandomXiThetaGunProducer
Browse files Browse the repository at this point in the history
  • Loading branch information
makortel committed Nov 4, 2021
1 parent fc5836f commit 4bc3c4d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
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

0 comments on commit 4bc3c4d

Please sign in to comment.