Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "FWCore/ParameterSet/interface/FillProductRegistryTransients.h"
00012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00013 #include "FWCore/ParameterSet/interface/Registry.h"
00014 #include "DataFormats/Provenance/interface/ProcessConfigurationID.h"
00015 #include "DataFormats/Provenance/interface/ProcessConfiguration.h"
00016 #include "DataFormats/Provenance/interface/ProductRegistry.h"
00017
00018 namespace edm {
00019 void
00020 fillProductRegistryTransients(ProcessConfiguration const& pc, ProductRegistry const& preg, bool okToRegister) {
00021 std::string const triggerResults = std::string("TriggerResults");
00022 std::string const triggerResultsInserter = std::string("TriggerResultsInserter");
00023 std::string const triggerPaths = std::string("@trigger_paths");
00024 std::string const source = std::string("source");
00025 std::string const input = std::string("@main_input");
00026 ProcessConfigurationID pcid = pc.id();
00027 std::string const& processName = pc.processName();
00028 ParameterSetID const& processParameterSetID = pc.parameterSetID();
00029 ParameterSet const* processParameterSet = pset::Registry::instance()->getMapped(processParameterSetID);
00030 if(0 == processParameterSet || processParameterSet->empty()) {
00031 return;
00032 }
00033 for(ProductRegistry::ProductList::const_iterator it = preg.productList().begin(),
00034 itEnd = preg.productList().end();
00035 it != itEnd; ++it) {
00036 BranchDescription const& bd = it->second;
00037 if(processName != bd.processName()) {
00038 continue;
00039 }
00040 std::string moduleLabel = bd.moduleLabel();
00041 bool isTriggerResults = (moduleLabel == triggerResults);
00042 if(isTriggerResults) {
00043 moduleLabel = triggerPaths;
00044 } else if(moduleLabel == source) {
00045 moduleLabel = input;
00046 }
00047 if(processParameterSet->existsAs<ParameterSet>(moduleLabel)) {
00048 ParameterSet const& moduleParameterSet = processParameterSet->getParameterSet(moduleLabel);
00049 if(okToRegister && !moduleParameterSet.isRegistered()) {
00050 ParameterSet moduleParameterSetCopy = processParameterSet->getParameterSet(moduleLabel);
00051 moduleParameterSetCopy.registerIt();
00052 bd.parameterSetIDs().insert(std::make_pair(pcid, moduleParameterSetCopy.id()));
00053 } else {
00054 bd.parameterSetIDs().insert(std::make_pair(pcid, moduleParameterSet.id()));
00055 }
00056 if(isTriggerResults) {
00057 bd.moduleNames().insert(std::make_pair(pcid, triggerResultsInserter));
00058 } else {
00059 bd.moduleNames().insert(std::make_pair(pcid, moduleParameterSet.getParameter<std::string>("@module_type")));
00060 }
00061 }
00062 }
00063 }
00064
00065 void
00066 fillProductRegistryTransients(std::vector<ProcessConfiguration> const& pcVec, ProductRegistry const& preg, bool okToRegister) {
00067 typedef std::vector<ProcessConfiguration>::const_iterator PCIter;
00068 for(PCIter i = pcVec.begin(), iEnd = pcVec.end(); i != iEnd; ++i) {
00069 fillProductRegistryTransients(*i, preg, okToRegister);
00070 }
00071 }
00072 }