CMS 3D CMS Logo

EventSetupProviderMaker.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 
4 // user include files
6 
18 
19 #include <exception>
20 #include <string>
21 
22 namespace edm {
23  namespace eventsetup {
24  // ---------------------------------------------------------------
25  std::unique_ptr<EventSetupProvider> makeEventSetupProvider(ParameterSet const& params,
26  unsigned subProcessIndex,
27  ActivityRegistry* activityRegistry,
28  tbb::task_arena* taskArena) {
29  std::vector<std::string> prefers = params.getParameter<std::vector<std::string> >("@all_esprefers");
30 
31  if (prefers.empty()) {
32  return std::make_unique<EventSetupProvider>(activityRegistry, taskArena, subProcessIndex);
33  }
34 
37 
38  //recordToData.insert(std::make_pair(std::string("DummyRecord"),
39  // std::make_pair(std::string("DummyData"), std::string())));
40  //preferInfo[ComponentDescription("DummyProxyProvider", "", false)]=
41  // recordToData;
42 
43  for (std::vector<std::string>::iterator itName = prefers.begin(), itNameEnd = prefers.end(); itName != itNameEnd;
44  ++itName) {
45  recordToData.clear();
46  ParameterSet const& preferPSet = params.getParameterSet(*itName);
47  std::vector<std::string> recordNames = preferPSet.getParameterNames();
48  for (std::vector<std::string>::iterator itRecordName = recordNames.begin(), itRecordNameEnd = recordNames.end();
49  itRecordName != itRecordNameEnd;
50  ++itRecordName) {
51  if ((*itRecordName)[0] == '@') {
52  //this is a 'hidden parameter' so skip it
53  continue;
54  }
55 
56  //this should be a record name with its info
57  try {
58  std::vector<std::string> dataInfo = preferPSet.getParameter<std::vector<std::string> >(*itRecordName);
59 
60  if (dataInfo.empty()) {
61  //FUTURE: empty should just mean all data
63  << "The record named " << *itRecordName << " specifies no data items";
64  }
65  //FUTURE: 'any' should be a special name
66  for (std::vector<std::string>::iterator itDatum = dataInfo.begin(), itDatumEnd = dataInfo.end();
67  itDatum != itDatumEnd;
68  ++itDatum) {
69  std::string datumName(*itDatum, 0, itDatum->find_first_of("/"));
70  std::string labelName;
71 
72  if (itDatum->size() != datumName.size()) {
73  labelName = std::string(*itDatum, datumName.size() + 1);
74  }
75  recordToData.insert(std::make_pair(std::string(*itRecordName), std::make_pair(datumName, labelName)));
76  }
77  } catch (cms::Exception const& iException) {
78  cms::Exception theError("ESPreferConfigurationError");
79  theError << "While parsing the es_prefer statement for type="
80  << preferPSet.getParameter<std::string>("@module_type") << " label=\""
81  << preferPSet.getParameter<std::string>("@module_label") << "\" an error occurred.";
82  theError.append(iException);
83  throw theError;
84  }
85  }
86  preferInfo[ComponentDescription(preferPSet.getParameter<std::string>("@module_type"),
87  preferPSet.getParameter<std::string>("@module_label"),
88  false)] = recordToData;
89  }
90  return std::make_unique<EventSetupProvider>(activityRegistry, taskArena, subProcessIndex, &preferInfo);
91  }
92 
93  // ---------------------------------------------------------------
95  std::vector<std::string> providers = params.getParameter<std::vector<std::string> >("@all_esmodules");
96 
97  for (std::vector<std::string>::iterator itName = providers.begin(), itNameEnd = providers.end();
98  itName != itNameEnd;
99  ++itName) {
100  ParameterSet* providerPSet = params.getPSetForUpdate(*itName);
101  validateEventSetupParameters(*providerPSet);
102  providerPSet->registerIt();
103  ModuleFactory::get()->addTo(esController, cp, *providerPSet);
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  validateEventSetupParameters(*providerPSet);
112  providerPSet->registerIt();
113  SourceFactory::get()->addTo(esController, cp, *providerPSet);
114  }
115  }
116 
117  // ---------------------------------------------------------------
119  std::string modtype;
121  modtype = pset.getParameter<std::string>("@module_type");
122  moduleLabel = pset.getParameter<std::string>("@module_label");
123  // Check for the "unlabeled" case
124  // This is an artifact left over from the old configuration language
125  // we were using before switching to the python configuration
126  // This is handled in the validation code and python configuration
127  // files by using a label equal to the module typename.
128  if (moduleLabel == std::string("")) {
129  moduleLabel = modtype;
130  }
131 
132  std::unique_ptr<ParameterSetDescriptionFillerBase> filler(
134  ConfigurationDescriptions descriptions(filler->baseType(), modtype);
135  filler->fill(descriptions);
136  try {
137  edm::convertException::wrap([&]() { descriptions.validate(pset, moduleLabel); });
138  } catch (cms::Exception& iException) {
139  std::ostringstream ost;
140  ost << "Validating configuration of ESProducer or ESSource of type " << modtype << " with label: '"
141  << moduleLabel << "'";
142  iException.addContext(ost.str());
143  throw;
144  }
145  }
146  } // namespace eventsetup
147 } // namespace edm
edm::ParameterSet::registerIt
ParameterSet const & registerIt()
Definition: ParameterSet.cc:113
ConfigurationDescriptions.h
ParameterSetDescriptionFillerBase.h
cms::Exception::addContext
void addContext(std::string const &context)
Definition: Exception.cc:165
EventSetupProvider.h
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
edm
HLT enums.
Definition: AlignableModifier.h:19
ComponentDescription.h
edm::eventsetup::EventSetupProvider::PreferredProviderInfo
std::map< ComponentDescription, RecordToDataMap > PreferredProviderInfo
Definition: EventSetupProvider.h:57
CalibrationSummaryClient_cfi.sources
sources
Definition: CalibrationSummaryClient_cfi.py:23
hgcal_conditions::parameters
Definition: HGCConditions.h:86
beamerCreator.create
def create(alignables, pedeDump, additionalData, outputFile, config)
Definition: beamerCreator.py:44
edm::eventsetup::EventSetupProvider::RecordToDataMap
std::multimap< RecordName, DataKeyInfo > RecordToDataMap
Definition: EventSetupProvider.h:56
edm::eventsetup::ComponentFactory::get
static ComponentFactory< T > const * get()
edm::eventsetup::makeEventSetupProvider
std::unique_ptr< EventSetupProvider > makeEventSetupProvider(ParameterSet const &params, unsigned subProcessIndex, ActivityRegistry *activityRegistry, tbb::task_arena *taskArena)
Definition: EventSetupProviderMaker.cc:25
ParameterSetDescriptionFillerPluginFactory.h
EDMException.h
edm::eventsetup::EventSetupProvider
Definition: EventSetupProvider.h:50
edm::convertException::wrap
auto wrap(F iFunc) -> decltype(iFunc())
Definition: ConvertException.h:19
edm::ActivityRegistry
Definition: ActivityRegistry.h:134
ConvertException.h
cms::Exception::append
void append(Exception const &another)
Definition: Exception.cc:153
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::eventsetup::ComponentDescription
Definition: ComponentDescription.h:30
SourceFactory.h
edm::eventsetup::validateEventSetupParameters
void validateEventSetupParameters(ParameterSet &pset)
Definition: EventSetupProviderMaker.cc:118
edm::ParameterSet
Definition: ParameterSet.h:47
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
edm::ParameterSet::getParameterNames
std::vector< std::string > getParameterNames() const
Definition: ParameterSet.cc:663
get
#define get
edm::eventsetup::EventSetupsController
Definition: EventSetupsController.h:80
ModuleFactory.h
Exception
Definition: hltDiff.cc:245
edm::eventsetup::fillEventSetupProvider
void fillEventSetupProvider(EventSetupsController &esController, EventSetupProvider &cp, ParameterSet &params)
Definition: EventSetupProviderMaker.cc:94
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Exception.h
cms::Exception
Definition: Exception.h:70
ParameterSet.h
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
EventSetupProviderMaker.h
edm::errors::Configuration
Definition: EDMException.h:36
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27