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