CMS 3D CMS Logo

EventSetupProviderMaker.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 
4 // user include files
6 
17 
18 #include <exception>
19 #include <string>
20 
21 namespace edm {
22  namespace eventsetup {
23  // ---------------------------------------------------------------
24  std::unique_ptr<EventSetupProvider> makeEventSetupProvider(ParameterSet const& params,
25  unsigned subProcessIndex,
26  ActivityRegistry* activityRegistry) {
27  std::vector<std::string> prefers = params.getParameter<std::vector<std::string> >("@all_esprefers");
28 
29  if (prefers.empty()) {
30  return std::make_unique<EventSetupProvider>(activityRegistry, subProcessIndex);
31  }
32 
35 
36  //recordToData.insert(std::make_pair(std::string("DummyRecord"),
37  // std::make_pair(std::string("DummyData"), std::string())));
38  //preferInfo[ComponentDescription("DummyESProductResolverProvider", "", false)]=
39  // recordToData;
40 
41  for (std::vector<std::string>::iterator itName = prefers.begin(), itNameEnd = prefers.end(); itName != itNameEnd;
42  ++itName) {
43  recordToData.clear();
44  ParameterSet const& preferPSet = params.getParameterSet(*itName);
45  std::vector<std::string> recordNames = preferPSet.getParameterNames();
46  for (std::vector<std::string>::iterator itRecordName = recordNames.begin(), itRecordNameEnd = recordNames.end();
47  itRecordName != itRecordNameEnd;
48  ++itRecordName) {
49  if ((*itRecordName)[0] == '@') {
50  //this is a 'hidden parameter' so skip it
51  continue;
52  }
53 
54  //this should be a record name with its info
55  try {
56  std::vector<std::string> dataInfo = preferPSet.getParameter<std::vector<std::string> >(*itRecordName);
57 
58  if (dataInfo.empty()) {
59  //FUTURE: empty should just mean all data
61  << "The record named " << *itRecordName << " specifies no data items";
62  }
63  //FUTURE: 'any' should be a special name
64  for (std::vector<std::string>::iterator itDatum = dataInfo.begin(), itDatumEnd = dataInfo.end();
65  itDatum != itDatumEnd;
66  ++itDatum) {
67  std::string datumName(*itDatum, 0, itDatum->find_first_of("/"));
69 
70  if (itDatum->size() != datumName.size()) {
71  labelName = std::string(*itDatum, datumName.size() + 1);
72  }
73  recordToData.insert(std::make_pair(std::string(*itRecordName), std::make_pair(datumName, labelName)));
74  }
75  } catch (cms::Exception const& iException) {
76  cms::Exception theError("ESPreferConfigurationError");
77  theError << "While parsing the es_prefer statement for type="
78  << preferPSet.getParameter<std::string>("@module_type") << " label=\""
79  << preferPSet.getParameter<std::string>("@module_label") << "\" an error occurred.";
80  theError.append(iException);
81  throw theError;
82  }
83  }
84  preferInfo[ComponentDescription(preferPSet.getParameter<std::string>("@module_type"),
85  preferPSet.getParameter<std::string>("@module_label"),
87  false)] = recordToData;
88  }
89  return std::make_unique<EventSetupProvider>(activityRegistry, subProcessIndex, &preferInfo);
90  }
91 
92  // ---------------------------------------------------------------
94  EventSetupsController& esController,
97  std::vector<std::string> providers = params.getParameter<std::vector<std::string> >("@all_esmodules");
98 
99  for (std::vector<std::string>::iterator itName = providers.begin(), itNameEnd = providers.end();
100  itName != itNameEnd;
101  ++itName) {
102  ParameterSet* providerPSet = params.getPSetForUpdate(*itName);
103  ModuleFactory::get()->addTo(esController, cp, *providerPSet, resolverMaker);
104  }
105 
106  std::vector<std::string> sources = params.getParameter<std::vector<std::string> >("@all_essources");
107 
108  for (std::vector<std::string>::iterator itName = sources.begin(), itNameEnd = sources.end(); itName != itNameEnd;
109  ++itName) {
110  ParameterSet* providerPSet = params.getPSetForUpdate(*itName);
111  SourceFactory::get()->addTo(esController, cp, *providerPSet, resolverMaker);
112  }
113  }
114  } // namespace eventsetup
115 } // namespace edm
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void append(Exception const &another)
Definition: Exception.cc:157
std::multimap< RecordName, DataKeyInfo > RecordToDataMap
std::unique_ptr< EventSetupProvider > makeEventSetupProvider(ParameterSet const &params, unsigned subProcessIndex, ActivityRegistry *activityRegistry)
void fillEventSetupProvider(ModuleTypeResolverMaker const *resolverMaker, EventSetupsController &esController, EventSetupProvider &cp, ParameterSet &params)
std::map< ComponentDescription, RecordToDataMap > PreferredProviderInfo
labelName
Custom Jet reco ####.
static constexpr unsigned int unknownID() noexcept
HLT enums.
static ComponentFactory< T > const * get()
std::vector< std::string > getParameterNames() const