diff --git a/TopQuarkAnalysis/TopSkimming/interface/TopDecayChannelFilter.h b/TopQuarkAnalysis/TopSkimming/interface/TopDecayChannelFilter.h index b5a9e294de94e..b83b74cd76d6a 100644 --- a/TopQuarkAnalysis/TopSkimming/interface/TopDecayChannelFilter.h +++ b/TopQuarkAnalysis/TopSkimming/interface/TopDecayChannelFilter.h @@ -1,15 +1,14 @@ #include "AnalysisDataFormats/TopObjects/interface/TtGenEvent.h" #include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EDFilter.h" +#include "FWCore/Framework/interface/stream/EDFilter.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/HepMCCandidate/interface/GenParticle.h" template -class TopDecayChannelFilter : public edm::EDFilter { +class TopDecayChannelFilter : public edm::stream::EDFilter<> { public: TopDecayChannelFilter(const edm::ParameterSet&); - ~TopDecayChannelFilter() override; private: bool filter(edm::Event&, const edm::EventSetup&) override; @@ -30,26 +29,22 @@ TopDecayChannelFilter::TopDecayChannelFilter(const edm::ParameterSet& cfg) checkedSrcType_(false), useTtGenEvent_(false) {} -template -TopDecayChannelFilter::~TopDecayChannelFilter() {} - template bool TopDecayChannelFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) { - edm::Handle parts; edm::Handle genEvt; if (!checkedSrcType_) { checkedSrcType_ = true; - if (iEvent.getByToken(genEvt_, genEvt)) { + if (genEvt = iEvent.getHandle(genEvt_); genEvt.isValid()) { useTtGenEvent_ = true; return sel_(genEvt->particles(), src_.label()); } } else { if (useTtGenEvent_) { - iEvent.getByToken(genEvt_, genEvt); + genEvt = iEvent.getHandle(genEvt_); return sel_(genEvt->particles(), src_.label()); } } - iEvent.getByToken(parts_, parts); - return sel_(*parts, src_.label()); + const auto& parts = iEvent.get(parts_); + return sel_(parts, src_.label()); } diff --git a/TopQuarkAnalysis/TopSkimming/interface/TtDecayChannelSelector.h b/TopQuarkAnalysis/TopSkimming/interface/TtDecayChannelSelector.h index 81f3fa670f053..3231d4beee2a8 100644 --- a/TopQuarkAnalysis/TopSkimming/interface/TtDecayChannelSelector.h +++ b/TopQuarkAnalysis/TopSkimming/interface/TtDecayChannelSelector.h @@ -1,6 +1,7 @@ #include #include #include +#include #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/HepMCCandidate/interface/GenParticle.h" @@ -14,10 +15,8 @@ class TtDecayChannelSelector { /// std contructor TtDecayChannelSelector(const edm::ParameterSet&); - /// default destructor - ~TtDecayChannelSelector(); /// operator for decay channel selection - bool operator()(const reco::GenParticleCollection& parts, std::string inputType) const; + bool operator()(const reco::GenParticleCollection& parts, std::string_view inputType) const; private: /// return decay channel to select for from configuration @@ -25,9 +24,9 @@ class TtDecayChannelSelector { // return the check sum of all entries unsigned int checkSum(const Decay& vec) const; /// search for particle with pdgId in given listing (for top) - bool search(reco::GenParticleCollection::const_iterator& part, int pdgId, std::string& inputType) const; + bool search(reco::GenParticleCollection::const_iterator& part, int pdgId, std::string_view inputType) const; /// search for particle with pdgId in given listing (for top daughters) - bool search(reco::GenParticle::const_iterator& part, int pdgId, std::string& inputType) const; + bool search(reco::GenParticle::const_iterator& part, int pdgId, std::string_view inputType) const; /// check tau decay to be leptonic, 1-prong or 3-prong bool tauDecay(const reco::Candidate&) const; /// count the number of charged particles for tau decays diff --git a/TopQuarkAnalysis/TopSkimming/src/TtDecayChannelSelector.cc b/TopQuarkAnalysis/TopSkimming/src/TtDecayChannelSelector.cc index ac056ad15ae63..4c2ee0b8a03df 100644 --- a/TopQuarkAnalysis/TopSkimming/src/TtDecayChannelSelector.cc +++ b/TopQuarkAnalysis/TopSkimming/src/TtDecayChannelSelector.cc @@ -56,9 +56,7 @@ TtDecayChannelSelector::TtDecayChannelSelector(const edm::ParameterSet& cfg) } } -TtDecayChannelSelector::~TtDecayChannelSelector() {} - -bool TtDecayChannelSelector::operator()(const reco::GenParticleCollection& parts, std::string inputType) const { +bool TtDecayChannelSelector::operator()(const reco::GenParticleCollection& parts, std::string_view inputType) const { bool verbose = false; // set this to true for debugging and add TtDecayChannelSelector category to the MessageLogger in your cfg file unsigned int iLep = 0; @@ -167,7 +165,7 @@ bool TtDecayChannelSelector::operator()(const reco::GenParticleCollection& parts bool TtDecayChannelSelector::search(reco::GenParticleCollection::const_iterator& part, int pdgId, - std::string& inputType) const { + std::string_view inputType) const { if (inputType == kGenParticles) { return (std::abs(part->pdgId()) == pdgId && part->status() == TopDecayID::unfrag) ? true : false; } else { @@ -175,7 +173,9 @@ bool TtDecayChannelSelector::search(reco::GenParticleCollection::const_iterator& } } -bool TtDecayChannelSelector::search(reco::GenParticle::const_iterator& part, int pdgId, std::string& inputType) const { +bool TtDecayChannelSelector::search(reco::GenParticle::const_iterator& part, + int pdgId, + std::string_view inputType) const { if (inputType == kGenParticles) { return (std::abs(part->pdgId()) == pdgId && part->status() == TopDecayID::unfrag) ? true : false; } else {