diff --git a/CommonTools/ParticleFlow/plugins/TopProjector.h b/CommonTools/ParticleFlow/plugins/TopProjector.h index 2cbb46d0a56a4..1e733d56f076d 100644 --- a/CommonTools/ParticleFlow/plugins/TopProjector.h +++ b/CommonTools/ParticleFlow/plugins/TopProjector.h @@ -8,7 +8,7 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/Event.h" @@ -134,7 +134,7 @@ template < class Top, class Bottom> }; template< class Top, class Bottom, class Matcher = TopProjectorFwdPtrOverlap > -class TopProjector : public edm::EDProducer { +class TopProjector : public edm::stream::EDProducer<> { public: @@ -199,8 +199,8 @@ TopProjector< Top, Bottom, Matcher>::TopProjector(const edm::ParameterSet& iConf template< class Top, class Bottom, class Matcher > -void TopProjector< Top, Bottom, Matcher >::produce(edm::Event& iEvent, - const edm::EventSetup& iSetup) { +void TopProjector< Top, Bottom, Matcher >::produce( edm::Event& iEvent, + const edm::EventSetup& iSetup) { // get the various collections // Access the masking collection diff --git a/CommonTools/RecoAlgos/plugins/JetDeltaRTagInfoValueMapProducer.cc b/CommonTools/RecoAlgos/plugins/JetDeltaRTagInfoValueMapProducer.cc index dd8c126953498..0de879457af18 100644 --- a/CommonTools/RecoAlgos/plugins/JetDeltaRTagInfoValueMapProducer.cc +++ b/CommonTools/RecoAlgos/plugins/JetDeltaRTagInfoValueMapProducer.cc @@ -21,7 +21,7 @@ */ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "DataFormats/JetReco/interface/Jet.h" #include "DataFormats/BTauReco/interface/CATopJetTagInfo.h" @@ -34,7 +34,7 @@ #include "DataFormats/Math/interface/deltaR.h" template < class T, class I > -class JetDeltaRTagInfoValueMapProducer : public edm::EDProducer { +class JetDeltaRTagInfoValueMapProducer : public edm::global::EDProducer<> { public: @@ -57,7 +57,7 @@ class JetDeltaRTagInfoValueMapProducer : public edm::EDProducer { virtual void beginJob() override {} virtual void endJob() override {} - virtual void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override { + virtual void produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const override { std::auto_ptr< TagInfosCollection > mappedTagInfos ( new TagInfosCollection() ); @@ -69,7 +69,7 @@ class JetDeltaRTagInfoValueMapProducer : public edm::EDProducer { edm::Handle< typename edm::View > h_tagInfos; iEvent.getByToken( matchedTagInfosToken_, h_tagInfos ); - double distMax2 = distMax_*distMax_; + const double distMax2 = distMax_*distMax_; std::vector jets2_locks( h_jets2->size(), false ); @@ -126,10 +126,10 @@ class JetDeltaRTagInfoValueMapProducer : public edm::EDProducer { iEvent.put(mappedTagInfos); } - edm::EDGetTokenT< typename edm::View > srcToken_; - edm::EDGetTokenT< typename edm::View > matchedToken_; - edm::EDGetTokenT< typename edm::View > matchedTagInfosToken_; - double distMax_; + const edm::EDGetTokenT< typename edm::View > srcToken_; + const edm::EDGetTokenT< typename edm::View > matchedToken_; + const edm::EDGetTokenT< typename edm::View > matchedTagInfosToken_; + const double distMax_; }; diff --git a/CommonTools/RecoAlgos/plugins/JetDeltaRValueMapProducer.cc b/CommonTools/RecoAlgos/plugins/JetDeltaRValueMapProducer.cc index e8c11762add63..bb58df213db9d 100644 --- a/CommonTools/RecoAlgos/plugins/JetDeltaRValueMapProducer.cc +++ b/CommonTools/RecoAlgos/plugins/JetDeltaRValueMapProducer.cc @@ -16,7 +16,7 @@ */ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "DataFormats/JetReco/interface/Jet.h" #include "DataFormats/JetReco/interface/PFJet.h" @@ -29,7 +29,7 @@ #include "DataFormats/Math/interface/deltaR.h" template < class T > -class JetDeltaRValueMapProducer : public edm::EDProducer { +class JetDeltaRValueMapProducer : public edm::stream::EDProducer<> { public: @@ -47,7 +47,7 @@ class JetDeltaRValueMapProducer : public edm::EDProducer { { if( value_!="" ) { - evaluationMap_.insert( std::make_pair( value_, StringObjectFunction( value_, lazyParser_ ) ) ); + evaluationMap_.insert( std::make_pair( value_, std::unique_ptr >( new StringObjectFunction( value_, lazyParser_ ) ) ) ); produces< JetValueMap >(); } @@ -58,7 +58,7 @@ class JetDeltaRValueMapProducer : public edm::EDProducer { multiValue_ = true; for( size_t i=0; i( values_[i], lazyParser_ ) ) ); + evaluationMap_.insert( std::make_pair( valueLabels_[i], std::unique_ptr >( new StringObjectFunction( values_[i], lazyParser_ ) ) ) ); produces< JetValueMap >(valueLabels_[i]); } } @@ -70,10 +70,7 @@ class JetDeltaRValueMapProducer : public edm::EDProducer { virtual ~JetDeltaRValueMapProducer() {} private: - - virtual void beginJob() override {} - virtual void endJob() override {} - + virtual void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override { edm::Handle< typename edm::View > h_jets1; @@ -121,11 +118,11 @@ class JetDeltaRValueMapProducer : public edm::EDProducer { { jets1_locks.at(matched_index) = true; if( value_!="" ) - values.at(matched_index) = (evaluationMap_.at(value_))(*ijet); + values.at(matched_index) = (*(evaluationMap_.at(value_)))(*ijet); if( multiValue_ ) { for( size_t i=0; i valueLabels_; const bool lazyParser_; bool multiValue_; - std::map > evaluationMap_; + std::map > > evaluationMap_; }; typedef JetDeltaRValueMapProducer RecoJetDeltaRValueMapProducer; diff --git a/CommonTools/RecoUtils/interface/PFCand_AssoMap.h b/CommonTools/RecoUtils/interface/PFCand_AssoMap.h index 61558aba573de..78f5e9488d57d 100644 --- a/CommonTools/RecoUtils/interface/PFCand_AssoMap.h +++ b/CommonTools/RecoUtils/interface/PFCand_AssoMap.h @@ -18,7 +18,7 @@ // #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -34,7 +34,7 @@ // class declaration // -class PFCand_AssoMap : public edm::EDProducer, public PFCand_AssoMapAlgos { +class PFCand_AssoMap : public edm::stream::EDProducer<>, public PFCand_AssoMapAlgos { public: explicit PFCand_AssoMap(const edm::ParameterSet&); ~PFCand_AssoMap(); diff --git a/CommonTools/RecoUtils/interface/PF_PU_AssoMap.h b/CommonTools/RecoUtils/interface/PF_PU_AssoMap.h index 4f577f86cfc17..67e9412a7abd6 100644 --- a/CommonTools/RecoUtils/interface/PF_PU_AssoMap.h +++ b/CommonTools/RecoUtils/interface/PF_PU_AssoMap.h @@ -23,7 +23,7 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -38,7 +38,7 @@ // class declaration // -class PF_PU_AssoMap : public edm::EDProducer, public PF_PU_AssoMapAlgos { +class PF_PU_AssoMap : public edm::stream::EDProducer<>, public PF_PU_AssoMapAlgos { public: explicit PF_PU_AssoMap(const edm::ParameterSet&); ~PF_PU_AssoMap(); diff --git a/CommonTools/UtilAlgos/interface/PhysObjectMatcher.h b/CommonTools/UtilAlgos/interface/PhysObjectMatcher.h index ac00d3137b028..f34225f299d64 100644 --- a/CommonTools/UtilAlgos/interface/PhysObjectMatcher.h +++ b/CommonTools/UtilAlgos/interface/PhysObjectMatcher.h @@ -10,7 +10,7 @@ * (3) the ranking of several matches. * */ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" #include "CommonTools/UtilAlgos/interface/DeltaR.h" @@ -60,7 +60,7 @@ namespace reco { typename C2::value_type>, C1, C2 > > - class PhysObjectMatcher : public edm::EDProducer { + class PhysObjectMatcher : public edm::stream::EDProducer<> { public: PhysObjectMatcher(const edm::ParameterSet & cfg); ~PhysObjectMatcher(); diff --git a/CommonTools/Utils/src/MethodInvoker.cc b/CommonTools/Utils/src/MethodInvoker.cc index be96b3380aed0..6e7ae92d7c4c4 100755 --- a/CommonTools/Utils/src/MethodInvoker.cc +++ b/CommonTools/Utils/src/MethodInvoker.cc @@ -191,13 +191,14 @@ invoker(const edm::TypeWithDict& type) const { //std::cout << "LazyInvoker for " << name_ << " called on type " << // type.qualifiedName() << std::endl; - SingleInvokerPtr& invoker = invokers_[edm::TypeID(type.typeInfo())]; - if (!invoker) { - //std::cout << " Making new invoker for " << name_ << " on type " << - // type.qualifiedName() << std::endl; - invoker.reset(new SingleInvoker(type, name_, argsBeforeFixups_)); + const edm::TypeID thetype(type.typeInfo()); + auto found = invokers_.find(thetype); + if( found != invokers_.cend() ) { + return *(found->second); } - return *invoker; + auto to_add = std::make_shared(type, name_, argsBeforeFixups_); + auto emplace_result = invokers_.insert(std::make_pair(thetype,to_add) ); + return *(emplace_result.first->second); } edm::ObjectWithDict diff --git a/CommonTools/Utils/src/MethodInvoker.h b/CommonTools/Utils/src/MethodInvoker.h index 67b092b328d5e..fd5c622a2606b 100755 --- a/CommonTools/Utils/src/MethodInvoker.h +++ b/CommonTools/Utils/src/MethodInvoker.h @@ -14,6 +14,17 @@ #include #include +#include "tbb/concurrent_unordered_map.h" + +namespace edm { + struct TypeIDHasher { + size_t operator()(TypeID const& tid) const { + tbb::tbb_hash hasher; + return hasher(std::string(tid.name())); + } + }; +} + namespace reco { namespace parser { @@ -88,14 +99,15 @@ struct SingleInvoker : boost::noncopyable { /// Keeps different SingleInvokers for each dynamic type of the objects passed to invoke() struct LazyInvoker { + typedef std::shared_ptr SingleInvokerPtr; + typedef tbb::concurrent_unordered_map InvokerMap; private: // Private Data Members std::string name_; std::vector argsBeforeFixups_; // the shared ptr is only to make the code exception safe // otherwise I think it could leak if the constructor of - // SingleInvoker throws an exception (which can happen) - typedef boost::shared_ptr SingleInvokerPtr; - mutable std::map invokers_; + // SingleInvoker throws an exception (which can happen) + mutable InvokerMap invokers_; private: // Private Function Members const SingleInvoker& invoker(const edm::TypeWithDict&) const; public: // Public Function Members diff --git a/DataFormats/PatCandidates/src/TriggerObjectStandAlone.cc b/DataFormats/PatCandidates/src/TriggerObjectStandAlone.cc index 42eac43ee1102..63ecab20dfbc7 100644 --- a/DataFormats/PatCandidates/src/TriggerObjectStandAlone.cc +++ b/DataFormats/PatCandidates/src/TriggerObjectStandAlone.cc @@ -275,8 +275,8 @@ void TriggerObjectStandAlone::packPathNames(const edm::TriggerNames &names) { for (unsigned int i = 0; i < n; ++i) { uint16_t id = names.triggerIndex(pathNames_[i]); if (id >= end) { - static int _warn = 0; - if (++_warn < 5) std::cerr << "Warning: can't resolve '" << pathNames_[i] << "' to a path index" << std::endl; + static std::atomic _warn(0); + if (++_warn < 5) edm::LogWarning("TriggerObjectStandAlone::packPathNames()") << "Warning: can't resolve '" << pathNames_[i] << "' to a path index" << std::endl; ok = false; break; } else { indices[i] = id; diff --git a/JetMETCorrections/Type1MET/interface/CorrectedMETProducerT.h b/JetMETCorrections/Type1MET/interface/CorrectedMETProducerT.h index e86a420fbfcff..88a431a191420 100644 --- a/JetMETCorrections/Type1MET/interface/CorrectedMETProducerT.h +++ b/JetMETCorrections/Type1MET/interface/CorrectedMETProducerT.h @@ -18,7 +18,7 @@ * */ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -61,7 +61,7 @@ namespace CorrectedMETProducer_namespace } template -class CorrectedMETProducerT : public edm::EDProducer +class CorrectedMETProducerT : public edm::stream::EDProducer<> { typedef std::vector METCollection; @@ -94,7 +94,7 @@ class CorrectedMETProducerT : public edm::EDProducer for ( typename METCollection::const_iterator rawMEt = rawMEtCollection->begin(); rawMEt != rawMEtCollection->end(); ++rawMEt ) { CorrMETData correction = algorithm_->compMETCorrection(evt, es); - + static const CorrectedMETProducer_namespace::CorrectedMETFactoryT correctedMET_factory {}; T correctedMEt = correctedMET_factory(*rawMEt, correction); diff --git a/JetMETCorrections/Type1MET/interface/PFJetMETcorrInputProducerT.h b/JetMETCorrections/Type1MET/interface/PFJetMETcorrInputProducerT.h index e8b596ffb093c..a7ec32d861bab 100644 --- a/JetMETCorrections/Type1MET/interface/PFJetMETcorrInputProducerT.h +++ b/JetMETCorrections/Type1MET/interface/PFJetMETcorrInputProducerT.h @@ -16,7 +16,7 @@ * */ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -68,7 +68,7 @@ namespace PFJetMETcorrInputProducer_namespace } template -class PFJetMETcorrInputProducerT : public edm::EDProducer +class PFJetMETcorrInputProducerT : public edm::stream::EDProducer<> { public: @@ -160,6 +160,7 @@ class PFJetMETcorrInputProducerT : public edm::EDProducer const static PFJetMETcorrInputProducer_namespace::RawJetExtractorT rawJetExtractor {}; reco::Candidate::LorentzVector rawJetP4 = rawJetExtractor(jet); + if ( skipMuons_ ) { const std::vector & cands = jet.daughterPtrVector(); for ( std::vector::const_iterator cand = cands.begin(); diff --git a/JetMETCorrections/Type1MET/plugins/PFCandMETcorrInputProducer.cc b/JetMETCorrections/Type1MET/plugins/PFCandMETcorrInputProducer.cc index c8d55fd26b5ea..88aa2b7e0d7c1 100644 --- a/JetMETCorrections/Type1MET/plugins/PFCandMETcorrInputProducer.cc +++ b/JetMETCorrections/Type1MET/plugins/PFCandMETcorrInputProducer.cc @@ -12,29 +12,25 @@ PFCandMETcorrInputProducer::PFCandMETcorrInputProducer(const edm::ParameterSet& vParameterSet cfgBinning = cfg.getParameter("binning"); for ( vParameterSet::const_iterator cfgBinningEntry = cfgBinning.begin(); cfgBinningEntry != cfgBinning.end(); ++cfgBinningEntry ) { - binning_.push_back(new binningEntryType(*cfgBinningEntry)); + binning_.emplace_back(new binningEntryType(*cfgBinningEntry)); } } else { - binning_.push_back(new binningEntryType()); + binning_.emplace_back(new binningEntryType()); } - for ( std::vector::const_iterator binningEntry = binning_.begin(); + for ( auto binningEntry = binning_.begin(); binningEntry != binning_.end(); ++binningEntry ) { produces((*binningEntry)->binLabel_); } } PFCandMETcorrInputProducer::~PFCandMETcorrInputProducer() -{ - for ( std::vector::const_iterator it = binning_.begin(); - it != binning_.end(); ++it ) { - delete (*it); - } +{ } void PFCandMETcorrInputProducer::produce(edm::Event& evt, const edm::EventSetup& es) { - for ( std::vector::iterator binningEntry = binning_.begin(); + for ( auto binningEntry = binning_.begin(); binningEntry != binning_.end(); ++binningEntry ) { (*binningEntry)->binUnclEnergySum_ = CorrMETData(); } @@ -45,7 +41,7 @@ void PFCandMETcorrInputProducer::produce(edm::Event& evt, const edm::EventSetup& for ( edm::View::const_iterator cand = cands->begin(); cand != cands->end(); ++cand ) { - for ( std::vector::iterator binningEntry = binning_.begin(); + for ( auto binningEntry = binning_.begin(); binningEntry != binning_.end(); ++binningEntry ) { if ( !(*binningEntry)->binSelection_ || (*(*binningEntry)->binSelection_)(cand->p4()) ) { (*binningEntry)->binUnclEnergySum_.mex += cand->px(); @@ -56,8 +52,8 @@ void PFCandMETcorrInputProducer::produce(edm::Event& evt, const edm::EventSetup& } //--- add momentum sum of PFCandidates not within jets ("unclustered energy") to the event - for ( std::vector::const_iterator binningEntry = binning_.begin(); - binningEntry != binning_.end(); ++binningEntry ) { + for ( auto binningEntry = binning_.cbegin(); + binningEntry != binning_.cend(); ++binningEntry ) { evt.put(std::auto_ptr(new CorrMETData((*binningEntry)->binUnclEnergySum_)), (*binningEntry)->binLabel_); } } diff --git a/JetMETCorrections/Type1MET/plugins/PFCandMETcorrInputProducer.h b/JetMETCorrections/Type1MET/plugins/PFCandMETcorrInputProducer.h index 718055b566b07..f6a401e03c9e5 100644 --- a/JetMETCorrections/Type1MET/plugins/PFCandMETcorrInputProducer.h +++ b/JetMETCorrections/Type1MET/plugins/PFCandMETcorrInputProducer.h @@ -46,21 +46,20 @@ class PFCandMETcorrInputProducer : public edm::stream::EDProducer<> { binningEntryType() : binLabel_(""), - binSelection_(0) + binSelection_(nullptr) {} binningEntryType(const edm::ParameterSet& cfg) : binLabel_(cfg.getParameter("binLabel")), binSelection_(new StringCutObjectSelector(cfg.getParameter("binSelection"))) {} ~binningEntryType() - { - delete binSelection_; + { } - std::string binLabel_; - StringCutObjectSelector* binSelection_; + const std::string binLabel_; + std::unique_ptr > binSelection_; CorrMETData binUnclEnergySum_; }; - std::vector binning_; + std::vector > binning_; }; #endif diff --git a/PhysicsTools/HepMCCandAlgos/plugins/GenParticlePruner.cc b/PhysicsTools/HepMCCandAlgos/plugins/GenParticlePruner.cc index 413785e68fadb..d1918349112a0 100644 --- a/PhysicsTools/HepMCCandAlgos/plugins/GenParticlePruner.cc +++ b/PhysicsTools/HepMCCandAlgos/plugins/GenParticlePruner.cc @@ -1,4 +1,4 @@ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Utilities/interface/InputTag.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/Event.h" @@ -19,7 +19,7 @@ namespace helper { }; } -class GenParticlePruner : public edm::EDProducer { +class GenParticlePruner : public edm::stream::EDProducer<> { public: GenParticlePruner(const edm::ParameterSet&); private: diff --git a/PhysicsTools/IsolationAlgos/plugins/CITKPFIsolationSumProducer.cc b/PhysicsTools/IsolationAlgos/plugins/CITKPFIsolationSumProducer.cc index 80b0c400fbab7..c1b69fd4d31a0 100644 --- a/PhysicsTools/IsolationAlgos/plugins/CITKPFIsolationSumProducer.cc +++ b/PhysicsTools/IsolationAlgos/plugins/CITKPFIsolationSumProducer.cc @@ -1,7 +1,7 @@ #ifndef PhysicsTools_IsolationAlgos_CITKIsolationSumProducer_H #define PhysicsTools_IsolationAlgos_CITKIsolationSumProducer_H -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -29,7 +29,7 @@ namespace edm { class Event; } namespace edm { class EventSetup; } namespace citk { - class PFIsolationSumProducer : public edm::EDProducer { + class PFIsolationSumProducer : public edm::stream::EDProducer<> { public: PFIsolationSumProducer(const edm::ParameterSet&); diff --git a/PhysicsTools/JetCharge/plugins/JetChargeProducer.cc b/PhysicsTools/JetCharge/plugins/JetChargeProducer.cc index ada9c30d0325a..91457853b990a 100644 --- a/PhysicsTools/JetCharge/plugins/JetChargeProducer.cc +++ b/PhysicsTools/JetCharge/plugins/JetChargeProducer.cc @@ -6,7 +6,7 @@ algo_(cfg) { produces(); } -void JetChargeProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) { +void JetChargeProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const { edm::Handle hJTAs; iEvent.getByToken(srcToken_, hJTAs); typedef reco::JetTracksAssociationCollection::const_iterator IT; diff --git a/PhysicsTools/JetCharge/plugins/JetChargeProducer.h b/PhysicsTools/JetCharge/plugins/JetChargeProducer.h index a95562155fe65..2f9a660801bd9 100755 --- a/PhysicsTools/JetCharge/plugins/JetChargeProducer.h +++ b/PhysicsTools/JetCharge/plugins/JetChargeProducer.h @@ -1,5 +1,5 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" @@ -10,15 +10,15 @@ #include "PhysicsTools/JetCharge/interface/JetCharge.h" -class JetChargeProducer : public edm::EDProducer { +class JetChargeProducer : public edm::global::EDProducer<> { public: typedef reco::JetFloatAssociation::Container JetChargeCollection; explicit JetChargeProducer(const edm::ParameterSet &cfg) ; - virtual void produce(edm::Event&, const edm::EventSetup&); + virtual void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const; private: - edm::EDGetTokenT srcToken_; - JetCharge algo_; + const edm::EDGetTokenT srcToken_; + const JetCharge algo_; }; diff --git a/PhysicsTools/JetMCAlgos/plugins/HadronAndPartonSelector.cc b/PhysicsTools/JetMCAlgos/plugins/HadronAndPartonSelector.cc index a701029f968ea..a77fd8797b4a4 100644 --- a/PhysicsTools/JetMCAlgos/plugins/HadronAndPartonSelector.cc +++ b/PhysicsTools/JetMCAlgos/plugins/HadronAndPartonSelector.cc @@ -46,7 +46,7 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -76,7 +76,7 @@ typedef boost::shared_ptr PartonSelectorPtr; // class declaration // -class HadronAndPartonSelector : public edm::EDProducer { +class HadronAndPartonSelector : public edm::stream::EDProducer<> { public: explicit HadronAndPartonSelector(const edm::ParameterSet&); ~HadronAndPartonSelector(); @@ -84,15 +84,8 @@ class HadronAndPartonSelector : public edm::EDProducer { static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: - virtual void beginJob() ; virtual void produce(edm::Event&, const edm::EventSetup&); - virtual void endJob() ; - - virtual void beginRun(edm::Run&, edm::EventSetup const&); - virtual void endRun(edm::Run&, edm::EventSetup const&); - virtual void beginLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&); - virtual void endLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&); - + // ----------member data --------------------------- const edm::EDGetTokenT srcToken_; // To get handronizer module type const edm::EDGetTokenT particlesToken_; // Input GenParticle collection @@ -268,41 +261,6 @@ HadronAndPartonSelector::produce(edm::Event& iEvent, const edm::EventSetup& iSet iEvent.put( leptons, "leptons" ); } -// ------------ method called once each job just before starting event loop ------------ -void -HadronAndPartonSelector::beginJob() -{ -} - -// ------------ method called once each job just after ending the event loop ------------ -void -HadronAndPartonSelector::endJob() { -} - -// ------------ method called when starting to processes a run ------------ -void -HadronAndPartonSelector::beginRun(edm::Run&, edm::EventSetup const&) -{ -} - -// ------------ method called when ending the processing of a run ------------ -void -HadronAndPartonSelector::endRun(edm::Run&, edm::EventSetup const&) -{ -} - -// ------------ method called when starting to processes a luminosity block ------------ -void -HadronAndPartonSelector::beginLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&) -{ -} - -// ------------ method called when ending the processing of a luminosity block ------------ -void -HadronAndPartonSelector::endLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&) -{ -} - // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void HadronAndPartonSelector::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { diff --git a/PhysicsTools/JetMCAlgos/plugins/JetFlavourClustering.cc b/PhysicsTools/JetMCAlgos/plugins/JetFlavourClustering.cc index 97c65dc976aaa..24b87cd88e102 100644 --- a/PhysicsTools/JetMCAlgos/plugins/JetFlavourClustering.cc +++ b/PhysicsTools/JetMCAlgos/plugins/JetFlavourClustering.cc @@ -79,7 +79,7 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -136,7 +136,7 @@ class GhostInfo : public fastjet::PseudoJet::UserInfoBase{ int m_type; }; -class JetFlavourClustering : public edm::EDProducer { +class JetFlavourClustering : public edm::stream::EDProducer<> { public: explicit JetFlavourClustering(const edm::ParameterSet&); ~JetFlavourClustering(); @@ -144,15 +144,8 @@ class JetFlavourClustering : public edm::EDProducer { static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: - virtual void beginJob() ; virtual void produce(edm::Event&, const edm::EventSetup&); - virtual void endJob() ; - - virtual void beginRun(edm::Run&, edm::EventSetup const&); - virtual void endRun(edm::Run&, edm::EventSetup const&); - virtual void beginLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&); - virtual void endLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&); - + void insertGhosts(const edm::Handle& particles, const double ghostRescaling, const bool isHadron, const bool isbHadron, const bool isParton, const bool isLepton, @@ -715,41 +708,6 @@ JetFlavourClustering::assignToSubjets(const reco::GenParticleRefVector& clustere } } -// ------------ method called once each job just before starting event loop ------------ -void -JetFlavourClustering::beginJob() -{ -} - -// ------------ method called once each job just after ending the event loop ------------ -void -JetFlavourClustering::endJob() { -} - -// ------------ method called when starting to processes a run ------------ -void -JetFlavourClustering::beginRun(edm::Run&, edm::EventSetup const&) -{ -} - -// ------------ method called when ending the processing of a run ------------ -void -JetFlavourClustering::endRun(edm::Run&, edm::EventSetup const&) -{ -} - -// ------------ method called when starting to processes a luminosity block ------------ -void -JetFlavourClustering::beginLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&) -{ -} - -// ------------ method called when ending the processing of a luminosity block ------------ -void -JetFlavourClustering::endLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&) -{ -} - // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void JetFlavourClustering::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { diff --git a/PhysicsTools/JetMCAlgos/plugins/TauGenJetProducer.cc b/PhysicsTools/JetMCAlgos/plugins/TauGenJetProducer.cc index 3a3f27c772f4c..d5ea635dba3ce 100644 --- a/PhysicsTools/JetMCAlgos/plugins/TauGenJetProducer.cc +++ b/PhysicsTools/JetMCAlgos/plugins/TauGenJetProducer.cc @@ -16,26 +16,21 @@ using namespace std; using namespace edm; using namespace reco; -TauGenJetProducer::TauGenJetProducer(const edm::ParameterSet& iConfig) +TauGenJetProducer::TauGenJetProducer(const edm::ParameterSet& iConfig) : + inputTagGenParticles_(iConfig.getParameter("GenParticles")), + tokenGenParticles_(consumes(inputTagGenParticles_)), + includeNeutrinos_(iConfig.getParameter("includeNeutrinos")), + verbose_(iConfig.getUntrackedParameter("verbose",false)) { - inputTagGenParticles_ - = iConfig.getParameter("GenParticles"); - tokenGenParticles_ - = consumes(inputTagGenParticles_); - - includeNeutrinos_ - = iConfig.getParameter("includeNeutrinos"); - - verbose_ = - iConfig.getUntrackedParameter("verbose",false); + produces(); } TauGenJetProducer::~TauGenJetProducer() { } -void TauGenJetProducer::produce(Event& iEvent, - const EventSetup& iSetup) { +void TauGenJetProducer::produce(edm::StreamID, Event& iEvent, + const EventSetup& iSetup) const { Handle genParticles; diff --git a/PhysicsTools/JetMCAlgos/plugins/TauGenJetProducer.h b/PhysicsTools/JetMCAlgos/plugins/TauGenJetProducer.h index 3a58768b15224..968a5a8cd16c2 100644 --- a/PhysicsTools/JetMCAlgos/plugins/TauGenJetProducer.h +++ b/PhysicsTools/JetMCAlgos/plugins/TauGenJetProducer.h @@ -22,26 +22,26 @@ \author Colin Bernet \date february 2008 */ -class TauGenJetProducer : public edm::EDProducer { +class TauGenJetProducer : public edm::global::EDProducer<> { public: explicit TauGenJetProducer(const edm::ParameterSet&); ~TauGenJetProducer(); - virtual void produce(edm::Event&, const edm::EventSetup&) override; + virtual void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; private: /// Input PFCandidates - edm::InputTag inputTagGenParticles_; - edm::EDGetTokenT tokenGenParticles_; + const edm::InputTag inputTagGenParticles_; + const edm::EDGetTokenT tokenGenParticles_; /// if yes, neutrinos will be included, for debug purposes - bool includeNeutrinos_; + const bool includeNeutrinos_; /// verbose ? - bool verbose_; + const bool verbose_; }; diff --git a/PhysicsTools/PatAlgos/interface/EfficiencyLoader.h b/PhysicsTools/PatAlgos/interface/EfficiencyLoader.h index cd101355baa57..9da8a566415a2 100644 --- a/PhysicsTools/PatAlgos/interface/EfficiencyLoader.h +++ b/PhysicsTools/PatAlgos/interface/EfficiencyLoader.h @@ -25,7 +25,7 @@ class EfficiencyLoader { bool enabled() const { return !names_.empty(); } /// To be called for each new event, reads in the ValueMaps for efficiencies - void newEvent(const edm::Event &event) const ; + void newEvent(const edm::Event &event); /// Sets the efficiencies for this object, using the reference to the original objects template @@ -34,7 +34,7 @@ class EfficiencyLoader { private: std::vector names_; std::vector > > tokens_; - mutable std::vector > > handles_; + std::vector > > handles_; }; // class template diff --git a/PhysicsTools/PatAlgos/interface/KinResolutionsLoader.h b/PhysicsTools/PatAlgos/interface/KinResolutionsLoader.h index b1e628c5df9ae..92ed383e2981a 100644 --- a/PhysicsTools/PatAlgos/interface/KinResolutionsLoader.h +++ b/PhysicsTools/PatAlgos/interface/KinResolutionsLoader.h @@ -27,7 +27,7 @@ class KinResolutionsLoader { bool enabled() const { return !patlabels_.empty(); } /// To be called for each new event, reads in the EventSetup object - void newEvent(const edm::Event &event, const edm::EventSetup &setup) const ; + void newEvent(const edm::Event &event, const edm::EventSetup &setup); /// Sets the efficiencies for this object, using the reference to the original objects template @@ -41,7 +41,7 @@ class KinResolutionsLoader { /// Labels of the KinematicResolutionProvider in the EventSetup std::vector eslabels_; /// Handles to the EventSetup - mutable std::vector > handles_; + std::vector > handles_; }; // class template diff --git a/PhysicsTools/PatAlgos/plugins/CandidateSummaryTable.cc b/PhysicsTools/PatAlgos/plugins/CandidateSummaryTable.cc index b89fd997b523a..eefbcc71b818d 100644 --- a/PhysicsTools/PatAlgos/plugins/CandidateSummaryTable.cc +++ b/PhysicsTools/PatAlgos/plugins/CandidateSummaryTable.cc @@ -12,65 +12,89 @@ */ -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/stream/EDAnalyzer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include +#include #include "DataFormats/Common/interface/View.h" #include "DataFormats/Candidate/interface/Candidate.h" -namespace pat { - class CandidateSummaryTable : public edm::EDAnalyzer { - public: - explicit CandidateSummaryTable(const edm::ParameterSet & iConfig); - ~CandidateSummaryTable(); - - virtual void analyze(const edm::Event & iEvent, const edm::EventSetup& iSetup) override; - virtual void endJob() override; - - private: - struct Record { - edm::InputTag src; - edm::EDGetTokenT > srcToken; - size_t present, empty, min, max, total; - Record(edm::InputTag tag, edm::ConsumesCollector && iC) : src(tag), srcToken(iC.consumes >(tag)), present(0), empty(0), min(0), max(0), total(0) {} - - void update(const edm::View &items) { - present++; - size_t size = items.size(); - if (size == 0) { - empty++; - } else { - if (min > size) min = size; - if (max < size) max = size; - } - total += size; - } - }; - std::vector collections_; - size_t totalEvents_; - bool perEvent_, perJob_; - std::string self_, logName_; - bool dumpItems_; +namespace pathelpers { + struct Record { + const edm::InputTag src; + mutable std::atomic present, empty, min, max, total; + Record(const edm::InputTag& tag) : src(tag), present(0), empty(0), min(0), max(0), total(0) {} + Record(const Record& other) : src(other.src), + present(other.present.load()), + empty(other.empty.load()), + min(other.min.load()), + max(other.max.load()), + total(other.total.load()) {} + void update(const edm::View &items) const { + present++; + const size_t size = items.size(); + if (size == 0) { + empty++; + } else { + auto previousMin = min.load(); + while( previousMin > size and not min.compare_exchange_weak(previousMin, size) ) {} + auto previousMax = max.load(); + while( previousMax < size and not max.compare_exchange_weak(previousMax, size) ) {} + } + total += size; + } }; + struct RecordCache { + RecordCache(const edm::ParameterSet& iConfig) : + perEvent_(iConfig.getUntrackedParameter("perEvent", false)), + perJob_(iConfig.getUntrackedParameter("perJob", true)), + self_(iConfig.getParameter("@module_label")), + logName_(iConfig.getUntrackedParameter("logName")), + dumpItems_(iConfig.getUntrackedParameter("dumpItems", false)), + totalEvents_(0) { + const std::vector& tags = iConfig.getParameter >("candidates"); + for( const auto& tag : tags ) { + collections_.emplace_back( tag ); + } + } + const bool perEvent_, perJob_; + const std::string self_, logName_; + const bool dumpItems_; + mutable std::atomic totalEvents_; + std::vector collections_; // size of vector is never altered later! (atomics are in the class below) + }; + +} + +namespace pat { + class CandidateSummaryTable : public edm::stream::EDAnalyzer > { + public: + explicit CandidateSummaryTable(const edm::ParameterSet & iConfig, const pathelpers::RecordCache*); + ~CandidateSummaryTable(); + + static std::unique_ptr initializeGlobalCache(edm::ParameterSet const& conf) { + return std::unique_ptr(new pathelpers::RecordCache(conf)); + } + + virtual void analyze(const edm::Event & iEvent, const edm::EventSetup& iSetup) override; + + static void globalEndJob(const pathelpers::RecordCache*); + + private: + std::vector > > > srcTokens; + }; } // namespace -pat::CandidateSummaryTable::CandidateSummaryTable(const edm::ParameterSet & iConfig) : - totalEvents_(0), - perEvent_(iConfig.getUntrackedParameter("perEvent", false)), - perJob_(iConfig.getUntrackedParameter("perJob", true)), - self_(iConfig.getParameter("@module_label")), - logName_(iConfig.getUntrackedParameter("logName")), - dumpItems_(iConfig.getUntrackedParameter("dumpItems", false)) -{ - std::vector inputs = iConfig.getParameter >("candidates"); - for (std::vector::const_iterator it = inputs.begin(); it != inputs.end(); ++it) { - collections_.push_back(Record(*it, consumesCollector())); +pat::CandidateSummaryTable::CandidateSummaryTable(const edm::ParameterSet & iConfig, const pathelpers::RecordCache*) { + const std::vector& inputs = iConfig.getParameter >("candidates"); + for (std::vector::const_iterator it = inputs.begin(); it != inputs.end(); ++it) { + srcTokens.emplace_back(*it, consumes >(*it)); } } @@ -83,17 +107,20 @@ pat::CandidateSummaryTable::analyze(const edm::Event & iEvent, const edm::EventS using std::setw; using std::left; using std::right; using std::setprecision; Handle > candidates; - if (perEvent_) { - LogInfo(logName_) << "Per Event Table " << logName_ << - " (" << self_ << ", run:event " << iEvent.id().run() << ":" << iEvent.id().event() << ")"; + if (globalCache()->perEvent_) { + LogInfo(globalCache()->logName_) << "Per Event Table " << globalCache()->logName_ + << " (" << globalCache()->self_ << ", run:event " + << iEvent.id().run() << ":" << iEvent.id().event() << ")"; } - totalEvents_++; - for (std::vector::iterator it = collections_.begin(), ed = collections_.end(); it != ed; ++it) { - iEvent.getByToken(it->srcToken, candidates); + ++(globalCache()->totalEvents_); + auto& collections = globalCache()->collections_; + auto tags = srcTokens.cbegin(); + for (auto it = collections.begin(), ed = collections.end(); it != ed; ++it, ++tags) { + iEvent.getByToken(tags->second, candidates); if (!candidates.failedToGet()) it->update(*candidates); - if (perEvent_) { - LogVerbatim(logName_) << " " << setw(30) << left << it->src.encode() << right; - if (dumpItems_) { + if (globalCache()->perEvent_) { + LogVerbatim(globalCache()->logName_) << " " << setw(30) << left << it->src.encode() << right; + if (globalCache()->dumpItems_) { size_t i = 0; std::ostringstream oss; for (View::const_iterator cand = candidates->begin(), endc = candidates->end(); cand != endc; ++cand, ++i) { @@ -107,31 +134,31 @@ pat::CandidateSummaryTable::analyze(const edm::Event & iEvent, const edm::EventS " id " << setw(7) << cand->pdgId() << " st " << setw(7) << cand->status() << "\n"; } - LogVerbatim(logName_) << oss.str(); + LogVerbatim(globalCache()->logName_) << oss.str(); } } } - if (perEvent_) LogInfo(logName_) << "" ; // add an empty line + if (globalCache()->perEvent_) LogInfo(globalCache()->logName_) << "" ; // add an empty line } void -pat::CandidateSummaryTable::endJob() { +pat::CandidateSummaryTable::globalEndJob(const pathelpers::RecordCache* rcd) { using std::setw; using std::left; using std::right; using std::setprecision; - if (perJob_) { + if (rcd->perJob_) { std::ostringstream oss; - oss << "Summary Table " << logName_ << " (" << self_ << ", events total " << totalEvents_ << ")\n"; - for (std::vector::iterator it = collections_.begin(), ed = collections_.end(); it != ed; ++it) { + oss << "Summary Table " << rcd->logName_ << " (" << rcd->self_ << ", events total " << rcd->totalEvents_ << ")\n"; + for (auto it = rcd->collections_.cbegin(), ed = rcd->collections_.cend(); it != ed; ++it) { oss << " " << setw(30) << left << it->src.encode() << right << - " present " << setw(7) << it->present << " (" << setw(4) << setprecision(3) << (it->present*100.0/totalEvents_) << "%)" << - " empty " << setw(7) << it->empty << " (" << setw(4) << setprecision(3) << (it->empty*100.0/totalEvents_) << "%)" << + " present " << setw(7) << it->present << " (" << setw(4) << setprecision(3) << (it->present*100.0/rcd->totalEvents_) << "%)" << + " empty " << setw(7) << it->empty << " (" << setw(4) << setprecision(3) << (it->empty*100.0/rcd->totalEvents_) << "%)" << " min " << setw(7) << it->min << " max " << setw(7) << it->max << " total " << setw(7) << it->total << - " avg " << setw(5) << setprecision(3) << (it->total/double(totalEvents_)) << "\n"; + " avg " << setw(5) << setprecision(3) << (it->total/double(rcd->totalEvents_)) << "\n"; } oss << "\n"; - edm::LogVerbatim(logName_) << oss.str(); + edm::LogVerbatim(rcd->logName_) << oss.str(); } } diff --git a/PhysicsTools/PatAlgos/plugins/DuplicatedElectronCleaner.cc b/PhysicsTools/PatAlgos/plugins/DuplicatedElectronCleaner.cc index 498a9fbdee45f..e2b428699e8a4 100644 --- a/PhysicsTools/PatAlgos/plugins/DuplicatedElectronCleaner.cc +++ b/PhysicsTools/PatAlgos/plugins/DuplicatedElectronCleaner.cc @@ -18,7 +18,7 @@ */ #include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/Utilities/interface/InputTag.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" //#include "DataFormats/Common/interface/RefVector.h" @@ -30,23 +30,23 @@ #include "PhysicsTools/PatUtils/interface/DuplicatedElectronRemover.h" namespace pat{ - class DuplicatedElectronCleaner : public edm::EDProducer{ + class DuplicatedElectronCleaner : public edm::global::EDProducer<> { public: explicit DuplicatedElectronCleaner(const edm::ParameterSet & iConfig); ~DuplicatedElectronCleaner(); - virtual void produce(edm::Event & iEvent, const edm::EventSetup& iSetup) override; - virtual void endJob() override; + virtual void produce(edm::StreamID, edm::Event & iEvent, const edm::EventSetup& iSetup) const override final; private: - edm::EDGetTokenT > electronSrcToken_; - pat::DuplicatedElectronRemover duplicateRemover_; - uint64_t try_, pass_; + const edm::EDGetTokenT > electronSrcToken_; + const pat::DuplicatedElectronRemover duplicateRemover_; + mutable std::atomic try_, pass_; }; } // namespace pat::DuplicatedElectronCleaner::DuplicatedElectronCleaner(const edm::ParameterSet & iConfig): electronSrcToken_(consumes >(iConfig.getParameter("electronSource"))), + duplicateRemover_(), try_(0), pass_(0) { //produces >(); @@ -59,7 +59,7 @@ pat::DuplicatedElectronCleaner::~DuplicatedElectronCleaner() } void -pat::DuplicatedElectronCleaner::produce(edm::Event & iEvent, const edm::EventSetup & iSetup) +pat::DuplicatedElectronCleaner::produce(edm::StreamID, edm::Event & iEvent, const edm::EventSetup & iSetup) const { using namespace edm; Handle > electrons; @@ -83,11 +83,6 @@ pat::DuplicatedElectronCleaner::produce(edm::Event & iEvent, const edm::EventSet iEvent.put(result); } -void -pat::DuplicatedElectronCleaner::endJob() -{ -} - #include "FWCore/Framework/interface/MakerMacros.h" using pat::DuplicatedElectronCleaner; DEFINE_FWK_MODULE(DuplicatedElectronCleaner); diff --git a/PhysicsTools/PatAlgos/plugins/JetCorrFactorsProducer.cc b/PhysicsTools/PatAlgos/plugins/JetCorrFactorsProducer.cc index c1df1092cba54..861149705f916 100644 --- a/PhysicsTools/PatAlgos/plugins/JetCorrFactorsProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/JetCorrFactorsProducer.cc @@ -148,7 +148,7 @@ JetCorrFactorsProducer::params(const JetCorrectorParametersCollection& parameter float JetCorrFactorsProducer::evaluate(edm::View::const_iterator& jet, const JetCorrFactors::Flavor& flavor, int level) { - std::shared_ptr& corrector = correctors_.find(flavor)->second; + std::unique_ptr& corrector = correctors_.find(flavor)->second; // add parameters for JPT corrections const reco::JPTJet* jpt = dynamic_cast( &*jet ); if( jpt ){ @@ -200,11 +200,11 @@ JetCorrFactorsProducer::produce(edm::Event& event, const edm::EventSetup& setup) setup.get().get(payload(), parameters); // initialize jet correctors for(FlavorCorrLevelMap::const_iterator flavor=levels_.begin(); flavor!=levels_.end(); ++flavor){ - correctors_[flavor->first] = std::shared_ptr( new FactorizedJetCorrector(params(*parameters, flavor->second)) ); + correctors_[flavor->first].reset( new FactorizedJetCorrector(params(*parameters, flavor->second)) ); } // initialize extra jet corrector for jpt if needed if(!extraJPTOffset_.empty()){ - extraJPTOffsetCorrector_ = std::shared_ptr( new FactorizedJetCorrector(params(*parameters, extraJPTOffset_)) ); + extraJPTOffsetCorrector_.reset( new FactorizedJetCorrector(params(*parameters, extraJPTOffset_)) ); } cacheId_ = rec.cacheIdentifier(); } diff --git a/PhysicsTools/PatAlgos/plugins/JetCorrFactorsProducer.h b/PhysicsTools/PatAlgos/plugins/JetCorrFactorsProducer.h index 8101c639c4a4a..f9b40630e4df7 100644 --- a/PhysicsTools/PatAlgos/plugins/JetCorrFactorsProducer.h +++ b/PhysicsTools/PatAlgos/plugins/JetCorrFactorsProducer.h @@ -45,7 +45,7 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Utilities/interface/InputTag.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/Common/interface/ValueMap.h" @@ -56,7 +56,7 @@ namespace pat { - class JetCorrFactorsProducer : public edm::EDProducer { + class JetCorrFactorsProducer : public edm::stream::EDProducer<> { public: /// value map for JetCorrFactors (to be written into the event) typedef edm::ValueMap JetCorrFactorsMap; @@ -126,9 +126,9 @@ namespace pat { /// cache identifier for JetCorrectionsRecord unsigned long long cacheId_; /// cache container for jet corrections - std::map > correctors_; + std::map > correctors_; /// cache container for JPTOffset jet corrections - std::shared_ptr extraJPTOffsetCorrector_; + std::unique_ptr extraJPTOffsetCorrector_; }; inline int diff --git a/PhysicsTools/PatAlgos/plugins/PATCleaner.h b/PhysicsTools/PatAlgos/plugins/PATCleaner.h index 0c382b3f10716..b5a42ac48741b 100644 --- a/PhysicsTools/PatAlgos/plugins/PATCleaner.h +++ b/PhysicsTools/PatAlgos/plugins/PATCleaner.h @@ -14,7 +14,7 @@ */ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" @@ -32,30 +32,29 @@ #include "DataFormats/PatCandidates/interface/PFParticle.h" #include "PhysicsTools/PatAlgos/interface/OverlapTest.h" -#include +#include +#include namespace pat { template - class PATCleaner : public edm::EDProducer { + class PATCleaner : public edm::stream::EDProducer<> { public: explicit PATCleaner(const edm::ParameterSet & iConfig); virtual ~PATCleaner() {} - virtual void produce(edm::Event & iEvent, const edm::EventSetup& iSetup) override; + virtual void produce(edm::Event & iEvent, const edm::EventSetup& iSetup) override final; private: typedef StringCutObjectSelector Selector; - edm::InputTag src_; - edm::EDGetTokenT > srcToken_; - bool doPreselection_, doFinalCut_; - Selector preselectionCut_; - Selector finalCut_; + const edm::InputTag src_; + const edm::EDGetTokenT > srcToken_; + const Selector preselectionCut_; + const Selector finalCut_; typedef pat::helper::OverlapTest OverlapTest; - // make a list of overlap tests (ptr_vector instead of std::vector because they're polymorphic) - boost::ptr_vector overlapTests_; + std::vector > overlapTests_; }; } // namespace @@ -81,9 +80,9 @@ pat::PATCleaner::PATCleaner(const edm::ParameterSet & iConfig) : std::string algorithm = cfg.getParameter("algorithm"); // create the appropriate OverlapTest if (algorithm == "byDeltaR") { - overlapTests_.push_back(new pat::helper::BasicOverlapTest(*itn, cfg, consumesCollector())); + overlapTests_.emplace_back(new pat::helper::BasicOverlapTest(*itn, cfg, consumesCollector())); } else if (algorithm == "bySuperClusterSeed") { - overlapTests_.push_back(new pat::helper::OverlapBySuperClusterSeed(*itn, cfg, consumesCollector())); + overlapTests_.emplace_back(new pat::helper::OverlapBySuperClusterSeed(*itn, cfg, consumesCollector())); } else { throw cms::Exception("Configuration") << "PATCleaner for " << src_ << ": unsupported algorithm '" << algorithm << "'\n"; } @@ -105,7 +104,7 @@ pat::PATCleaner::produce(edm::Event & iEvent, const edm::EventSetup std::auto_ptr< std::vector > output(new std::vector()); // initialize the overlap tests - for (boost::ptr_vector::iterator itov = overlapTests_.begin(), edov = overlapTests_.end(); itov != edov; ++itov) { + for (auto& itov : overlapTests_) { itov->readInput(iEvent,iSetup); } @@ -120,7 +119,7 @@ pat::PATCleaner::produce(edm::Event & iEvent, const edm::EventSetup // Look for overlaps bool badForOverlap = false; - for (boost::ptr_vector::iterator itov = overlapTests_.begin(), edov = overlapTests_.end(); itov != edov; ++itov) { + for (auto& itov : overlapTests_) { reco::CandidatePtrVector overlaps; bool hasOverlap = itov->fillOverlapsForItem(obj, overlaps); if (hasOverlap && itov->requireNoOverlaps()) { diff --git a/PhysicsTools/PatAlgos/plugins/PATCompositeCandidateProducer.cc b/PhysicsTools/PatAlgos/plugins/PATCompositeCandidateProducer.cc index e6291a1ac5d36..880efccac9223 100755 --- a/PhysicsTools/PatAlgos/plugins/PATCompositeCandidateProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATCompositeCandidateProducer.cc @@ -18,29 +18,23 @@ using namespace std; using namespace edm; PATCompositeCandidateProducer::PATCompositeCandidateProducer(const ParameterSet & iConfig) : - userDataHelper_( iConfig.getParameter("userData"), consumesCollector() ) + srcToken_(consumes >(iConfig.getParameter( "src" ))), + useUserData_(iConfig.exists("userData")), + userDataHelper_( iConfig.getParameter("userData"), consumesCollector() ), + addEfficiencies_(iConfig.getParameter("addEfficiencies")), + addResolutions_(iConfig.getParameter("addResolutions")) { - // initialize the configurables - srcToken_ = consumes >(iConfig.getParameter( "src" )); - - useUserData_ = false; - if ( iConfig.exists("userData") ) { - useUserData_ = true; - } - + // Efficiency configurables - addEfficiencies_ = iConfig.getParameter("addEfficiencies"); if (addEfficiencies_) { efficiencyLoader_ = pat::helper::EfficiencyLoader(iConfig.getParameter("efficiencies"), consumesCollector()); } // Resolution configurables - addResolutions_ = iConfig.getParameter("addResolutions"); if (addResolutions_) { resolutionLoader_ = pat::helper::KinResolutionsLoader(iConfig.getParameter("resolutions")); } - - + // produces vector of particles produces >(); diff --git a/PhysicsTools/PatAlgos/plugins/PATCompositeCandidateProducer.h b/PhysicsTools/PatAlgos/plugins/PATCompositeCandidateProducer.h index 2127b2c36329d..e0f727855ea5b 100644 --- a/PhysicsTools/PatAlgos/plugins/PATCompositeCandidateProducer.h +++ b/PhysicsTools/PatAlgos/plugins/PATCompositeCandidateProducer.h @@ -16,7 +16,7 @@ */ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -37,7 +37,7 @@ namespace pat { - class PATCompositeCandidateProducer : public edm::EDProducer { + class PATCompositeCandidateProducer : public edm::stream::EDProducer<> { public: @@ -49,15 +49,15 @@ namespace pat { private: // configurables - edm::EDGetTokenT > srcToken_; // list of reco::CompositeCandidates + const edm::EDGetTokenT > srcToken_; // list of reco::CompositeCandidates - bool useUserData_; + const bool useUserData_; pat::PATUserDataHelper userDataHelper_; - bool addEfficiencies_; + const bool addEfficiencies_; pat::helper::EfficiencyLoader efficiencyLoader_; - bool addResolutions_; + const bool addResolutions_; pat::helper::KinResolutionsLoader resolutionLoader_; }; diff --git a/PhysicsTools/PatAlgos/plugins/PATConversionProducer.cc b/PhysicsTools/PatAlgos/plugins/PATConversionProducer.cc index 60a09ee3727e2..5a92f8f630967 100755 --- a/PhysicsTools/PatAlgos/plugins/PATConversionProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATConversionProducer.cc @@ -43,16 +43,12 @@ using namespace pat; using namespace std; -PATConversionProducer::PATConversionProducer(const edm::ParameterSet & iConfig){ - - // general configurables - electronToken_ = consumes >(iConfig.getParameter( "electronSource" )); - bsToken_ = consumes(edm::InputTag("offlineBeamSpot")); - conversionsToken_ = consumes(edm::InputTag("allConversions")); - +PATConversionProducer::PATConversionProducer(const edm::ParameterSet & iConfig) : + electronToken_(consumes >(iConfig.getParameter( "electronSource" ))), + bsToken_(consumes(edm::InputTag("offlineBeamSpot"))), + conversionsToken_(consumes(edm::InputTag("allConversions"))) { // produces vector of muons produces >(); - } @@ -60,7 +56,7 @@ PATConversionProducer::~PATConversionProducer() { } -void PATConversionProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup) { +void PATConversionProducer::produce(edm::StreamID, edm::Event & iEvent, const edm::EventSetup & iSetup) const { // Get the collection of electrons from the event edm::Handle > electrons; diff --git a/PhysicsTools/PatAlgos/plugins/PATConversionProducer.h b/PhysicsTools/PatAlgos/plugins/PATConversionProducer.h index d475c1deec866..7483a0b509484 100644 --- a/PhysicsTools/PatAlgos/plugins/PATConversionProducer.h +++ b/PhysicsTools/PatAlgos/plugins/PATConversionProducer.h @@ -4,7 +4,7 @@ #ifndef PhysicsTools_PatAlgos_PATConversionProducer_h #define PhysicsTools_PatAlgos_PATConversionProducer_h -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" @@ -34,21 +34,21 @@ namespace pat { - class PATConversionProducer : public edm::EDProducer { + class PATConversionProducer : public edm::global::EDProducer<> { public: explicit PATConversionProducer(const edm::ParameterSet & iConfig); ~PATConversionProducer(); - virtual void produce(edm::Event & iEvent, const edm::EventSetup& iSetup) override; + virtual void produce(edm::StreamID, edm::Event & iEvent, const edm::EventSetup& iSetup) const override; private: // configurables - edm::EDGetTokenT > electronToken_; - edm::EDGetTokenT bsToken_; - edm::EDGetTokenT conversionsToken_; + const edm::EDGetTokenT > electronToken_; + const edm::EDGetTokenT bsToken_; + const edm::EDGetTokenT conversionsToken_; }; diff --git a/PhysicsTools/PatAlgos/plugins/PATElectronProducer.cc b/PhysicsTools/PatAlgos/plugins/PATElectronProducer.cc index 1b6bb5870d935..1b14ae9724f0d 100755 --- a/PhysicsTools/PatAlgos/plugins/PATElectronProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATElectronProducer.cc @@ -48,43 +48,51 @@ using namespace std; PATElectronProducer::PATElectronProducer(const edm::ParameterSet & iConfig) : - isolator_(iConfig.exists("userIsolation") ? iConfig.getParameter("userIsolation") : edm::ParameterSet(), consumesCollector(), false) , - useUserData_(iConfig.exists("userData")) -{ // general configurables - electronToken_ = consumes >(iConfig.getParameter( "electronSource" )); - hConversionsToken_ = consumes(edm::InputTag("allConversions")); - embedGsfElectronCore_ = iConfig.getParameter( "embedGsfElectronCore" ); - embedGsfTrack_ = iConfig.getParameter( "embedGsfTrack" ); - embedSuperCluster_ = iConfig.getParameter ( "embedSuperCluster" ); - embedPflowSuperCluster_ = iConfig.getParameter ( "embedPflowSuperCluster" ); - embedSeedCluster_ = iConfig.getParameter( "embedSeedCluster" ); - embedBasicClusters_ = iConfig.getParameter( "embedBasicClusters" ); - embedPreshowerClusters_ = iConfig.getParameter( "embedPreshowerClusters" ); - embedPflowBasicClusters_ = iConfig.getParameter( "embedPflowBasicClusters" ); - embedPflowPreshowerClusters_ = iConfig.getParameter( "embedPflowPreshowerClusters" ); - embedTrack_ = iConfig.getParameter( "embedTrack" ); - embedRecHits_ = iConfig.getParameter( "embedRecHits" ); + electronToken_(consumes >(iConfig.getParameter( "electronSource" ))), + hConversionsToken_(consumes(edm::InputTag("allConversions"))), + embedGsfElectronCore_(iConfig.getParameter( "embedGsfElectronCore" )), + embedGsfTrack_(iConfig.getParameter( "embedGsfTrack" )), + embedSuperCluster_(iConfig.getParameter ( "embedSuperCluster" )), + embedPflowSuperCluster_(iConfig.getParameter ( "embedPflowSuperCluster" )), + embedSeedCluster_(iConfig.getParameter( "embedSeedCluster" )), + embedBasicClusters_(iConfig.getParameter( "embedBasicClusters" )), + embedPreshowerClusters_(iConfig.getParameter( "embedPreshowerClusters" )), + embedPflowBasicClusters_(iConfig.getParameter( "embedPflowBasicClusters" )), + embedPflowPreshowerClusters_(iConfig.getParameter( "embedPflowPreshowerClusters" )), + embedTrack_(iConfig.getParameter( "embedTrack" )), + addGenMatch_(iConfig.getParameter( "addGenMatch" )), + embedGenMatch_(addGenMatch_ ? iConfig.getParameter( "embedGenMatch" ) : false), + embedRecHits_(iConfig.getParameter( "embedRecHits" )), // pflow configurables - pfElecToken_ = consumes(iConfig.getParameter( "pfElectronSource" )); - pfCandidateMapToken_ = mayConsume >(iConfig.getParameter( "pfCandidateMap" )); - useParticleFlow_ = iConfig.getParameter( "useParticleFlow" ); - embedPFCandidate_ = iConfig.getParameter( "embedPFCandidate" ); + useParticleFlow_(iConfig.getParameter( "useParticleFlow" )), + pfElecToken_(consumes(iConfig.getParameter( "pfElectronSource" ))), + pfCandidateMapToken_(mayConsume >(iConfig.getParameter( "pfCandidateMap" ))), + embedPFCandidate_(iConfig.getParameter( "embedPFCandidate" )), // mva input variables - reducedBarrelRecHitCollection_ = iConfig.getParameter("reducedBarrelRecHitCollection"); - reducedBarrelRecHitCollectionToken_ = mayConsume(reducedBarrelRecHitCollection_); - reducedEndcapRecHitCollection_ = iConfig.getParameter("reducedEndcapRecHitCollection"); - reducedEndcapRecHitCollectionToken_ = mayConsume(reducedEndcapRecHitCollection_); - + reducedBarrelRecHitCollection_(iConfig.getParameter("reducedBarrelRecHitCollection")), + reducedBarrelRecHitCollectionToken_(mayConsume(reducedBarrelRecHitCollection_)), + reducedEndcapRecHitCollection_(iConfig.getParameter("reducedEndcapRecHitCollection")), + reducedEndcapRecHitCollectionToken_(mayConsume(reducedEndcapRecHitCollection_)), // PFCluster Isolation maps - addPFClusterIso_ = iConfig.getParameter("addPFClusterIso"); - ecalPFClusterIsoT_ = consumes >(iConfig.getParameter("ecalPFClusterIsoMap")); - hcalPFClusterIsoT_ = consumes >(iConfig.getParameter("hcalPFClusterIsoMap")); - + addPFClusterIso_(iConfig.getParameter("addPFClusterIso")), + ecalPFClusterIsoT_(consumes >(iConfig.getParameter("ecalPFClusterIsoMap"))), + hcalPFClusterIsoT_(consumes >(iConfig.getParameter("hcalPFClusterIsoMap"))), + // embed high level selection variables? + embedHighLevelSelection_(iConfig.getParameter("embedHighLevelSelection")), + beamLineToken_(consumes(iConfig.getParameter("beamLineSrc"))), + pvToken_(mayConsume >(iConfig.getParameter("pvSrc"))), + addElecID_(iConfig.getParameter( "addElectronID" )), + pTComparator_(), + isolator_(iConfig.exists("userIsolation") ? iConfig.getParameter("userIsolation") : edm::ParameterSet(), consumesCollector(), false) , + addEfficiencies_(iConfig.getParameter("addEfficiencies")), + addResolutions_(iConfig.getParameter( "addResolutions" )), + useUserData_(iConfig.exists("userData")) + +{ // MC matching configurables (scheduled mode) - addGenMatch_ = iConfig.getParameter( "addGenMatch" ); + if (addGenMatch_) { - embedGenMatch_ = iConfig.getParameter( "embedGenMatch" ); if (iConfig.existsAs("genParticleMatch")) { genMatchTokens_.push_back(consumes >(iConfig.getParameter( "genParticleMatch" ))); } @@ -93,12 +101,10 @@ PATElectronProducer::PATElectronProducer(const edm::ParameterSet & iConfig) : } } // resolution configurables - addResolutions_ = iConfig.getParameter( "addResolutions" ); if (addResolutions_) { resolutionLoader_ = pat::helper::KinResolutionsLoader(iConfig.getParameter("resolutions")); } // electron ID configurables - addElecID_ = iConfig.getParameter( "addElectronID" ); if (addElecID_) { // it might be a single electron ID if (iConfig.existsAs("electronIDSource")) { @@ -156,7 +162,6 @@ PATElectronProducer::PATElectronProducer(const edm::ParameterSet & iConfig) : // read isolation value labels for non PF identified electron, for direct embedding readIsolationLabels(iConfig, "isolationValuesNoPFId", isolationValueLabelsNoPFId_, isolationValueNoPFIdTokens_); // Efficiency configurables - addEfficiencies_ = iConfig.getParameter("addEfficiencies"); if (addEfficiencies_) { efficiencyLoader_ = pat::helper::EfficiencyLoader(iConfig.getParameter("efficiencies"), consumesCollector()); } @@ -164,12 +169,7 @@ PATElectronProducer::PATElectronProducer(const edm::ParameterSet & iConfig) : if ( useUserData_ ) { userDataHelper_ = PATUserDataHelper(iConfig.getParameter("userData"), consumesCollector()); } - // embed high level selection variables? - embedHighLevelSelection_ = iConfig.getParameter("embedHighLevelSelection"); - beamLineToken_ = consumes(iConfig.getParameter("beamLineSrc")); - if ( embedHighLevelSelection_ ) { - pvToken_ = consumes >(iConfig.getParameter("pvSrc")); - } + // produces vector of muons produces >(); } diff --git a/PhysicsTools/PatAlgos/plugins/PATElectronProducer.h b/PhysicsTools/PatAlgos/plugins/PATElectronProducer.h index 4edffeb07d941..7f926a1c91930 100644 --- a/PhysicsTools/PatAlgos/plugins/PATElectronProducer.h +++ b/PhysicsTools/PatAlgos/plugins/PATElectronProducer.h @@ -15,7 +15,7 @@ */ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" @@ -51,7 +51,7 @@ namespace pat { class LeptonLRCalc; - class PATElectronProducer : public edm::EDProducer { + class PATElectronProducer : public edm::stream::EDProducer<> { public: @@ -65,46 +65,46 @@ namespace pat { private: // configurables - edm::EDGetTokenT > electronToken_; - edm::EDGetTokenT hConversionsToken_; - bool embedGsfElectronCore_; - bool embedGsfTrack_; - bool embedSuperCluster_; - bool embedPflowSuperCluster_; - bool embedSeedCluster_; - bool embedBasicClusters_; - bool embedPreshowerClusters_; - bool embedPflowBasicClusters_; - bool embedPflowPreshowerClusters_; - bool embedTrack_; - bool addGenMatch_; - bool embedGenMatch_; - bool embedRecHits_; + const edm::EDGetTokenT > electronToken_; + const edm::EDGetTokenT hConversionsToken_; + const bool embedGsfElectronCore_; + const bool embedGsfTrack_; + const bool embedSuperCluster_; + const bool embedPflowSuperCluster_; + const bool embedSeedCluster_; + const bool embedBasicClusters_; + const bool embedPreshowerClusters_; + const bool embedPflowBasicClusters_; + const bool embedPflowPreshowerClusters_; + const bool embedTrack_; + bool addGenMatch_; + bool embedGenMatch_; + const bool embedRecHits_; typedef std::vector > > GenAssociations; std::vector > > genMatchTokens_; /// pflow specific - bool useParticleFlow_; - edm::EDGetTokenT pfElecToken_; - edm::EDGetTokenT > pfCandidateMapToken_; - bool embedPFCandidate_; + const bool useParticleFlow_; + const edm::EDGetTokenT pfElecToken_; + const edm::EDGetTokenT > pfCandidateMapToken_; + const bool embedPFCandidate_; /// mva input variables - edm::InputTag reducedBarrelRecHitCollection_; - edm::EDGetTokenT reducedBarrelRecHitCollectionToken_; - edm::InputTag reducedEndcapRecHitCollection_; - edm::EDGetTokenT reducedEndcapRecHitCollectionToken_; + const edm::InputTag reducedBarrelRecHitCollection_; + const edm::EDGetTokenT reducedBarrelRecHitCollectionToken_; + const edm::InputTag reducedEndcapRecHitCollection_; + const edm::EDGetTokenT reducedEndcapRecHitCollectionToken_; - bool addPFClusterIso_; - edm::EDGetTokenT > ecalPFClusterIsoT_; - edm::EDGetTokenT > hcalPFClusterIsoT_; + const bool addPFClusterIso_; + const edm::EDGetTokenT > ecalPFClusterIsoT_; + const edm::EDGetTokenT > hcalPFClusterIsoT_; /// embed high level selection variables? - bool embedHighLevelSelection_; - edm::EDGetTokenT beamLineToken_; - edm::EDGetTokenT > pvToken_; + const bool embedHighLevelSelection_; + const edm::EDGetTokenT beamLineToken_; + const edm::EDGetTokenT > pvToken_; typedef edm::RefToBase ElectronBaseRef; typedef std::vector< edm::Handle< edm::ValueMap > > IsoDepositMaps; @@ -149,13 +149,13 @@ namespace pat { IsolationLabels& labels, std::vector > > & tokens); - bool addElecID_; + const bool addElecID_; typedef std::pair NameTag; std::vector elecIDSrcs_; std::vector > > elecIDTokens_; // tools - GreaterByPt pTComparator_; + const GreaterByPt pTComparator_; pat::helper::MultiIsolator isolator_; pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_; // better here than recreate at each event @@ -166,70 +166,63 @@ namespace pat { IsolationLabels isolationValueLabelsNoPFId_; std::vector > > isolationValueNoPFIdTokens_; - bool addEfficiencies_; + const bool addEfficiencies_; pat::helper::EfficiencyLoader efficiencyLoader_; - bool addResolutions_; + const bool addResolutions_; pat::helper::KinResolutionsLoader resolutionLoader_; - bool useUserData_; + const bool useUserData_; pat::PATUserDataHelper userDataHelper_; const CaloTopology * ecalTopology_; }; - - } - - - - + template void pat::PATElectronProducer::readIsolationLabels( const edm::ParameterSet & iConfig, - const char* psetName, - pat::PATElectronProducer::IsolationLabels& labels, - std::vector > > & tokens) { - - labels.clear(); - - if (iConfig.exists( psetName )) { - edm::ParameterSet depconf - = iConfig.getParameter(psetName); - - if (depconf.exists("tracker")) labels.push_back(std::make_pair(pat::TrackIso, depconf.getParameter("tracker"))); - if (depconf.exists("ecal")) labels.push_back(std::make_pair(pat::EcalIso, depconf.getParameter("ecal"))); - if (depconf.exists("hcal")) labels.push_back(std::make_pair(pat::HcalIso, depconf.getParameter("hcal"))); - if (depconf.exists("pfAllParticles")) { - labels.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter("pfAllParticles"))); - } - if (depconf.exists("pfChargedHadrons")) { - labels.push_back(std::make_pair(pat::PfChargedHadronIso, depconf.getParameter("pfChargedHadrons"))); - } - if (depconf.exists("pfChargedAll")) { - labels.push_back(std::make_pair(pat::PfChargedAllIso, depconf.getParameter("pfChargedAll"))); - } - if (depconf.exists("pfPUChargedHadrons")) { - labels.push_back(std::make_pair(pat::PfPUChargedHadronIso, depconf.getParameter("pfPUChargedHadrons"))); - } - if (depconf.exists("pfNeutralHadrons")) { - labels.push_back(std::make_pair(pat::PfNeutralHadronIso, depconf.getParameter("pfNeutralHadrons"))); - } - if (depconf.exists("pfPhotons")) { - labels.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter("pfPhotons"))); - } - if (depconf.exists("user")) { - std::vector userdeps = depconf.getParameter >("user"); - std::vector::const_iterator it = userdeps.begin(), ed = userdeps.end(); - int key = pat::IsolationKeys::UserBaseIso; - for ( ; it != ed; ++it, ++key) { - labels.push_back(std::make_pair(pat::IsolationKeys(key), *it)); + const char* psetName, + pat::PATElectronProducer::IsolationLabels& labels, + std::vector > > & tokens) { + + labels.clear(); + + if (iConfig.exists( psetName )) { + edm::ParameterSet depconf + = iConfig.getParameter(psetName); + + if (depconf.exists("tracker")) labels.push_back(std::make_pair(pat::TrackIso, depconf.getParameter("tracker"))); + if (depconf.exists("ecal")) labels.push_back(std::make_pair(pat::EcalIso, depconf.getParameter("ecal"))); + if (depconf.exists("hcal")) labels.push_back(std::make_pair(pat::HcalIso, depconf.getParameter("hcal"))); + if (depconf.exists("pfAllParticles")) { + labels.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter("pfAllParticles"))); + } + if (depconf.exists("pfChargedHadrons")) { + labels.push_back(std::make_pair(pat::PfChargedHadronIso, depconf.getParameter("pfChargedHadrons"))); + } + if (depconf.exists("pfChargedAll")) { + labels.push_back(std::make_pair(pat::PfChargedAllIso, depconf.getParameter("pfChargedAll"))); + } + if (depconf.exists("pfPUChargedHadrons")) { + labels.push_back(std::make_pair(pat::PfPUChargedHadronIso, depconf.getParameter("pfPUChargedHadrons"))); + } + if (depconf.exists("pfNeutralHadrons")) { + labels.push_back(std::make_pair(pat::PfNeutralHadronIso, depconf.getParameter("pfNeutralHadrons"))); + } + if (depconf.exists("pfPhotons")) { + labels.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter("pfPhotons"))); + } + if (depconf.exists("user")) { + std::vector userdeps = depconf.getParameter >("user"); + std::vector::const_iterator it = userdeps.begin(), ed = userdeps.end(); + int key = pat::IsolationKeys::UserBaseIso; + for ( ; it != ed; ++it, ++key) { + labels.push_back(std::make_pair(pat::IsolationKeys(key), *it)); + } } } - } - tokens = edm::vector_transform(labels, [this](IsolationLabel const & label){return consumes >(label.second);}); - - + tokens = edm::vector_transform(labels, [this](IsolationLabel const & label){return consumes >(label.second);}); } #endif diff --git a/PhysicsTools/PatAlgos/plugins/PATElectronSlimmer.cc b/PhysicsTools/PatAlgos/plugins/PATElectronSlimmer.cc index 1dd0d3490dbb9..675dfa165c01d 100644 --- a/PhysicsTools/PatAlgos/plugins/PATElectronSlimmer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATElectronSlimmer.cc @@ -9,7 +9,7 @@ #include "PhysicsTools/PatAlgos/interface/ObjectModifier.h" #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/Common/interface/RefToPtr.h" @@ -23,28 +23,28 @@ namespace pat { - class PATElectronSlimmer : public edm::EDProducer { - public: - explicit PATElectronSlimmer(const edm::ParameterSet & iConfig); - virtual ~PATElectronSlimmer() { } - - virtual void produce(edm::Event & iEvent, const edm::EventSetup & iSetup); - virtual void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override final; - + class PATElectronSlimmer : public edm::stream::EDProducer<> { + public: + explicit PATElectronSlimmer(const edm::ParameterSet & iConfig); + virtual ~PATElectronSlimmer() { } + + virtual void produce(edm::Event & iEvent, const edm::EventSetup & iSetup) override final; + virtual void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override final; + private: - edm::EDGetTokenT > src_; - - StringCutObjectSelector dropSuperClusters_, dropBasicClusters_, dropPFlowClusters_, dropPreshowerClusters_, dropSeedCluster_, dropRecHits_; - StringCutObjectSelector dropCorrections_,dropIsolations_,dropShapes_,dropExtrapolations_,dropClassifications_; - - edm::EDGetTokenT>> reco2pf_; - edm::EDGetTokenT> pf2pc_; - edm::EDGetTokenT pc_; - bool linkToPackedPF_; - StringCutObjectSelector saveNonZSClusterShapes_; - edm::EDGetTokenT reducedBarrelRecHitCollectionToken_, reducedEndcapRecHitCollectionToken_; - bool modifyElectron_; - std::unique_ptr > electronModifier_; + const edm::EDGetTokenT > src_; + + const StringCutObjectSelector dropSuperClusters_, dropBasicClusters_, dropPFlowClusters_, dropPreshowerClusters_, dropSeedCluster_, dropRecHits_; + const StringCutObjectSelector dropCorrections_,dropIsolations_,dropShapes_,dropExtrapolations_,dropClassifications_; + + const edm::EDGetTokenT > > reco2pf_; + const edm::EDGetTokenT > pf2pc_; + const edm::EDGetTokenT pc_; + const bool linkToPackedPF_; + const StringCutObjectSelector saveNonZSClusterShapes_; + const edm::EDGetTokenT reducedBarrelRecHitCollectionToken_, reducedEndcapRecHitCollectionToken_; + const bool modifyElectron_; + std::unique_ptr > electronModifier_; }; } // namespace @@ -62,6 +62,9 @@ pat::PATElectronSlimmer::PATElectronSlimmer(const edm::ParameterSet & iConfig) : dropShapes_(iConfig.getParameter("dropShapes")), dropExtrapolations_(iConfig.getParameter("dropExtrapolations")), dropClassifications_(iConfig.getParameter("dropClassifications")), + reco2pf_(mayConsume>>(iConfig.getParameter("recoToPFMap"))), + pf2pc_(mayConsume>(iConfig.getParameter("packedPFCandidates"))), + pc_(mayConsume(iConfig.getParameter("packedPFCandidates"))), linkToPackedPF_(iConfig.getParameter("linkToPackedPFCandidates")), saveNonZSClusterShapes_(iConfig.getParameter("saveNonZSClusterShapes")), reducedBarrelRecHitCollectionToken_(consumes(iConfig.getParameter("reducedBarrelRecHitCollection"))), @@ -77,14 +80,10 @@ pat::PATElectronSlimmer::PATElectronSlimmer(const edm::ParameterSet & iConfig) : electronModifier_.reset(nullptr); } - produces >(); - if (linkToPackedPF_) { - reco2pf_ = consumes>>(iConfig.getParameter("recoToPFMap")); - pf2pc_ = consumes>(iConfig.getParameter("packedPFCandidates")); - pc_ = consumes(iConfig.getParameter("packedPFCandidates")); - } mayConsume(edm::InputTag("reducedEcalRecHitsEB")); mayConsume(edm::InputTag("reducedEcalRecHitsEE")); + + produces >(); } void diff --git a/PhysicsTools/PatAlgos/plugins/PATGenCandsFromSimTracksProducer.cc b/PhysicsTools/PatAlgos/plugins/PATGenCandsFromSimTracksProducer.cc index b702d5bb7a814..8116723fcc34c 100644 --- a/PhysicsTools/PatAlgos/plugins/PATGenCandsFromSimTracksProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATGenCandsFromSimTracksProducer.cc @@ -26,38 +26,37 @@ #include namespace pat { -class PATGenCandsFromSimTracksProducer : public edm::EDProducer { -public: - explicit PATGenCandsFromSimTracksProducer(const edm::ParameterSet&); - ~PATGenCandsFromSimTracksProducer() {} - -private: - virtual void produce(edm::Event&, const edm::EventSetup&) override; - virtual void endJob() override {} - - bool firstEvent_; - edm::EDGetTokenT simTracksToken_; - edm::EDGetTokenT simVertexToken_; - int setStatus_; - std::set pdgIds_; // these are the ones we really use - std::vector pdts_; // these are needed before we get the EventSetup - std::set motherPdgIds_; // these are the ones we really use - std::vector motherPdts_; // these are needed before we get the EventSetup - - typedef StringCutObjectSelector StrFilter; - std::auto_ptr filter_; - - /// If true, I'll try to make a link from the GEANT particle to a GenParticle - bool makeMotherLink_; - /// If true, I'll save GenParticles corresponding to the ancestors of this GEANT particle. Common ancestors are only written once. - bool writeAncestors_; - - /// Collection of GenParticles I need to make refs to. It must also have its associated vector of barcodes, aligned with them. - edm::EDGetTokenT genParticlesToken_; - edm::EDGetTokenT > genBarcodesToken_; - + class PATGenCandsFromSimTracksProducer : public edm::stream::EDProducer<> { + public: + explicit PATGenCandsFromSimTracksProducer(const edm::ParameterSet&); + ~PATGenCandsFromSimTracksProducer() {} + + private: + virtual void produce(edm::Event&, const edm::EventSetup&) override; + + bool firstEvent_; + edm::EDGetTokenT simTracksToken_; + edm::EDGetTokenT simVertexToken_; + int setStatus_; + std::set pdgIds_; // these are the ones we really use + std::vector pdts_; // these are needed before we get the EventSetup + std::set motherPdgIds_; // these are the ones we really use + std::vector motherPdts_; // these are needed before we get the EventSetup + + typedef StringCutObjectSelector StrFilter; + const StrFilter filter_; + + /// If true, I'll try to make a link from the GEANT particle to a GenParticle + bool makeMotherLink_; + /// If true, I'll save GenParticles corresponding to the ancestors of this GEANT particle. Common ancestors are only written once. + bool writeAncestors_; + + /// Collection of GenParticles I need to make refs to. It must also have its associated vector of barcodes, aligned with them. + edm::EDGetTokenT genParticlesToken_; + edm::EDGetTokenT > genBarcodesToken_; + /// Global context for all recursive methods - struct GlobalContext { + struct GlobalContext { GlobalContext(const edm::SimTrackContainer &simtks1, const edm::SimVertexContainer &simvtxs1, const edm::Handle &gens1, @@ -65,9 +64,9 @@ class PATGenCandsFromSimTracksProducer : public edm::EDProducer { bool barcodesAreSorted1, reco::GenParticleCollection & output1, const edm::RefProd & refprod1) : - simtks(simtks1), simvtxs(simvtxs1), - gens(gens1), genBarcodes(genBarcodes1), barcodesAreSorted(barcodesAreSorted1), - output(output1), refprod(refprod1), simTksProcessed() {} + simtks(simtks1), simvtxs(simvtxs1), + gens(gens1), genBarcodes(genBarcodes1), barcodesAreSorted(barcodesAreSorted1), + output(output1), refprod(refprod1), simTksProcessed() {} // GEANT info const edm::SimTrackContainer &simtks; const edm::SimVertexContainer &simvtxs; @@ -80,34 +79,33 @@ class PATGenCandsFromSimTracksProducer : public edm::EDProducer { const edm::RefProd & refprod; // BOOK-KEEPING std::map simTksProcessed; // key = sim track id; - // val = 0: not processed; - // i>0: (index+1) in my output - // i<0: -(index+1) in pythia [NOT USED] - }; - - /// Find the mother of a given GEANT track (or NULL if it can't be found). - const SimTrack * findGeantMother(const SimTrack &tk, const GlobalContext &g) const ; - /// Find the GenParticle reference for a given GEANT or PYTHIA track. - /// - if the track corresponds to a PYTHIA particle, return a ref to that particle - /// - otherwise, if this simtrack has no mother simtrack, return a null ref - /// - otherwise, if writeAncestors is true, make a GenParticle for it and return a ref to it - /// - otherwise, if writeAncestors is false, return the ref to the GEANT mother of this track - edm::Ref findRef(const SimTrack &tk, GlobalContext &g) const ; - - /// Used by findRef if the track is a PYTHIA particle - edm::Ref generatorRef_(const SimTrack &tk, const GlobalContext &g) const ; - /// Make a GenParticle for this SimTrack, with a given mother - reco::GenParticle makeGenParticle_(const SimTrack &tk, const edm::Ref & mother, const GlobalContext &g) const ; - - - - struct LessById { - bool operator()(const SimTrack &tk1, const SimTrack &tk2) const { return tk1.trackId() < tk2.trackId(); } - bool operator()(const SimTrack &tk1, unsigned int id ) const { return tk1.trackId() < id; } - bool operator()(unsigned int id, const SimTrack &tk2) const { return id < tk2.trackId(); } + // val = 0: not processed; + // i>0: (index+1) in my output + // i<0: -(index+1) in pythia [NOT USED] + }; + + /// Find the mother of a given GEANT track (or NULL if it can't be found). + const SimTrack * findGeantMother(const SimTrack &tk, const GlobalContext &g) const ; + /// Find the GenParticle reference for a given GEANT or PYTHIA track. + /// - if the track corresponds to a PYTHIA particle, return a ref to that particle + /// - otherwise, if this simtrack has no mother simtrack, return a null ref + /// - otherwise, if writeAncestors is true, make a GenParticle for it and return a ref to it + /// - otherwise, if writeAncestors is false, return the ref to the GEANT mother of this track + edm::Ref findRef(const SimTrack &tk, GlobalContext &g) const ; + + /// Used by findRef if the track is a PYTHIA particle + edm::Ref generatorRef_(const SimTrack &tk, const GlobalContext &g) const ; + /// Make a GenParticle for this SimTrack, with a given mother + reco::GenParticle makeGenParticle_(const SimTrack &tk, const edm::Ref & mother, const GlobalContext &g) const ; + + + + struct LessById { + bool operator()(const SimTrack &tk1, const SimTrack &tk2) const { return tk1.trackId() < tk2.trackId(); } + bool operator()(const SimTrack &tk1, unsigned int id ) const { return tk1.trackId() < id; } + bool operator()(unsigned int id, const SimTrack &tk2) const { return id < tk2.trackId(); } + }; }; - -}; } using namespace std; @@ -120,6 +118,7 @@ PATGenCandsFromSimTracksProducer::PATGenCandsFromSimTracksProducer(const Paramet simTracksToken_(consumes(cfg.getParameter("src"))), // source sim tracks simVertexToken_(consumes(cfg.getParameter("src"))), // source sim vertices setStatus_(cfg.getParameter("setStatus")), // set status of GenParticle to this code + filter_( cfg.existsAs("filter") ? cfg.getParameter("filter") : std::string("1 == 1") ), makeMotherLink_(cfg.existsAs("makeMotherLink") ? cfg.getParameter("makeMotherLink") : false), writeAncestors_(cfg.existsAs("writeAncestors") ? cfg.getParameter("writeAncestors") : false), genParticlesToken_(mayConsume(cfg.getParameter("genParticles"))), @@ -132,15 +131,7 @@ PATGenCandsFromSimTracksProducer::PATGenCandsFromSimTracksProducer(const Paramet if (cfg.exists("motherTypes")) { motherPdts_ = cfg.getParameter >("motherTypes"); } - - // Possibly allow a string cut - if (cfg.existsAs("filter")) { - string filter = cfg.getParameter("filter"); - if (!filter.empty()) { - filter_ = auto_ptr(new StrFilter(filter)); - } - } - + if (writeAncestors_ && !makeMotherLink_) { edm::LogWarning("Configuration") << "PATGenCandsFromSimTracksProducer: " << "you have set 'writeAncestors' to 'true' and 'makeMotherLink' to false;" << @@ -228,7 +219,7 @@ PATGenCandsFromSimTracksProducer::makeGenParticle_(const SimTrack &tk, const edm void PATGenCandsFromSimTracksProducer::produce(Event& event, - const EventSetup& iSetup) { + const EventSetup& iSetup) { if (firstEvent_){ if (!pdts_.empty()) { @@ -301,9 +292,8 @@ void PATGenCandsFromSimTracksProducer::produce(Event& event, GenParticle genp = makeGenParticle_(*isimtrk, Ref(), globals); // Maybe apply filter on the particle - if (filter_.get() != 0) { - if (!(*filter_)(genp)) continue; - } + if (!(filter_(genp))) continue; + if (!motherPdgIds_.empty()) { const SimTrack *motherSimTk = findGeantMother(*isimtrk, globals); diff --git a/PhysicsTools/PatAlgos/plugins/PATGenJetSlimmer.cc b/PhysicsTools/PatAlgos/plugins/PATGenJetSlimmer.cc index 78375eb366201..16954e81642a8 100644 --- a/PhysicsTools/PatAlgos/plugins/PATGenJetSlimmer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATGenJetSlimmer.cc @@ -11,7 +11,7 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "CommonTools/Utils/interface/StringCutObjectSelector.h" @@ -22,23 +22,23 @@ namespace pat { - class PATGenJetSlimmer : public edm::EDProducer { - public: - explicit PATGenJetSlimmer(const edm::ParameterSet & iConfig); - virtual ~PATGenJetSlimmer() { } - - virtual void produce(edm::Event & iEvent, const edm::EventSetup & iSetup); - - private: - edm::EDGetTokenT > src_; - edm::EDGetTokenT > > gp2pgp_; - - StringCutObjectSelector cut_; - - /// reset daughters to an empty vector - bool clearDaughters_; - /// drop the specific - bool dropSpecific_; + class PATGenJetSlimmer : public edm::stream::EDProducer<> { + public: + explicit PATGenJetSlimmer(const edm::ParameterSet & iConfig); + virtual ~PATGenJetSlimmer() { } + + virtual void produce(edm::Event & iEvent, const edm::EventSetup & iSetup); + + private: + const edm::EDGetTokenT > src_; + const edm::EDGetTokenT > > gp2pgp_; + + const StringCutObjectSelector cut_; + + /// reset daughters to an empty vector + const bool clearDaughters_; + /// drop the specific + const bool dropSpecific_; }; } // namespace diff --git a/PhysicsTools/PatAlgos/plugins/PATGenericParticleProducer.h b/PhysicsTools/PatAlgos/plugins/PATGenericParticleProducer.h index ff7250f2be138..8852b86a08016 100644 --- a/PhysicsTools/PatAlgos/plugins/PATGenericParticleProducer.h +++ b/PhysicsTools/PatAlgos/plugins/PATGenericParticleProducer.h @@ -16,7 +16,7 @@ */ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -39,7 +39,7 @@ namespace pat { - class PATGenericParticleProducer : public edm::EDProducer { + class PATGenericParticleProducer : public edm::stream::EDProducer<> { public: diff --git a/PhysicsTools/PatAlgos/plugins/PATHeavyIonProducer.cc b/PhysicsTools/PatAlgos/plugins/PATHeavyIonProducer.cc index 828c271dacb8c..739c443defeab 100644 --- a/PhysicsTools/PatAlgos/plugins/PATHeavyIonProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATHeavyIonProducer.cc @@ -24,7 +24,7 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -43,23 +43,20 @@ using namespace std; // class decleration // -class PATHeavyIonProducer : public edm::EDProducer { - public: - explicit PATHeavyIonProducer(const edm::ParameterSet&); - ~PATHeavyIonProducer(); - - private: - virtual void beginJob() override ; - virtual void produce(edm::Event&, const edm::EventSetup&) override; - virtual void endJob() override ; - - // ----------member data --------------------------- - - bool doMC_; - bool doReco_; - std::vector hepmcSrc_; - edm::InputTag centSrc_; - edm::InputTag evtPlaneSrc_; +class PATHeavyIonProducer : public edm::global::EDProducer<> { +public: + explicit PATHeavyIonProducer(const edm::ParameterSet&); + ~PATHeavyIonProducer(); + +private: + virtual void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; + // ----------member data --------------------------- + + const bool doMC_; + const bool doReco_; + const std::vector hepmcSrc_; + const edm::InputTag centSrc_; + const edm::InputTag evtPlaneSrc_; }; @@ -75,23 +72,15 @@ class PATHeavyIonProducer : public edm::EDProducer { // // constructors and destructor // -PATHeavyIonProducer::PATHeavyIonProducer(const edm::ParameterSet& iConfig) +PATHeavyIonProducer::PATHeavyIonProducer(const edm::ParameterSet& iConfig) : + doMC_(iConfig.getParameter("doMC")), + doReco_(iConfig.getParameter("doReco")), + hepmcSrc_( doMC_ ? iConfig.getParameter >("generators") : std::vector() ), + centSrc_( doReco_ ? iConfig.getParameter("centrality") : edm::InputTag() ), + evtPlaneSrc_(doReco_ ? iConfig.getParameter("evtPlane") : edm::InputTag() ) { //register your products - produces(); - - //now do what ever other initialization is needed - doReco_ = iConfig.getParameter("doReco"); - if(doReco_){ - centSrc_ = iConfig.getParameter("centrality"); - evtPlaneSrc_ = iConfig.getParameter("evtPlane"); - } - - doMC_ = iConfig.getParameter("doMC"); - if(doMC_){ - hepmcSrc_ = iConfig.getParameter >("generators"); - } - + produces(); } @@ -110,20 +99,8 @@ PATHeavyIonProducer::~PATHeavyIonProducer() // ------------ method called to produce the data ------------ void -PATHeavyIonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - -} - -// ------------ method called once each job just before starting event loop ------------ -void -PATHeavyIonProducer::beginJob() -{ -} +PATHeavyIonProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const { -// ------------ method called once each job just after ending the event loop ------------ -void -PATHeavyIonProducer::endJob() { } //define this as a plug-in diff --git a/PhysicsTools/PatAlgos/plugins/PATHemisphereProducer.cc b/PhysicsTools/PatAlgos/plugins/PATHemisphereProducer.cc index 3aee0488fd5e6..4b61ebd004df0 100644 --- a/PhysicsTools/PatAlgos/plugins/PATHemisphereProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATHemisphereProducer.cc @@ -96,75 +96,79 @@ PATHemisphereProducer::~PATHemisphereProducer() // ------------ method called to produce the data ------------ void -PATHemisphereProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - using namespace edm; - using namespace std; - - //Jets - Handle pJets; - iEvent.getByToken(_patJetsToken,pJets); - - //Muons - Handle pMuons; - iEvent.getByToken(_patMuonsToken,pMuons); - - //Electrons - Handle pElectrons; - iEvent.getByToken(_patElectronsToken,pElectrons); - - //Photons - Handle pPhotons; - iEvent.getByToken(_patPhotonsToken,pPhotons); - - //Taus - Handle pTaus; - iEvent.getByToken(_patTausToken,pTaus); - - - //fill e,p vector with information from all objects (hopefully cleaned before) - for(int i = 0; i < (int) (*pJets).size() ; i++){ - if((*pJets)[i].pt() < _minJetEt || fabs((*pJets)[i].eta()) > _maxJetEta) continue; - - componentPtrs_.push_back(pJets->ptrAt(i)); - } - - for(int i = 0; i < (int) (*pMuons).size() ; i++){ - if((*pMuons)[i].pt() < _minMuonEt || fabs((*pMuons)[i].eta()) > _maxMuonEta) continue; - - componentPtrs_.push_back(pMuons->ptrAt(i)); - } - - for(int i = 0; i < (int) (*pElectrons).size() ; i++){ - if((*pElectrons)[i].pt() < _minElectronEt || fabs((*pElectrons)[i].eta()) > _maxElectronEta) continue; - - componentPtrs_.push_back(pElectrons->ptrAt(i)); - } - - for(int i = 0; i < (int) (*pPhotons).size() ; i++){ - if((*pPhotons)[i].pt() < _minPhotonEt || fabs((*pPhotons)[i].eta()) > _maxPhotonEta) continue; - - componentPtrs_.push_back(pPhotons->ptrAt(i)); - } - - //aren't taus included in jets? - for(int i = 0; i < (int) (*pTaus).size() ; i++){ - if((*pTaus)[i].pt() < _minTauEt || fabs((*pTaus)[i].eta()) > _maxTauEta) continue; - - componentPtrs_.push_back(pTaus->ptrAt(i)); - } - - // create product - std::auto_ptr< std::vector > hemispheres(new std::vector);; - hemispheres->reserve(2); - +PATHemisphereProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const { + using namespace edm; + using namespace std; + + std::vector vPx, vPy, vPz, vE; + std::vector vA1, vA2; + std::vector vgroups; + std::vector componentPtrs; + + //Jets + Handle pJets; + iEvent.getByToken(_patJetsToken,pJets); + + //Muons + Handle pMuons; + iEvent.getByToken(_patMuonsToken,pMuons); + + //Electrons + Handle pElectrons; + iEvent.getByToken(_patElectronsToken,pElectrons); + + //Photons + Handle pPhotons; + iEvent.getByToken(_patPhotonsToken,pPhotons); + + //Taus + Handle pTaus; + iEvent.getByToken(_patTausToken,pTaus); + + + //fill e,p vector with information from all objects (hopefully cleaned before) + for(int i = 0; i < (int) (*pJets).size() ; i++){ + if((*pJets)[i].pt() < _minJetEt || fabs((*pJets)[i].eta()) > _maxJetEta) continue; + + componentPtrs.push_back(pJets->ptrAt(i)); + } + + for(int i = 0; i < (int) (*pMuons).size() ; i++){ + if((*pMuons)[i].pt() < _minMuonEt || fabs((*pMuons)[i].eta()) > _maxMuonEta) continue; + + componentPtrs.push_back(pMuons->ptrAt(i)); + } + + for(int i = 0; i < (int) (*pElectrons).size() ; i++){ + if((*pElectrons)[i].pt() < _minElectronEt || fabs((*pElectrons)[i].eta()) > _maxElectronEta) continue; + + componentPtrs.push_back(pElectrons->ptrAt(i)); + } + + for(int i = 0; i < (int) (*pPhotons).size() ; i++){ + if((*pPhotons)[i].pt() < _minPhotonEt || fabs((*pPhotons)[i].eta()) > _maxPhotonEta) continue; + + componentPtrs.push_back(pPhotons->ptrAt(i)); + } + + //aren't taus included in jets? + for(int i = 0; i < (int) (*pTaus).size() ; i++){ + if((*pTaus)[i].pt() < _minTauEt || fabs((*pTaus)[i].eta()) > _maxTauEta) continue; + + componentPtrs.push_back(pTaus->ptrAt(i)); + } + + // create product + std::auto_ptr< std::vector > hemispheres(new std::vector);; + hemispheres->reserve(2); + //calls HemiAlgorithm for seed method 3 (transv. inv. Mass) and association method 3 (Lund algo) - HemisphereAlgo myHemi(componentPtrs_,_seedMethod,_combinationMethod); - + HemisphereAlgo myHemi(componentPtrs,_seedMethod,_combinationMethod); + //get Hemisphere Axis vA1 = myHemi.getAxis1(); vA2 = myHemi.getAxis2(); - + reco::Particle::LorentzVector p1(vA1[0]*vA1[3],vA1[1]*vA1[3],vA1[2]*vA1[3],vA1[4]); hemispheres->push_back(Hemisphere(p1)); @@ -176,32 +180,15 @@ PATHemisphereProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup for ( unsigned int i=0; i _patJetsToken; -// edm::EDGetTokenT _patMetsToken; - edm::EDGetTokenT _patMuonsToken; - edm::EDGetTokenT _patElectronsToken; - edm::EDGetTokenT _patPhotonsToken; - edm::EDGetTokenT _patTausToken; - - float _minJetEt; - float _minMuonEt; - float _minElectronEt; - float _minTauEt; - float _minPhotonEt; - - float _maxJetEta; - float _maxMuonEta; - float _maxElectronEta; - float _maxTauEta; - float _maxPhotonEta; - - int _seedMethod; - int _combinationMethod; - - HemisphereAlgo* myHemi; - - std::vector vPx, vPy, vPz, vE; - std::vector vA1, vA2; - std::vector vgroups; - std::vector componentPtrs_; - - +class PATHemisphereProducer : public edm::global::EDProducer<> { +public: + explicit PATHemisphereProducer(const edm::ParameterSet&); + ~PATHemisphereProducer(); + + virtual void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; + +private: + // ----------member data --------------------------- + /// Input: All PAT objects that are to cross-clean or needed for that + const edm::EDGetTokenT _patJetsToken; + // edm::EDGetTokenT _patMetsToken; + const edm::EDGetTokenT _patMuonsToken; + const edm::EDGetTokenT _patElectronsToken; + const edm::EDGetTokenT _patPhotonsToken; + const edm::EDGetTokenT _patTausToken; + + const float _minJetEt; + const float _minMuonEt; + const float _minElectronEt; + const float _minTauEt; + const float _minPhotonEt; + + const float _maxJetEta; + const float _maxMuonEta; + const float _maxElectronEta; + const float _maxTauEta; + const float _maxPhotonEta; + + const int _seedMethod; + const int _combinationMethod; + typedef std::vector HemiAxis; - - - - }; #endif diff --git a/PhysicsTools/PatAlgos/plugins/PATJetProducer.h b/PhysicsTools/PatAlgos/plugins/PATJetProducer.h index 1e41aac2fadca..ea2b24b15222d 100644 --- a/PhysicsTools/PatAlgos/plugins/PATJetProducer.h +++ b/PhysicsTools/PatAlgos/plugins/PATJetProducer.h @@ -16,7 +16,7 @@ */ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" @@ -44,7 +44,7 @@ class JetFlavourIdentifier; namespace pat { - class PATJetProducer : public edm::EDProducer { + class PATJetProducer : public edm::stream::EDProducer<> { public: diff --git a/PhysicsTools/PatAlgos/plugins/PATJetSelector.h b/PhysicsTools/PatAlgos/plugins/PATJetSelector.h index 082ca9f886111..b79d6897a6eac 100644 --- a/PhysicsTools/PatAlgos/plugins/PATJetSelector.h +++ b/PhysicsTools/PatAlgos/plugins/PATJetSelector.h @@ -4,7 +4,7 @@ #ifndef PhysicsTools_PatAlgos_PATJetSelector_h #define PhysicsTools_PatAlgos_PATJetSelector_h -#include "FWCore/Framework/interface/EDFilter.h" +#include "FWCore/Framework/interface/stream/EDFilter.h" #include "DataFormats/Common/interface/RefVector.h" @@ -21,15 +21,14 @@ namespace pat { - class PATJetSelector : public edm::EDFilter { + class PATJetSelector : public edm::stream::EDFilter<> { public: PATJetSelector( edm::ParameterSet const & params ) : - edm::EDFilter( ), srcToken_(consumes >( params.getParameter("src") )), cut_( params.getParameter("cut") ), - filter_(false), + filter_( params.exists("filter") ? params.getParameter("filter") : false ), selector_( cut_ ) { produces< std::vector >(); @@ -37,10 +36,6 @@ namespace pat { produces > ("caloTowers"); produces ("pfCandidates"); produces > ("tagInfos"); - - if ( params.exists("filter") ) { - filter_ = params.getParameter("filter"); - } } virtual ~PATJetSelector() {} @@ -196,10 +191,10 @@ namespace pat { } protected: - edm::EDGetTokenT > srcToken_; - std::string cut_; - bool filter_; - StringCutObjectSelector selector_; + const edm::EDGetTokenT > srcToken_; + const std::string cut_; + const bool filter_; + const StringCutObjectSelector selector_; }; } diff --git a/PhysicsTools/PatAlgos/plugins/PATJetSlimmer.cc b/PhysicsTools/PatAlgos/plugins/PATJetSlimmer.cc index 95775cbd36596..d2bdc32ebacb4 100644 --- a/PhysicsTools/PatAlgos/plugins/PATJetSlimmer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATJetSlimmer.cc @@ -11,7 +11,7 @@ #include "DataFormats/Candidate/interface/CandidateFwd.h" #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/PatCandidates/interface/PackedCandidate.h" @@ -23,7 +23,7 @@ namespace pat { - class PATJetSlimmer : public edm::EDProducer { + class PATJetSlimmer : public edm::stream::EDProducer<> { public: explicit PATJetSlimmer(const edm::ParameterSet & iConfig); virtual ~PATJetSlimmer() { } @@ -32,10 +32,10 @@ namespace pat { virtual void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override final; private: - edm::EDGetTokenT> pf2pc_; - edm::EDGetTokenT > jets_; - StringCutObjectSelector dropJetVars_,dropDaughters_,rekeyDaughters_,dropTrackRefs_,dropSpecific_,dropTagInfos_; - bool modifyJet_; + const edm::EDGetTokenT> pf2pc_; + const edm::EDGetTokenT > jets_; + const StringCutObjectSelector dropJetVars_,dropDaughters_,rekeyDaughters_,dropTrackRefs_,dropSpecific_,dropTagInfos_; + const bool modifyJet_; std::unique_ptr > jetModifier_; }; diff --git a/PhysicsTools/PatAlgos/plugins/PATJetUpdater.h b/PhysicsTools/PatAlgos/plugins/PATJetUpdater.h index 449debec1a459..99e8fff150088 100644 --- a/PhysicsTools/PatAlgos/plugins/PATJetUpdater.h +++ b/PhysicsTools/PatAlgos/plugins/PATJetUpdater.h @@ -16,7 +16,7 @@ */ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" @@ -31,7 +31,7 @@ namespace pat { - class PATJetUpdater : public edm::EDProducer { + class PATJetUpdater : public edm::stream::EDProducer<> { public: diff --git a/PhysicsTools/PatAlgos/plugins/PATLeptonCountFilter.cc b/PhysicsTools/PatAlgos/plugins/PATLeptonCountFilter.cc index 03a4417fa6769..5b7af6e886af4 100755 --- a/PhysicsTools/PatAlgos/plugins/PATLeptonCountFilter.cc +++ b/PhysicsTools/PatAlgos/plugins/PATLeptonCountFilter.cc @@ -9,15 +9,16 @@ using namespace pat; -PATLeptonCountFilter::PATLeptonCountFilter(const edm::ParameterSet & iConfig) { - electronToken_ = mayConsume >(iConfig.getParameter( "electronSource" )); - muonToken_ = mayConsume >(iConfig.getParameter( "muonSource" )); - tauToken_ = mayConsume >(iConfig.getParameter( "tauSource" )); - countElectrons_ = iConfig.getParameter ( "countElectrons" ); - countMuons_ = iConfig.getParameter ( "countMuons" ); - countTaus_ = iConfig.getParameter ( "countTaus" ); - minNumber_ = iConfig.getParameter ( "minNumber" ); - maxNumber_ = iConfig.getParameter ( "maxNumber" ); +PATLeptonCountFilter::PATLeptonCountFilter(const edm::ParameterSet & iConfig) : + electronToken_(mayConsume >(iConfig.getParameter( "electronSource" ))), + muonToken_(mayConsume >(iConfig.getParameter( "muonSource" ))), + tauToken_(mayConsume >(iConfig.getParameter( "tauSource" ))), + countElectrons_(iConfig.getParameter ( "countElectrons" )), + countMuons_(iConfig.getParameter ( "countMuons" )), + countTaus_(iConfig.getParameter ( "countTaus" )), + minNumber_(iConfig.getParameter ( "minNumber" )), + maxNumber_(iConfig.getParameter ( "maxNumber" )) { + } @@ -25,7 +26,7 @@ PATLeptonCountFilter::~PATLeptonCountFilter() { } -bool PATLeptonCountFilter::filter(edm::Event & iEvent, const edm::EventSetup & iSetup) { +bool PATLeptonCountFilter::filter(edm::StreamID, edm::Event & iEvent, const edm::EventSetup & iSetup) const { edm::Handle > electrons; if (countElectrons_) iEvent.getByToken(electronToken_, electrons); edm::Handle > muons; diff --git a/PhysicsTools/PatAlgos/plugins/PATLeptonCountFilter.h b/PhysicsTools/PatAlgos/plugins/PATLeptonCountFilter.h index 72b698191852b..ac7041eef8dfb 100644 --- a/PhysicsTools/PatAlgos/plugins/PATLeptonCountFilter.h +++ b/PhysicsTools/PatAlgos/plugins/PATLeptonCountFilter.h @@ -4,7 +4,7 @@ #ifndef PhysicsTools_PatAlgos_PATLeptonCountFilter_h #define PhysicsTools_PatAlgos_PATLeptonCountFilter_h -#include "FWCore/Framework/interface/EDFilter.h" +#include "FWCore/Framework/interface/global/EDFilter.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -19,7 +19,7 @@ namespace pat { - class PATLeptonCountFilter : public edm::EDFilter { + class PATLeptonCountFilter : public edm::global::EDFilter<> { public: @@ -28,18 +28,18 @@ namespace pat { private: - virtual bool filter(edm::Event & iEvent, const edm::EventSetup& iSetup) override; + virtual bool filter(edm::StreamID, edm::Event & iEvent, const edm::EventSetup& iSetup) const override; private: - edm::EDGetTokenT > electronToken_; - edm::EDGetTokenT > muonToken_; - edm::EDGetTokenT > tauToken_; - bool countElectrons_; - bool countMuons_; - bool countTaus_; - unsigned int minNumber_; - unsigned int maxNumber_; + const edm::EDGetTokenT > electronToken_; + const edm::EDGetTokenT > muonToken_; + const edm::EDGetTokenT > tauToken_; + const bool countElectrons_; + const bool countMuons_; + const bool countTaus_; + const unsigned int minNumber_; + const unsigned int maxNumber_; }; diff --git a/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc b/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc index 3fbb5f425f127..39e34746d9373 100644 --- a/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc +++ b/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc @@ -9,7 +9,7 @@ #include "DataFormats/PatCandidates/interface/PackedCandidate.h" #include "DataFormats/PatCandidates/interface/Jet.h" #include "DataFormats/Common/interface/Association.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "DataFormats/Common/interface/View.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" @@ -26,24 +26,24 @@ namespace pat { - class PATLostTracks : public edm::EDProducer { - public: - explicit PATLostTracks(const edm::ParameterSet&); - ~PATLostTracks(); - - virtual void produce(edm::Event&, const edm::EventSetup&); - - private: - edm::EDGetTokenT Cands_; - edm::EDGetTokenT > map_; - edm::EDGetTokenT Tracks_; - edm::EDGetTokenT Vertices_; - edm::EDGetTokenT PV_; - edm::EDGetTokenT PVOrigs_; - double minPt_; - double minHits_; - double minPixelHits_; - }; + class PATLostTracks : public edm::global::EDProducer<> { + public: + explicit PATLostTracks(const edm::ParameterSet&); + ~PATLostTracks(); + + virtual void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; + + private: + const edm::EDGetTokenT Cands_; + const edm::EDGetTokenT > map_; + const edm::EDGetTokenT Tracks_; + const edm::EDGetTokenT Vertices_; + const edm::EDGetTokenT PV_; + const edm::EDGetTokenT PVOrigs_; + const double minPt_; + const double minHits_; + const double minPixelHits_; + }; } pat::PATLostTracks::PATLostTracks(const edm::ParameterSet& iConfig) : @@ -60,12 +60,11 @@ pat::PATLostTracks::PATLostTracks(const edm::ParameterSet& iConfig) : produces< std::vector > (); produces< std::vector > (); produces< edm::Association > (); - } pat::PATLostTracks::~PATLostTracks() {} -void pat::PATLostTracks::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { +void pat::PATLostTracks::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const { edm::Handle cands; iEvent.getByToken( Cands_, cands ); diff --git a/PhysicsTools/PatAlgos/plugins/PATMETProducer.h b/PhysicsTools/PatAlgos/plugins/PATMETProducer.h index 2fd8b2e56def5..8805ff220725d 100644 --- a/PhysicsTools/PatAlgos/plugins/PATMETProducer.h +++ b/PhysicsTools/PatAlgos/plugins/PATMETProducer.h @@ -16,7 +16,7 @@ */ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -35,7 +35,7 @@ namespace pat { - class PATMETProducer : public edm::EDProducer { + class PATMETProducer : public edm::stream::EDProducer<> { public: diff --git a/PhysicsTools/PatAlgos/plugins/PATMETSlimmer.cc b/PhysicsTools/PatAlgos/plugins/PATMETSlimmer.cc index 691586229390d..671fb48155100 100644 --- a/PhysicsTools/PatAlgos/plugins/PATMETSlimmer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATMETSlimmer.cc @@ -5,7 +5,7 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -15,46 +15,45 @@ #include "DataFormats/PatCandidates/interface/MET.h" namespace pat { - - class PATMETSlimmer : public edm::EDProducer { + + class PATMETSlimmer : public edm::global::EDProducer<> { + public: + explicit PATMETSlimmer(const edm::ParameterSet & iConfig); + virtual ~PATMETSlimmer() { } + + virtual void produce(edm::StreamID, edm::Event & iEvent, const edm::EventSetup & iSetup) const; + + private: + class OneMETShift { public: - explicit PATMETSlimmer(const edm::ParameterSet & iConfig); - virtual ~PATMETSlimmer() { } - - virtual void produce(edm::Event & iEvent, const edm::EventSetup & iSetup); - + OneMETShift() : shift(pat::MET::NoShift), level(pat::MET::None), t0FromMiniAOD(false), corShift(false), uncShift(false), isSmeared(false) {} + OneMETShift(pat::MET::METUncertainty shift_, pat::MET::METCorrectionType level_, const edm::InputTag & baseTag, edm::ConsumesCollector && cc, + bool t0FromMiniAOD_, bool corShift_, bool uncShift_, bool isSmeared_=false) ; + void readAndSet(const edm::Event &ev, pat::MET &met) const; private: - struct OneMETShift { - OneMETShift() {} - OneMETShift(pat::MET::METUncertainty shift_, pat::MET::METCorrectionType level_, const edm::InputTag & baseTag, edm::ConsumesCollector && cc, - bool t0FromMiniAOD_, bool corShift_, bool uncShift_, bool isSmeared_=false) ; - pat::MET::METUncertainty shift; - pat::MET::METCorrectionType level; - edm::EDGetTokenT token; - bool t0FromMiniAOD; - bool corShift; - bool uncShift; - bool isSmeared; - void readAndSet(const edm::Event &ev, pat::MET &met) ; - }; + const pat::MET::METUncertainty shift; + const pat::MET::METCorrectionType level; + edm::EDGetTokenT token; + const bool t0FromMiniAOD; + const bool corShift; + const bool uncShift; + const bool isSmeared; + + }; void maybeReadShifts(const edm::ParameterSet &basePSet, const std::string &name, pat::MET::METCorrectionType level, bool readFromMiniAOD=false) ; - - edm::EDGetTokenT src_; - std::vector shifts_; - - bool onMiniAOD_; + + const edm::EDGetTokenT src_; + std::vector shifts_; + + const bool onMiniAOD_; }; - + } // namespace pat::PATMETSlimmer::PATMETSlimmer(const edm::ParameterSet & iConfig) : - src_(consumes(iConfig.getParameter("src"))) + src_(consumes(iConfig.getParameter("src"))), + onMiniAOD_(iConfig.existsAs("runningOnMiniAOD") ? iConfig.getParameter("runningOnMiniAOD") : false) { - onMiniAOD_ =false; - if(iConfig.existsAs("runningOnMiniAOD")) { - onMiniAOD_ = iConfig.getParameter("runningOnMiniAOD"); - } - maybeReadShifts( iConfig, "rawVariation", pat::MET::None ); maybeReadShifts( iConfig, "t1Uncertainties", pat::MET::T1 ); maybeReadShifts( iConfig, "t01Variation", pat::MET::T0, onMiniAOD_ ); @@ -133,7 +132,7 @@ pat::PATMETSlimmer::OneMETShift::OneMETShift(pat::MET::METUncertainty shift_, pa } void -pat::PATMETSlimmer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup) { +pat::PATMETSlimmer::produce(edm::StreamID, edm::Event & iEvent, const edm::EventSetup & iSetup) const { using namespace edm; using namespace std; @@ -143,9 +142,9 @@ pat::PATMETSlimmer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup) auto_ptr > out(new vector(1, src->front())); pat::MET & met = out->back(); - - for (OneMETShift &shift : shifts_) { - shift.readAndSet(iEvent, met); + + for (const OneMETShift &shift : shifts_) { + shift.readAndSet(iEvent, met); } iEvent.put(out); @@ -153,8 +152,8 @@ pat::PATMETSlimmer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup) } void -pat::PATMETSlimmer::OneMETShift::readAndSet(const edm::Event &ev, pat::MET &met) { +pat::PATMETSlimmer::OneMETShift::readAndSet(const edm::Event &ev, pat::MET &met) const { edm::Handle src; ev.getByToken(token, src); diff --git a/PhysicsTools/PatAlgos/plugins/PATMHTProducer.cc b/PhysicsTools/PatAlgos/plugins/PATMHTProducer.cc index f545c419ffd2f..9513e87735cb9 100755 --- a/PhysicsTools/PatAlgos/plugins/PATMHTProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATMHTProducer.cc @@ -45,6 +45,8 @@ pat::PATMHTProducer::PATMHTProducer(const edm::ParameterSet & iConfig){ towerEtThreshold_ = iConfig.getParameter( "towerEtThreshold") ; useHO_ = iConfig.getParameter("useHO"); + setUncertaintyParameters(); + produces(); } @@ -53,13 +55,6 @@ pat::PATMHTProducer::PATMHTProducer(const edm::ParameterSet & iConfig){ pat::PATMHTProducer::~PATMHTProducer() { } -void pat::PATMHTProducer::beginJob() { - setUncertaintyParameters(); -} -void pat::PATMHTProducer::endJob() { -} - - void pat::PATMHTProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup) { @@ -385,63 +380,63 @@ void pat::PATMHTProducer::setUncertaintyParameters(){ //-- Ecal Uncertainty Functions ------------------------------------// //-- From: FastSimulation/Calorimetry/data/HcalResponse.cfi --// //-- Ecal Barrel --// - ecalEBUncertainty.etUncertainty = new TF1("ecalEBEtFunc","x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))",3); + ecalEBUncertainty.etUncertainty.reset( new TF1("ecalEBEtFunc","x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))",3) ); ecalEBUncertainty.etUncertainty->SetParameter(0,0.2); ecalEBUncertainty.etUncertainty->SetParameter(1,0.03); ecalEBUncertainty.etUncertainty->SetParameter(2,0.005); - ecalEBUncertainty.phiUncertainty = new TF1("ecalEBphiFunc","[0]*x",1); + ecalEBUncertainty.phiUncertainty.reset( new TF1("ecalEBphiFunc","[0]*x",1) ); ecalEBUncertainty.phiUncertainty->SetParameter(0,0.0174); //-- Ecal Endcap --// - ecalEEUncertainty.etUncertainty = new TF1("ecalEEEtFunc","x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))",3); + ecalEEUncertainty.etUncertainty.reset( new TF1("ecalEEEtFunc","x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))",3) ); ecalEEUncertainty.etUncertainty->SetParameter(0,0.2); ecalEEUncertainty.etUncertainty->SetParameter(1,0.03); ecalEEUncertainty.etUncertainty->SetParameter(2,0.005); - ecalEEUncertainty.phiUncertainty = new TF1("ecalEEphiFunc","[0]*x",1); + ecalEEUncertainty.phiUncertainty.reset( new TF1("ecalEEphiFunc","[0]*x",1) ); ecalEEUncertainty.phiUncertainty->SetParameter(0,0.087); //-- Hcal Uncertainty Functions --------------------------------------// //-- From: FastSimulation/Calorimetry/data/HcalResponse.cfi --// //-- Hcal Barrel --// - hcalHBUncertainty.etUncertainty = new TF1("hcalHBEtFunc","x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))",3); + hcalHBUncertainty.etUncertainty.reset( new TF1("hcalHBEtFunc","x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))",3) ); hcalHBUncertainty.etUncertainty->SetParameter(0,0.); hcalHBUncertainty.etUncertainty->SetParameter(1,1.22); hcalHBUncertainty.etUncertainty->SetParameter(2,0.05); - hcalHBUncertainty.phiUncertainty = new TF1("ecalHBphiFunc","[0]*x",1); + hcalHBUncertainty.phiUncertainty.reset( new TF1("ecalHBphiFunc","[0]*x",1) ); hcalHBUncertainty.phiUncertainty->SetParameter(0,0.087); //-- Hcal Endcap --// - hcalHEUncertainty.etUncertainty = new TF1("hcalHEEtFunc","x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))",3); + hcalHEUncertainty.etUncertainty.reset( new TF1("hcalHEEtFunc","x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))",3) ); hcalHEUncertainty.etUncertainty->SetParameter(0,0.); hcalHEUncertainty.etUncertainty->SetParameter(1,1.3); hcalHEUncertainty.etUncertainty->SetParameter(2,0.05); - hcalHEUncertainty.phiUncertainty = new TF1("ecalHEphiFunc","[0]*x",1); + hcalHEUncertainty.phiUncertainty.reset( new TF1("ecalHEphiFunc","[0]*x",1) ); hcalHEUncertainty.phiUncertainty->SetParameter(0,0.087); //-- Hcal Outer --// - hcalHOUncertainty.etUncertainty = new TF1("hcalHOEtFunc","x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))",3); + hcalHOUncertainty.etUncertainty.reset( new TF1("hcalHOEtFunc","x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))",3) ); hcalHOUncertainty.etUncertainty->SetParameter(0,0.); hcalHOUncertainty.etUncertainty->SetParameter(1,1.82); hcalHOUncertainty.etUncertainty->SetParameter(2,0.09); - hcalHOUncertainty.phiUncertainty = new TF1("ecalHOphiFunc","[0]*x",1); + hcalHOUncertainty.phiUncertainty.reset( new TF1("ecalHOphiFunc","[0]*x",1) ); hcalHOUncertainty.phiUncertainty->SetParameter(0,0.087); //-- Hcal Forward --// - hcalHFUncertainty.etUncertainty = new TF1("hcalHFEtFunc","x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))",3); + hcalHFUncertainty.etUncertainty.reset( new TF1("hcalHFEtFunc","x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))",3) ); hcalHFUncertainty.etUncertainty->SetParameter(0,0.); hcalHFUncertainty.etUncertainty->SetParameter(1,1.82); hcalHFUncertainty.etUncertainty->SetParameter(2,0.09); - hcalHFUncertainty.phiUncertainty = new TF1("ecalHFphiFunc","[0]*x",1); + hcalHFUncertainty.phiUncertainty.reset( new TF1("ecalHFphiFunc","[0]*x",1) ); hcalHFUncertainty.phiUncertainty->SetParameter(0,0.174); //--- Jet Uncertainty Functions --------------------------------------// - jetUncertainty.etUncertainty = new TF1("jetEtFunc","x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))",3); + jetUncertainty.etUncertainty.reset( new TF1("jetEtFunc","x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))",3) ); //-- values from PTDR 1, ch 11.4 --// jetUncertainty.etUncertainty->SetParameter(0, jetEtUncertaintyParameter0_); jetUncertainty.etUncertainty->SetParameter(1, jetEtUncertaintyParameter1_); @@ -449,12 +444,12 @@ void pat::PATMHTProducer::setUncertaintyParameters(){ //-- phi value from our own fits --// - //jetUncertainty.phiUncertainty = new TF1("jetPhiFunc","[0]*x",1); + //jetUncertainty.phiUncertainty.reset( new TF1("jetPhiFunc","[0]*x",1) ); //jetUncertainty.phiUncertainty->SetParameter(0, jetPhiUncertaintyParameter0_); //-- phi Functions and values from // http://indico.cern.ch/getFile.py/access?contribId=9&sessionId=0&resId=0&materialId=slides&confId=46394 - jetUncertainty.phiUncertainty = new TF1("jetPhiFunc","x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))",3); + jetUncertainty.phiUncertainty.reset( new TF1("jetPhiFunc","x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))",3) ); jetUncertainty.phiUncertainty->SetParameter(0, jetPhiUncertaintyParameter0_); jetUncertainty.phiUncertainty->SetParameter(1, jetPhiUncertaintyParameter1_); jetUncertainty.phiUncertainty->SetParameter(2, jetPhiUncertaintyParameter2_); @@ -462,9 +457,9 @@ void pat::PATMHTProducer::setUncertaintyParameters(){ //-- Jet corrections are assumed not to have an error --// - /*jetCorrUncertainty.etUncertainty = new TF1("jetCorrEtFunc","[0]*x",1); + /*jetCorrUncertainty.etUncertainty.reset( new TF1("jetCorrEtFunc","[0]*x",1) ); jetCorrUncertainty.etUncertainty->SetParameter(0,0.0); - jetCorrUncertainty.phiUncertainty = new TF1("jetCorrPhiFunc","[0]*x",1); + jetCorrUncertainty.phiUncertainty.reset( new TF1("jetCorrPhiFunc","[0]*x",1) ); jetCorrUncertainty.phiUncertainty->SetParameter(0,0.0*(3.14159/180.));*/ @@ -474,29 +469,29 @@ void pat::PATMHTProducer::setUncertaintyParameters(){ // https://twiki.cern.ch/twiki/bin/view/CMS/EgammaCMSSWVal // electron resolution in energy is around 3.4%, measured for 10 < pT < 50 at realistic events with pile-up. - eleUncertainty.etUncertainty = new TF1("eleEtFunc","[0] * x",1); + eleUncertainty.etUncertainty.reset( new TF1("eleEtFunc","[0] * x",1) ); // eleUncertainty.etUncertainty->SetParameter(0,0.034); eleUncertainty.etUncertainty->SetParameter(0, eleEtUncertaintyParameter0_); - eleUncertainty.phiUncertainty = new TF1("elePhiFunc","[0] * x",1); + eleUncertainty.phiUncertainty.reset( new TF1("elePhiFunc","[0] * x",1) ); // eleUncertainty.phiUncertainty->SetParameter(0,1*(3.14159/180.)); eleUncertainty.phiUncertainty->SetParameter(0, elePhiUncertaintyParameter0_); //--- Muon Uncertainty Functions ------------------------------------// // and ambiguious values for the muons... - muonUncertainty.etUncertainty = new TF1("muonEtFunc","[0] * x",1); + muonUncertainty.etUncertainty.reset( new TF1("muonEtFunc","[0] * x",1) ); // muonUncertainty.etUncertainty->SetParameter(0,0.01); muonUncertainty.etUncertainty->SetParameter(0, muonEtUncertaintyParameter0_); - muonUncertainty.phiUncertainty = new TF1("muonPhiFunc","[0] * x",1); + muonUncertainty.phiUncertainty.reset( new TF1("muonPhiFunc","[0] * x",1) ); // muonUncertainty.phiUncertainty->SetParameter(0,1*(3.14159/180.)); muonUncertainty.phiUncertainty->SetParameter(0, muonPhiUncertaintyParameter0_); //-- Muon calo deposites are assumed not to have an error --// - /*muonCorrUncertainty.etUncertainty = new TF1("muonCorrEtFunc","[0] * x",1); + /*muonCorrUncertainty.etUncertainty.reset( new TF1("muonCorrEtFunc","[0] * x",1) ); muonCorrUncertainty.etUncertainty->SetParameter(0,0.0); - muonCorrUncertainty.phiUncertainty = new TF1("muonCorrPhiFunc","[0] * x",1); + muonCorrUncertainty.phiUncertainty.reset( new TF1("muonCorrPhiFunc","[0] * x",1) ); muonCorrUncertainty.phiUncertainty->SetParameter(0,0.0*(3.14159/180.)); */ } diff --git a/PhysicsTools/PatAlgos/plugins/PATMHTProducer.h b/PhysicsTools/PatAlgos/plugins/PATMHTProducer.h index fe88d52e85f7b..9adb1b8aa5db3 100644 --- a/PhysicsTools/PatAlgos/plugins/PATMHTProducer.h +++ b/PhysicsTools/PatAlgos/plugins/PATMHTProducer.h @@ -27,7 +27,7 @@ // user include files #include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -61,15 +61,13 @@ // namespace pat { - class PATMHTProducer : public edm::EDProducer { + class PATMHTProducer : public edm::stream::EDProducer<> { public: explicit PATMHTProducer(const edm::ParameterSet&); ~PATMHTProducer(); private: - virtual void beginJob() ; virtual void produce(edm::Event&, const edm::EventSetup&) override; - virtual void endJob() ; double getJets(edm::Event&, const edm::EventSetup&); double getElectrons(edm::Event&, const edm::EventSetup&); @@ -99,8 +97,8 @@ namespace pat { class uncertaintyFunctions{ public: - TF1 *etUncertainty; - TF1 *phiUncertainty; + std::unique_ptr etUncertainty; + std::unique_ptr phiUncertainty; }; void setUncertaintyParameters();// fills the following uncertaintyFunctions objects: diff --git a/PhysicsTools/PatAlgos/plugins/PATMuonProducer.h b/PhysicsTools/PatAlgos/plugins/PATMuonProducer.h index c9a05bc18e193..28696128b5241 100644 --- a/PhysicsTools/PatAlgos/plugins/PATMuonProducer.h +++ b/PhysicsTools/PatAlgos/plugins/PATMuonProducer.h @@ -18,7 +18,7 @@ #include #include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "DataFormats/PatCandidates/interface/Muon.h" #include "CommonTools/Utils/interface/PtComparator.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -39,7 +39,7 @@ namespace pat { class CaloIsolationEnergy; /// class definition - class PATMuonProducer : public edm::EDProducer { + class PATMuonProducer : public edm::stream::EDProducer<> { public: /// default constructir diff --git a/PhysicsTools/PatAlgos/plugins/PATMuonSlimmer.cc b/PhysicsTools/PatAlgos/plugins/PATMuonSlimmer.cc index 0226731bdddfa..af940b6d81571 100644 --- a/PhysicsTools/PatAlgos/plugins/PATMuonSlimmer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATMuonSlimmer.cc @@ -5,7 +5,7 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -22,7 +22,7 @@ namespace pat { - class PATMuonSlimmer : public edm::EDProducer { + class PATMuonSlimmer : public edm::stream::EDProducer<> { public: explicit PATMuonSlimmer(const edm::ParameterSet & iConfig); virtual ~PATMuonSlimmer() { } @@ -31,12 +31,12 @@ namespace pat { virtual void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override final; private: - edm::EDGetTokenT src_; - edm::EDGetTokenT pf_; - edm::EDGetTokenT> pf2pc_; - bool linkToPackedPF_; - StringCutObjectSelector saveTeVMuons_; - bool modifyMuon_; + const edm::EDGetTokenT src_; + const edm::EDGetTokenT pf_; + const edm::EDGetTokenT> pf2pc_; + const bool linkToPackedPF_; + const StringCutObjectSelector saveTeVMuons_; + const bool modifyMuon_; std::unique_ptr > muonModifier_; }; @@ -44,6 +44,8 @@ namespace pat { pat::PATMuonSlimmer::PATMuonSlimmer(const edm::ParameterSet & iConfig) : src_(consumes(iConfig.getParameter("src"))), + pf_(mayConsume(iConfig.getParameter("pfCandidates"))), + pf2pc_(mayConsume>(iConfig.getParameter("packedPFCandidates"))), linkToPackedPF_(iConfig.getParameter("linkToPackedPFCandidates")), saveTeVMuons_(iConfig.getParameter("saveTeVMuons")), modifyMuon_(iConfig.getParameter("modifyMuons")) @@ -57,10 +59,6 @@ pat::PATMuonSlimmer::PATMuonSlimmer(const edm::ParameterSet & iConfig) : muonModifier_.reset(nullptr); } produces >(); - if (linkToPackedPF_) { - pf_ = consumes(iConfig.getParameter("pfCandidates")); - pf2pc_ = consumes>(iConfig.getParameter("packedPFCandidates")); - } } void diff --git a/PhysicsTools/PatAlgos/plugins/PATPFParticleProducer.h b/PhysicsTools/PatAlgos/plugins/PATPFParticleProducer.h index 02bee7cdb5e4d..2a3ae6ba5123d 100644 --- a/PhysicsTools/PatAlgos/plugins/PATPFParticleProducer.h +++ b/PhysicsTools/PatAlgos/plugins/PATPFParticleProducer.h @@ -16,7 +16,7 @@ */ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" @@ -40,7 +40,7 @@ namespace pat { class LeptonLRCalc; - class PATPFParticleProducer : public edm::EDProducer { + class PATPFParticleProducer : public edm::stream::EDProducer<> { public: diff --git a/PhysicsTools/PatAlgos/plugins/PATPackedCandidateProducer.cc b/PhysicsTools/PatAlgos/plugins/PATPackedCandidateProducer.cc index 7743fcb29bb31..945544da8973f 100644 --- a/PhysicsTools/PatAlgos/plugins/PATPackedCandidateProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATPackedCandidateProducer.cc @@ -9,7 +9,7 @@ #include "DataFormats/PatCandidates/interface/PackedCandidate.h" #include "DataFormats/PatCandidates/interface/Jet.h" #include "DataFormats/Common/interface/Association.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "DataFormats/Common/interface/View.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" @@ -31,17 +31,17 @@ namespace pat { ///conversion map from quality flags used in PV association and miniAOD one - static int qualityMap[8] = {1,0,1,1,4,4,5,6}; + const static int qualityMap[8] = {1,0,1,1,4,4,5,6}; - class PATPackedCandidateProducer : public edm::EDProducer { + class PATPackedCandidateProducer : public edm::global::EDProducer<> { public: explicit PATPackedCandidateProducer(const edm::ParameterSet&); ~PATPackedCandidateProducer(); - virtual void produce(edm::Event&, const edm::EventSetup&); + virtual void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; //sorting of cands to maximize the zlib compression - bool candsOrdering(pat::PackedCandidate i,pat::PackedCandidate j) { + bool candsOrdering(pat::PackedCandidate i,pat::PackedCandidate j) const { if (std::abs(i.charge()) == std::abs(j.charge())) { if(i.charge()!=0){ if(i.pt() > minPtForTrackProperties_ and j.pt() <= minPtForTrackProperties_ ) return true; @@ -55,7 +55,7 @@ namespace pat { return std::abs(i.charge()) > std::abs(j.charge()); } template - std::vector sort_indexes(const std::vector &v ) { + std::vector sort_indexes(const std::vector &v ) const { std::vector idx(v.size()); for (size_t i = 0; i != idx.size(); ++i) idx[i] = i; std::sort(idx.begin(), idx.end(),[&v,this](size_t i1, size_t i2) { return candsOrdering(v[i1],v[i2]);}); @@ -63,25 +63,25 @@ namespace pat { } private: - edm::EDGetTokenT Cands_; - edm::EDGetTokenT PVs_; - edm::EDGetTokenT > PVAsso_; - edm::EDGetTokenT > PVAssoQuality_; - edm::EDGetTokenT PVOrigs_; - edm::EDGetTokenT TKOrigs_; - edm::EDGetTokenT< edm::ValueMap > PuppiWeight_; - edm::EDGetTokenT< edm::ValueMap > PuppiWeightNoLep_; - edm::EDGetTokenT > PuppiCandsMap_; - edm::EDGetTokenT > PuppiCands_; - edm::EDGetTokenT > PuppiCandsNoLep_; - edm::EDGetTokenT > SVWhiteList_; - - double minPtForTrackProperties_; + const edm::EDGetTokenT Cands_; + const edm::EDGetTokenT PVs_; + const edm::EDGetTokenT > PVAsso_; + const edm::EDGetTokenT > PVAssoQuality_; + const edm::EDGetTokenT PVOrigs_; + const edm::EDGetTokenT TKOrigs_; + const edm::EDGetTokenT< edm::ValueMap > PuppiWeight_; + const edm::EDGetTokenT< edm::ValueMap > PuppiWeightNoLep_; + const edm::EDGetTokenT > PuppiCandsMap_; + const edm::EDGetTokenT > PuppiCands_; + const edm::EDGetTokenT > PuppiCandsNoLep_; + const edm::EDGetTokenT > SVWhiteList_; + + const double minPtForTrackProperties_; // for debugging - float calcDxy(float dx, float dy, float phi) { + float calcDxy(float dx, float dy, float phi) const { return - dx * std::sin(phi) + dy * std::cos(phi); } - float calcDz(reco::Candidate::Point p, reco::Candidate::Point v, const reco::Candidate &c) { + float calcDz(reco::Candidate::Point p, reco::Candidate::Point v, const reco::Candidate &c) const { return p.Z()-v.Z() - ((p.X()-v.X()) * c.px() + (p.Y()-v.Y())*c.py()) * c.pz()/(c.pt()*c.pt()); } }; @@ -111,7 +111,7 @@ pat::PATPackedCandidateProducer::~PATPackedCandidateProducer() {} -void pat::PATPackedCandidateProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { +void pat::PATPackedCandidateProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const { edm::Handle cands; iEvent.getByToken( Cands_, cands ); diff --git a/PhysicsTools/PatAlgos/plugins/PATPackedGenParticleProducer.cc b/PhysicsTools/PatAlgos/plugins/PATPackedGenParticleProducer.cc index 9be1ef28c0c4f..2200ef36e0b5b 100644 --- a/PhysicsTools/PatAlgos/plugins/PATPackedGenParticleProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATPackedGenParticleProducer.cc @@ -9,7 +9,7 @@ #include "DataFormats/PatCandidates/interface/PackedGenParticle.h" #include "DataFormats/PatCandidates/interface/Jet.h" #include "DataFormats/Common/interface/Association.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "DataFormats/Common/interface/View.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" @@ -37,21 +37,21 @@ namespace pat { - class PATPackedGenParticleProducer : public edm::EDProducer { - public: - explicit PATPackedGenParticleProducer(const edm::ParameterSet&); - ~PATPackedGenParticleProducer(); - - virtual void produce(edm::Event&, const edm::EventSetup&); - - private: - edm::EDGetTokenT Cands_; - edm::EDGetTokenT GenOrigs_; - edm::EDGetTokenT > Asso_; - edm::EDGetTokenT > AssoOriginal_; - edm::EDGetTokenT PVs_; - double maxRapidity_; - }; + class PATPackedGenParticleProducer : public edm::global::EDProducer<> { + public: + explicit PATPackedGenParticleProducer(const edm::ParameterSet&); + ~PATPackedGenParticleProducer(); + + virtual void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const; + + private: + const edm::EDGetTokenT Cands_; + const edm::EDGetTokenT GenOrigs_; + const edm::EDGetTokenT > Asso_; + const edm::EDGetTokenT > AssoOriginal_; + const edm::EDGetTokenT PVs_; + const double maxRapidity_; + }; } pat::PATPackedGenParticleProducer::PATPackedGenParticleProducer(const edm::ParameterSet& iConfig) : @@ -64,12 +64,11 @@ pat::PATPackedGenParticleProducer::PATPackedGenParticleProducer(const edm::Param { produces< std::vector > (); produces< edm::Association< std::vector > >(); - } pat::PATPackedGenParticleProducer::~PATPackedGenParticleProducer() {} -void pat::PATPackedGenParticleProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { +void pat::PATPackedGenParticleProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const { edm::Handle cands; diff --git a/PhysicsTools/PatAlgos/plugins/PATPhotonProducer.h b/PhysicsTools/PatAlgos/plugins/PATPhotonProducer.h index 6422d30bebdb0..4a58b159cdf4c 100644 --- a/PhysicsTools/PatAlgos/plugins/PATPhotonProducer.h +++ b/PhysicsTools/PatAlgos/plugins/PATPhotonProducer.h @@ -16,7 +16,7 @@ */ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -50,7 +50,7 @@ namespace pat { - class PATPhotonProducer : public edm::EDProducer { + class PATPhotonProducer : public edm::stream::EDProducer<> { public: @@ -178,9 +178,7 @@ void pat::PATPhotonProducer::readIsolationLabels( const edm::ParameterSet & iCon } } } - - tokens = edm::vector_transform(labels, [this](IsolationLabel const & label){return consumes >(label.second);}); - + tokens = edm::vector_transform(labels, [this](IsolationLabel const & label){return consumes >(label.second);}); } diff --git a/PhysicsTools/PatAlgos/plugins/PATPhotonSlimmer.cc b/PhysicsTools/PatAlgos/plugins/PATPhotonSlimmer.cc index 251bdfeca409c..1bcfc4fe233ae 100644 --- a/PhysicsTools/PatAlgos/plugins/PATPhotonSlimmer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATPhotonSlimmer.cc @@ -4,7 +4,7 @@ */ #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -24,7 +24,7 @@ namespace pat { - class PATPhotonSlimmer : public edm::EDProducer { + class PATPhotonSlimmer : public edm::stream::EDProducer<> { public: explicit PATPhotonSlimmer(const edm::ParameterSet & iConfig); virtual ~PATPhotonSlimmer() { } @@ -33,17 +33,17 @@ namespace pat { virtual void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override final; private: - edm::EDGetTokenT > src_; + const edm::EDGetTokenT > src_; - StringCutObjectSelector dropSuperClusters_, dropBasicClusters_, dropPreshowerClusters_, dropSeedCluster_, dropRecHits_; + const StringCutObjectSelector dropSuperClusters_, dropBasicClusters_, dropPreshowerClusters_, dropSeedCluster_, dropRecHits_; - edm::EDGetTokenT>> reco2pf_; - edm::EDGetTokenT> pf2pc_; - edm::EDGetTokenT pc_; - bool linkToPackedPF_; - StringCutObjectSelector saveNonZSClusterShapes_; - edm::EDGetTokenT reducedBarrelRecHitCollectionToken_, reducedEndcapRecHitCollectionToken_; - bool modifyPhoton_; + const edm::EDGetTokenT > > reco2pf_; + const edm::EDGetTokenT > pf2pc_; + const edm::EDGetTokenT pc_; + const bool linkToPackedPF_; + const StringCutObjectSelector saveNonZSClusterShapes_; + const edm::EDGetTokenT reducedBarrelRecHitCollectionToken_, reducedEndcapRecHitCollectionToken_; + const bool modifyPhoton_; std::unique_ptr > photonModifier_; }; @@ -56,6 +56,9 @@ pat::PATPhotonSlimmer::PATPhotonSlimmer(const edm::ParameterSet & iConfig) : dropPreshowerClusters_(iConfig.getParameter("dropPreshowerClusters")), dropSeedCluster_(iConfig.getParameter("dropSeedCluster")), dropRecHits_(iConfig.getParameter("dropRecHits")), + reco2pf_(mayConsume > >(iConfig.getParameter("recoToPFMap"))), + pf2pc_(mayConsume>(iConfig.getParameter("packedPFCandidates"))), + pc_(mayConsume(iConfig.getParameter("packedPFCandidates"))), linkToPackedPF_(iConfig.getParameter("linkToPackedPFCandidates")), saveNonZSClusterShapes_(iConfig.getParameter("saveNonZSClusterShapes")), reducedBarrelRecHitCollectionToken_(consumes(iConfig.getParameter("reducedBarrelRecHitCollection"))), @@ -71,14 +74,10 @@ pat::PATPhotonSlimmer::PATPhotonSlimmer(const edm::ParameterSet & iConfig) : photonModifier_.reset(nullptr); } - produces >(); - if (linkToPackedPF_) { - reco2pf_ = consumes>>(iConfig.getParameter("recoToPFMap")); - pf2pc_ = consumes>(iConfig.getParameter("packedPFCandidates")); - pc_ = consumes(iConfig.getParameter("packedPFCandidates")); - } mayConsume(edm::InputTag("reducedEcalRecHitsEB")); mayConsume(edm::InputTag("reducedEcalRecHitsEE")); + + produces >(); } void diff --git a/PhysicsTools/PatAlgos/plugins/PATSecondaryVertexSlimmer.cc b/PhysicsTools/PatAlgos/plugins/PATSecondaryVertexSlimmer.cc index 4fa2bf4f97d21..0f248add1c6d9 100644 --- a/PhysicsTools/PatAlgos/plugins/PATSecondaryVertexSlimmer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATSecondaryVertexSlimmer.cc @@ -3,7 +3,7 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/Event.h" @@ -15,32 +15,32 @@ #include "DataFormats/Common/interface/RefToPtr.h" namespace pat { - class PATSecondaryVertexSlimmer : public edm::EDProducer { - public: - explicit PATSecondaryVertexSlimmer(const edm::ParameterSet&); - ~PATSecondaryVertexSlimmer(); - - virtual void produce(edm::Event&, const edm::EventSetup&); - private: - edm::EDGetTokenT src_; - edm::EDGetTokenT > srcLegacy_; - edm::EDGetTokenT > map_; - edm::EDGetTokenT > map2_; + class PATSecondaryVertexSlimmer : public edm::global::EDProducer<> { + public: + explicit PATSecondaryVertexSlimmer(const edm::ParameterSet&); + ~PATSecondaryVertexSlimmer(); + + virtual void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const; + private: + const edm::EDGetTokenT src_; + const edm::EDGetTokenT > srcLegacy_; + const edm::EDGetTokenT > map_; + const edm::EDGetTokenT > map2_; }; } pat::PATSecondaryVertexSlimmer::PATSecondaryVertexSlimmer(const edm::ParameterSet& iConfig) : - src_(mayConsume(iConfig.getParameter("src"))), - srcLegacy_(mayConsume >(iConfig.getParameter("src"))), - map_(consumes >(iConfig.getParameter("packedPFCandidates"))), - map2_(mayConsume >(iConfig.existsAs("lostTracksCandidates") ? iConfig.getParameter("lostTracksCandidates") : edm::InputTag("lostTracks") )) + src_(consumes(iConfig.getParameter("src"))), + srcLegacy_(mayConsume >(iConfig.getParameter("src"))), + map_(consumes >(iConfig.getParameter("packedPFCandidates"))), + map2_(mayConsume >(iConfig.existsAs("lostTracksCandidates") ? iConfig.getParameter("lostTracksCandidates") : edm::InputTag("lostTracks") )) { produces< reco::VertexCompositePtrCandidateCollection >(); } pat::PATSecondaryVertexSlimmer::~PATSecondaryVertexSlimmer() {} -void pat::PATSecondaryVertexSlimmer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { +void pat::PATSecondaryVertexSlimmer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const { std::auto_ptr outPtr(new reco::VertexCompositePtrCandidateCollection); @@ -93,7 +93,7 @@ void pat::PATSecondaryVertexSlimmer::produce(edm::Event& iEvent, const edm::Even if((*pf2pc2)[*it].isNonnull()) { outPtr->back().addDaughter(reco::CandidatePtr(edm::refToPtr((*pf2pc2)[*it]) )); } - else { std::cout << "HELPME" << std::endl;} + else { edm::LogError("PATSecondaryVertexSlimmer") << "HELPME" << std::endl;} } } } diff --git a/PhysicsTools/PatAlgos/plugins/PATSingleVertexSelector.cc b/PhysicsTools/PatAlgos/plugins/PATSingleVertexSelector.cc index 0591e2a762e67..802842585370d 100644 --- a/PhysicsTools/PatAlgos/plugins/PATSingleVertexSelector.cc +++ b/PhysicsTools/PatAlgos/plugins/PATSingleVertexSelector.cc @@ -11,7 +11,7 @@ using pat::PATSingleVertexSelector; PATSingleVertexSelector::Mode -PATSingleVertexSelector::parseMode(const std::string &mode) { +PATSingleVertexSelector::parseMode(const std::string &mode) const { if (mode == "firstVertex") { return First; } else if (mode == "nearestToCandidate") { @@ -26,8 +26,10 @@ PATSingleVertexSelector::parseMode(const std::string &mode) { } -PATSingleVertexSelector::PATSingleVertexSelector(const edm::ParameterSet & iConfig) - : doFilterEvents_(false) +PATSingleVertexSelector::PATSingleVertexSelector(const edm::ParameterSet & iConfig) : + vtxPreselection_( iConfig.existsAs("vertexPreselection") ? iConfig.getParameter("vertexPreselection") : std::string(" 1 == 1 ") ), + candPreselection_( iConfig.existsAs("candidatePreselection") ? iConfig.getParameter("candidatePreselection") : std::string(" 1 == 1 ") ), + doFilterEvents_(false) { using namespace std; @@ -39,18 +41,10 @@ PATSingleVertexSelector::PATSingleVertexSelector(const edm::ParameterSet & iConf } } if (hasMode_(First) || hasMode_(NearestToCand)) { - verticesToken_ = consumes >(iConfig.getParameter("vertices")); - if (iConfig.existsAs("vertexPreselection")) { - string presel = iConfig.getParameter("vertexPreselection"); - if (!presel.empty()) vtxPreselection_ = auto_ptr(new VtxSel(presel)); - } + verticesToken_ = consumes >(iConfig.getParameter("vertices")); } if (hasMode_(NearestToCand) || hasMode_(FromCand)) { - candidatesToken_ = edm::vector_transform(iConfig.getParameter >("candidates"), [this](edm::InputTag const & tag){return consumes >(tag);}); - if (iConfig.existsAs("candidatePreselection")) { - string presel = iConfig.getParameter("candidatePreselection"); - if (!presel.empty()) candPreselection_ = auto_ptr(new CandSel(presel)); - } + candidatesToken_ = edm::vector_transform(iConfig.getParameter >("candidates"), [this](edm::InputTag const & tag){return consumes >(tag);}); } if (hasMode_(FromBeamSpot)) { beamSpotToken_ = consumes(iConfig.getParameter("beamSpot")); @@ -72,101 +66,100 @@ bool PATSingleVertexSelector::hasMode_(Mode mode) const { bool PATSingleVertexSelector::filter(edm::Event & iEvent, const edm::EventSetup & iSetup) { - using namespace edm; - using namespace std; - - // Clear - selVtxs_.clear(); bestCand_ = 0; - - // Gather data from the Event - // -- vertex data -- - if (hasMode_(First) || hasMode_(NearestToCand)) { - Handle > vertices; - iEvent.getByToken(verticesToken_, vertices); - for (vector::const_iterator itv = vertices->begin(), edv = vertices->end(); itv != edv; ++itv) { - if ((vtxPreselection_.get() != 0) && !((*vtxPreselection_)(*itv)) ) continue; - selVtxs_.push_back( &*itv ); - } + using namespace edm; + using namespace std; + + // Clear + selVtxs_.clear(); bestCand_ = reco::CandidatePtr(); + + // Gather data from the Event + // -- vertex data -- + if (hasMode_(First) || hasMode_(NearestToCand)) { + Handle > vertices; + iEvent.getByToken(verticesToken_, vertices); + for (vector::const_iterator itv = vertices->begin(), edv = vertices->end(); itv != edv; ++itv) { + if ( !(vtxPreselection_(*itv)) ) continue; + selVtxs_.push_back( reco::VertexRef(vertices,std::distance(vertices->begin(),itv) ) ); } - // -- candidate data -- - if (hasMode_(NearestToCand) || hasMode_(FromCand)) { - vector > cands; - for (vector > >::const_iterator itt = candidatesToken_.begin(), edt = candidatesToken_.end(); itt != edt; ++itt) { - Handle > theseCands; - iEvent.getByToken(*itt, theseCands); - for (View::const_iterator itc = theseCands->begin(), edc = theseCands->end(); itc != edc; ++itc) { - if ((candPreselection_.get() != 0) && !((*candPreselection_)(*itc))) continue; - cands.push_back( pair(-itc->pt(), &*itc) ); - } - } - if (!cands.empty()) bestCand_ = cands.front().second; + } + // -- candidate data -- + if (hasMode_(NearestToCand) || hasMode_(FromCand)) { + vector > cands; + for (vector > >::const_iterator itt = candidatesToken_.begin(), edt = candidatesToken_.end(); itt != edt; ++itt) { + Handle > theseCands; + iEvent.getByToken(*itt, theseCands); + for (View::const_iterator itc = theseCands->begin(), edc = theseCands->end(); itc != edc; ++itc) { + if ( !(candPreselection_(*itc)) ) continue; + cands.push_back( pair(-itc->pt(), reco::CandidatePtr(theseCands,std::distance(theseCands->begin(),itc) ) ) ); + } } - - bool passes = false; - auto_ptr > result; - // Run main mode + possible fallback modes - for (std::vector::const_iterator itm = modes_.begin(), endm = modes_.end(); itm != endm; ++itm) { - result = filter_(*itm, iEvent, iSetup); - // Check if we got any vertices. If so, take them. - if (result->size()) { - passes = true; - break; - } + if (!cands.empty()) bestCand_ = cands.front().second; + } + + bool passes = false; + auto_ptr > result; + // Run main mode + possible fallback modes + for (std::vector::const_iterator itm = modes_.begin(), endm = modes_.end(); itm != endm; ++itm) { + result = filter_(*itm, iEvent, iSetup); + // Check if we got any vertices. If so, take them. + if (result->size()) { + passes = true; + break; } - iEvent.put(result); - // Check if we want to apply the EDFilter - if (doFilterEvents_) - return passes; - else return true; + } + iEvent.put(result); + // Check if we want to apply the EDFilter + if (doFilterEvents_) + return passes; + else return true; } std::auto_ptr > PATSingleVertexSelector::filter_(Mode mode, const edm::Event &iEvent, const edm::EventSetup & iSetup) { - using namespace edm; - using namespace std; - std::auto_ptr > result( - new std::vector()); - switch(mode) { - case First: { - if (selVtxs_.empty()) return result; - result->push_back(*selVtxs_.front()); - return result; - } - case FromCand: { - if (bestCand_ == 0) return result; - reco::Vertex vtx; - if (typeid(*bestCand_) == typeid(reco::VertexCompositeCandidate)) { - vtx = reco::Vertex(bestCand_->vertex(), bestCand_->vertexCovariance(), - bestCand_->vertexChi2(), bestCand_->vertexNdof(), bestCand_->numberOfDaughters() ); - } else { - vtx = reco::Vertex(bestCand_->vertex(), reco::Vertex::Error(), 0, 0, 0); - } - result->push_back(vtx); - return result; - } - case NearestToCand: { - if (selVtxs_.empty() || (bestCand_ == 0)) return result; - const reco::Vertex * which = 0; - float dzmin = 9999.0; - for (vector::const_iterator itv = selVtxs_.begin(), edv = selVtxs_.end(); itv != edv; ++itv) { - float dz = std::abs((*itv)->z() - bestCand_->vz()); - if (dz < dzmin) { dzmin = dz; which = *itv; } - } - if (which != 0) // actually it should not happen, but better safe than sorry - result->push_back(*which); - return result; - } - case FromBeamSpot: { - Handle beamSpot; - iEvent.getByToken(beamSpotToken_, beamSpot); - reco::Vertex bs(beamSpot->position(), beamSpot->covariance3D(), 0, 0, 0); - result->push_back(bs); - return result; - } - default: - // Return an empty vector signifying no vertices found. - return result; + using namespace edm; + using namespace std; + std::auto_ptr > result(new std::vector()); + switch(mode) { + case First: { + if (selVtxs_.empty()) return result; + result->push_back(*selVtxs_.front()); + return result; + } + case FromCand: { + if (bestCand_.isNull()) return result; + reco::Vertex vtx; + if (typeid(*bestCand_) == typeid(reco::VertexCompositeCandidate)) { + vtx = reco::Vertex(bestCand_->vertex(), bestCand_->vertexCovariance(), + bestCand_->vertexChi2(), bestCand_->vertexNdof(), bestCand_->numberOfDaughters() ); + } else { + vtx = reco::Vertex(bestCand_->vertex(), reco::Vertex::Error(), 0, 0, 0); + } + result->push_back(vtx); + return result; + } + case NearestToCand: { + if (selVtxs_.empty() || (bestCand_.isNull())) return result; + reco::VertexRef which; + float dzmin = 9999.0; + for (auto itv = selVtxs_.begin(), edv = selVtxs_.end(); itv != edv; ++itv) { + float dz = std::abs((*itv)->z() - bestCand_->vz()); + if (dz < dzmin) { dzmin = dz; which = *itv; } } + if (which.isNonnull()) // actually it should not happen, but better safe than sorry + result->push_back(*which); + return result; + } + case FromBeamSpot: { + Handle beamSpot; + iEvent.getByToken(beamSpotToken_, beamSpot); + reco::Vertex bs(beamSpot->position(), beamSpot->covariance3D(), 0, 0, 0); + result->push_back(bs); + return result; + } + default: + // Return an empty vector signifying no vertices found. + return result; + } } #include "FWCore/Framework/interface/MakerMacros.h" diff --git a/PhysicsTools/PatAlgos/plugins/PATSingleVertexSelector.h b/PhysicsTools/PatAlgos/plugins/PATSingleVertexSelector.h index 8039232d43399..b798bf4573eb3 100644 --- a/PhysicsTools/PatAlgos/plugins/PATSingleVertexSelector.h +++ b/PhysicsTools/PatAlgos/plugins/PATSingleVertexSelector.h @@ -12,18 +12,20 @@ \version $Id: PATSingleVertexSelector.h,v 1.5 2011/06/15 11:47:25 friis Exp $ */ -#include "FWCore/Framework/interface/EDFilter.h" +#include "FWCore/Framework/interface/stream/EDFilter.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" #include "CommonTools/Utils/interface/StringCutObjectSelector.h" #include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" #include "DataFormats/Candidate/interface/Candidate.h" +#include "DataFormats/Candidate/interface/CandidateFwd.h" namespace pat { - class PATSingleVertexSelector : public edm::EDFilter { + class PATSingleVertexSelector : public edm::stream::EDFilter<> { public: @@ -37,7 +39,8 @@ namespace pat { typedef StringCutObjectSelector VtxSel; typedef StringCutObjectSelector CandSel; - static Mode parseMode(const std::string &name) ; + Mode parseMode(const std::string &name) const; + std::auto_ptr > filter_(Mode mode, const edm::Event & iEvent, const edm::EventSetup & iSetup); bool hasMode_(Mode mode) const ; @@ -45,12 +48,12 @@ namespace pat { std::vector modes_; // mode + optional fallbacks edm::EDGetTokenT > verticesToken_; std::vector > > candidatesToken_; - std::auto_ptr vtxPreselection_; - std::auto_ptr candPreselection_; + const VtxSel vtxPreselection_; + const CandSel candPreselection_; edm::EDGetTokenT beamSpotToken_; // transient data. meaningful while 'filter()' is on the stack - std::vector selVtxs_; - const reco::Candidate * bestCand_; + std::vector selVtxs_; + reco::CandidatePtr bestCand_; // flag to enable/disable EDFilter functionality: // if set to false, PATSingleVertexSelector selects the "one" event vertex, diff --git a/PhysicsTools/PatAlgos/plugins/PATTauProducer.h b/PhysicsTools/PatAlgos/plugins/PATTauProducer.h index 85bf710000804..f1dc6866de901 100644 --- a/PhysicsTools/PatAlgos/plugins/PATTauProducer.h +++ b/PhysicsTools/PatAlgos/plugins/PATTauProducer.h @@ -15,7 +15,7 @@ */ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" @@ -43,7 +43,7 @@ typedef edm::AssociationVector > PFTauTIPAssociationByRef; namespace pat { - class PATTauProducer : public edm::EDProducer { + class PATTauProducer : public edm::stream::EDProducer<> { public: diff --git a/PhysicsTools/PatAlgos/plugins/PATTauSlimmer.cc b/PhysicsTools/PatAlgos/plugins/PATTauSlimmer.cc index 1ee03c23ff2fe..1894e552a8365 100644 --- a/PhysicsTools/PatAlgos/plugins/PATTauSlimmer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATTauSlimmer.cc @@ -5,7 +5,7 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/Common/interface/RefToPtr.h" @@ -16,25 +16,24 @@ #include "PhysicsTools/PatAlgos/interface/ObjectModifier.h" namespace pat { - - class PATTauSlimmer : public edm::EDProducer { - public: - explicit PATTauSlimmer(const edm::ParameterSet & iConfig); - virtual ~PATTauSlimmer() { } - - virtual void produce(edm::Event & iEvent, const edm::EventSetup & iSetup); - virtual void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override final; - - private: - edm::EDGetTokenT > src_; - bool linkToPackedPF_; - edm::EDGetTokenT> pf2pc_; - bool dropPiZeroRefs_; - bool dropTauChargedHadronRefs_; - bool dropPFSpecific_; - bool modifyTau_; - std::unique_ptr > tauModifier_; - + + class PATTauSlimmer : public edm::stream::EDProducer<> { + public: + explicit PATTauSlimmer(const edm::ParameterSet & iConfig); + virtual ~PATTauSlimmer() { } + + virtual void produce(edm::Event & iEvent, const edm::EventSetup & iSetup); + virtual void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override final; + + private: + const edm::EDGetTokenT > src_; + const bool linkToPackedPF_; + const edm::EDGetTokenT > pf2pc_; + const bool dropPiZeroRefs_; + const bool dropTauChargedHadronRefs_; + const bool dropPFSpecific_; + const bool modifyTau_; + std::unique_ptr > tauModifier_; }; } // namespace @@ -42,6 +41,10 @@ namespace pat { pat::PATTauSlimmer::PATTauSlimmer(const edm::ParameterSet & iConfig) : src_(consumes >(iConfig.getParameter("src"))), linkToPackedPF_(iConfig.getParameter("linkToPackedPFCandidates")), + pf2pc_(mayConsume >(iConfig.getParameter("packedPFCandidates"))), + dropPiZeroRefs_(iConfig.exists("dropPiZeroRefs") ? iConfig.getParameter("dropPiZeroRefs") : true ), + dropTauChargedHadronRefs_(iConfig.exists("dropTauChargedHadronRefs") ? iConfig.getParameter("dropTauChargedHadronRefs") : true), + dropPFSpecific_(iConfig.exists("dropPFSpecific") ? iConfig.getParameter("dropPFSpecific") : true), modifyTau_(iConfig.getParameter("modifyTaus")) { edm::ConsumesCollector sumes(consumesCollector()); @@ -53,11 +56,6 @@ pat::PATTauSlimmer::PATTauSlimmer(const edm::ParameterSet & iConfig) : tauModifier_.reset(nullptr); } produces >(); - if (linkToPackedPF_) pf2pc_ = consumes>(iConfig.getParameter("packedPFCandidates")); - dropPiZeroRefs_ = iConfig.exists("dropPiZeroRefs") ? iConfig.getParameter("dropPiZeroRefs") : true; - dropTauChargedHadronRefs_ = iConfig.exists("dropTauChargedHadronRefs") ? iConfig.getParameter("dropTauChargedHadronRefs") : true; - dropPFSpecific_ = iConfig.exists("dropPFSpecific") ? iConfig.getParameter("dropPFSpecific"): true; - } void diff --git a/PhysicsTools/PatAlgos/plugins/PATTriggerEventProducer.h b/PhysicsTools/PatAlgos/plugins/PATTriggerEventProducer.h index 40c215436efa2..cc6f45b0abd13 100644 --- a/PhysicsTools/PatAlgos/plugins/PATTriggerEventProducer.h +++ b/PhysicsTools/PatAlgos/plugins/PATTriggerEventProducer.h @@ -29,7 +29,7 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/GetterOfProducts.h" #include @@ -47,7 +47,7 @@ namespace pat { - class PATTriggerEventProducer : public edm::EDProducer { + class PATTriggerEventProducer : public edm::stream::EDProducer<> { public: diff --git a/PhysicsTools/PatAlgos/plugins/PATTriggerMatchEmbedder.cc b/PhysicsTools/PatAlgos/plugins/PATTriggerMatchEmbedder.cc index d6187e1bde89b..1b091fd0951c5 100644 --- a/PhysicsTools/PatAlgos/plugins/PATTriggerMatchEmbedder.cc +++ b/PhysicsTools/PatAlgos/plugins/PATTriggerMatchEmbedder.cc @@ -21,7 +21,7 @@ #include "FWCore/Utilities/interface/transform.h" #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" @@ -39,12 +39,12 @@ namespace pat { template< class PATObjectType > - class PATTriggerMatchEmbedder : public edm::EDProducer { + class PATTriggerMatchEmbedder : public edm::global::EDProducer<> { - edm::InputTag src_; - edm::EDGetTokenT< edm::View< PATObjectType > > srcToken_; - std::vector< edm::InputTag > matches_; - std::vector< edm::EDGetTokenT< TriggerObjectStandAloneMatch > > matchesTokens_; + const edm::InputTag src_; + const edm::EDGetTokenT< edm::View< PATObjectType > > srcToken_; + const std::vector< edm::InputTag > matches_; + const std::vector< edm::EDGetTokenT< TriggerObjectStandAloneMatch > > matchesTokens_; public: @@ -53,7 +53,7 @@ namespace pat { private: - virtual void produce( edm::Event & iEvent, const edm::EventSetup& iSetup) override; + virtual void produce( edm::StreamID, edm::Event & iEvent, const edm::EventSetup& iSetup) const override; }; @@ -81,7 +81,7 @@ PATTriggerMatchEmbedder< PATObjectType >::PATTriggerMatchEmbedder( const edm::Pa } template< class PATObjectType > -void PATTriggerMatchEmbedder< PATObjectType >::produce( edm::Event & iEvent, const edm::EventSetup& iSetup) +void PATTriggerMatchEmbedder< PATObjectType >::produce( edm::StreamID, edm::Event & iEvent, const edm::EventSetup& iSetup) const { std::auto_ptr< std::vector< PATObjectType > > output( new std::vector< PATObjectType >() ); diff --git a/PhysicsTools/PatAlgos/plugins/PATTriggerObjectStandAloneUnpacker.cc b/PhysicsTools/PatAlgos/plugins/PATTriggerObjectStandAloneUnpacker.cc index 30dd394380647..17b6f65a2e091 100644 --- a/PhysicsTools/PatAlgos/plugins/PATTriggerObjectStandAloneUnpacker.cc +++ b/PhysicsTools/PatAlgos/plugins/PATTriggerObjectStandAloneUnpacker.cc @@ -14,7 +14,7 @@ */ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -24,23 +24,23 @@ #include "DataFormats/Common/interface/TriggerResults.h" namespace pat { - - class PATTriggerObjectStandAloneUnpacker : public edm::EDProducer { - - public: - - explicit PATTriggerObjectStandAloneUnpacker( const edm::ParameterSet & iConfig ); - ~PATTriggerObjectStandAloneUnpacker() {}; - - private: - - virtual void produce( edm::Event & iEvent, const edm::EventSetup& iSetup) override; - - edm::EDGetTokenT< TriggerObjectStandAloneCollection > patTriggerObjectsStandAloneToken_; - edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_; - + + class PATTriggerObjectStandAloneUnpacker : public edm::global::EDProducer<> { + + public: + + explicit PATTriggerObjectStandAloneUnpacker( const edm::ParameterSet & iConfig ); + ~PATTriggerObjectStandAloneUnpacker() {}; + + private: + + virtual void produce(edm::StreamID, edm::Event & iEvent, const edm::EventSetup& iSetup) const override; + + const edm::EDGetTokenT< TriggerObjectStandAloneCollection > patTriggerObjectsStandAloneToken_; + const edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_; + }; - + } @@ -54,7 +54,7 @@ PATTriggerObjectStandAloneUnpacker::PATTriggerObjectStandAloneUnpacker( const ed produces< TriggerObjectStandAloneCollection >(); } -void PATTriggerObjectStandAloneUnpacker::produce( edm::Event & iEvent, const edm::EventSetup& iSetup) +void PATTriggerObjectStandAloneUnpacker::produce( edm::StreamID, edm::Event & iEvent, const edm::EventSetup& iSetup) const { edm::Handle< TriggerObjectStandAloneCollection > patTriggerObjectsStandAlone; iEvent.getByToken( patTriggerObjectsStandAloneToken_, patTriggerObjectsStandAlone ); diff --git a/PhysicsTools/PatAlgos/plugins/PATTriggerProducer.h b/PhysicsTools/PatAlgos/plugins/PATTriggerProducer.h index 899116e7b3b64..f55ee29231421 100644 --- a/PhysicsTools/PatAlgos/plugins/PATTriggerProducer.h +++ b/PhysicsTools/PatAlgos/plugins/PATTriggerProducer.h @@ -37,7 +37,7 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/GetterOfProducts.h" #include @@ -55,7 +55,7 @@ namespace pat { - class PATTriggerProducer : public edm::EDProducer { + class PATTriggerProducer : public edm::stream::EDProducer<> { public: diff --git a/PhysicsTools/PatAlgos/plugins/PATVertexSlimmer.cc b/PhysicsTools/PatAlgos/plugins/PATVertexSlimmer.cc index d01edfc29bd6b..5a929b19d23bb 100644 --- a/PhysicsTools/PatAlgos/plugins/PATVertexSlimmer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATVertexSlimmer.cc @@ -3,7 +3,7 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/Common/interface/ValueMap.h" @@ -14,17 +14,17 @@ #include "DataFormats/PatCandidates/interface/libminifloat.h" namespace pat { - class PATVertexSlimmer : public edm::EDProducer { - public: - explicit PATVertexSlimmer(const edm::ParameterSet&); - ~PATVertexSlimmer(); - - virtual void produce(edm::Event&, const edm::EventSetup&); - private: - edm::EDGetTokenT > src_; - edm::EDGetTokenT > score_; - bool rekeyScores_; - }; + class PATVertexSlimmer : public edm::global::EDProducer<> { + public: + explicit PATVertexSlimmer(const edm::ParameterSet&); + ~PATVertexSlimmer(); + + virtual void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const; + private: + const edm::EDGetTokenT > src_; + const edm::EDGetTokenT > score_; + const bool rekeyScores_; + }; } pat::PATVertexSlimmer::PATVertexSlimmer(const edm::ParameterSet& iConfig) : @@ -38,7 +38,7 @@ pat::PATVertexSlimmer::PATVertexSlimmer(const edm::ParameterSet& iConfig) : pat::PATVertexSlimmer::~PATVertexSlimmer() {} -void pat::PATVertexSlimmer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { +void pat::PATVertexSlimmer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const { edm::Handle > vertices; iEvent.getByToken(src_, vertices); std::auto_ptr > outPtr(new std::vector()); diff --git a/PhysicsTools/PatAlgos/plugins/TauJetCorrFactorsProducer.h b/PhysicsTools/PatAlgos/plugins/TauJetCorrFactorsProducer.h index 7f8e05ad6d764..e0a0097d56584 100644 --- a/PhysicsTools/PatAlgos/plugins/TauJetCorrFactorsProducer.h +++ b/PhysicsTools/PatAlgos/plugins/TauJetCorrFactorsProducer.h @@ -17,7 +17,7 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Utilities/interface/InputTag.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "CondFormats/JetMETObjects/interface/FactorizedJetCorrector.h" @@ -35,7 +35,7 @@ namespace pat { - class TauJetCorrFactorsProducer : public edm::EDProducer + class TauJetCorrFactorsProducer : public edm::stream::EDProducer<> { public: /// value map for JetCorrFactors (to be written into the event) diff --git a/PhysicsTools/PatAlgos/plugins/TrackAndVertexUnpacker.cc b/PhysicsTools/PatAlgos/plugins/TrackAndVertexUnpacker.cc index 06f3a659ee8fd..a779b2234aeae 100644 --- a/PhysicsTools/PatAlgos/plugins/TrackAndVertexUnpacker.cc +++ b/PhysicsTools/PatAlgos/plugins/TrackAndVertexUnpacker.cc @@ -6,7 +6,7 @@ */ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" @@ -24,26 +24,26 @@ namespace pat { - - class PATTrackAndVertexUnpacker : public edm::EDProducer { - - - public: - - explicit PATTrackAndVertexUnpacker(const edm::ParameterSet & iConfig); - ~PATTrackAndVertexUnpacker(); - - virtual void produce(edm::Event & iEvent, const edm::EventSetup& iSetup) override; - - private: - typedef std::vector VInputTag; - // configurables - edm::EDGetTokenT< std::vector > Cands_; - edm::EDGetTokenT PVs_; - edm::EDGetTokenT SVs_; - edm::EDGetTokenT > AdditionalTracks_; -////// std::vector > > particlesTokens_; - + + class PATTrackAndVertexUnpacker : public edm::global::EDProducer<> { + + + public: + + explicit PATTrackAndVertexUnpacker(const edm::ParameterSet & iConfig); + ~PATTrackAndVertexUnpacker(); + + virtual void produce(edm::StreamID, edm::Event & iEvent, const edm::EventSetup& iSetup) const override; + + private: + typedef std::vector VInputTag; + // configurables + const edm::EDGetTokenT > Cands_; + const edm::EDGetTokenT PVs_; + const edm::EDGetTokenT SVs_; + const edm::EDGetTokenT > AdditionalTracks_; + ////// std::vector > > particlesTokens_; + }; } @@ -66,7 +66,7 @@ PATTrackAndVertexUnpacker::~PATTrackAndVertexUnpacker() { } -void PATTrackAndVertexUnpacker::produce(edm::Event & iEvent, const edm::EventSetup & iSetup) { +void PATTrackAndVertexUnpacker::produce(edm::StreamID, edm::Event & iEvent, const edm::EventSetup & iSetup) const { using namespace edm; using namespace std; using namespace reco; Handle > cands; iEvent.getByToken(Cands_, cands); diff --git a/PhysicsTools/PatAlgos/plugins/VertexAssociationProducer.cc b/PhysicsTools/PatAlgos/plugins/VertexAssociationProducer.cc index 71ac5669926dc..e1f81df754609 100644 --- a/PhysicsTools/PatAlgos/plugins/VertexAssociationProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/VertexAssociationProducer.cc @@ -13,7 +13,7 @@ */ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" @@ -26,7 +26,7 @@ namespace pat { - class PATVertexAssociationProducer : public edm::EDProducer { + class PATVertexAssociationProducer : public edm::stream::EDProducer<> { typedef edm::ValueMap VertexAssociationMap; diff --git a/PhysicsTools/PatAlgos/src/EfficiencyLoader.cc b/PhysicsTools/PatAlgos/src/EfficiencyLoader.cc index 545b81159d077..0964679ec2daa 100644 --- a/PhysicsTools/PatAlgos/src/EfficiencyLoader.cc +++ b/PhysicsTools/PatAlgos/src/EfficiencyLoader.cc @@ -20,7 +20,7 @@ EfficiencyLoader::EfficiencyLoader(const edm::ParameterSet &iConfig, edm::Consum } void -EfficiencyLoader::newEvent(const edm::Event &iEvent) const { +EfficiencyLoader::newEvent(const edm::Event &iEvent) { for (size_t i = 0, n = names_.size(); i < n; ++i) { iEvent.getByToken(tokens_[i], handles_[i]); } diff --git a/PhysicsTools/PatAlgos/src/KinResolutionsLoader.cc b/PhysicsTools/PatAlgos/src/KinResolutionsLoader.cc index 6b6e7ade956f3..12cd6c5ce1d9f 100644 --- a/PhysicsTools/PatAlgos/src/KinResolutionsLoader.cc +++ b/PhysicsTools/PatAlgos/src/KinResolutionsLoader.cc @@ -25,7 +25,7 @@ KinResolutionsLoader::KinResolutionsLoader(const edm::ParameterSet &iConfig) } void -KinResolutionsLoader::newEvent(const edm::Event &iEvent, const edm::EventSetup &iSetup) const { +KinResolutionsLoader::newEvent(const edm::Event &iEvent, const edm::EventSetup &iSetup) { for (size_t i = 0, n = patlabels_.size(); i < n; ++i) { iSetup.get().get(eslabels_[i], handles_[i]); handles_[i]->setup(iSetup); diff --git a/PhysicsTools/PatUtils/plugins/ShiftedParticleMETcorrInputProducer.cc b/PhysicsTools/PatUtils/plugins/ShiftedParticleMETcorrInputProducer.cc index 443d05d60e821..1766f333f0424 100644 --- a/PhysicsTools/PatUtils/plugins/ShiftedParticleMETcorrInputProducer.cc +++ b/PhysicsTools/PatUtils/plugins/ShiftedParticleMETcorrInputProducer.cc @@ -12,7 +12,7 @@ ShiftedParticleMETcorrInputProducer::~ShiftedParticleMETcorrInputProducer() // nothing to be done yet... } -void ShiftedParticleMETcorrInputProducer::produce(edm::Event& evt, const edm::EventSetup& es) +void ShiftedParticleMETcorrInputProducer::produce(edm::StreamID, edm::Event& evt, const edm::EventSetup& es) const { edm::Handle originalParticles; evt.getByToken(srcOriginalToken_, originalParticles); diff --git a/PhysicsTools/PatUtils/plugins/ShiftedParticleMETcorrInputProducer.h b/PhysicsTools/PatUtils/plugins/ShiftedParticleMETcorrInputProducer.h index 9a0c74d66a610..324543cc36681 100644 --- a/PhysicsTools/PatUtils/plugins/ShiftedParticleMETcorrInputProducer.h +++ b/PhysicsTools/PatUtils/plugins/ShiftedParticleMETcorrInputProducer.h @@ -11,7 +11,7 @@ * */ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -24,7 +24,7 @@ #include #include -class ShiftedParticleMETcorrInputProducer : public edm::EDProducer +class ShiftedParticleMETcorrInputProducer : public edm::global::EDProducer<> { public: @@ -34,10 +34,10 @@ class ShiftedParticleMETcorrInputProducer : public edm::EDProducer private: typedef edm::View CandidateView; - void produce(edm::Event&, const edm::EventSetup&); + void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const; - edm::EDGetTokenT srcOriginalToken_; - edm::EDGetTokenT srcShiftedToken_; + const edm::EDGetTokenT srcOriginalToken_; + const edm::EDGetTokenT srcShiftedToken_; }; #endif diff --git a/PhysicsTools/UtilAlgos/interface/EDFilterObjectWrapper.h b/PhysicsTools/UtilAlgos/interface/EDFilterObjectWrapper.h index 855ca2f3b46bb..87a8ff01ea490 100644 --- a/PhysicsTools/UtilAlgos/interface/EDFilterObjectWrapper.h +++ b/PhysicsTools/UtilAlgos/interface/EDFilterObjectWrapper.h @@ -37,7 +37,7 @@ */ -#include "FWCore/Framework/interface/global/EDFilter.h" +#include "FWCore/Framework/interface/stream/EDFilter.h" #include "FWCore/Common/interface/EventBase.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -46,7 +46,7 @@ namespace edm { template - class FilterObjectWrapper : public edm::global::EDFilter<> { + class FilterObjectWrapper : public edm::stream::EDFilter<> { public: /// some convenient typedefs. Recall that C is a container class. @@ -67,7 +67,7 @@ namespace edm { /// default destructor virtual ~FilterObjectWrapper(){} /// everything which has to be done during the event loop. NOTE: We can't use the eventSetup in FWLite so ignore it - virtual bool filter(edm::StreamID, edm::Event& event, const edm::EventSetup& eventSetup) const override { + virtual bool filter(edm::Event& event, const edm::EventSetup& eventSetup) override { // create a collection of the objects to put into the event std::auto_ptr objsToPut( new C() ); // get the handle to the objects in the event. diff --git a/RecoEgamma/EgammaPhotonProducers/interface/ReducedEGProducer.h b/RecoEgamma/EgammaPhotonProducers/interface/ReducedEGProducer.h index d7800b3ff74f4..200a18b7979fb 100644 --- a/RecoEgamma/EgammaPhotonProducers/interface/ReducedEGProducer.h +++ b/RecoEgamma/EgammaPhotonProducers/interface/ReducedEGProducer.h @@ -44,29 +44,29 @@ // ReducedEGProducer inherits from EDProducer, so it can be a module: -class ReducedEGProducer : public edm::EDProducer { +class ReducedEGProducer : public edm::stream::EDProducer<> { public: ReducedEGProducer (const edm::ParameterSet& ps); ~ReducedEGProducer(); - virtual void produce(edm::Event& evt, const edm::EventSetup& es); + virtual void produce(edm::Event& evt, const edm::EventSetup& es) override final; private: //tokens for input collections - edm::EDGetTokenT photonT_; - edm::EDGetTokenT gsfElectronT_; - edm::EDGetTokenT conversionT_; - edm::EDGetTokenT singleConversionT_; + const edm::EDGetTokenT photonT_; + const edm::EDGetTokenT gsfElectronT_; + const edm::EDGetTokenT conversionT_; + const edm::EDGetTokenT singleConversionT_; - edm::EDGetTokenT barrelEcalHits_; - edm::EDGetTokenT endcapEcalHits_; - edm::EDGetTokenT preshowerEcalHits_; + const edm::EDGetTokenT barrelEcalHits_; + const edm::EDGetTokenT endcapEcalHits_; + const edm::EDGetTokenT preshowerEcalHits_; - edm::EDGetTokenT > > photonPfCandMapT_; - edm::EDGetTokenT > > gsfElectronPfCandMapT_; + const edm::EDGetTokenT > > photonPfCandMapT_; + const edm::EDGetTokenT > > gsfElectronPfCandMapT_; std::vector > > photonIdTs_; std::vector > > gsfElectronIdTs_; @@ -75,34 +75,31 @@ class ReducedEGProducer : public edm::EDProducer { std::vector > > gsfElectronPFClusterIsoTs_; //names for output collections - std::string outPhotons_; - std::string outPhotonCores_; - std::string outGsfElectrons_; - std::string outGsfElectronCores_; - std::string outConversions_; - std::string outSingleConversions_; - std::string outSuperClusters_; - std::string outEBEEClusters_; - std::string outESClusters_; - std::string outEBRecHits_; - std::string outEERecHits_; - std::string outESRecHits_; - std::string outPhotonPfCandMap_; - std::string outGsfElectronPfCandMap_; - std::vector outPhotonIds_; - std::vector outGsfElectronIds_; - std::vector outPhotonPFClusterIsos_; - std::vector outGsfElectronPFClusterIsos_; + const std::string outPhotons_; + const std::string outPhotonCores_; + const std::string outGsfElectrons_; + const std::string outGsfElectronCores_; + const std::string outConversions_; + const std::string outSingleConversions_; + const std::string outSuperClusters_; + const std::string outEBEEClusters_; + const std::string outESClusters_; + const std::string outEBRecHits_; + const std::string outEERecHits_; + const std::string outESRecHits_; + const std::string outPhotonPfCandMap_; + const std::string outGsfElectronPfCandMap_; + const std::vector outPhotonIds_; + const std::vector outGsfElectronIds_; + const std::vector outPhotonPFClusterIsos_; + const std::vector outGsfElectronPFClusterIsos_; - StringCutObjectSelector keepPhotonSel_; - StringCutObjectSelector slimRelinkPhotonSel_; - StringCutObjectSelector relinkPhotonSel_; - StringCutObjectSelector keepGsfElectronSel_; - StringCutObjectSelector slimRelinkGsfElectronSel_; - StringCutObjectSelector relinkGsfElectronSel_; - - - + const StringCutObjectSelector keepPhotonSel_; + const StringCutObjectSelector slimRelinkPhotonSel_; + const StringCutObjectSelector relinkPhotonSel_; + const StringCutObjectSelector keepGsfElectronSel_; + const StringCutObjectSelector slimRelinkGsfElectronSel_; + const StringCutObjectSelector relinkGsfElectronSel_; }; #endif diff --git a/RecoEgamma/EgammaPhotonProducers/src/ReducedEGProducer.cc b/RecoEgamma/EgammaPhotonProducers/src/ReducedEGProducer.cc index 0eea59ef890e0..8af2e28c34a9a 100644 --- a/RecoEgamma/EgammaPhotonProducers/src/ReducedEGProducer.cc +++ b/RecoEgamma/EgammaPhotonProducers/src/ReducedEGProducer.cc @@ -1,6 +1,7 @@ #include #include #include +#include // Framework #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -43,70 +44,74 @@ #include "RecoEgamma/EgammaTools/interface/ConversionTools.h" +namespace std { + template<> + struct hash { + size_t operator()(const DetId& id) const { + return std::hash()(id.rawId()); + } + }; +} + ReducedEGProducer::ReducedEGProducer(const edm::ParameterSet& config) : + photonT_(consumes(config.getParameter("photons"))), + gsfElectronT_(consumes(config.getParameter("gsfElectrons"))), + conversionT_(consumes(config.getParameter("conversions"))), + singleConversionT_(consumes(config.getParameter("singleConversions"))), + barrelEcalHits_(consumes(config.getParameter("barrelEcalHits"))), + endcapEcalHits_(consumes(config.getParameter("endcapEcalHits"))), + preshowerEcalHits_(consumes(config.getParameter("preshowerEcalHits"))), + photonPfCandMapT_(consumes > >(config.getParameter("photonsPFValMap"))), + gsfElectronPfCandMapT_(consumes > >(config.getParameter("gsfElectronsPFValMap"))), + //output collections + outPhotons_("reducedGedPhotons"), + outPhotonCores_("reducedGedPhotonCores"), + outGsfElectrons_("reducedGedGsfElectrons"), + outGsfElectronCores_("reducedGedGsfElectronCores"), + outConversions_("reducedConversions"), + outSingleConversions_("reducedSingleLegConversions"), + outSuperClusters_("reducedSuperClusters"), + outEBEEClusters_("reducedEBEEClusters"), + outESClusters_("reducedESClusters"), + outEBRecHits_("reducedEBRecHits"), + outEERecHits_("reducedEERecHits"), + outESRecHits_("reducedESRecHits"), + outPhotonPfCandMap_("reducedPhotonPfCandMap"), + outGsfElectronPfCandMap_("reducedGsfElectronPfCandMap"), + outPhotonIds_(config.getParameter >("photonIDOutput")), + outGsfElectronIds_(config.getParameter >("gsfElectronIDOutput")), + outPhotonPFClusterIsos_(config.getParameter >("photonPFClusterIsoOutput")), + outGsfElectronPFClusterIsos_(config.getParameter >("gsfElectronPFClusterIsoOutput")), keepPhotonSel_(config.getParameter("keepPhotons")), slimRelinkPhotonSel_(config.getParameter("slimRelinkPhotons")), relinkPhotonSel_(config.getParameter("relinkPhotons")), keepGsfElectronSel_(config.getParameter("keepGsfElectrons")), slimRelinkGsfElectronSel_(config.getParameter("slimRelinkGsfElectrons")), relinkGsfElectronSel_(config.getParameter("relinkGsfElectrons")) -{ - - - photonT_ = consumes(config.getParameter("photons")); - gsfElectronT_ = consumes(config.getParameter("gsfElectrons")); - conversionT_ = consumes(config.getParameter("conversions")); - singleConversionT_ = consumes(config.getParameter("singleConversions")); - - barrelEcalHits_ = - consumes(config.getParameter("barrelEcalHits")); - endcapEcalHits_ = - consumes(config.getParameter("endcapEcalHits")); - preshowerEcalHits_ = - consumes(config.getParameter("preshowerEcalHits")); - - photonPfCandMapT_ = consumes > >(config.getParameter("photonsPFValMap")); - gsfElectronPfCandMapT_ = consumes > >(config.getParameter("gsfElectronsPFValMap")); - - std::vector photonidinputs(config.getParameter >("photonIDSources")); - for (edm::InputTag &tag : photonidinputs) { +{ + const std::vector& photonidinputs = + config.getParameter >("photonIDSources"); + for (const edm::InputTag &tag : photonidinputs) { photonIdTs_.emplace_back(consumes >(tag)); } - std::vector gsfelectronidinputs(config.getParameter >("gsfElectronIDSources")); - for (edm::InputTag &tag : gsfelectronidinputs) { + const std::vector& gsfelectronidinputs = + config.getParameter >("gsfElectronIDSources"); + for (const edm::InputTag &tag : gsfelectronidinputs) { gsfElectronIdTs_.emplace_back(consumes >(tag)); } - std::vector photonpfclusterisoinputs(config.getParameter >("photonPFClusterIsoSources")); - for (edm::InputTag &tag : photonpfclusterisoinputs) { + const std::vector& photonpfclusterisoinputs = + config.getParameter >("photonPFClusterIsoSources"); + for (const edm::InputTag &tag : photonpfclusterisoinputs) { photonPFClusterIsoTs_.emplace_back(consumes >(tag)); } - std::vector gsfelectronpfclusterisoinputs(config.getParameter >("gsfElectronPFClusterIsoSources")); - for (edm::InputTag &tag : gsfelectronpfclusterisoinputs) { + const std::vector& gsfelectronpfclusterisoinputs = + config.getParameter >("gsfElectronPFClusterIsoSources"); + for (const edm::InputTag &tag : gsfelectronpfclusterisoinputs) { gsfElectronPFClusterIsoTs_.emplace_back(consumes >(tag)); } - - //output collections - outPhotons_ = "reducedGedPhotons"; - outPhotonCores_ = "reducedGedPhotonCores"; - outGsfElectrons_ = "reducedGedGsfElectrons"; - outGsfElectronCores_ = "reducedGedGsfElectronCores"; - outConversions_ = "reducedConversions"; - outSingleConversions_ = "reducedSingleLegConversions"; - outSuperClusters_ = "reducedSuperClusters"; - outEBEEClusters_ = "reducedEBEEClusters"; - outESClusters_ = "reducedESClusters"; - outEBRecHits_ = "reducedEBRecHits"; - outEERecHits_ = "reducedEERecHits"; - outESRecHits_ = "reducedESRecHits"; - outPhotonPfCandMap_ = "reducedPhotonPfCandMap"; - outGsfElectronPfCandMap_ = "reducedGsfElectronPfCandMap"; - outPhotonIds_ = config.getParameter >("photonIDOutput"); - outGsfElectronIds_ = config.getParameter >("gsfElectronIDOutput"); - outPhotonPFClusterIsos_ = config.getParameter >("photonPFClusterIsoOutput"); - outGsfElectronPFClusterIsos_ = config.getParameter >("gsfElectronPFClusterIsoOutput"); produces< reco::PhotonCollection >(outPhotons_); produces< reco::PhotonCoreCollection >(outPhotonCores_); @@ -195,8 +200,6 @@ void ReducedEGProducer::produce(edm::Event& theEvent, const edm::EventSetup& the theEvent.getByToken(photonPFClusterIsoTs_[itok],photonPFClusterIsoHandles[itok]); } - - edm::ESHandle theCaloTopology; theEventSetup.get().get(theCaloTopology); const CaloTopology *caloTopology = & (*theCaloTopology); @@ -245,13 +248,13 @@ void ReducedEGProducer::produce(edm::Event& theEvent, const edm::EventSetup& the std::map superClusterMap; std::map ebeeClusterMap; std::map esClusterMap; - std::set rechitMap; + std::unordered_set rechitMap; - std::set superClusterFullRelinkMap; + std::unordered_set superClusterFullRelinkMap; //vectors for pfcandidate valuemaps - std::vector> pfCandIsoPairVecPho; - std::vector> pfCandIsoPairVecEle; + std::vector > pfCandIsoPairVecPho; + std::vector > pfCandIsoPairVecEle; //vectors for id valuemaps std::vector > photonIdVals(photonIds.size()); diff --git a/RecoJets/JetProducers/interface/NjettinessAdder.h b/RecoJets/JetProducers/interface/NjettinessAdder.h index 7c9f6576fc361..f79f52633628b 100644 --- a/RecoJets/JetProducers/interface/NjettinessAdder.h +++ b/RecoJets/JetProducers/interface/NjettinessAdder.h @@ -4,7 +4,7 @@ #include #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/one/EDProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" #include "DataFormats/JetReco/interface/Jet.h" @@ -12,7 +12,7 @@ #include "fastjet/contrib/Njettiness.hh" -class NjettinessAdder : public edm::EDProducer { +class NjettinessAdder : public edm::one::EDProducer<> { public: enum MeasureDefinition_t { diff --git a/RecoJets/JetProducers/plugins/CATopJetTagger.cc b/RecoJets/JetProducers/plugins/CATopJetTagger.cc index 793f2da5cf807..28216ec85eee9 100644 --- a/RecoJets/JetProducers/plugins/CATopJetTagger.cc +++ b/RecoJets/JetProducers/plugins/CATopJetTagger.cc @@ -21,12 +21,10 @@ CATopJetTagger::CATopJetTagger(const edm::ParameterSet& iConfig): src_(iConfig.getParameter("src") ), TopMass_(iConfig.getParameter("TopMass") ), WMass_(iConfig.getParameter("WMass") ), - verbose_(iConfig.getParameter("verbose") ) + verbose_(iConfig.getParameter("verbose") ), + input_jet_token_(consumes >(src_)) { produces(); - - input_jet_token_ = consumes >(src_); - } @@ -41,7 +39,7 @@ CATopJetTagger::~CATopJetTagger() // ------------ method called to for each event ------------ void -CATopJetTagger::produce( edm::Event& iEvent, const edm::EventSetup& iSetup) +CATopJetTagger::produce( edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const { // Set up output list @@ -62,7 +60,7 @@ CATopJetTagger::produce( edm::Event& iEvent, const edm::EventSetup& iSetup) size_t iihardJet = 0; for ( ; ihardJet != ihardJetEnd; ++ihardJet, ++iihardJet ) { - if ( verbose_ ) cout << "Processing ihardJet with pt = " << ihardJet->pt() << endl; + if ( verbose_ ) edm::LogInfo("CATopJetTagger") << "Processing ihardJet with pt = " << ihardJet->pt() << endl; // Initialize output variables // Get a ref to the hard jet @@ -80,18 +78,5 @@ CATopJetTagger::produce( edm::Event& iEvent, const edm::EventSetup& iSetup) return; } - -// ------------ method called once each job just before starting event loop ------------ -void -CATopJetTagger::beginJob() -{ -} - -// ------------ method called once each job just after ending the event loop ------------ -void -CATopJetTagger::endJob() { - -} - //define this as a plug-in DEFINE_FWK_MODULE(CATopJetTagger); diff --git a/RecoJets/JetProducers/plugins/CATopJetTagger.h b/RecoJets/JetProducers/plugins/CATopJetTagger.h index 3bc02eb0be417..88cbb976cf0d4 100644 --- a/RecoJets/JetProducers/plugins/CATopJetTagger.h +++ b/RecoJets/JetProducers/plugins/CATopJetTagger.h @@ -34,7 +34,7 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -62,26 +62,24 @@ // class decleration // -class CATopJetTagger : public edm::EDProducer { - public: - explicit CATopJetTagger(const edm::ParameterSet&); - ~CATopJetTagger(); - - - private: - virtual void beginJob() ; - virtual void produce( edm::Event&, const edm::EventSetup&); - virtual void endJob() ; - - // ----------member data --------------------------- - - edm::InputTag src_; - - double TopMass_; - double WMass_; - bool verbose_; - - edm::EDGetTokenT > input_jet_token_; +class CATopJetTagger : public edm::global::EDProducer<> { + public: + explicit CATopJetTagger(const edm::ParameterSet&); + ~CATopJetTagger(); + + + private: + virtual void produce( edm::StreamID, edm::Event&, const edm::EventSetup&) const override; + + // ----------member data --------------------------- + + const edm::InputTag src_; + + const double TopMass_; + const double WMass_; + const bool verbose_; + + const edm::EDGetTokenT > input_jet_token_; }; diff --git a/RecoLocalCalo/HcalRecProducers/src/HBHEIsolatedNoiseReflagger.h b/RecoLocalCalo/HcalRecProducers/src/HBHEIsolatedNoiseReflagger.h index 5a9d5fcc57679..1c4de9274869b 100644 --- a/RecoLocalCalo/HcalRecProducers/src/HBHEIsolatedNoiseReflagger.h +++ b/RecoLocalCalo/HcalRecProducers/src/HBHEIsolatedNoiseReflagger.h @@ -10,13 +10,13 @@ Original Author: John Paul Chou (Brown University) #include #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "RecoLocalCalo/HcalRecAlgos/interface/HBHEIsolatedNoiseAlgos.h" -class HBHEIsolatedNoiseReflagger : public edm::EDProducer { +class HBHEIsolatedNoiseReflagger : public edm::stream::EDProducer<> { public: explicit HBHEIsolatedNoiseReflagger(const edm::ParameterSet&); ~HBHEIsolatedNoiseReflagger(); diff --git a/RecoLocalCalo/HcalRecProducers/src/HcalHitSelection.cc b/RecoLocalCalo/HcalRecProducers/src/HcalHitSelection.cc index 35f929845e01f..41b8a1ce321f3 100644 --- a/RecoLocalCalo/HcalRecProducers/src/HcalHitSelection.cc +++ b/RecoLocalCalo/HcalRecProducers/src/HcalHitSelection.cc @@ -22,7 +22,7 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -43,7 +43,7 @@ // class declaration // -class HcalHitSelection : public edm::EDProducer { +class HcalHitSelection : public edm::stream::EDProducer<> { public: explicit HcalHitSelection(const edm::ParameterSet&); ~HcalHitSelection(); @@ -63,12 +63,12 @@ class HcalHitSelection : public edm::EDProducer { edm::ESHandle theHcalChStatus; edm::ESHandle theHcalSevLvlComputer; std::set toBeKept; - template void skim( const edm::Handle & input, std::auto_ptr & output,int severityThreshold=0); + template void skim( const edm::Handle & input, std::auto_ptr & output,int severityThreshold=0) const; // ----------member data --------------------------- }; -template void HcalHitSelection::skim( const edm::Handle & input, std::auto_ptr & output,int severityThreshold){ +template void HcalHitSelection::skim( const edm::Handle & input, std::auto_ptr & output,int severityThreshold) const { output->reserve(input->size()); typename CollectionType::const_iterator begin=input->begin(); typename CollectionType::const_iterator end=input->end(); diff --git a/RecoTauTag/RecoTau/interface/PFRecoTauTagInfoAlgorithm.h b/RecoTauTag/RecoTau/interface/PFRecoTauTagInfoAlgorithm.h index eb447b7442360..72b093556fa19 100644 --- a/RecoTauTag/RecoTau/interface/PFRecoTauTagInfoAlgorithm.h +++ b/RecoTauTag/RecoTau/interface/PFRecoTauTagInfoAlgorithm.h @@ -17,7 +17,7 @@ class PFRecoTauTagInfoAlgorithm { PFRecoTauTagInfoAlgorithm(){} PFRecoTauTagInfoAlgorithm(const edm::ParameterSet&); ~PFRecoTauTagInfoAlgorithm(){} - reco::PFTauTagInfo buildPFTauTagInfo(const reco::PFJetRef&,const std::vector&,const reco::TrackRefVector&,const reco::Vertex&); + reco::PFTauTagInfo buildPFTauTagInfo(const reco::PFJetRef&,const std::vector&,const reco::TrackRefVector&,const reco::Vertex&) const; private: double ChargedHadrCand_tkminPt_; int ChargedHadrCand_tkminPixelHitsn_; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauTagInfoProducer.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauTagInfoProducer.cc index 1b9a352806e37..6cd3f957ea8a1 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauTagInfoProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauTagInfoProducer.cc @@ -17,7 +17,7 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -32,13 +32,13 @@ using namespace reco; using namespace edm; using namespace std; -class PFRecoTauTagInfoProducer : public EDProducer { +class PFRecoTauTagInfoProducer : public edm::global::EDProducer<> { public: explicit PFRecoTauTagInfoProducer(const edm::ParameterSet& iConfig); ~PFRecoTauTagInfoProducer(); - virtual void produce(edm::Event&,const edm::EventSetup&) override; + virtual void produce(edm::StreamID, edm::Event&,const edm::EventSetup&) const override; private: - PFRecoTauTagInfoAlgorithm* PFRecoTauTagInfoAlgo_; + std::unique_ptr PFRecoTauTagInfoAlgo_; edm::InputTag PFCandidateProducer_; edm::InputTag PFJetTracksAssociatorProducer_; edm::InputTag PVProducer_; @@ -59,17 +59,16 @@ PFRecoTauTagInfoProducer::PFRecoTauTagInfoProducer(const edm::ParameterSet& iCon smearedPVsigmaX_ = iConfig.getParameter("smearedPVsigmaX"); smearedPVsigmaY_ = iConfig.getParameter("smearedPVsigmaY"); smearedPVsigmaZ_ = iConfig.getParameter("smearedPVsigmaZ"); - PFRecoTauTagInfoAlgo_=new PFRecoTauTagInfoAlgorithm(iConfig); + PFRecoTauTagInfoAlgo_.reset( new PFRecoTauTagInfoAlgorithm(iConfig) ); PFCandidate_token = consumes(PFCandidateProducer_); PFJetTracksAssociator_token = consumes(PFJetTracksAssociatorProducer_); PV_token = consumes(PVProducer_); produces(); } PFRecoTauTagInfoProducer::~PFRecoTauTagInfoProducer(){ - delete PFRecoTauTagInfoAlgo_; } -void PFRecoTauTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup){ +void PFRecoTauTagInfoProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const { edm::Handle thePFJetTracksAssociatorCollection; iEvent.getByToken(PFJetTracksAssociator_token,thePFJetTracksAssociatorCollection); // *** access the PFCandidateCollection in the event in order to retrieve the PFCandidateRefVector which constitutes each PFJet diff --git a/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc index f458bc2c6b246..c1e570c50d7e6 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc @@ -17,7 +17,7 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/Exception.h" @@ -47,19 +47,20 @@ using namespace reco; using namespace edm; using namespace std; -class PFTauSecondaryVertexProducer : public EDProducer { +class PFTauSecondaryVertexProducer : public edm::global::EDProducer<> { public: enum Alg{useInputPV=0, usePVwithMaxSumPt, useTauPV}; explicit PFTauSecondaryVertexProducer(const edm::ParameterSet& iConfig); ~PFTauSecondaryVertexProducer(); - virtual void produce(edm::Event&,const edm::EventSetup&); + virtual void produce(edm::StreamID, edm::Event&,const edm::EventSetup&) const override; private: - edm::InputTag PFTauTag_; - edm::EDGetTokenT > PFTauToken_; + const edm::InputTag PFTauTag_; + const edm::EDGetTokenT > PFTauToken_; }; PFTauSecondaryVertexProducer::PFTauSecondaryVertexProducer(const edm::ParameterSet& iConfig): + PFTauTag_(iConfig.getParameter("PFTauTag")), PFTauToken_(consumes >(iConfig.getParameter("PFTauTag"))) { produces > > >(); @@ -70,7 +71,7 @@ PFTauSecondaryVertexProducer::~PFTauSecondaryVertexProducer(){ } -void PFTauSecondaryVertexProducer::produce(edm::Event& iEvent,const edm::EventSetup& iSetup){ +void PFTauSecondaryVertexProducer::produce(edm::StreamID, edm::Event& iEvent,const edm::EventSetup& iSetup) const { // Obtain edm::ESHandle transTrackBuilder; iSetup.get().get("TransientTrackBuilder",transTrackBuilder); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc b/RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc index bcd25e08227e2..ff05f8fdfbe12 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc @@ -18,7 +18,7 @@ #include #include -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" @@ -38,15 +38,15 @@ #include "CommonTools/Utils/interface/StringCutObjectSelector.h" template -class RecoTauCleanerImpl : public edm::EDProducer +class RecoTauCleanerImpl : public edm::stream::EDProducer<> { typedef reco::tau::RecoTauCleanerPlugin Cleaner; struct CleanerEntryType { - boost::shared_ptr plugin_; + std::shared_ptr plugin_; float tolerance_; }; - typedef std::vector CleanerList; + typedef std::vector > CleanerList; // Define our output type - i.e. reco::PFTau OR reco::PFTauRef typedef typename Prod::value_type output_type; @@ -54,7 +54,7 @@ class RecoTauCleanerImpl : public edm::EDProducer class RemoveDuplicateJets { public: - bool operator()(const reco::PFTauRef& a, const reco::PFTauRef& b) { return (a->jetRef() == b->jetRef()); } + bool operator()(const reco::PFTauRef& a, const reco::PFTauRef& b) const { return (a->jetRef() == b->jetRef()); } }; public: @@ -66,7 +66,7 @@ class RecoTauCleanerImpl : public edm::EDProducer edm::InputTag tauSrc_; CleanerList cleaners_; // Optional selection on the output of the taus - std::auto_ptr > outputSelector_; + std::unique_ptr > outputSelector_; edm::EDGetTokenT tau_token; int verbosity_; }; @@ -89,7 +89,7 @@ RecoTauCleanerImpl::RecoTauCleanerImpl(const edm::ParameterSet& pset) cleanerEntry->plugin_.reset(RecoTauCleanerPluginFactory::get()->create(pluginType, *cleanerPSet, consumesCollector())); cleanerEntry->tolerance_ = ( cleanerPSet->exists("tolerance") ) ? cleanerPSet->getParameter("tolerance") : 0.; - cleaners_.push_back(cleanerEntry); + cleaners_.emplace_back(cleanerEntry); } // Check if we want to apply a final output selection @@ -110,11 +110,7 @@ RecoTauCleanerImpl::RecoTauCleanerImpl(const edm::ParameterSet& pset) template RecoTauCleanerImpl::~RecoTauCleanerImpl() -{ - for ( typename CleanerList::const_iterator it = cleaners_.begin(); - it != cleaners_.end(); ++it ) { - delete (*it); - } +{ } namespace { diff --git a/RecoTauTag/RecoTau/src/PFRecoTauTagInfoAlgorithm.cc b/RecoTauTag/RecoTau/src/PFRecoTauTagInfoAlgorithm.cc index 62dd9fef4837d..3a93f26a67707 100644 --- a/RecoTauTag/RecoTau/src/PFRecoTauTagInfoAlgorithm.cc +++ b/RecoTauTag/RecoTau/src/PFRecoTauTagInfoAlgorithm.cc @@ -26,7 +26,7 @@ PFRecoTauTagInfoAlgorithm::PFRecoTauTagInfoAlgorithm(const edm::ParameterSet& pa tkPVmaxDZ_ = parameters.getParameter("tkPVmaxDZ"); } -PFTauTagInfo PFRecoTauTagInfoAlgorithm::buildPFTauTagInfo(const PFJetRef& thePFJet,const std::vector& thePFCandsInEvent, const TrackRefVector& theTracks,const Vertex& thePV){ +PFTauTagInfo PFRecoTauTagInfoAlgorithm::buildPFTauTagInfo(const PFJetRef& thePFJet,const std::vector& thePFCandsInEvent, const TrackRefVector& theTracks,const Vertex& thePV) const { PFTauTagInfo resultExtended; resultExtended.setpfjetRef(thePFJet);