Skip to content

Commit

Permalink
Merge pull request #36248 from bsunanda/Run3-gex99D
Browse files Browse the repository at this point in the history
Run3-gex99D Use ESGetToken in the test example of PhysicsTools/HepMCCandAlgos
  • Loading branch information
cmsbuild authored Nov 28, 2021
2 parents 415d587 + 0d04967 commit 4095d81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#include "DataFormats/HepMCCandidate/interface/FlavorHistory.h"
#include "DataFormats/HepMCCandidate/interface/FlavorHistoryEvent.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Utilities/interface/EDMException.h"
Expand Down
15 changes: 8 additions & 7 deletions PhysicsTools/HepMCCandAlgos/test/DummyHepMCAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@

class DummyHepMCAnalyzer : public edm::one::EDAnalyzer<> {
private:
bool dumpHepMC_;
bool dumpPDF_;
bool checkPDG_;
edm::EDGetTokenT<edm::HepMCProduct> srcToken_;
const bool dumpHepMC_;
const bool dumpPDF_;
const bool checkPDG_;
const edm::EDGetTokenT<edm::HepMCProduct> srcToken_;
const edm::ESGetToken<HepPDT::ParticleDataTable, PDTRecord> pdtToken_;

public:
explicit DummyHepMCAnalyzer(const edm::ParameterSet& cfg)
: dumpHepMC_(cfg.getUntrackedParameter<bool>("dumpHepMC")),
dumpPDF_(cfg.getUntrackedParameter<bool>("dumpPDF")),
checkPDG_(cfg.getUntrackedParameter<bool>("checkPDG")),
srcToken_(consumes<edm::HepMCProduct>(cfg.getParameter<edm::InputTag>("src"))) {}
srcToken_(consumes<edm::HepMCProduct>(cfg.getParameter<edm::InputTag>("src"))),
pdtToken_(esConsumes<HepPDT::ParticleDataTable, PDTRecord>()) {}

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
Expand All @@ -50,8 +52,7 @@ class DummyHepMCAnalyzer : public edm::one::EDAnalyzer<> {
}

if (checkPDG_) {
edm::ESHandle<HepPDT::ParticleDataTable> fPDGTable;
es.getData(fPDGTable);
const auto& fPDGTable = es.getHandle(pdtToken_);
for (HepMC::GenEvent::particle_const_iterator part = mc->particles_begin(); part != mc->particles_end(); ++part) {
const HepPDT::ParticleData* PData = fPDGTable->particle(HepPDT::ParticleID((*part)->pdg_id()));
if (!PData) {
Expand Down

0 comments on commit 4095d81

Please sign in to comment.