From b35619ff0210d819e71fbe2c85da7c52b75c3ea1 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Wed, 13 Oct 2021 16:30:06 -0500 Subject: [PATCH] Added ConsumesCollector usage to ExternalDecayDriver Only Tauola needed it. --- GeneratorInterface/Core/interface/GeneratorFilter.h | 3 ++- GeneratorInterface/Core/interface/HadronizerFilter.h | 3 ++- GeneratorInterface/Core/test/FailingGeneratorFilter.cc | 2 +- .../ExternalDecays/interface/ExternalDecayDriver.h | 3 ++- .../ExternalDecays/src/ExternalDecayDriver.cc | 5 +++-- .../TauolaInterface/interface/TauolaFactory.h | 4 +++- .../TauolaInterface/interface/TauolappInterface.h | 4 +++- .../TauolaInterface/plugins/Tauolapp/TauolappInterface.cc | 8 +++----- 8 files changed, 19 insertions(+), 13 deletions(-) diff --git a/GeneratorInterface/Core/interface/GeneratorFilter.h b/GeneratorInterface/Core/interface/GeneratorFilter.h index de8816869f0cd..1b9b6d847a656 100644 --- a/GeneratorInterface/Core/interface/GeneratorFilter.h +++ b/GeneratorInterface/Core/interface/GeneratorFilter.h @@ -21,6 +21,7 @@ #include "FWCore/Framework/interface/LuminosityBlock.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/Run.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ServiceRegistry/interface/RandomEngineSentry.h" #include "FWCore/Utilities/interface/EDMException.h" @@ -100,7 +101,7 @@ namespace edm { if (ps.exists("ExternalDecays")) { //decayer_ = new gen::ExternalDecayDriver(ps.getParameter("ExternalDecays")); ParameterSet ps1 = ps.getParameter("ExternalDecays"); - decayer_ = new Decayer(ps1); + decayer_ = new Decayer(ps1, consumesCollector()); std::vector const& sharedResourcesDec = decayer_->sharedResources(); for (auto const& resource : sharedResourcesDec) { diff --git a/GeneratorInterface/Core/interface/HadronizerFilter.h b/GeneratorInterface/Core/interface/HadronizerFilter.h index ff94e0cb079e4..1dfc22e4ab9d4 100644 --- a/GeneratorInterface/Core/interface/HadronizerFilter.h +++ b/GeneratorInterface/Core/interface/HadronizerFilter.h @@ -21,6 +21,7 @@ #include "FWCore/Framework/interface/LuminosityBlock.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/Run.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ServiceRegistry/interface/RandomEngineSentry.h" #include "FWCore/Utilities/interface/BranchType.h" @@ -131,7 +132,7 @@ namespace edm { if (ps.exists("ExternalDecays")) { //decayer_ = new gen::ExternalDecayDriver(ps.getParameter("ExternalDecays")); ParameterSet ps1 = ps.getParameter("ExternalDecays"); - decayer_ = new Decayer(ps1); + decayer_ = new Decayer(ps1, consumesCollector()); std::vector const& sharedResourcesDec = decayer_->sharedResources(); for (auto const& resource : sharedResourcesDec) { diff --git a/GeneratorInterface/Core/test/FailingGeneratorFilter.cc b/GeneratorInterface/Core/test/FailingGeneratorFilter.cc index 0717a728a199d..ae9240740c5d6 100644 --- a/GeneratorInterface/Core/test/FailingGeneratorFilter.cc +++ b/GeneratorInterface/Core/test/FailingGeneratorFilter.cc @@ -108,7 +108,7 @@ namespace test { class DummyDec { public: - DummyDec(const edm::ParameterSet&) {} + DummyDec(const edm::ParameterSet&, edm::ConsumesCollector) {} std::vector sharedResources() const { return {}; } HepMC::GenEvent* decay(HepMC::GenEvent const*) { return nullptr; } diff --git a/GeneratorInterface/ExternalDecays/interface/ExternalDecayDriver.h b/GeneratorInterface/ExternalDecays/interface/ExternalDecayDriver.h index 1d6ef1762b012..c914017e98957 100644 --- a/GeneratorInterface/ExternalDecays/interface/ExternalDecayDriver.h +++ b/GeneratorInterface/ExternalDecays/interface/ExternalDecayDriver.h @@ -3,6 +3,7 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" #include #include @@ -28,7 +29,7 @@ namespace gen { class ExternalDecayDriver { public: // ctor & dtor - ExternalDecayDriver(const edm::ParameterSet&); + ExternalDecayDriver(const edm::ParameterSet&, edm::ConsumesCollector); ~ExternalDecayDriver(); void init(const edm::EventSetup&); diff --git a/GeneratorInterface/ExternalDecays/src/ExternalDecayDriver.cc b/GeneratorInterface/ExternalDecays/src/ExternalDecayDriver.cc index c70474081d2db..f9a14fb12baff 100644 --- a/GeneratorInterface/ExternalDecays/src/ExternalDecayDriver.cc +++ b/GeneratorInterface/ExternalDecays/src/ExternalDecayDriver.cc @@ -20,7 +20,8 @@ using namespace gen; using namespace edm; -ExternalDecayDriver::ExternalDecayDriver(const ParameterSet& pset) : fIsInitialized(false) { +ExternalDecayDriver::ExternalDecayDriver(const ParameterSet& pset, edm::ConsumesCollector iCollector) + : fIsInitialized(false) { std::vector extGenNames = pset.getParameter >("parameterSets"); for (unsigned int ip = 0; ip < extGenNames.size(); ++ip) { @@ -41,7 +42,7 @@ ExternalDecayDriver::ExternalDecayDriver(const ParameterSet& pset) : fIsInitiali exSharedResources.emplace_back(gen::FortranInstance::kFortranInstance); } else if (curSet == "Tauola" || curSet == "Tauolapp" || curSet == "Tauolapp114") { fTauolaInterface = std::unique_ptr( - TauolaFactory::get()->create("Tauolapp114", pset.getUntrackedParameter(curSet))); + TauolaFactory::get()->create("Tauolapp114", pset.getUntrackedParameter(curSet), iCollector)); fPhotosInterface = std::unique_ptr( PhotosFactory::get()->create("Photos2155", pset.getUntrackedParameter(curSet))); fPhotosInterface->configureOnlyFor(15); diff --git a/GeneratorInterface/TauolaInterface/interface/TauolaFactory.h b/GeneratorInterface/TauolaInterface/interface/TauolaFactory.h index fb68d5bbc2c08..ccc20e77d5676 100644 --- a/GeneratorInterface/TauolaInterface/interface/TauolaFactory.h +++ b/GeneratorInterface/TauolaInterface/interface/TauolaFactory.h @@ -3,8 +3,10 @@ #include "FWCore/PluginManager/interface/PluginFactory.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" #include "GeneratorInterface/TauolaInterface/interface/TauolaInterfaceBase.h" -typedef edmplugin::PluginFactory TauolaFactory; +typedef edmplugin::PluginFactory + TauolaFactory; #endif diff --git a/GeneratorInterface/TauolaInterface/interface/TauolappInterface.h b/GeneratorInterface/TauolaInterface/interface/TauolappInterface.h index 0d9bb16d7ddb7..a9485a3d8a573 100644 --- a/GeneratorInterface/TauolaInterface/interface/TauolappInterface.h +++ b/GeneratorInterface/TauolaInterface/interface/TauolappInterface.h @@ -6,6 +6,7 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" #include "GeneratorInterface/TauolaInterface/interface/TauolaInterfaceBase.h" #include "TLorentzVector.h" #include "TVector.h" @@ -27,7 +28,7 @@ namespace gen { class TauolappInterface : public TauolaInterfaceBase { public: // ctor & dtor - TauolappInterface(const edm::ParameterSet&); + TauolappInterface(const edm::ParameterSet&, edm::ConsumesCollector); ~TauolappInterface() override; void enablePolarization() override { @@ -72,6 +73,7 @@ namespace gen { std::vector fPDGs; bool fPolarization; edm::ESHandle fPDGTable; + edm::ESGetToken fPDGTableToken; edm::ParameterSet* fPSet; bool fIsInitialized; diff --git a/GeneratorInterface/TauolaInterface/plugins/Tauolapp/TauolappInterface.cc b/GeneratorInterface/TauolaInterface/plugins/Tauolapp/TauolappInterface.cc index b30dd56af1958..f0c85c2a19db3 100644 --- a/GeneratorInterface/TauolaInterface/plugins/Tauolapp/TauolappInterface.cc +++ b/GeneratorInterface/TauolaInterface/plugins/Tauolapp/TauolappInterface.cc @@ -47,8 +47,9 @@ void gen::ranmar_(float* rvec, int* lenv) { void gen::rmarin_(int*, int*, int*) { return; } } -TauolappInterface::TauolappInterface(const edm::ParameterSet& pset) +TauolappInterface::TauolappInterface(const edm::ParameterSet& pset, edm::ConsumesCollector iCollector) : fPolarization(false), + fPDGTableToken(iCollector.esConsumes()), fPSet(nullptr), fIsInitialized(false), fMDTAU(-1), @@ -58,9 +59,6 @@ TauolappInterface::TauolappInterface(const edm::ParameterSet& pset) dolhe(false), dolheBosonCorr(false), ntries(10) { - if (fPSet != nullptr) - throw cms::Exception("TauolappInterfaceError") << "Attempt to override Tauola an existing ParameterSet\n" - << std::endl; fPSet = new ParameterSet(pset); } @@ -78,7 +76,7 @@ void TauolappInterface::init(const edm::EventSetup& es) { fIsInitialized = true; - es.getData(fPDGTable); + fPDGTable = es.getHandle(fPDGTableToken); Tauolapp::Tauola::setDecayingParticle(15);