Skip to content

Commit

Permalink
Added ConsumesCollector usage to ExternalDecayDriver
Browse files Browse the repository at this point in the history
Only Tauola needed it.
  • Loading branch information
Dr15Jones committed Oct 13, 2021
1 parent 05f57d3 commit 1d78e81
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 13 deletions.
3 changes: 2 additions & 1 deletion GeneratorInterface/Core/interface/GeneratorFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -100,7 +101,7 @@ namespace edm {
if (ps.exists("ExternalDecays")) {
//decayer_ = new gen::ExternalDecayDriver(ps.getParameter<ParameterSet>("ExternalDecays"));
ParameterSet ps1 = ps.getParameter<ParameterSet>("ExternalDecays");
decayer_ = new Decayer(ps1);
decayer_ = new Decayer(ps1, consumesCollector());

std::vector<std::string> const& sharedResourcesDec = decayer_->sharedResources();
for (auto const& resource : sharedResourcesDec) {
Expand Down
3 changes: 2 additions & 1 deletion GeneratorInterface/Core/interface/HadronizerFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -131,7 +132,7 @@ namespace edm {
if (ps.exists("ExternalDecays")) {
//decayer_ = new gen::ExternalDecayDriver(ps.getParameter<ParameterSet>("ExternalDecays"));
ParameterSet ps1 = ps.getParameter<ParameterSet>("ExternalDecays");
decayer_ = new Decayer(ps1);
decayer_ = new Decayer(ps1, consumesCollector());

std::vector<std::string> const& sharedResourcesDec = decayer_->sharedResources();
for (auto const& resource : sharedResourcesDec) {
Expand Down
2 changes: 1 addition & 1 deletion GeneratorInterface/Core/test/FailingGeneratorFilter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ namespace test {

class DummyDec {
public:
DummyDec(const edm::ParameterSet&) {}
DummyDec(const edm::ParameterSet&, edm::ConsumesCollector) {}
std::vector<std::string> sharedResources() const { return {}; }

HepMC::GenEvent* decay(HepMC::GenEvent const*) { return nullptr; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

#include <string>
#include <vector>
Expand All @@ -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&);
Expand Down
5 changes: 3 additions & 2 deletions GeneratorInterface/ExternalDecays/src/ExternalDecayDriver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> extGenNames = pset.getParameter<std::vector<std::string> >("parameterSets");

for (unsigned int ip = 0; ip < extGenNames.size(); ++ip) {
Expand All @@ -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<TauolaInterfaceBase>(
TauolaFactory::get()->create("Tauolapp114", pset.getUntrackedParameter<ParameterSet>(curSet)));
TauolaFactory::get()->create("Tauolapp114", pset.getUntrackedParameter<ParameterSet>(curSet), iCollector));
fPhotosInterface = std::unique_ptr<PhotosInterfaceBase>(
PhotosFactory::get()->create("Photos2155", pset.getUntrackedParameter<ParameterSet>(curSet)));
fPhotosInterface->configureOnlyFor(15);
Expand Down
4 changes: 3 additions & 1 deletion GeneratorInterface/TauolaInterface/interface/TauolaFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<gen::TauolaInterfaceBase*(const edm::ParameterSet&)> TauolaFactory;
typedef edmplugin::PluginFactory<gen::TauolaInterfaceBase*(const edm::ParameterSet&, edm::ConsumesCollector)>
TauolaFactory;

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand Down Expand Up @@ -72,6 +73,7 @@ namespace gen {
std::vector<int> fPDGs;
bool fPolarization;
edm::ESHandle<HepPDT::ParticleDataTable> fPDGTable;
edm::ESGetToken<HepPDT::ParticleDataTable, edm::DefaultRecord> fPDGTableToken;
edm::ParameterSet* fPSet;
bool fIsInitialized;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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);
}

Expand All @@ -78,7 +76,7 @@ void TauolappInterface::init(const edm::EventSetup& es) {

fIsInitialized = true;

es.getData(fPDGTable);
fPDGTable = es.getHandle(fPDGTableToken);

Tauolapp::Tauola::setDecayingParticle(15);

Expand Down

0 comments on commit 1d78e81

Please sign in to comment.