diff --git a/FWCore/Framework/test/stubs/HistoryAnalyzer.cc b/FWCore/Framework/test/stubs/HistoryAnalyzer.cc index dd3a25aa68459..e568f650c45ce 100644 --- a/FWCore/Framework/test/stubs/HistoryAnalyzer.cc +++ b/FWCore/Framework/test/stubs/HistoryAnalyzer.cc @@ -86,6 +86,17 @@ namespace edmtest { edm::ParameterSet proc_pset; event.getProcessParameterSet(event.processHistory().rbegin()->processName(),proc_pset); + { + // test the function getProcessParameterSetContainingModule this is a + // convenient spot to test because this module is run in both a + // a single process and in a subprocess. + edm::ParameterSet proc_pset2 = edm::getProcessParameterSetContainingModule(moduleDescription()); + assert(proc_pset2.id() == proc_pset.id()); + vstring paths1 = proc_pset.getParameter("@paths"); + vstring paths2 = proc_pset2.getParameter("@paths"); + assert(paths1 == paths2); + } + edm::pset::Registry* reg = edm::pset::Registry::instance(); if (!expectedPaths_.empty()) { diff --git a/FWCore/Integration/test/EventHistory_SubProcess_cfg.py b/FWCore/Integration/test/EventHistory_SubProcess_cfg.py index 9045b2b494173..f3d9497926818 100644 --- a/FWCore/Integration/test/EventHistory_SubProcess_cfg.py +++ b/FWCore/Integration/test/EventHistory_SubProcess_cfg.py @@ -260,3 +260,13 @@ process6.ep61 = cms.EndPath(process6.out) process6.ep62 = cms.EndPath(process6.producerOnEndPath*process6.filterOnEndPath*process6.out*process6.historytest) process6.ep63 = cms.EndPath(process6.analyzerOnEndPath*process6.out2*process6.out) + +process7 = cms.Process("SEVENTH") + +process6.subProcess = cms.SubProcess(process7) + +process7.dummyproducerxxx = cms.EDProducer("IntProducer", + ivalue = cms.int32(2) +) + +process7.p1 = cms.Path(process7.dummyproducerxxx) diff --git a/FWCore/ParameterSet/interface/ParameterSet.h b/FWCore/ParameterSet/interface/ParameterSet.h index 84503329daafc..a83e87382795a 100644 --- a/FWCore/ParameterSet/interface/ParameterSet.h +++ b/FWCore/ParameterSet/interface/ParameterSet.h @@ -30,6 +30,7 @@ namespace cms { } namespace edm { + class ModuleDescription; typedef std::vector VParameterSet; class ParameterSet { @@ -335,6 +336,9 @@ namespace edm { ParameterSet const& getParameterSet(ParameterSetID const& id); + ParameterSet const& + getProcessParameterSetContainingModule(ModuleDescription const& moduleDescription); + // specializations // ---------------------------------------------------------------------- diff --git a/FWCore/ParameterSet/src/ParameterSet.cc b/FWCore/ParameterSet/src/ParameterSet.cc index a562219ed5fd0..cf8f79c0817ae 100644 --- a/FWCore/ParameterSet/src/ParameterSet.cc +++ b/FWCore/ParameterSet/src/ParameterSet.cc @@ -16,6 +16,8 @@ #include "FWCore/Utilities/interface/Digest.h" #include "FWCore/Utilities/interface/EDMException.h" +#include "DataFormats/Provenance/interface/ModuleDescription.h" + #include #include #include @@ -951,14 +953,19 @@ namespace edm { // Free function to return a parameterSet given its ID. ParameterSet const& getParameterSet(ParameterSetID const& id) { - ParameterSet const* result = 0; - if(0 == (result = pset::Registry::instance()->getMapped(id))) { - throw Exception(errors::Configuration, "MissingParameterSet:") + ParameterSet const* result = nullptr; + if(nullptr == (result = pset::Registry::instance()->getMapped(id))) { + throw Exception(errors::LogicError, "MissingParameterSet:") << "Parameter Set ID '" << id << "' not found."; } return *result; } + ParameterSet const& + getProcessParameterSetContainingModule(ModuleDescription const& moduleDescription) { + return getParameterSet(moduleDescription.mainParameterSetID()); + } + void ParameterSet::deprecatedInputTagWarning(std::string const& name, std::string const& label) const { LogWarning("Configuration") << "Warning:\n\tstring " << name