diff --git a/CommonTools/CandAlgos/interface/CandCombiner.h b/CommonTools/CandAlgos/interface/CandCombiner.h index ac93f2a9b3b49..bdc09f03082c0 100644 --- a/CommonTools/CandAlgos/interface/CandCombiner.h +++ b/CommonTools/CandAlgos/interface/CandCombiner.h @@ -131,6 +131,7 @@ namespace reco { /// constructor from parameter settypedef explicit CandCombiner(const edm::ParameterSet& cfg) : CandCombinerBase(cfg), + combinerInit_(consumesCollector()), combiner_(reco::modules::make(cfg, consumesCollector()), reco::modules::make(cfg), Setup(cfg), @@ -146,7 +147,7 @@ namespace reco { private: /// process an event void produce(edm::Event& evt, const edm::EventSetup& es) override { - Init::init(combiner_.setup(), evt, es); + combinerInit_.init(combiner_.setup(), evt, es); int n = labels_.size(); std::vector > colls(n); for (int i = 0; i < n; ++i) @@ -168,6 +169,7 @@ namespace reco { evt.put(std::move(out)); } /// combiner utility + Init combinerInit_; ::CandCombiner combiner_; RoleNames names_; diff --git a/CommonTools/RecoAlgos/interface/CandidateProducer.h b/CommonTools/RecoAlgos/interface/CandidateProducer.h index b1b2963bb30db..5e1bcb2f82d92 100644 --- a/CommonTools/RecoAlgos/interface/CandidateProducer.h +++ b/CommonTools/RecoAlgos/interface/CandidateProducer.h @@ -73,6 +73,7 @@ class CandidateProducer : public edm::stream::EDProducer<> { CandidateProducer(const edm::ParameterSet& cfg) : srcToken_(consumes(cfg.template getParameter("src"))), converter_(cfg, consumesCollector()), + selectorInit_(consumesCollector()), selector_(reco::modules::make(cfg, consumesCollector())), initialized_(false) { produces(); @@ -92,7 +93,7 @@ class CandidateProducer : public edm::stream::EDProducer<> { void produce(edm::Event& evt, const edm::EventSetup& es) override { edm::Handle src; evt.getByToken(srcToken_, src); - Init::init(selector_, evt, es); + selectorInit_.init(selector_, evt, es); ::helper::MasterCollection master(src, evt); std::unique_ptr cands(new CColl); if (!src->empty()) { @@ -110,6 +111,7 @@ class CandidateProducer : public edm::stream::EDProducer<> { /// converter helper Conv converter_; /// selector + Init selectorInit_; Selector selector_; /// particles initialized? bool initialized_; diff --git a/CommonTools/UtilAlgos/interface/AssociatedVariableCollectionSelector.h b/CommonTools/UtilAlgos/interface/AssociatedVariableCollectionSelector.h index 46d67a6ff47a5..1bd74a740e2e9 100644 --- a/CommonTools/UtilAlgos/interface/AssociatedVariableCollectionSelector.h +++ b/CommonTools/UtilAlgos/interface/AssociatedVariableCollectionSelector.h @@ -66,10 +66,11 @@ namespace reco { namespace modules { template struct AssociatedVariableCollectionSelectorEventSetupInit { - static void init(S& s, const edm::Event& evt, const edm::EventSetup& es) { - typedef typename EventSetupInit::type ESI; - ESI::init(s.select_, evt, es); - } + explicit AssociatedVariableCollectionSelectorEventSetupInit(edm::ConsumesCollector iC) : esi_(iC) {} + + void init(S& s, const edm::Event& evt, const edm::EventSetup& es) { esi_.init(s.select_, evt, es); } + typedef typename EventSetupInit::type ESI; + ESI esi_; }; template @@ -77,6 +78,7 @@ namespace reco { typedef AssociatedVariableCollectionSelectorEventSetupInit > type; }; + } // namespace modules } // namespace reco diff --git a/CommonTools/UtilAlgos/interface/EventSetupInitTrait.h b/CommonTools/UtilAlgos/interface/EventSetupInitTrait.h index 52acbf4d23132..4cd4a78b6501d 100644 --- a/CommonTools/UtilAlgos/interface/EventSetupInitTrait.h +++ b/CommonTools/UtilAlgos/interface/EventSetupInitTrait.h @@ -2,6 +2,7 @@ #define UtilAlgos_EventSetupInitTrait_h #include "CommonTools/UtilAlgos/interface/AndSelector.h" #include "CommonTools/UtilAlgos/interface/OrSelector.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" namespace edm { class EventSetup; @@ -17,14 +18,18 @@ namespace reco { /// take no action (default) template struct NoEventSetupInit { - static void init(T&, const edm::Event&, const edm::EventSetup&) {} + explicit NoEventSetupInit(edm::ConsumesCollector) {} + NoEventSetupInit() = delete; + void init(T&, const edm::Event&, const edm::EventSetup&) {} }; /// implement common interface defined in: /// https://twiki.cern.ch/twiki/bin/view/CMS/SelectorInterface struct CommonSelectorEventSetupInit { + explicit CommonSelectorEventSetupInit(edm::ConsumesCollector) {} + CommonSelectorEventSetupInit() = delete; template - static void init(Selector& selector, const edm::Event& evt, const edm::EventSetup& es) { + void init(Selector& selector, const edm::Event& evt, const edm::EventSetup& es) { selector.newEvent(evt, es); } }; @@ -40,51 +45,68 @@ namespace reco { typename T4 = helpers::NullAndOperand, typename T5 = helpers::NullAndOperand> struct CombinedEventSetupInit { + explicit CombinedEventSetupInit(edm::ConsumesCollector iC) : t1_(iC), t2_(iC), t3_(iC), t4_(iC), t5_(iC) {} template