Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getProducerParameterSet #29148

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions FWCore/Framework/interface/getProducerParameterSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,19 @@
// Original Author: W. David Dagenhart
// Created: 7 September 2017

#include <string>

namespace edm {

class ParameterSet;
class Provenance;
class ProcessHistory;

ParameterSet const* getProducerParameterSet(Provenance const& provenance, ProcessHistory const&);

ParameterSet const* getProducerParameterSet(ProcessHistory const&,
std::string const& processName,
std::string const& moduleLabel);

} // namespace edm
#endif
33 changes: 20 additions & 13 deletions FWCore/Framework/src/getProducerParameterSet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include "FWCore/ParameterSet/interface/Registry.h"
#include "FWCore/Utilities/interface/Exception.h"

#include <string>

namespace edm {

ParameterSet const* getProducerParameterSet(Provenance const& provenance, ProcessHistory const& processHistory) {
Expand All @@ -19,20 +17,29 @@ namespace edm {
if (branchDescription) {
std::string const& process = branchDescription->processName();
std::string const& label = branchDescription->moduleLabel();

for (ProcessConfiguration const& pc : processHistory) {
if (pc.processName() == process) {
ParameterSetID const& psetID = pc.parameterSetID();
pset::Registry const* psetRegistry = pset::Registry::instance();
ParameterSet const* processPset = psetRegistry->getMapped(psetID);
if (processPset) {
return &processPset->getParameterSet(label);
}
}
}
return getProducerParameterSet(processHistory, process, label);
}
// This should never happen
throw cms::Exception("LogicError") << "getProducerParameterSet failed";
return nullptr;
}

ParameterSet const* getProducerParameterSet(ProcessHistory const& processHistory,
std::string const& processName,
std::string const& moduleLabel) {
ParameterSet const* iConfig = nullptr;
pset::Registry const* psetRegistry = pset::Registry::instance();
for (ProcessConfiguration const& pc : processHistory) {
if (!processName.empty() && processName != pc.processName())
continue;
ParameterSet const* processPset = psetRegistry->getMapped(pc.parameterSetID());
if (processPset && processPset->exists(moduleLabel))
iConfig = &processPset->getParameterSet(moduleLabel);
}
if (!iConfig)
throw cms::Exception("Configuration")
<< "Failed to find module " << moduleLabel << " in process " << processName << ".";
return iConfig;
}

} // namespace edm