CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FillProductRegistryTransients.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: ParameterSet
4 //
5 // fillProductRegistry()
6 // This free function reads information from the process parameter set
7 // and writes information derived from this into the ProductRegistry.
8 // It really does not belong in ParameterSet, but ParameterSet is the only existing
9 // package in which it can go without introducing additional package dependencies.
10 
17 
18 namespace edm {
19  void
20  fillProductRegistryTransients(ProcessConfiguration const& pc, ProductRegistry const& preg, bool okToRegister) {
21  std::string const triggerResults = std::string("TriggerResults");
22  std::string const triggerResultsInserter = std::string("TriggerResultsInserter");
23  std::string const triggerPaths = std::string("@trigger_paths");
24  std::string const source = std::string("source");
25  std::string const input = std::string("@main_input");
26  ProcessConfigurationID pcid = pc.id();
27  std::string const& processName = pc.processName();
28  ParameterSetID const& processParameterSetID = pc.parameterSetID();
29  ParameterSet const* processParameterSet = pset::Registry::instance()->getMapped(processParameterSetID);
30  if(0 == processParameterSet || processParameterSet->empty()) {
31  return;
32  }
33  for(ProductRegistry::ProductList::const_iterator it = preg.productList().begin(),
34  itEnd = preg.productList().end();
35  it != itEnd; ++it) {
36  BranchDescription const& bd = it->second;
37  if(processName != bd.processName()) {
38  continue;
39  }
40  std::string moduleLabel = bd.moduleLabel();
41  bool isTriggerResults = (moduleLabel == triggerResults);
42  if(isTriggerResults) {
43  moduleLabel = triggerPaths;
44  } else if(moduleLabel == source) {
45  moduleLabel = input;
46  }
47  if(processParameterSet->existsAs<ParameterSet>(moduleLabel)) {
48  ParameterSet const& moduleParameterSet = processParameterSet->getParameterSet(moduleLabel);
49  if(okToRegister && !moduleParameterSet.isRegistered()) {
50  ParameterSet moduleParameterSetCopy = processParameterSet->getParameterSet(moduleLabel);
51  moduleParameterSetCopy.registerIt();
52  bd.parameterSetIDs().insert(std::make_pair(pcid, moduleParameterSetCopy.id()));
53  } else {
54  bd.parameterSetIDs().insert(std::make_pair(pcid, moduleParameterSet.id()));
55  }
56  if(isTriggerResults) {
57  bd.moduleNames().insert(std::make_pair(pcid, triggerResultsInserter));
58  } else {
59  bd.moduleNames().insert(std::make_pair(pcid, moduleParameterSet.getParameter<std::string>("@module_type")));
60  }
61  }
62  }
63  }
64 
65  void
66  fillProductRegistryTransients(std::vector<ProcessConfiguration> const& pcVec, ProductRegistry const& preg, bool okToRegister) {
67  typedef std::vector<ProcessConfiguration>::const_iterator PCIter;
68  for(PCIter i = pcVec.begin(), iEnd = pcVec.end(); i != iEnd; ++i) {
69  fillProductRegistryTransients(*i, preg, okToRegister);
70  }
71  }
72 }
T getParameter(std::string const &) const
bool empty() const
Definition: ParameterSet.h:219
int i
Definition: DBlmapReader.cc:9
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:187
ProcessConfigurationID id() const
ParameterSetID id() const
std::map< ProcessConfigurationID, std::string > & moduleNames() const
static ThreadSafeRegistry * instance()
std::string const & processName() const
void fillProductRegistryTransients(std::vector< ProcessConfiguration > const &pcVec, ProductRegistry const &preg, bool okToRegister=false)
std::string const & processName() const
ProductList const & productList() const
ParameterSetID const & parameterSetID() const
bool getMapped(key_type const &k, value_type &result) const
std::string const & moduleLabel() const
bool isRegistered() const
Definition: ParameterSet.h:66
ParameterSet const & getParameterSet(std::string const &) const
std::map< ProcessConfigurationID, ParameterSetID > & parameterSetIDs() const
author Stefano ARGIRO author Bill Tanenbaum
ParameterSet const & registerIt()