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

added esConsumes to modules in PhysicsTools/HepMCCandAlgos #30129

Merged
merged 3 commits into from Jun 10, 2020
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
6 changes: 5 additions & 1 deletion PhysicsTools/HepMCCandAlgos/plugins/GenParticleProducer.cc
Expand Up @@ -9,6 +9,7 @@
*/
#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "DataFormats/Candidate/interface/CandidateFwd.h"
#include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
#include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
Expand Down Expand Up @@ -105,6 +106,7 @@ class GenParticleProducer : public edm::global::EDProducer<edm::RunCache<IDto3Ch
edm::EDGetTokenT<edm::HepMCProduct> srcToken_;
std::vector<edm::EDGetTokenT<edm::HepMCProduct>> vectorSrcTokens_;
edm::EDGetTokenT<CrossingFrame<edm::HepMCProduct>> mixToken_;
edm::ESGetToken<HepPDT::ParticleDataTable, edm::DefaultRecord> particleTableToken_;

/// unknown code treatment flag
bool abortOnUnknownPDGCode_;
Expand Down Expand Up @@ -132,6 +134,7 @@ class GenParticleProducer : public edm::global::EDProducer<edm::RunCache<IDto3Ch
#include "FWCore/Utilities/interface/EDMException.h"
#include "FWCore/Utilities/interface/transform.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include <fstream>
#include <algorithm>
using namespace edm;
Expand All @@ -147,6 +150,7 @@ GenParticleProducer::GenParticleProducer(const ParameterSet& cfg)
saveBarCodes_(cfg.getUntrackedParameter<bool>("saveBarCodes", false)),
doSubEvent_(cfg.getUntrackedParameter<bool>("doSubEvent", false)),
useCF_(cfg.getUntrackedParameter<bool>("useCrossingFrame", false)) {
particleTableToken_ = esConsumes<HepPDT::ParticleDataTable, edm::DefaultRecord, edm::Transition::BeginRun>();
produces<GenParticleCollection>();
produces<math::XYZPointF>("xyz0");
produces<float>("t0");
Expand All @@ -165,7 +169,7 @@ GenParticleProducer::GenParticleProducer(const ParameterSet& cfg)
GenParticleProducer::~GenParticleProducer() {}

std::shared_ptr<IDto3Charge> GenParticleProducer::globalBeginRun(const Run&, const EventSetup& es) const {
ESHandle<HepPDT::ParticleDataTable> pdt;
ESHandle<HepPDT::ParticleDataTable> pdt = es.getHandle(particleTableToken_);
es.getData(pdt);
return std::make_shared<IDto3Charge>(*pdt, abortOnUnknownPDGCode_);
}
Expand Down
1 change: 0 additions & 1 deletion PhysicsTools/HepMCCandAlgos/plugins/PDFWeightsTest.cc
Expand Up @@ -2,7 +2,6 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
Expand Down
5 changes: 4 additions & 1 deletion PhysicsTools/HepMCCandAlgos/plugins/ParticleDecayDrawer.cc
Expand Up @@ -5,6 +5,7 @@
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
#include "DataFormats/Common/interface/View.h"
#include "DataFormats/Candidate/interface/Candidate.h"
Expand All @@ -18,6 +19,7 @@ class ParticleDecayDrawer : public edm::EDAnalyzer {
edm::EDGetTokenT<edm::View<reco::Candidate> > srcToken_;
std::string decay(const reco::Candidate &, std::list<const reco::Candidate *> &) const;
edm::ESHandle<ParticleDataTable> pdt_;
edm::ESGetToken<ParticleDataTable, edm::DefaultRecord> pdtToken_;
/// print parameters
bool printP4_, printPtEtaPhi_, printVertex_;
/// print 4 momenta
Expand All @@ -44,6 +46,7 @@ using namespace reco;

ParticleDecayDrawer::ParticleDecayDrawer(const ParameterSet &cfg)
: srcToken_(consumes<edm::View<reco::Candidate> >(cfg.getParameter<InputTag>("src"))),
pdtToken_(esConsumes<ParticleDataTable, edm::DefaultRecord>()),
printP4_(cfg.getUntrackedParameter<bool>("printP4", false)),
printPtEtaPhi_(cfg.getUntrackedParameter<bool>("printPtEtaPhi", false)),
printVertex_(cfg.getUntrackedParameter<bool>("printVertex", false)) {}
Expand All @@ -65,7 +68,7 @@ bool ParticleDecayDrawer::hasValidDaughters(const reco::Candidate &c) const {
}

void ParticleDecayDrawer::analyze(const Event &event, const EventSetup &es) {
es.getData(pdt_);
pdt_ = es.getHandle(pdtToken_);
Handle<View<Candidate> > particles;
event.getByToken(srcToken_, particles);
list<const Candidate *> skip;
Expand Down
5 changes: 4 additions & 1 deletion PhysicsTools/HepMCCandAlgos/plugins/ParticleListDrawer.cc
Expand Up @@ -6,6 +6,7 @@
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/MakerMacros.h"
Expand Down Expand Up @@ -50,6 +51,7 @@ class ParticleListDrawer : public edm::EDAnalyzer {
edm::InputTag src_;
edm::EDGetTokenT<reco::CandidateView> srcToken_;
edm::ESHandle<ParticleDataTable> pdt_;
edm::ESGetToken<ParticleDataTable, edm::DefaultRecord> pdtToken_;
int maxEventsToPrint_; // Must be signed, because -1 is used for no limit
unsigned int nEventAnalyzed_;
bool printOnlyHardInteraction_;
Expand All @@ -61,6 +63,7 @@ class ParticleListDrawer : public edm::EDAnalyzer {
ParticleListDrawer::ParticleListDrawer(const edm::ParameterSet& pset)
: src_(pset.getParameter<InputTag>("src")),
srcToken_(consumes<reco::CandidateView>(src_)),
pdtToken_(esConsumes<ParticleDataTable, edm::DefaultRecord>()),
maxEventsToPrint_(pset.getUntrackedParameter<int>("maxEventsToPrint", 1)),
nEventAnalyzed_(0),
printOnlyHardInteraction_(pset.getUntrackedParameter<bool>("printOnlyHardInteraction", false)),
Expand All @@ -81,7 +84,7 @@ std::string ParticleListDrawer::getParticleName(int id) const {
void ParticleListDrawer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
Handle<reco::CandidateView> particles;
iEvent.getByToken(srcToken_, particles);
iSetup.getData(pdt_);
pdt_ = iSetup.getHandle(pdtToken_);

if (maxEventsToPrint_ < 0 || nEventAnalyzed_ < static_cast<unsigned int>(maxEventsToPrint_)) {
ostringstream out;
Expand Down
5 changes: 4 additions & 1 deletion PhysicsTools/HepMCCandAlgos/plugins/ParticleTreeDrawer.cc
Expand Up @@ -7,6 +7,7 @@
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
#include "DataFormats/Common/interface/View.h"
#include "DataFormats/Candidate/interface/Candidate.h"
Expand All @@ -21,6 +22,7 @@ class ParticleTreeDrawer : public edm::EDAnalyzer {
edm::EDGetTokenT<edm::View<reco::Candidate> > srcToken_;
void printDecay(const reco::Candidate &, const std::string &pre) const;
edm::ESHandle<ParticleDataTable> pdt_;
edm::ESGetToken<ParticleDataTable, edm::DefaultRecord> pdtToken_;
/// print parameters
bool printP4_, printPtEtaPhi_, printVertex_, printStatus_, printIndex_;
/// accepted status codes
Expand Down Expand Up @@ -49,6 +51,7 @@ using namespace reco;

ParticleTreeDrawer::ParticleTreeDrawer(const ParameterSet &cfg)
: srcToken_(consumes<edm::View<reco::Candidate> >(cfg.getParameter<InputTag>("src"))),
pdtToken_(esConsumes<ParticleDataTable, edm::DefaultRecord>()),
printP4_(cfg.getUntrackedParameter<bool>("printP4", false)),
printPtEtaPhi_(cfg.getUntrackedParameter<bool>("printPtEtaPhi", false)),
printVertex_(cfg.getUntrackedParameter<bool>("printVertex", false)),
Expand Down Expand Up @@ -81,7 +84,7 @@ std::string ParticleTreeDrawer::getParticleName(int id) const {
}

void ParticleTreeDrawer::analyze(const Event &event, const EventSetup &es) {
es.getData(pdt_);
pdt_ = es.getHandle(pdtToken_);
Handle<View<Candidate> > particles;
event.getByToken(srcToken_, particles);
cands_.clear();
Expand Down